diff options
Diffstat (limited to 'src/DisplayApp')
-rw-r--r-- | src/DisplayApp/DisplayApp.cpp | 25 | ||||
-rw-r--r-- | src/DisplayApp/DisplayApp.h | 16 | ||||
-rw-r--r-- | src/DisplayApp/Screens/Modal.cpp | 41 | ||||
-rw-r--r-- | src/DisplayApp/Screens/Modal.h | 4 | ||||
-rw-r--r-- | src/DisplayApp/Screens/Tile.cpp | 4 |
5 files changed, 23 insertions, 67 deletions
diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 2e07cbc5..1b4515e0 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -15,18 +15,16 @@ #include <DisplayApp/Screens/Gauge.h> #include <DisplayApp/Screens/Brightness.h> #include <DisplayApp/Screens/ScreenList.h> +#include <Components/Ble/NotificationManager.h> #include "../SystemTask/SystemTask.h" using namespace Pinetime::Applications; -DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, - Pinetime::Components::LittleVgl& lvgl, - Pinetime::Drivers::Cst816S& touchPanel, - Controllers::Battery &batteryController, - Controllers::Ble &bleController, - Controllers::DateTime &dateTimeController, - Pinetime::Drivers::WatchdogView& watchdog, - Pinetime::System::SystemTask& systemTask) : +DisplayApp::DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &touchPanel, + Controllers::Battery &batteryController, Controllers::Ble &bleController, + Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, + System::SystemTask &systemTask, + Pinetime::Controllers::NotificationManager& notificationManager) : lcd{lcd}, lvgl{lvgl}, batteryController{batteryController}, @@ -35,7 +33,8 @@ DisplayApp::DisplayApp(Pinetime::Drivers::St7789& lcd, watchdog{watchdog}, touchPanel{touchPanel}, currentScreen{new Screens::Clock(this, dateTimeController, batteryController, bleController) }, - systemTask{systemTask} { + systemTask{systemTask}, + notificationManager{notificationManager} { msgQueue = xQueueCreate(queueSize, itemSize); onClockApp = true; modal.reset(new Screens::Modal(this)); @@ -113,12 +112,8 @@ void DisplayApp::Refresh() { // clockScreen.SetBatteryPercentRemaining(batteryController.PercentRemaining()); break; case Messages::NewNotification: { - Pinetime::Controllers::Ble::NotificationMessage notificationMessage; - if (bleController.PopNotification(notificationMessage)) { - std::string m {notificationMessage.message, notificationMessage.size}; - modal->Show(m); - // TODO delete message - } + auto notification = notificationManager.Pop(); + modal->Show(notification.message.data()); } break; case Messages::TouchEvent: { diff --git a/src/DisplayApp/DisplayApp.h b/src/DisplayApp/DisplayApp.h index ad817331..09f0d1cd 100644 --- a/src/DisplayApp/DisplayApp.h +++ b/src/DisplayApp/DisplayApp.h @@ -17,6 +17,7 @@ #include <DisplayApp/Screens/Clock.h> #include <drivers/Watchdog.h> #include <DisplayApp/Screens/Modal.h> +#include <Components/Ble/NotificationManager.h> #include "TouchEvents.h" @@ -34,14 +35,11 @@ namespace Pinetime { enum class FullRefreshDirections { None, Up, Down }; - DisplayApp(Pinetime::Drivers::St7789& lcd, - Pinetime::Components::LittleVgl& lvgl, - Pinetime::Drivers::Cst816S&, - Controllers::Battery &batteryController, - Controllers::Ble &bleController, - Controllers::DateTime& dateTimeController, - Pinetime::Drivers::WatchdogView& watchdog, - Pinetime::System::SystemTask& systemTask); + DisplayApp(Drivers::St7789 &lcd, Components::LittleVgl &lvgl, Drivers::Cst816S &, + Controllers::Battery &batteryController, Controllers::Ble &bleController, + Controllers::DateTime &dateTimeController, Drivers::WatchdogView &watchdog, + System::SystemTask &systemTask, + Pinetime::Controllers::NotificationManager& notificationManager); void Start(); void PushMessage(Messages msg); @@ -82,7 +80,7 @@ namespace Pinetime { bool onClockApp = false; // TODO find a better way to know that we should handle gestures and button differently for the Clock app. Controllers::BrightnessController brightnessController; std::unique_ptr<Screens::Modal> modal; - + Pinetime::Controllers::NotificationManager& notificationManager; }; } } diff --git a/src/DisplayApp/Screens/Modal.cpp b/src/DisplayApp/Screens/Modal.cpp index ec477b6e..63ae70c0 100644 --- a/src/DisplayApp/Screens/Modal.cpp +++ b/src/DisplayApp/Screens/Modal.cpp @@ -25,42 +25,6 @@ bool Modal::OnButtonPushed() { return true; } -void Modal::Show() { - if(isVisible) return; - isVisible = true; - lv_style_copy(&modal_style, &lv_style_plain_color); - modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK; - modal_style.body.opa = LV_OPA_50; - - obj = lv_obj_create(lv_scr_act(), NULL); - lv_obj_set_style(obj, &modal_style); - lv_obj_set_pos(obj, 0, 0); - lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES); - lv_obj_set_opa_scale_enable(obj, true); /* Enable opacity scaling for the animation */ - - static const char * btns2[] = {"Ok", ""}; - - /* Create the message box as a child of the modal background */ - mbox = lv_mbox_create(obj, NULL); - lv_mbox_add_btns(mbox, btns2); - char versionStr[20]; - sprintf(versionStr, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); - lv_mbox_set_text(mbox, versionStr); -// lv_mbox_set_text(mbox, "Hello world!"); - lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_event_cb(mbox, Modal::mbox_event_cb); - - mbox->user_data = this; - - /* Fade the message box in with an animation */ - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_time(&a, 500, 0); - lv_anim_set_values(&a, LV_OPA_TRANSP, LV_OPA_COVER); - lv_anim_set_exec_cb(&a, obj, (lv_anim_exec_xcb_t)lv_obj_set_opa_scale); - lv_anim_create(&a); -} - void Modal::Hide() { /* Delete the parent modal background */ lv_obj_del_async(lv_obj_get_parent(mbox)); @@ -83,9 +47,8 @@ void Modal::OnEvent(lv_obj_t *event_obj, lv_event_t evt) { } } -void Modal::Show(const std::string& message) { +void Modal::Show(const char* msg) { if(isVisible) return; - this->message = message; isVisible = true; lv_style_copy(&modal_style, &lv_style_plain_color); modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK; @@ -102,7 +65,7 @@ void Modal::Show(const std::string& message) { /* Create the message box as a child of the modal background */ mbox = lv_mbox_create(obj, NULL); lv_mbox_add_btns(mbox, btns2); - lv_mbox_set_text(mbox, message.data()); + lv_mbox_set_text(mbox, msg); lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_set_event_cb(mbox, Modal::mbox_event_cb); diff --git a/src/DisplayApp/Screens/Modal.h b/src/DisplayApp/Screens/Modal.h index b13b5c60..b5425906 100644 --- a/src/DisplayApp/Screens/Modal.h +++ b/src/DisplayApp/Screens/Modal.h @@ -22,8 +22,7 @@ namespace Pinetime { Modal(DisplayApp* app); ~Modal() override; - void Show(); - void Show(const std::string& message); + void Show(const char* msg); void Hide(); bool Refresh() override; @@ -39,7 +38,6 @@ namespace Pinetime { lv_obj_t *info; bool running = true; bool isVisible = false; - std::string message; }; } diff --git a/src/DisplayApp/Screens/Tile.cpp b/src/DisplayApp/Screens/Tile.cpp index 7eb1018c..6c225c9d 100644 --- a/src/DisplayApp/Screens/Tile.cpp +++ b/src/DisplayApp/Screens/Tile.cpp @@ -123,7 +123,9 @@ void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) { tile->StartClockApp(); break; case 3: - modal->Show(); + char versionStr[20]; + sprintf(versionStr, "VERSION: %d.%d.%d", Version::Major(), Version::Minor(), Version::Patch()); + modal->Show(versionStr); break; case 4: tile->StartSysInfoApp(); |