Implement a return app stack
Each opened app (screen) is pushed on a stack, which is then popped from when returning instead of hard coded "previous apps". Return swipe and refresh directions are automatically determined from the app transition.
This commit is contained in:
parent
3617569795
commit
5ef3c0d3be
38
src/StaticStack.h
Normal file
38
src/StaticStack.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#include <array>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
template <typename T, size_t N> class StaticStack {
|
||||||
|
public:
|
||||||
|
T Pop();
|
||||||
|
void Push(T element);
|
||||||
|
void Reset();
|
||||||
|
T Top();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::array<T, N> elementArray;
|
||||||
|
// Number of elements in stack, points to the next empty slot
|
||||||
|
size_t stackPointer = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns random data when popping from empty array.
|
||||||
|
template <typename T, size_t N> T StaticStack<T, N>::Pop() {
|
||||||
|
if (stackPointer > 0) {
|
||||||
|
stackPointer--;
|
||||||
|
}
|
||||||
|
return elementArray[stackPointer];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t N> void StaticStack<T, N>::Push(T element) {
|
||||||
|
if (stackPointer < elementArray.size()) {
|
||||||
|
elementArray[stackPointer] = element;
|
||||||
|
stackPointer++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t N> void StaticStack<T, N>::Reset() {
|
||||||
|
stackPointer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T, size_t N> T StaticStack<T, N>::Top() {
|
||||||
|
return elementArray[stackPointer - 1];
|
||||||
|
}
|
|
@ -102,9 +102,9 @@ void DisplayApp::Start(System::BootErrors error) {
|
||||||
bootError = error;
|
bootError = error;
|
||||||
|
|
||||||
if (error == System::BootErrors::TouchController) {
|
if (error == System::BootErrors::TouchController) {
|
||||||
LoadApp(Apps::Error, DisplayApp::FullRefreshDirections::None);
|
LoadNewScreen(Apps::Error, DisplayApp::FullRefreshDirections::None);
|
||||||
} else {
|
} else {
|
||||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
|
if (pdPASS != xTaskCreate(DisplayApp::Process, "displayapp", 800, this, 0, &taskHandle)) {
|
||||||
|
@ -132,7 +132,25 @@ void DisplayApp::InitHw() {
|
||||||
|
|
||||||
void DisplayApp::Refresh() {
|
void DisplayApp::Refresh() {
|
||||||
auto LoadPreviousScreen = [this]() {
|
auto LoadPreviousScreen = [this]() {
|
||||||
LoadApp(returnToApp, returnDirection);
|
FullRefreshDirections returnDirection;
|
||||||
|
switch (appStackDirections.Pop()) {
|
||||||
|
case FullRefreshDirections::Up:
|
||||||
|
returnDirection = FullRefreshDirections::Down;
|
||||||
|
break;
|
||||||
|
case FullRefreshDirections::Down:
|
||||||
|
returnDirection = FullRefreshDirections::Up;
|
||||||
|
break;
|
||||||
|
case FullRefreshDirections::LeftAnim:
|
||||||
|
returnDirection = FullRefreshDirections::RightAnim;
|
||||||
|
break;
|
||||||
|
case FullRefreshDirections::RightAnim:
|
||||||
|
returnDirection = FullRefreshDirections::LeftAnim;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
returnDirection = FullRefreshDirections::None;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
LoadScreen(returnAppStack.Pop(), returnDirection);
|
||||||
};
|
};
|
||||||
|
|
||||||
TickType_t queueTimeout;
|
TickType_t queueTimeout;
|
||||||
|
@ -180,14 +198,14 @@ void DisplayApp::Refresh() {
|
||||||
// Screens::Clock::BleConnectionStates::NotConnected);
|
// Screens::Clock::BleConnectionStates::NotConnected);
|
||||||
break;
|
break;
|
||||||
case Messages::NewNotification:
|
case Messages::NewNotification:
|
||||||
LoadApp(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down);
|
||||||
break;
|
break;
|
||||||
case Messages::TimerDone:
|
case Messages::TimerDone:
|
||||||
if (currentApp == Apps::Timer) {
|
if (currentApp == Apps::Timer) {
|
||||||
auto* timer = static_cast<Screens::Timer*>(currentScreen.get());
|
auto* timer = static_cast<Screens::Timer*>(currentScreen.get());
|
||||||
timer->Reset();
|
timer->Reset();
|
||||||
} else {
|
} else {
|
||||||
LoadApp(Apps::Timer, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::Timer, DisplayApp::FullRefreshDirections::Up);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::AlarmTriggered:
|
case Messages::AlarmTriggered:
|
||||||
|
@ -195,11 +213,11 @@ void DisplayApp::Refresh() {
|
||||||
auto* alarm = static_cast<Screens::Alarm*>(currentScreen.get());
|
auto* alarm = static_cast<Screens::Alarm*>(currentScreen.get());
|
||||||
alarm->SetAlerting();
|
alarm->SetAlerting();
|
||||||
} else {
|
} else {
|
||||||
LoadApp(Apps::Alarm, DisplayApp::FullRefreshDirections::None);
|
LoadNewScreen(Apps::Alarm, DisplayApp::FullRefreshDirections::None);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::ShowPairingKey:
|
case Messages::ShowPairingKey:
|
||||||
LoadApp(Apps::PassKey, DisplayApp::FullRefreshDirections::Up);
|
LoadNewScreen(Apps::PassKey, DisplayApp::FullRefreshDirections::Up);
|
||||||
break;
|
break;
|
||||||
case Messages::TouchEvent: {
|
case Messages::TouchEvent: {
|
||||||
if (state != States::Running) {
|
if (state != States::Running) {
|
||||||
|
@ -209,17 +227,30 @@ void DisplayApp::Refresh() {
|
||||||
if (gesture == TouchEvents::None) {
|
if (gesture == TouchEvents::None) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
auto LoadDirToReturnSwipe = [](DisplayApp::FullRefreshDirections refreshDirection) {
|
||||||
|
switch (refreshDirection) {
|
||||||
|
default:
|
||||||
|
case DisplayApp::FullRefreshDirections::Up:
|
||||||
|
return TouchEvents::SwipeDown;
|
||||||
|
case DisplayApp::FullRefreshDirections::Down:
|
||||||
|
return TouchEvents::SwipeUp;
|
||||||
|
case DisplayApp::FullRefreshDirections::LeftAnim:
|
||||||
|
return TouchEvents::SwipeRight;
|
||||||
|
case DisplayApp::FullRefreshDirections::RightAnim:
|
||||||
|
return TouchEvents::SwipeLeft;
|
||||||
|
}
|
||||||
|
};
|
||||||
if (!currentScreen->OnTouchEvent(gesture)) {
|
if (!currentScreen->OnTouchEvent(gesture)) {
|
||||||
if (currentApp == Apps::Clock) {
|
if (currentApp == Apps::Clock) {
|
||||||
switch (gesture) {
|
switch (gesture) {
|
||||||
case TouchEvents::SwipeUp:
|
case TouchEvents::SwipeUp:
|
||||||
LoadApp(Apps::Launcher, DisplayApp::FullRefreshDirections::Up);
|
LoadNewScreen(Apps::Launcher, DisplayApp::FullRefreshDirections::Up);
|
||||||
break;
|
break;
|
||||||
case TouchEvents::SwipeDown:
|
case TouchEvents::SwipeDown:
|
||||||
LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::Notifications, DisplayApp::FullRefreshDirections::Down);
|
||||||
break;
|
break;
|
||||||
case TouchEvents::SwipeRight:
|
case TouchEvents::SwipeRight:
|
||||||
LoadApp(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim);
|
LoadNewScreen(Apps::QuickSettings, DisplayApp::FullRefreshDirections::RightAnim);
|
||||||
break;
|
break;
|
||||||
case TouchEvents::DoubleTap:
|
case TouchEvents::DoubleTap:
|
||||||
PushMessageToSystemTask(System::Messages::GoToSleep);
|
PushMessageToSystemTask(System::Messages::GoToSleep);
|
||||||
|
@ -227,7 +258,7 @@ void DisplayApp::Refresh() {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (returnTouchEvent == gesture) {
|
} else if (gesture == LoadDirToReturnSwipe(appStackDirections.Top())) {
|
||||||
LoadPreviousScreen();
|
LoadPreviousScreen();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -246,26 +277,28 @@ void DisplayApp::Refresh() {
|
||||||
case Messages::ButtonLongPressed:
|
case Messages::ButtonLongPressed:
|
||||||
if (currentApp != Apps::Clock) {
|
if (currentApp != Apps::Clock) {
|
||||||
if (currentApp == Apps::Notifications) {
|
if (currentApp == Apps::Notifications) {
|
||||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Up);
|
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::Up);
|
||||||
} else if (currentApp == Apps::QuickSettings) {
|
} else if (currentApp == Apps::QuickSettings) {
|
||||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::LeftAnim);
|
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::LeftAnim);
|
||||||
} else {
|
} else {
|
||||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::Down);
|
||||||
}
|
}
|
||||||
|
appStackDirections.Reset();
|
||||||
|
returnAppStack.Reset();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Messages::ButtonLongerPressed:
|
case Messages::ButtonLongerPressed:
|
||||||
// Create reboot app and open it instead
|
// Create reboot app and open it instead
|
||||||
LoadApp(Apps::SysInfo, DisplayApp::FullRefreshDirections::Up);
|
LoadNewScreen(Apps::SysInfo, DisplayApp::FullRefreshDirections::Up);
|
||||||
break;
|
break;
|
||||||
case Messages::ButtonDoubleClicked:
|
case Messages::ButtonDoubleClicked:
|
||||||
if (currentApp != Apps::Notifications && currentApp != Apps::NotificationsPreview) {
|
if (currentApp != Apps::Notifications && currentApp != Apps::NotificationsPreview) {
|
||||||
LoadApp(Apps::Notifications, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::Notifications, DisplayApp::FullRefreshDirections::Down);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Messages::BleFirmwareUpdateStarted:
|
case Messages::BleFirmwareUpdateStarted:
|
||||||
LoadApp(Apps::FirmwareUpdate, DisplayApp::FullRefreshDirections::Down);
|
LoadNewScreen(Apps::FirmwareUpdate, DisplayApp::FullRefreshDirections::Down);
|
||||||
break;
|
break;
|
||||||
case Messages::BleRadioEnableToggle:
|
case Messages::BleRadioEnableToggle:
|
||||||
PushMessageToSystemTask(System::Messages::BleRadioEnableToggle);
|
PushMessageToSystemTask(System::Messages::BleRadioEnableToggle);
|
||||||
|
@ -275,7 +308,7 @@ void DisplayApp::Refresh() {
|
||||||
// What should happen here?
|
// What should happen here?
|
||||||
break;
|
break;
|
||||||
case Messages::Clock:
|
case Messages::Clock:
|
||||||
LoadApp(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
LoadNewScreen(Apps::Clock, DisplayApp::FullRefreshDirections::None);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,7 +318,7 @@ void DisplayApp::Refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextApp != Apps::None) {
|
if (nextApp != Apps::None) {
|
||||||
LoadApp(nextApp, nextDirection);
|
LoadNewScreen(nextApp, nextDirection);
|
||||||
nextApp = Apps::None;
|
nextApp = Apps::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,27 +328,23 @@ void DisplayApp::StartApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
nextDirection = direction;
|
nextDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent) {
|
void DisplayApp::LoadNewScreen(Apps app, DisplayApp::FullRefreshDirections direction) {
|
||||||
returnToApp = app;
|
returnAppStack.Push(currentApp);
|
||||||
returnDirection = direction;
|
appStackDirections.Push(direction);
|
||||||
returnTouchEvent = touchEvent;
|
LoadScreen(app, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) {
|
void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections direction) {
|
||||||
touchHandler.CancelTap();
|
touchHandler.CancelTap();
|
||||||
ApplyBrightness();
|
ApplyBrightness();
|
||||||
|
|
||||||
currentScreen.reset(nullptr);
|
currentScreen.reset(nullptr);
|
||||||
SetFullRefresh(direction);
|
SetFullRefresh(direction);
|
||||||
|
|
||||||
// default return to launcher
|
|
||||||
ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
|
|
||||||
switch (app) {
|
switch (app) {
|
||||||
case Apps::Launcher:
|
case Apps::Launcher:
|
||||||
currentScreen =
|
currentScreen =
|
||||||
std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, bleController, dateTimeController);
|
std::make_unique<Screens::ApplicationList>(this, settingsController, batteryController, bleController, dateTimeController);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::None:
|
case Apps::None:
|
||||||
case Apps::Clock:
|
case Apps::Clock:
|
||||||
|
@ -332,21 +361,17 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
|
|
||||||
case Apps::Error:
|
case Apps::Error:
|
||||||
currentScreen = std::make_unique<Screens::Error>(this, bootError);
|
currentScreen = std::make_unique<Screens::Error>(this, bootError);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Apps::FirmwareValidation:
|
case Apps::FirmwareValidation:
|
||||||
currentScreen = std::make_unique<Screens::FirmwareValidation>(this, validator);
|
currentScreen = std::make_unique<Screens::FirmwareValidation>(this, validator);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::FirmwareUpdate:
|
case Apps::FirmwareUpdate:
|
||||||
currentScreen = std::make_unique<Screens::FirmwareUpdate>(this, bleController);
|
currentScreen = std::make_unique<Screens::FirmwareUpdate>(this, bleController);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::None);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Apps::PassKey:
|
case Apps::PassKey:
|
||||||
currentScreen = std::make_unique<Screens::PassKey>(this, bleController.GetPairingKey());
|
currentScreen = std::make_unique<Screens::PassKey>(this, bleController.GetPairingKey());
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Apps::Notifications:
|
case Apps::Notifications:
|
||||||
|
@ -356,7 +381,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
motorController,
|
motorController,
|
||||||
*systemTask,
|
*systemTask,
|
||||||
Screens::Notifications::Modes::Normal);
|
Screens::Notifications::Modes::Normal);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
|
||||||
break;
|
break;
|
||||||
case Apps::NotificationsPreview:
|
case Apps::NotificationsPreview:
|
||||||
currentScreen = std::make_unique<Screens::Notifications>(this,
|
currentScreen = std::make_unique<Screens::Notifications>(this,
|
||||||
|
@ -365,7 +389,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
motorController,
|
motorController,
|
||||||
*systemTask,
|
*systemTask,
|
||||||
Screens::Notifications::Modes::Preview);
|
Screens::Notifications::Modes::Preview);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::Up, TouchEvents::SwipeUp);
|
|
||||||
break;
|
break;
|
||||||
case Apps::Timer:
|
case Apps::Timer:
|
||||||
currentScreen = std::make_unique<Screens::Timer>(this, timerController);
|
currentScreen = std::make_unique<Screens::Timer>(this, timerController);
|
||||||
|
@ -383,55 +406,42 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
motorController,
|
motorController,
|
||||||
settingsController,
|
settingsController,
|
||||||
bleController);
|
bleController);
|
||||||
ReturnApp(Apps::Clock, FullRefreshDirections::LeftAnim, TouchEvents::SwipeLeft);
|
|
||||||
break;
|
break;
|
||||||
case Apps::Settings:
|
case Apps::Settings:
|
||||||
currentScreen = std::make_unique<Screens::Settings>(this, settingsController);
|
currentScreen = std::make_unique<Screens::Settings>(this, settingsController);
|
||||||
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingWatchFace:
|
case Apps::SettingWatchFace:
|
||||||
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController, filesystem);
|
currentScreen = std::make_unique<Screens::SettingWatchFace>(this, settingsController, filesystem);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingTimeFormat:
|
case Apps::SettingTimeFormat:
|
||||||
currentScreen = std::make_unique<Screens::SettingTimeFormat>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingTimeFormat>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingWakeUp:
|
case Apps::SettingWakeUp:
|
||||||
currentScreen = std::make_unique<Screens::SettingWakeUp>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingWakeUp>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingDisplay:
|
case Apps::SettingDisplay:
|
||||||
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingDisplay>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingSteps:
|
case Apps::SettingSteps:
|
||||||
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingSteps>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingSetDate:
|
case Apps::SettingSetDate:
|
||||||
currentScreen = std::make_unique<Screens::SettingSetDate>(this, dateTimeController);
|
currentScreen = std::make_unique<Screens::SettingSetDate>(this, dateTimeController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingSetTime:
|
case Apps::SettingSetTime:
|
||||||
currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController, settingsController);
|
currentScreen = std::make_unique<Screens::SettingSetTime>(this, dateTimeController, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingChimes:
|
case Apps::SettingChimes:
|
||||||
currentScreen = std::make_unique<Screens::SettingChimes>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingChimes>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingShakeThreshold:
|
case Apps::SettingShakeThreshold:
|
||||||
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask);
|
currentScreen = std::make_unique<Screens::SettingShakeThreshold>(this, settingsController, motionController, *systemTask);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SettingBluetooth:
|
case Apps::SettingBluetooth:
|
||||||
currentScreen = std::make_unique<Screens::SettingBluetooth>(this, settingsController);
|
currentScreen = std::make_unique<Screens::SettingBluetooth>(this, settingsController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::BatteryInfo:
|
case Apps::BatteryInfo:
|
||||||
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
currentScreen = std::make_unique<Screens::BatteryInfo>(this, batteryController);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::SysInfo:
|
case Apps::SysInfo:
|
||||||
currentScreen = std::make_unique<Screens::SystemInfo>(this,
|
currentScreen = std::make_unique<Screens::SystemInfo>(this,
|
||||||
|
@ -442,11 +452,9 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
watchdog,
|
watchdog,
|
||||||
motionController,
|
motionController,
|
||||||
touchPanel);
|
touchPanel);
|
||||||
ReturnApp(Apps::Settings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::FlashLight:
|
case Apps::FlashLight:
|
||||||
currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
|
currentScreen = std::make_unique<Screens::FlashLight>(this, *systemTask, brightnessController);
|
||||||
ReturnApp(Apps::QuickSettings, FullRefreshDirections::Down, TouchEvents::SwipeDown);
|
|
||||||
break;
|
break;
|
||||||
case Apps::StopWatch:
|
case Apps::StopWatch:
|
||||||
currentScreen = std::make_unique<Screens::StopWatch>(this, *systemTask);
|
currentScreen = std::make_unique<Screens::StopWatch>(this, *systemTask);
|
||||||
|
@ -471,7 +479,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
|
||||||
break;
|
break;
|
||||||
case Apps::Metronome:
|
case Apps::Metronome:
|
||||||
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
|
currentScreen = std::make_unique<Screens::Metronome>(this, motorController, *systemTask);
|
||||||
ReturnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::None);
|
|
||||||
break;
|
break;
|
||||||
case Apps::Motion:
|
case Apps::Motion:
|
||||||
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
|
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "displayapp/Messages.h"
|
#include "displayapp/Messages.h"
|
||||||
#include "BootErrors.h"
|
#include "BootErrors.h"
|
||||||
|
|
||||||
|
#include "StaticStack.h"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
|
|
||||||
namespace Drivers {
|
namespace Drivers {
|
||||||
|
@ -114,14 +116,18 @@ namespace Pinetime {
|
||||||
static void Process(void* instance);
|
static void Process(void* instance);
|
||||||
void InitHw();
|
void InitHw();
|
||||||
void Refresh();
|
void Refresh();
|
||||||
void ReturnApp(Apps app, DisplayApp::FullRefreshDirections direction, TouchEvents touchEvent);
|
void LoadNewScreen(Apps app, DisplayApp::FullRefreshDirections direction);
|
||||||
void LoadApp(Apps app, DisplayApp::FullRefreshDirections direction);
|
void LoadScreen(Apps app, DisplayApp::FullRefreshDirections direction);
|
||||||
void PushMessageToSystemTask(Pinetime::System::Messages message);
|
void PushMessageToSystemTask(Pinetime::System::Messages message);
|
||||||
|
|
||||||
Apps nextApp = Apps::None;
|
Apps nextApp = Apps::None;
|
||||||
DisplayApp::FullRefreshDirections nextDirection;
|
DisplayApp::FullRefreshDirections nextDirection;
|
||||||
System::BootErrors bootError;
|
System::BootErrors bootError;
|
||||||
void ApplyBrightness();
|
void ApplyBrightness();
|
||||||
|
|
||||||
|
static constexpr size_t returnAppStackSize = 10;
|
||||||
|
StaticStack<Apps, returnAppStackSize> returnAppStack;
|
||||||
|
StaticStack<FullRefreshDirections, returnAppStackSize> appStackDirections;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,6 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
bool Metronome::OnTouchEvent(TouchEvents event) {
|
bool Metronome::OnTouchEvent(TouchEvents event) {
|
||||||
if (event == TouchEvents::SwipeDown && allowExit) {
|
if (event == TouchEvents::SwipeDown && allowExit) {
|
||||||
running = false;
|
running = false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue