parent
ce26ef8a67
commit
34949a47c5
|
@ -165,8 +165,15 @@ void DisplayApp::Refresh() {
|
||||||
lastWakeTime = xTaskGetTickCount();
|
lastWakeTime = xTaskGetTickCount();
|
||||||
if (messageReceived) {
|
if (messageReceived) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case Messages::GoToSleep:
|
case Messages::DimScreen:
|
||||||
|
// Backup brightness is the brightness to return to after dimming or sleeping
|
||||||
brightnessController.Backup();
|
brightnessController.Backup();
|
||||||
|
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
|
||||||
|
break;
|
||||||
|
case Messages::RestoreBrightness:
|
||||||
|
brightnessController.Restore();
|
||||||
|
break;
|
||||||
|
case Messages::GoToSleep:
|
||||||
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
while (brightnessController.Level() != Controllers::BrightnessController::Levels::Off) {
|
||||||
brightnessController.Lower();
|
brightnessController.Lower();
|
||||||
vTaskDelay(100);
|
vTaskDelay(100);
|
||||||
|
@ -230,6 +237,8 @@ void DisplayApp::Refresh() {
|
||||||
}
|
}
|
||||||
} else if (returnTouchEvent == gesture) {
|
} else if (returnTouchEvent == gesture) {
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
|
brightnessController.Set(settingsController.GetBrightness());
|
||||||
|
brightnessController.Backup();
|
||||||
} else if (touchMode == TouchModes::Gestures) {
|
} else if (touchMode == TouchModes::Gestures) {
|
||||||
if (gesture == TouchEvents::Tap) {
|
if (gesture == TouchEvents::Tap) {
|
||||||
lvgl.SetNewTapEvent(info.x, info.y);
|
lvgl.SetNewTapEvent(info.x, info.y);
|
||||||
|
@ -243,6 +252,8 @@ void DisplayApp::Refresh() {
|
||||||
} else {
|
} else {
|
||||||
if (!currentScreen->OnButtonPushed()) {
|
if (!currentScreen->OnButtonPushed()) {
|
||||||
LoadApp(returnToApp, returnDirection);
|
LoadApp(returnToApp, returnDirection);
|
||||||
|
brightnessController.Set(settingsController.GetBrightness());
|
||||||
|
brightnessController.Backup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -13,7 +13,9 @@ namespace Pinetime {
|
||||||
NewNotification,
|
NewNotification,
|
||||||
TimerDone,
|
TimerDone,
|
||||||
BleFirmwareUpdateStarted,
|
BleFirmwareUpdateStarted,
|
||||||
UpdateTimeOut
|
UpdateTimeOut,
|
||||||
|
DimScreen,
|
||||||
|
RestoreBrightness
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,13 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DimTimerCallback(TimerHandle_t xTimer) {
|
||||||
|
|
||||||
|
NRF_LOG_INFO("DimTimerCallback");
|
||||||
|
auto sysTask = static_cast<SystemTask*>(pvTimerGetTimerID(xTimer));
|
||||||
|
sysTask->OnDim();
|
||||||
|
}
|
||||||
|
|
||||||
void IdleTimerCallback(TimerHandle_t xTimer) {
|
void IdleTimerCallback(TimerHandle_t xTimer) {
|
||||||
|
|
||||||
NRF_LOG_INFO("IdleTimerCallback");
|
NRF_LOG_INFO("IdleTimerCallback");
|
||||||
|
@ -114,7 +121,6 @@ void SystemTask::Work() {
|
||||||
|
|
||||||
nimbleController.Init();
|
nimbleController.Init();
|
||||||
nimbleController.StartAdvertising();
|
nimbleController.StartAdvertising();
|
||||||
brightnessController.Init();
|
|
||||||
lcd.Init();
|
lcd.Init();
|
||||||
|
|
||||||
twiMaster.Init();
|
twiMaster.Init();
|
||||||
|
@ -179,8 +185,9 @@ void SystemTask::Work() {
|
||||||
nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
|
nrf_gpio_cfg_sense_input(pinPowerPresentIrq, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut()), pdFALSE, this, IdleTimerCallback);
|
idleTimer = xTimerCreate("idleTimer", pdMS_TO_TICKS(2000), pdFALSE, this, IdleTimerCallback);
|
||||||
xTimerStart(idleTimer, 0);
|
dimTimer = xTimerCreate("dimTimer", pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), pdFALSE, this, DimTimerCallback);
|
||||||
|
xTimerStart(dimTimer, 0);
|
||||||
|
|
||||||
// Suppress endless loop diagnostic
|
// Suppress endless loop diagnostic
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
|
@ -208,7 +215,7 @@ void SystemTask::Work() {
|
||||||
doNotGoToSleep = true;
|
doNotGoToSleep = true;
|
||||||
break;
|
break;
|
||||||
case Messages::UpdateTimeOut:
|
case Messages::UpdateTimeOut:
|
||||||
xTimerChangePeriod(idleTimer, pdMS_TO_TICKS(settingsController.GetScreenTimeOut()), 0);
|
xTimerChangePeriod(dimTimer, pdMS_TO_TICKS(settingsController.GetScreenTimeOut() - 2000), 0);
|
||||||
break;
|
break;
|
||||||
case Messages::GoToRunning:
|
case Messages::GoToRunning:
|
||||||
spi.Wakeup();
|
spi.Wakeup();
|
||||||
|
@ -220,7 +227,7 @@ void SystemTask::Work() {
|
||||||
}
|
}
|
||||||
|
|
||||||
nimbleController.StartAdvertising();
|
nimbleController.StartAdvertising();
|
||||||
xTimerStart(idleTimer, 0);
|
xTimerStart(dimTimer, 0);
|
||||||
spiNorFlash.Wakeup();
|
spiNorFlash.Wakeup();
|
||||||
lcd.Wakeup();
|
lcd.Wakeup();
|
||||||
|
|
||||||
|
@ -230,6 +237,7 @@ void SystemTask::Work() {
|
||||||
|
|
||||||
isSleeping = false;
|
isSleeping = false;
|
||||||
isWakingUp = false;
|
isWakingUp = false;
|
||||||
|
isDimmed = false;
|
||||||
break;
|
break;
|
||||||
case Messages::TouchWakeUp: {
|
case Messages::TouchWakeUp: {
|
||||||
twiMaster.Wakeup();
|
twiMaster.Wakeup();
|
||||||
|
@ -246,6 +254,7 @@ void SystemTask::Work() {
|
||||||
isGoingToSleep = true;
|
isGoingToSleep = true;
|
||||||
NRF_LOG_INFO("[systemtask] Going to sleep");
|
NRF_LOG_INFO("[systemtask] Going to sleep");
|
||||||
xTimerStop(idleTimer, 0);
|
xTimerStop(idleTimer, 0);
|
||||||
|
xTimerStop(dimTimer, 0);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::GoToSleep);
|
||||||
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
heartRateApp.PushMessage(Pinetime::Applications::HeartRateTask::Messages::GoToSleep);
|
||||||
break;
|
break;
|
||||||
|
@ -283,13 +292,15 @@ void SystemTask::Work() {
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
doNotGoToSleep = false;
|
doNotGoToSleep = false;
|
||||||
xTimerStart(idleTimer, 0);
|
xTimerStart(dimTimer, 0);
|
||||||
break;
|
break;
|
||||||
case Messages::OnTouchEvent:
|
case Messages::OnTouchEvent:
|
||||||
ReloadIdleTimer();
|
ReloadIdleTimer();
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
||||||
break;
|
break;
|
||||||
case Messages::OnButtonEvent:
|
case Messages::OnButtonEvent:
|
||||||
ReloadIdleTimer();
|
ReloadIdleTimer();
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed);
|
||||||
break;
|
break;
|
||||||
case Messages::OnDisplayTaskSleeping:
|
case Messages::OnDisplayTaskSleeping:
|
||||||
if (BootloaderVersion::IsValid()) {
|
if (BootloaderVersion::IsValid()) {
|
||||||
|
@ -381,7 +392,6 @@ void SystemTask::OnButtonPushed() {
|
||||||
if (!isSleeping) {
|
if (!isSleeping) {
|
||||||
NRF_LOG_INFO("[systemtask] Button pushed");
|
NRF_LOG_INFO("[systemtask] Button pushed");
|
||||||
PushMessage(Messages::OnButtonEvent);
|
PushMessage(Messages::OnButtonEvent);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::ButtonPushed);
|
|
||||||
} else {
|
} else {
|
||||||
if (!isWakingUp) {
|
if (!isWakingUp) {
|
||||||
NRF_LOG_INFO("[systemtask] Button pushed, waking up");
|
NRF_LOG_INFO("[systemtask] Button pushed, waking up");
|
||||||
|
@ -402,7 +412,6 @@ void SystemTask::OnTouchEvent() {
|
||||||
return;
|
return;
|
||||||
if (!isSleeping) {
|
if (!isSleeping) {
|
||||||
PushMessage(Messages::OnTouchEvent);
|
PushMessage(Messages::OnTouchEvent);
|
||||||
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
|
|
||||||
} else if (!isWakingUp) {
|
} else if (!isWakingUp) {
|
||||||
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or
|
if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap) or
|
||||||
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) {
|
||||||
|
@ -430,6 +439,15 @@ void SystemTask::PushMessage(System::Messages msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SystemTask::OnDim() {
|
||||||
|
if (doNotGoToSleep)
|
||||||
|
return;
|
||||||
|
NRF_LOG_INFO("Dim timeout -> Dim screen")
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::DimScreen);
|
||||||
|
xTimerStart(idleTimer, 0);
|
||||||
|
isDimmed = true;
|
||||||
|
}
|
||||||
|
|
||||||
void SystemTask::OnIdle() {
|
void SystemTask::OnIdle() {
|
||||||
if (doNotGoToSleep)
|
if (doNotGoToSleep)
|
||||||
return;
|
return;
|
||||||
|
@ -437,8 +455,13 @@ void SystemTask::OnIdle() {
|
||||||
PushMessage(Messages::GoToSleep);
|
PushMessage(Messages::GoToSleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemTask::ReloadIdleTimer() const {
|
void SystemTask::ReloadIdleTimer() {
|
||||||
if (isSleeping || isGoingToSleep)
|
if (isSleeping || isGoingToSleep)
|
||||||
return;
|
return;
|
||||||
xTimerReset(idleTimer, 0);
|
if (isDimmed) {
|
||||||
|
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
|
||||||
|
isDimmed = false;
|
||||||
|
}
|
||||||
|
xTimerReset(dimTimer, 0);
|
||||||
|
xTimerStop(idleTimer, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace Pinetime {
|
||||||
void OnTouchEvent();
|
void OnTouchEvent();
|
||||||
|
|
||||||
void OnIdle();
|
void OnIdle();
|
||||||
|
void OnDim();
|
||||||
|
|
||||||
Pinetime::Controllers::NimbleController& nimble() {
|
Pinetime::Controllers::NimbleController& nimble() {
|
||||||
return nimbleController;
|
return nimbleController;
|
||||||
|
@ -99,6 +100,7 @@ namespace Pinetime {
|
||||||
std::atomic<bool> isSleeping {false};
|
std::atomic<bool> isSleeping {false};
|
||||||
std::atomic<bool> isGoingToSleep {false};
|
std::atomic<bool> isGoingToSleep {false};
|
||||||
std::atomic<bool> isWakingUp {false};
|
std::atomic<bool> isWakingUp {false};
|
||||||
|
std::atomic<bool> isDimmed {false};
|
||||||
Pinetime::Drivers::Watchdog& watchdog;
|
Pinetime::Drivers::Watchdog& watchdog;
|
||||||
Pinetime::Controllers::NotificationManager& notificationManager;
|
Pinetime::Controllers::NotificationManager& notificationManager;
|
||||||
Pinetime::Controllers::MotorController& motorController;
|
Pinetime::Controllers::MotorController& motorController;
|
||||||
|
@ -106,8 +108,6 @@ namespace Pinetime {
|
||||||
Pinetime::Drivers::Bma421& motionSensor;
|
Pinetime::Drivers::Bma421& motionSensor;
|
||||||
Pinetime::Controllers::Settings& settingsController;
|
Pinetime::Controllers::Settings& settingsController;
|
||||||
Pinetime::Controllers::HeartRateController& heartRateController;
|
Pinetime::Controllers::HeartRateController& heartRateController;
|
||||||
|
|
||||||
Controllers::BrightnessController brightnessController;
|
|
||||||
Pinetime::Controllers::MotionController& motionController;
|
Pinetime::Controllers::MotionController& motionController;
|
||||||
|
|
||||||
Pinetime::Applications::DisplayApp& displayApp;
|
Pinetime::Applications::DisplayApp& displayApp;
|
||||||
|
@ -126,9 +126,10 @@ namespace Pinetime {
|
||||||
|
|
||||||
static void Process(void* instance);
|
static void Process(void* instance);
|
||||||
void Work();
|
void Work();
|
||||||
void ReloadIdleTimer() const;
|
void ReloadIdleTimer();
|
||||||
bool isBleDiscoveryTimerRunning = false;
|
bool isBleDiscoveryTimerRunning = false;
|
||||||
uint8_t bleDiscoveryTimer = 0;
|
uint8_t bleDiscoveryTimer = 0;
|
||||||
|
TimerHandle_t dimTimer;
|
||||||
TimerHandle_t idleTimer;
|
TimerHandle_t idleTimer;
|
||||||
bool doNotGoToSleep = false;
|
bool doNotGoToSleep = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue