diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-03-26 06:49:50 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-03-26 06:49:50 (GMT) |
| commit | 1a8621c7b31746c86f59af0aa3f24c99b2eb0a69 (patch) | |
| tree | a3c250cb4b25cb05e6626ff804bb746804265e8c | |
| parent | 82fdffe8ad9b567655a81353b2b498bea19222fe (diff) | |
Revert "sans animations"
This reverts commit 268ddbdc7622ab2a6b0490701064ffdde13fee51.
| -rw-r--r-- | src/displayapp/DisplayApp.cpp | 97 | ||||
| -rw-r--r-- | src/displayapp/DisplayApp.h | 12 | ||||
| -rw-r--r-- | src/displayapp/LittleVgl.cpp | 69 | ||||
| -rw-r--r-- | src/displayapp/LittleVgl.h | 3 | ||||
| -rw-r--r-- | src/displayapp/screens/List.cpp | 2 | ||||
| -rw-r--r-- | src/displayapp/screens/Notifications.cpp | 2 | ||||
| -rw-r--r-- | src/displayapp/screens/ScreenList.h | 5 | ||||
| -rw-r--r-- | src/displayapp/screens/Tile.cpp | 2 | ||||
| -rw-r--r-- | src/displayapp/screens/settings/QuickSettings.cpp | 2 | ||||
| -rw-r--r-- | src/libs/lv_conf.h | 2 |
10 files changed, 154 insertions, 42 deletions
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 5600782..e62bd81 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -96,9 +96,9 @@ void DisplayApp::Start(System::BootErrors error) { bootError = error; if (error == System::BootErrors::TouchController) { - LoadApp(Apps::Error); + LoadApp(Apps::Error, DisplayApp::FullRefreshDirections::None); } else { - LoadApp(Apps::Clock); + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None); } if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) { @@ -132,7 +132,7 @@ void DisplayApp::Refresh() { break; case States::Running: if (!currentScreen->IsRunning()) { - LoadApp(returnToApp); + LoadApp(returnToApp, returnDirection); } queueTimeout = lv_task_handler(); break; @@ -174,7 +174,7 @@ void DisplayApp::Refresh() { // Screens::Clock::BleConnectionStates::NotConnected); break; case Messages::NewNotification: - LoadApp(Apps::NotificationsPreview); + LoadApp(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down); break; case Messages::TouchEvent: { if (state != States::Running) { @@ -188,13 +188,13 @@ void DisplayApp::Refresh() { if (currentApp == Apps::Clock) { switch (gesture) { case TouchEvents::SwipeUp: - LoadApp(Apps::Launcher); + LoadApp(Apps::Launcher, DisplayApp::FullRefreshDirections::Up); break; case TouchEvents::SwipeDown: - LoadApp(Apps::Notifications); + LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down); break; case TouchEvents::SwipeRight: - LoadApp(Apps::QuickSettings); + LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim); break; case TouchEvents::DoubleTap: PushMessageToSystemTask(System::Messages::GoToSleep); @@ -202,8 +202,8 @@ void DisplayApp::Refresh() { default: break; } - } else { - LoadApp(returnToApp); + } else if (returnTouchEvent == gesture) { + LoadApp(returnToApp, returnDirection); brightnessController.Set(settingsController.GetBrightness()); brightnessController.Backup(); } @@ -216,7 +216,7 @@ void DisplayApp::Refresh() { if (currentApp == Apps::Clock) { PushMessageToSystemTask(System::Messages::GoToSleep); } else { - LoadApp(returnToApp); + LoadApp(returnToApp, returnDirection); brightnessController.Set(settingsController.GetBrightness()); brightnessController.Backup(); } @@ -225,39 +225,39 @@ void DisplayApp::Refresh() { case Messages::ButtonLongPressed: if (currentApp != Apps::Clock) { if (currentApp == Apps::Notifications) { - LoadApp(Apps::Clock); + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Up); } else if (currentApp == Apps::QuickSettings) { - LoadApp(Apps::Clock); + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::LeftAnim); } else { - LoadApp(Apps::Clock); + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Down); } } break; case Messages::ButtonLongerPressed: // Open up Firmware window, before possible reboot if press continues - LoadApp(Apps::FirmwareValidation); + LoadApp(Apps::FirmwareValidation, DisplayApp::FullRefreshDirections::Up); break; case Messages::ButtonDoubleClicked: if (currentApp != Apps::Notifications && currentApp != Apps::NotificationsPreview) { - LoadApp(Apps::Notifications); + LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down); } break; case Messages::BleFirmwareUpdateStarted: - LoadApp(Apps::FirmwareUpdate); + LoadApp(Apps::FirmwareUpdate, DisplayApp::FullRefreshDirections::Down); break; case Messages::UpdateDateTime: // Added to remove warning // What should happen here? break; case Messages::Clock: - LoadApp(Apps::Clock); + LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None); break; } } if (nextApp != Apps::None) { - LoadApp(nextApp); + LoadApp(nextApp, nextDirection); nextApp = Apps::None; } @@ -266,25 +266,29 @@ void DisplayApp::Refresh() { } } -void DisplayApp::StartApp(Apps app) { +void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction) { nextApp = app; + nextDirection = direction; } -void DisplayApp::ReturnApp(Apps app) { +void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) { returnToApp = app; + returnDirection = direction; + returnTouchEvent = touchEvent; } -void DisplayApp::LoadApp(Apps app) { +void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) { touchHandler.CancelTap(); currentScreen.reset(nullptr); + SetFullRefresh(direction); // default return to launcher - ReturnApp(Apps::Launcher); + ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown); switch (app) { case Apps::Launcher: currentScreen = std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, dateTimeController); - ReturnApp(Apps::Clock); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::None: case Apps::Clock: @@ -299,52 +303,52 @@ void DisplayApp::LoadApp(Apps app) { case Apps::Error: currentScreen = std::make_unique<Screens::Error>(this, bootError); - ReturnApp(Apps::Clock); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); break; case Apps::FirmwareValidation: currentScreen = std::make_unique<Screens::FirmwareValidation>(this, validator); - ReturnApp(Apps::Settings); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::FirmwareUpdate: currentScreen = std::make_unique<Screens::FirmwareUpdate>(this, bleController); - ReturnApp(Apps::Clock); + ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None); break; case Apps::Notifications: currentScreen = std::make_unique<Screens::Notifications>( this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Normal); - ReturnApp(Apps::Clock); + ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; case Apps::NotificationsPreview: currentScreen = std::make_unique<Screens::Notifications>( this, notificationManager, systemTask->nimble().alertService(), motorController, *systemTask, Screens::Notifications::Modes::Preview); - ReturnApp(Apps::Clock); + ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp); break; // Settings case Apps::QuickSettings: currentScreen = std::make_unique<Screens::QuickSettings>( this, batteryController, dateTimeController, brightnessController, motorController, settingsController); - ReturnApp(Apps::Clock); + ReturnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft); break; case Apps::Settings: currentScreen = std::make_unique<Screens::Settings>(this, settingsController); - ReturnApp(Apps::QuickSettings); + ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingTimeFormat: currentScreen = std::make_unique<Screens::SettingTimeFormat>(this, settingsController); - ReturnApp(Apps::Settings); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingWakeUp: currentScreen = std::make_unique<Screens::SettingWakeUp>(this, settingsController); - ReturnApp(Apps::Settings); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingDisplay: currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController); - ReturnApp(Apps::Settings); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; case Apps::SettingShakeThreshold: currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask); - ReturnApp(Apps::Settings); + ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown); break; } currentApp = app; @@ -363,6 +367,31 @@ void DisplayApp::PushMessage(Messages msg) { } } +void DisplayApp::SetFullRefresh(DisplayApp::FullRefreshDirections direction) { + switch (direction) { + case DisplayApp::FullRefreshDirections::Down: + lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Down); + break; + case DisplayApp::FullRefreshDirections::Up: + lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Up); + break; + case DisplayApp::FullRefreshDirections::Left: + lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Left); + break; + case DisplayApp::FullRefreshDirections::Right: + lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::Right); + break; + case DisplayApp::FullRefreshDirections::LeftAnim: + lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::LeftAnim); + break; + case DisplayApp::FullRefreshDirections::RightAnim: + lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::RightAnim); + break; + default: + break; + } +} + void DisplayApp::PushMessageToSystemTask(Pinetime::System::Messages message) { if (systemTask != nullptr) { systemTask->PushMessage(message); diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index ad28499..b79952d 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -42,6 +42,7 @@ namespace Pinetime { class DisplayApp { public: enum class States { Idle, Running }; + enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim }; DisplayApp(Drivers::St7789& lcd, Components::LittleVgl& lvgl, @@ -59,7 +60,9 @@ namespace Pinetime { void Start(System::BootErrors error); void PushMessage(Display::Messages msg); - void StartApp(Apps app); + void StartApp(Apps app, DisplayApp::FullRefreshDirections direction); + + void SetFullRefresh(FullRefreshDirections direction); void Register(Pinetime::System::SystemTask* systemTask); @@ -93,16 +96,19 @@ namespace Pinetime { Apps currentApp = Apps::None; Apps returnToApp = Apps::None; + FullRefreshDirections returnDirection = FullRefreshDirections::None; + TouchEvents returnTouchEvent = TouchEvents::None; TouchEvents GetGesture(); static void Process(void* instance); void InitHw(); void Refresh(); - void ReturnApp(Apps app); - void LoadApp(Apps app); + void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent); + void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction); void PushMessageToSystemTask(Pinetime::System::Messages message); Apps nextApp = Apps::None; + DisplayApp::FullRefreshDirections nextDirection; System::BootErrors bootError; }; } diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 0e3fef9..e7b58c1 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -63,6 +63,23 @@ void LittleVgl::InitTouchpad() { lv_indev_drv_register(&indev_drv); } +void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { + if (scrollDirection == FullRefreshDirections::None) { + scrollDirection = direction; + if (scrollDirection == FullRefreshDirections::Down) { + lv_disp_set_direction(lv_disp_get_default(), 1); + } else if (scrollDirection == FullRefreshDirections::Right) { + lv_disp_set_direction(lv_disp_get_default(), 2); + } else if (scrollDirection == FullRefreshDirections::Left) { + lv_disp_set_direction(lv_disp_get_default(), 3); + } else if (scrollDirection == FullRefreshDirections::RightAnim) { + lv_disp_set_direction(lv_disp_get_default(), 5); + } else if (scrollDirection == FullRefreshDirections::LeftAnim) { + lv_disp_set_direction(lv_disp_get_default(), 4); + } + } +} + void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { uint16_t y1, y2, width, height = 0; @@ -70,13 +87,63 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { // NOtification is still needed (even if there is a mutex on SPI) because of the DataCommand pin // which cannot be set/clear during a transfert. + if ((scrollDirection == LittleVgl::FullRefreshDirections::Down) && (area->y2 == visibleNbLines - 1)) { + writeOffset = ((writeOffset + totalNbLines) - visibleNbLines) % totalNbLines; + } else if ((scrollDirection == FullRefreshDirections::Up) && (area->y1 == 0)) { + writeOffset = (writeOffset + visibleNbLines) % totalNbLines; + } + y1 = (area->y1 + writeOffset) % totalNbLines; y2 = (area->y2 + writeOffset) % totalNbLines; width = (area->x2 - area->x1) + 1; height = (area->y2 - area->y1) + 1; - // lv_disp_set_direction(lv_disp_get_default(), 0); + if (scrollDirection == LittleVgl::FullRefreshDirections::Down) { + + if (area->y2 < visibleNbLines - 1) { + uint16_t toScroll = 0; + if (area->y1 == 0) { + toScroll = height * 2; + scrollDirection = FullRefreshDirections::None; + lv_disp_set_direction(lv_disp_get_default(), 0); + } else { + toScroll = height; + } + + if (scrollOffset >= toScroll) + scrollOffset -= toScroll; + else { + toScroll -= scrollOffset; + scrollOffset = (totalNbLines) -toScroll; + } + lcd.VerticalScrollStartAddress(scrollOffset); + } + + } else if (scrollDirection == FullRefreshDirections::Up) { + + if (area->y1 > 0) { + if (area->y2 == visibleNbLines - 1) { + scrollOffset += (height * 2); + scrollDirection = FullRefreshDirections::None; + lv_disp_set_direction(lv_disp_get_default(), 0); + } else { + scrollOffset += height; + } + scrollOffset = scrollOffset % totalNbLines; + lcd.VerticalScrollStartAddress(scrollOffset); + } + } else if (scrollDirection == FullRefreshDirections::Left or scrollDirection == FullRefreshDirections::LeftAnim) { + if (area->x2 == visibleNbLines - 1) { + scrollDirection = FullRefreshDirections::None; + lv_disp_set_direction(lv_disp_get_default(), 0); + } + } else if (scrollDirection == FullRefreshDirections::Right or scrollDirection == FullRefreshDirections::RightAnim) { + if (area->x1 == 0) { + scrollDirection = FullRefreshDirections::None; + lv_disp_set_direction(lv_disp_get_default(), 0); + } + } if (y2 < y1) { height = totalNbLines - y1; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index af77eba..1f8a3d7 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -11,6 +11,7 @@ namespace Pinetime { namespace Components { class LittleVgl { public: + enum class FullRefreshDirections { None, Up, Down, Left, Right, LeftAnim, RightAnim }; LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel); LittleVgl(const LittleVgl&) = delete; @@ -22,6 +23,7 @@ namespace Pinetime { void FlushDisplay(const lv_area_t* area, lv_color_t* color_p); bool GetTouchPadInfo(lv_indev_data_t* ptr); + void SetFullRefresh(FullRefreshDirections direction); void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact); private: @@ -46,6 +48,7 @@ namespace Pinetime { static constexpr uint8_t MaxScrollOffset() { return LV_VER_RES_MAX - nbWriteLines; } + FullRefreshDirections scrollDirection = FullRefreshDirections::None; uint16_t writeOffset = 0; uint16_t scrollOffset = 0; diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index 47e3a4c..af3f30f 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -102,7 +102,7 @@ void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) { if (event == LV_EVENT_CLICKED) { for (int i = 0; i < MAXLISTITEMS; i++) { if (apps[i] != Apps::None && object == itemApps[i]) { - app->StartApp(apps[i]); + app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up); running = false; return; } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 221633d..c10a60d 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -120,6 +120,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { validDisplay = true; currentId = previousNotification.id; currentItem.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); currentItem = std::make_unique<NotificationItem>(previousNotification.Title(), previousNotification.Message(), previousNotification.index, @@ -145,6 +146,7 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { validDisplay = true; currentId = nextNotification.id; currentItem.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up); currentItem = std::make_unique<NotificationItem>(nextNotification.Title(), nextNotification.Message(), nextNotification.index, diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h index 4178704..e316e36 100644 --- a/src/displayapp/screens/ScreenList.h +++ b/src/displayapp/screens/ScreenList.h @@ -37,6 +37,7 @@ namespace Pinetime { case TouchEvents::SwipeDown: if (screenIndex > 0) { current.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Down); screenIndex--; current = screens[screenIndex](); return true; @@ -47,6 +48,7 @@ namespace Pinetime { case TouchEvents::SwipeUp: if (screenIndex < screens.size() - 1) { current.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::Up); screenIndex++; current = screens[screenIndex](); } @@ -59,6 +61,7 @@ namespace Pinetime { case TouchEvents::SwipeRight: if (screenIndex > 0) { current.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::None); screenIndex--; current = screens[screenIndex](); return true; @@ -69,6 +72,7 @@ namespace Pinetime { case TouchEvents::SwipeLeft: if (screenIndex < screens.size() - 1) { current.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::None); screenIndex++; current = screens[screenIndex](); } @@ -83,6 +87,7 @@ namespace Pinetime { screenIndex = 0; } current.reset(nullptr); + app->SetFullRefresh(DisplayApp::FullRefreshDirections::None); current = screens[screenIndex](); return true; } diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index f33408c..23d9bca 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -126,6 +126,6 @@ void Tile::UpdateScreen() { void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) { if(obj != btnm1) return; - app->StartApp(apps[buttonId]); + app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); running = false; } diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 191d587..c00518e 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -149,6 +149,6 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { } else if (object == btn4 && event == LV_EVENT_CLICKED) { running = false; settingsController.SetSettingsMenu(0); - app->StartApp(Apps::Settings); + app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up); } } diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index dd1b68c..6d968dd 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -139,7 +139,7 @@ typedef int16_t lv_coord_t; *==================*/ /*1: Enable the Animations */ -#define LV_USE_ANIMATION 0 +#define LV_USE_ANIMATION 1 #if LV_USE_ANIMATION /*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ |
