summaryrefslogtreecommitdiff
path: root/src/systemtask/SystemTask.cpp
diff options
context:
space:
mode:
authorAvamander <avamander@gmail.com>2021-12-05 22:22:06 +0200
committerJF <JF002@users.noreply.github.com>2021-12-09 21:30:04 +0100
commit6a442b90a1d310d082e2626128d0f2bf8e932851 (patch)
tree9dbed1540a3e7b35a6e8426c1719be6618a9e242 /src/systemtask/SystemTask.cpp
parent645f6f43dc956e90243aa9230876e537af84e1f6 (diff)
Improved format specifiers, bracing, removed C-style casts, whitespace fixes and removed Tiles shadowing
Diffstat (limited to 'src/systemtask/SystemTask.cpp')
-rw-r--r--src/systemtask/SystemTask.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index 4076d57d..24790a1d 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -115,8 +115,9 @@ SystemTask::SystemTask(Drivers::SpiMaster& spi,
void SystemTask::Start() {
systemTasksMsgQueue = xQueueCreate(10, 1);
- if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle))
+ if (pdPASS != xTaskCreate(SystemTask::Process, "MAIN", 350, this, 0, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
+ }
}
void SystemTask::Process(void* instance) {
@@ -187,20 +188,22 @@ void SystemTask::Work() {
pinConfig.skip_gpio_setup = false;
pinConfig.hi_accuracy = false;
pinConfig.is_watcher = false;
- pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_TOGGLE;
- pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pulldown;
+ pinConfig.sense = static_cast<nrf_gpiote_polarity_t>(NRF_GPIOTE_POLARITY_TOGGLE);
+ pinConfig.pull = static_cast<nrf_gpio_pin_pull_t>(GPIO_PIN_CNF_PULL_Pulldown);
nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler);
nrfx_gpiote_in_event_enable(PinMap::Button, true);
// Touchscreen
- nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup, (nrf_gpio_pin_sense_t) GPIO_PIN_CNF_SENSE_Low);
+ 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);
pinConfig.skip_gpio_setup = true;
pinConfig.hi_accuracy = false;
pinConfig.is_watcher = false;
- pinConfig.sense = (nrf_gpiote_polarity_t) NRF_GPIOTE_POLARITY_HITOLO;
- pinConfig.pull = (nrf_gpio_pin_pull_t) GPIO_PIN_CNF_PULL_Pullup;
+ 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;
nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler);
@@ -328,8 +331,9 @@ void SystemTask::Work() {
break;
case Messages::BleFirmwareUpdateStarted:
doNotGoToSleep = true;
- if (isSleeping && !isWakingUp)
+ if (isSleeping && !isWakingUp) {
GoToRunning();
+ }
displayApp.PushMessage(Pinetime::Applications::Display::Messages::BleFirmwareUpdateStarted);
break;
case Messages::BleFirmwareUpdateFinished:
@@ -429,18 +433,20 @@ void SystemTask::Work() {
uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG);
dateTimeController.UpdateTime(systick_counter);
NoInit_BackUpTime = dateTimeController.CurrentDateTime();
- if (!nrf_gpio_pin_read(PinMap::Button))
+ if (!nrf_gpio_pin_read(PinMap::Button)) {
watchdog.Kick();
+ }
}
-// Clear diagnostic suppression
-#pragma clang diagnostic pop
}
+
void SystemTask::UpdateMotion() {
- if (isGoingToSleep or isWakingUp)
+ if (isGoingToSleep or isWakingUp) {
return;
+ }
- if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist))
+ if (isSleeping && !settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)) {
return;
+ }
if (stepCounterMustBeReset) {
motionSensor.ResetStepCounter();
@@ -489,15 +495,17 @@ void SystemTask::HandleButtonAction(Controllers::ButtonActions action) {
}
void SystemTask::GoToRunning() {
- if (isGoingToSleep or (not isSleeping) or isWakingUp)
+ if (isGoingToSleep or (not isSleeping) or isWakingUp) {
return;
+ }
isWakingUp = true;
PushMessage(Messages::GoToRunning);
}
void SystemTask::OnTouchEvent() {
- if (isGoingToSleep)
+ if (isGoingToSleep) {
return;
+ }
if (!isSleeping) {
PushMessage(Messages::OnTouchEvent);
} else if (!isWakingUp) {
@@ -527,8 +535,9 @@ void SystemTask::PushMessage(System::Messages msg) {
}
void SystemTask::OnDim() {
- if (doNotGoToSleep)
+ if (doNotGoToSleep) {
return;
+ }
NRF_LOG_INFO("Dim timeout -> Dim screen")
displayApp.PushMessage(Pinetime::Applications::Display::Messages::DimScreen);
xTimerStart(idleTimer, 0);
@@ -536,15 +545,17 @@ void SystemTask::OnDim() {
}
void SystemTask::OnIdle() {
- if (doNotGoToSleep)
+ if (doNotGoToSleep) {
return;
+ }
NRF_LOG_INFO("Idle timeout -> Going to sleep")
PushMessage(Messages::GoToSleep);
}
void SystemTask::ReloadIdleTimer() {
- if (isSleeping || isGoingToSleep)
+ if (isSleeping || isGoingToSleep) {
return;
+ }
if (isDimmed) {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::RestoreBrightness);
isDimmed = false;