diff options
Diffstat (limited to 'src/systemtask')
-rw-r--r-- | src/systemtask/Messages.h | 2 | ||||
-rw-r--r-- | src/systemtask/SystemTask.cpp | 58 | ||||
-rw-r--r-- | src/systemtask/SystemTask.h | 3 |
3 files changed, 44 insertions, 19 deletions
diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h index 886505b5..ad13244f 100644 --- a/src/systemtask/Messages.h +++ b/src/systemtask/Messages.h @@ -21,6 +21,8 @@ namespace Pinetime { EnableSleeping, DisableSleeping, OnNewDay, + OnNewHour, + OnNewHalfHour, OnChargingEvent, OnPairing, SetOffAlarm, diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 5ce223a6..75a71ecc 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -1,18 +1,10 @@ #include "systemtask/SystemTask.h" -#define min // workaround: nimble's min/max macros conflict with libstdc++ -#define max -#include <host/ble_gap.h> -#include <host/ble_gatt.h> -#include <host/ble_hs_adv.h> -#include <host/util/util.h> -#include <nimble/hci_common.h> -#undef max -#undef min #include <hal/nrf_rtc.h> #include <libraries/gpiote/app_gpiote.h> #include <libraries/log/nrf_log.h> #include "BootloaderVersion.h" +#include "components/battery/BatteryController.h" #include "components/ble/BleController.h" #include "drivers/Cst816s.h" #include "drivers/St7789.h" @@ -197,13 +189,13 @@ void SystemTask::Work() { // Touchscreen nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup), - static_cast<nrf_gpio_pin_sense_t> GPIO_PIN_CNF_SENSE_Low); + static_cast<nrf_gpio_pin_sense_t>(GPIO_PIN_CNF_SENSE_Low)); pinConfig.skip_gpio_setup = true; pinConfig.hi_accuracy = false; pinConfig.is_watcher = false; pinConfig.sense = static_cast<nrf_gpiote_polarity_t>(NRF_GPIOTE_POLARITY_HITOLO); - pinConfig.pull = static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Pullup; + pinConfig.pull = static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pullup); nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler); @@ -239,6 +231,7 @@ void SystemTask::Work() { if (!bleController.IsFirmwareUpdating()) { doNotGoToSleep = false; } + ReloadIdleTimer(); break; case Messages::DisableSleeping: doNotGoToSleep = true; @@ -295,6 +288,9 @@ void SystemTask::Work() { case Messages::OnNewTime: ReloadIdleTimer(); displayApp.PushMessage(Pinetime::Applications::Display::Messages::UpdateDateTime); + if (alarmController.State() == Controllers::AlarmController::AlarmState::Set) { + alarmController.ScheduleAlarm(); + } break; case Messages::OnNewNotification: if (settingsController.GetNotificationStatus() == Pinetime::Controllers::Settings::Notification::ON) { @@ -343,18 +339,18 @@ void SystemTask::Work() { xTimerStart(dimTimer, 0); break; case Messages::StartFileTransfer: - NRF_LOG_INFO("[systemtask] FS Started"); + NRF_LOG_INFO("[systemtask] FS Started"); doNotGoToSleep = true; if (isSleeping && !isWakingUp) GoToRunning(); - //TODO add intent of fs access icon or something + // TODO add intent of fs access icon or something break; case Messages::StopFileTransfer: NRF_LOG_INFO("[systemtask] FS Stopped"); doNotGoToSleep = false; xTimerStart(dimTimer, 0); - //TODO add intent of fs access icon or something - break; + // TODO add intent of fs access icon or something + break; case Messages::OnTouchEvent: if (touchHandler.GetNewTouchInfo()) { touchHandler.UpdateLvglTouchPoint(); @@ -403,6 +399,26 @@ void SystemTask::Work() { // Remember we'll have to reset the counter next time we're awake stepCounterMustBeReset = true; break; + case Messages::OnNewHour: + using Pinetime::Controllers::AlarmController; + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::Hours && alarmController.State() != AlarmController::AlarmState::Alerting) { + if (isSleeping && !isWakingUp) { + GoToRunning(); + displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); + } + motorController.RunForDuration(35); + } + break; + case Messages::OnNewHalfHour: + using Pinetime::Controllers::AlarmController; + if (settingsController.GetChimeOption() == Controllers::Settings::ChimesOption::HalfHours && alarmController.State() != AlarmController::AlarmState::Alerting) { + if (isSleeping && !isWakingUp) { + GoToRunning(); + displayApp.PushMessage(Pinetime::Applications::Display::Messages::Clock); + } + motorController.RunForDuration(35); + } + break; case Messages::OnChargingEvent: batteryController.ReadPowerState(); motorController.RunForDuration(15); @@ -459,10 +475,10 @@ void SystemTask::UpdateMotion() { return; } - if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)) { + if (isSleeping && !(settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) || + settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake))) { return; } - if (stepCounterMustBeReset) { motionSensor.ResetStepCounter(); stepCounterMustBeReset = false; @@ -472,7 +488,13 @@ void SystemTask::UpdateMotion() { motionController.IsSensorOk(motionSensor.IsOk()); motionController.Update(motionValues.x, motionValues.y, motionValues.z, motionValues.steps); - if (motionController.ShouldWakeUp(isSleeping)) { + + if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist) && + motionController.Should_RaiseWake(isSleeping)) { + GoToRunning(); + } + if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::Shake) && + motionController.Should_ShakeWake(settingsController.GetShakeThreshold())) { GoToRunning(); } } diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index e2e6de7f..517ed1ae 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -3,6 +3,7 @@ #include <memory> #include <FreeRTOS.h> +#include <queue.h> #include <task.h> #include <timers.h> #include <heartratetask/HeartRateTask.h> @@ -12,7 +13,6 @@ #include <components/motion/MotionController.h> #include "systemtask/SystemMonitor.h" -#include "components/battery/BatteryController.h" #include "components/ble/NimbleController.h" #include "components/ble/NotificationManager.h" #include "components/motor/MotorController.h" @@ -46,6 +46,7 @@ namespace Pinetime { class Hrs3300; } namespace Controllers { + class Battery; class TouchHandler; class ButtonHandler; } |