Power optimization - Increase SystemTaskPeriod

Improve the timeout on the queue : by default, the timeout is 100ms, and it's extended to 4s in sleep mode, when no motion based wake up option is enabled.
This commit is contained in:
Jean-François Milants 2023-05-08 21:07:30 +02:00
parent 7ad970ea87
commit 491d3ae20f
2 changed files with 14 additions and 1 deletions

View file

@ -181,7 +181,7 @@ void SystemTask::Work() {
UpdateMotion();
Messages msg;
if (xQueueReceive(systemTasksMsgQueue, &msg, 4000) == pdTRUE) {
if (xQueueReceive(systemTasksMsgQueue, &msg, GetQueueTimeout()) == pdTRUE) {
switch (msg) {
case Messages::EnableSleeping:
// Make sure that exiting an app doesn't enable sleeping,
@ -504,3 +504,14 @@ void SystemTask::PushMessage(System::Messages msg) {
xQueueSend(systemTasksMsgQueue, &msg, portMAX_DELAY);
}
}
TickType_t SystemTask::GetQueueTimeout() const {
// By default, the timeout on the queue is 100ms.
// It's extended to 4s in sleep mode, when no motion based wake up option is enabled.
TickType_t timeout = pdMS_TO_TICKS(100);
if (state == SystemTaskState::Sleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) &&
!settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake)) {
timeout = pdMS_TO_TICKS(4000);
}
return timeout;
}

View file

@ -138,6 +138,8 @@ namespace Pinetime {
bool stepCounterMustBeReset = false;
static constexpr TickType_t batteryMeasurementPeriod = pdMS_TO_TICKS(10 * 60 * 1000);
TickType_t GetQueueTimeout() const;
SystemMonitor monitor;
};
}