summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy33
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/components/alarm/AlarmController.cpp2
-rw-r--r--src/components/battery/BatteryController.cpp10
-rw-r--r--src/components/ble/NavigationService.cpp2
-rw-r--r--src/components/heartrate/Ppg.cpp38
-rw-r--r--src/components/heartrate/Ppg.h6
-rw-r--r--src/components/heartrate/Ptagc.cpp8
-rw-r--r--src/components/motion/MotionController.cpp5
-rw-r--r--src/displayapp/DisplayApp.cpp10
-rw-r--r--src/displayapp/screens/FirmwareValidation.cpp6
-rw-r--r--src/displayapp/screens/HeartRate.cpp8
-rw-r--r--src/displayapp/screens/Motion.cpp12
-rw-r--r--src/displayapp/screens/Notifications.cpp18
-rw-r--r--src/displayapp/screens/Steps.h1
-rw-r--r--src/displayapp/screens/SystemInfo.cpp4
-rw-r--r--src/displayapp/screens/Tile.cpp8
-rw-r--r--src/displayapp/screens/Timer.h5
-rw-r--r--src/displayapp/screens/WatchFaceAnalog.cpp22
-rw-r--r--src/displayapp/screens/settings/SettingShakeThreshold.cpp4
-rw-r--r--src/heartratetask/HeartRateTask.cpp35
-rw-r--r--src/main.cpp39
-rw-r--r--src/systemtask/Messages.h4
-rw-r--r--src/systemtask/SystemTask.cpp20
24 files changed, 152 insertions, 150 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 88ca6c54..f1ddc572 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,14 +1,15 @@
-Checks: '*,
- -altera-unroll-loops,
- -llvmlibc-callee-namespace,
- -llvmlibc-implementation-in-namespace,
- -llvmlibc-restrict-system-libc-headers,
- -llvm-header-guard,
- -llvm-namespace-comment,
- -google-build-using-namespace,
- -google-runtime-int,
- -google-readability-namespace-comments,
- -fuchsia-statically-constructed-objects,
+Checks: 'bugprone-*,
+ cert-*,
+ cppcoreguidelines-*,
+ hicpp-*,
+ misc-*,
+ modernize-*,
+ performance-*,
+ portability-*,
+ readability-*,
+ fuchsia-trailing-return,
+ -cert-err58-cpp,
+ -cert-err60-cpp,
-cppcoreguidelines-prefer-member-initializer,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-cppcoreguidelines-pro-bounds-constant-array-index,
@@ -20,10 +21,6 @@ Checks: '*,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-special-member-functions,
- -readability-magic-numbers,
- -readability-uppercase-literal-suffix,
- -modernize-use-trailing-return-type,
- -modernize-avoid-c-arrays,
-hicpp-avoid-c-arrays,
-hicpp-uppercase-literal-suffix,
-hicpp-vararg,
@@ -31,8 +28,10 @@ Checks: '*,
-hicpp-no-array-decay,
-hicpp-signed-bitwise,
-hicpp-special-member-functions,
- -cert-err58-cpp,
- -cert-err60-cpp'
+ -modernize-use-trailing-return-type,
+ -modernize-avoid-c-arrays,
+ -readability-magic-numbers,
+ -readability-uppercase-literal-suffix'
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 100
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e59c0d81..00be3c87 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -778,7 +778,7 @@ link_directories(
)
-set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wextra -Warray-bounds=2 -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-nonliteral -ftree-vrp -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-expansion-to-defined -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin --short-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type -fstack-usage -fno-exceptions -fno-non-call-exceptions)
+set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wextra -Warray-bounds=2 -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-nonliteral -ftree-vrp -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-expansion-to-defined -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fshort-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wreturn-type -Werror=return-type -fstack-usage -fno-exceptions -fno-non-call-exceptions)
add_definitions(-DCONFIG_GPIO_AS_PINRESET)
add_definitions(-DNIMBLE_CFG_CONTROLLER)
add_definitions(-DOS_CPUTIME_FREQ)
diff --git a/src/components/alarm/AlarmController.cpp b/src/components/alarm/AlarmController.cpp
index d97e1cff..88f65d9a 100644
--- a/src/components/alarm/AlarmController.cpp
+++ b/src/components/alarm/AlarmController.cpp
@@ -28,7 +28,7 @@ AlarmController::AlarmController(Controllers::DateTime& dateTimeController) : da
namespace {
void SetOffAlarm(TimerHandle_t xTimer) {
- auto controller = static_cast<Pinetime::Controllers::AlarmController*>(pvTimerGetTimerID(xTimer));
+ auto* controller = static_cast<Pinetime::Controllers::AlarmController*>(pvTimerGetTimerID(xTimer));
controller->SetOffAlarmNow();
}
}
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index b61f0ce3..dc15612e 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -16,8 +16,8 @@ Battery::Battery() {
}
void Battery::ReadPowerState() {
- isCharging = !nrf_gpio_pin_read(PinMap::Charging);
- isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
+ isCharging = (nrf_gpio_pin_read(PinMap::Charging) == 0);
+ isPowerPresent = (nrf_gpio_pin_read(PinMap::PowerPresent) == 0);
if (isPowerPresent && !isCharging) {
isFull = true;
@@ -81,10 +81,8 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
// p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024
voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024;
- uint8_t newPercent;
- if (isFull) {
- newPercent = 100;
- } else {
+ uint8_t newPercent = 100;
+ if (!isFull) {
newPercent = std::min(aprox.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100});
}
diff --git a/src/components/ble/NavigationService.cpp b/src/components/ble/NavigationService.cpp
index 76143686..ea8f3a4d 100644
--- a/src/components/ble/NavigationService.cpp
+++ b/src/components/ble/NavigationService.cpp
@@ -40,7 +40,7 @@ namespace {
constexpr ble_uuid128_t navProgressCharUuid {CharUuid(0x04, 0x00)};
int NAVCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt* ctxt, void* arg) {
- auto navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
+ auto* navService = static_cast<Pinetime::Controllers::NavigationService*>(arg);
return navService->OnCommand(conn_handle, attr_handle, ctxt);
}
} // namespace
diff --git a/src/components/heartrate/Ppg.cpp b/src/components/heartrate/Ppg.cpp
index a5d83696..900b1c22 100644
--- a/src/components/heartrate/Ppg.cpp
+++ b/src/components/heartrate/Ppg.cpp
@@ -29,8 +29,9 @@ namespace {
auto z1 = CompareShift(d, mn - 1, size);
for (int i = mn; i < mx + 1; i++) {
auto z = CompareShift(d, i, size);
- if (z2 > z1 && z1 < z)
+ if (z2 > z1 && z1 < z) {
return i;
+ }
z2 = z1;
z1 = z;
}
@@ -52,41 +53,48 @@ int8_t Ppg::Preprocess(float spl) {
auto spl_int = static_cast<int8_t>(spl);
- if (dataIndex < 200)
+ if (dataIndex < 200) {
data[dataIndex++] = spl_int;
+ }
return spl_int;
}
-float Ppg::HeartRate() {
- if (dataIndex < 200)
+int Ppg::HeartRate() {
+ if (dataIndex < 200) {
return 0;
+ }
NRF_LOG_INFO("PREPROCESS, offset = %d", offset);
auto hr = ProcessHeartRate();
dataIndex = 0;
return hr;
}
-float Ppg::ProcessHeartRate() {
- auto t0 = Trough(data.data(), dataIndex, 7, 48);
- if (t0 < 0)
+
+int Ppg::ProcessHeartRate() {
+ int t0 = Trough(data.data(), dataIndex, 7, 48);
+ if (t0 < 0) {
return 0;
+ }
- float t1 = t0 * 2;
+ int t1 = t0 * 2;
t1 = Trough(data.data(), dataIndex, t1 - 5, t1 + 5);
- if (t1 < 0)
+ if (t1 < 0) {
return 0;
+ }
- float t2 = static_cast<int>(t1 * 3) / 2;
+ int t2 = (t1 * 3) / 2;
t2 = Trough(data.data(), dataIndex, t2 - 5, t2 + 5);
- if (t2 < 0)
+ if (t2 < 0) {
return 0;
+ }
- float t3 = static_cast<int>(t2 * 4) / 3;
+ int t3 = (t2 * 4) / 3;
t3 = Trough(data.data(), dataIndex, t3 - 4, t3 + 4);
- if (t3 < 0)
- return static_cast<int>(60 * 24 * 3) / static_cast<int>(t2);
+ if (t3 < 0) {
+ return (60 * 24 * 3) / t2;
+ }
- return static_cast<int>(60 * 24 * 4) / static_cast<int>(t3);
+ return (60 * 24 * 4) / t3;
}
void Ppg::SetOffset(uint16_t offset) {
diff --git a/src/components/heartrate/Ppg.h b/src/components/heartrate/Ppg.h
index 7000c871..1f709bab 100644
--- a/src/components/heartrate/Ppg.h
+++ b/src/components/heartrate/Ppg.h
@@ -12,9 +12,9 @@ namespace Pinetime {
public:
Ppg();
int8_t Preprocess(float spl);
- float HeartRate();
+ int HeartRate();
- void SetOffset(uint16_t i);
+ void SetOffset(uint16_t offset);
void Reset();
private:
@@ -25,7 +25,7 @@ namespace Pinetime {
Ptagc agc;
Biquad lpf;
- float ProcessHeartRate();
+ int ProcessHeartRate();
};
}
}
diff --git a/src/components/heartrate/Ptagc.cpp b/src/components/heartrate/Ptagc.cpp
index 1c60bc23..221be460 100644
--- a/src/components/heartrate/Ptagc.cpp
+++ b/src/components/heartrate/Ptagc.cpp
@@ -14,13 +14,15 @@ Ptagc::Ptagc(float start, float decay, float threshold) : peak {start}, decay {d
}
float Ptagc::Step(float spl) {
- if (std::abs(spl) > peak)
+ if (std::abs(spl) > peak) {
peak *= boost;
- else
+ } else {
peak *= decay;
+ }
- if ((spl > (peak * threshold)) || (spl < (peak * -threshold)))
+ if ((spl > (peak * threshold)) || (spl < (peak * -threshold))) {
return 0.0f;
+ }
spl = 100.0f * spl / (2.0f * peak);
return spl;
diff --git a/src/components/motion/MotionController.cpp b/src/components/motion/MotionController.cpp
index 7dd32127..d93d769b 100644
--- a/src/components/motion/MotionController.cpp
+++ b/src/components/motion/MotionController.cpp
@@ -26,10 +26,9 @@ bool MotionController::Should_RaiseWake(bool isSleeping) {
if (not isSleeping) {
if (y <= 0) {
return false;
- } else {
- lastYForWakeUp = 0;
- return false;
}
+ lastYForWakeUp = 0;
+ return false;
}
if (y >= 0) {
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 108e380d..015bc8de 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -152,7 +152,7 @@ void DisplayApp::Refresh() {
}
Messages msg;
- if (xQueueReceive(msgQueue, &msg, queueTimeout)) {
+ if (xQueueReceive(msgQueue, &msg, queueTimeout) == pdTRUE) {
switch (msg) {
case Messages::DimScreen:
brightnessController.Set(Controllers::BrightnessController::Levels::Low);
@@ -485,10 +485,9 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
void DisplayApp::PushMessage(Messages msg) {
if (in_isr()) {
- BaseType_t xHigherPriorityTaskWoken;
- xHigherPriorityTaskWoken = pdFALSE;
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(msgQueue, &msg, &xHigherPriorityTaskWoken);
- if (xHigherPriorityTaskWoken) {
+ if (xHigherPriorityTaskWoken == pdTRUE) {
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
} else {
@@ -532,8 +531,7 @@ void DisplayApp::Register(Pinetime::System::SystemTask* systemTask) {
}
void DisplayApp::ApplyBrightness() {
auto brightness = settingsController.GetBrightness();
- if(brightness != Controllers::BrightnessController::Levels::Low &&
- brightness != Controllers::BrightnessController::Levels::Medium &&
+ if (brightness != Controllers::BrightnessController::Levels::Low && brightness != Controllers::BrightnessController::Levels::Medium &&
brightness != Controllers::BrightnessController::Levels::High) {
brightness = Controllers::BrightnessController::Levels::High;
}
diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp
index a2314690..bda6d68d 100644
--- a/src/displayapp/screens/FirmwareValidation.cpp
+++ b/src/displayapp/screens/FirmwareValidation.cpp
@@ -32,16 +32,16 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_BREAK);
lv_obj_set_width(labelIsValidated, 240);
- if (validator.IsValidated())
+ if (validator.IsValidated()) {
lv_label_set_text_static(labelIsValidated, "You have already\n#00ff00 validated# this firmware#");
- else {
+ } else {
lv_label_set_text_static(labelIsValidated,
"Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version.");
buttonValidate = lv_btn_create(lv_scr_act(), nullptr);
buttonValidate->user_data = this;
lv_obj_set_size(buttonValidate, 115, 50);
- lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ lv_obj_align(buttonValidate, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_obj_set_event_cb(buttonValidate, ButtonEventHandler);
lv_obj_set_style_local_bg_color(buttonValidate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp
index 305e0c4b..71bf86ca 100644
--- a/src/displayapp/screens/HeartRate.cpp
+++ b/src/displayapp/screens/HeartRate.cpp
@@ -64,8 +64,9 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app,
label_startStop = lv_label_create(btn_startStop, nullptr);
UpdateStartStopButton(isHrRunning);
- if (isHrRunning)
+ if (isHrRunning) {
systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping);
+ }
taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this);
}
@@ -110,8 +111,9 @@ void HeartRate::OnStartStopEvent(lv_event_t event) {
}
void HeartRate::UpdateStartStopButton(bool isRunning) {
- if (isRunning)
+ if (isRunning) {
lv_label_set_text_static(label_startStop, "Stop");
- else
+ } else {
lv_label_set_text_static(label_startStop, "Start");
+ }
}
diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp
index c2dc4dac..e3689599 100644
--- a/src/displayapp/screens/Motion.cpp
+++ b/src/displayapp/screens/Motion.cpp
@@ -7,9 +7,9 @@ using namespace Pinetime::Applications::Screens;
Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController)
: Screen(app), motionController {motionController} {
- chart = lv_chart_create(lv_scr_act(), NULL);
+ chart = lv_chart_create(lv_scr_act(), nullptr);
lv_obj_set_size(chart, 240, 240);
- lv_obj_align(chart, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
+ lv_obj_align(chart, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
// lv_chart_set_series_opa(chart, LV_OPA_70); /*Opacity of the data series*/
// lv_chart_set_series_width(chart, 4); /*Line width and point radious*/
@@ -28,13 +28,13 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr
lv_chart_init_points(chart, ser3, 0);
lv_chart_refresh(chart); /*Required after direct set*/
- label = lv_label_create(lv_scr_act(), NULL);
+ label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_text_fmt(label, "X #FF0000 %d# Y #00B000 %d# Z #FFFF00 %d#", 0, 0, 0);
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
+ lv_obj_align(label, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
lv_label_set_recolor(label, true);
- labelStep = lv_label_create(lv_scr_act(), NULL);
+ labelStep = lv_label_create(lv_scr_act(), nullptr);
lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
lv_label_set_text_static(labelStep, "Steps ---");
@@ -58,5 +58,5 @@ void Motion::Refresh() {
motionController.X() / 0x10,
motionController.Y() / 0x10,
motionController.Z() / 0x10);
- lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
+ lv_obj_align(label, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
}
diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp
index 90a010f5..5100ef9b 100644
--- a/src/displayapp/screens/Notifications.cpp
+++ b/src/displayapp/screens/Notifications.cpp
@@ -139,15 +139,9 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
case Pinetime::Applications::TouchEvents::SwipeRight:
if (validDisplay) {
- Controllers::NotificationManager::Notification previousNotification;
auto previousMessage = notificationManager.GetPrevious(currentId);
auto nextMessage = notificationManager.GetNext(currentId);
- if (!previousMessage.valid) {
- // dismissed last message (like 5/5), need to go one message down (like 4/4)
- afterDismissNextMessageFromAbove = false; // show next message coming from below
- } else {
- afterDismissNextMessageFromAbove = true; // show next message coming from above
- }
+ afterDismissNextMessageFromAbove = previousMessage.valid;
notificationManager.Dismiss(currentId);
if (previousMessage.valid) {
currentId = previousMessage.id;
@@ -270,7 +264,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
lv_obj_t* alert_count = lv_label_create(container, nullptr);
lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb);
- lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
+ lv_obj_align(alert_count, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 16);
lv_obj_t* alert_type = lv_label_create(container, nullptr);
lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
@@ -288,7 +282,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
}
lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC);
lv_obj_set_width(alert_type, 180);
- lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16);
+ lv_obj_align(alert_type, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 16);
lv_obj_t* alert_subject = lv_label_create(subject_container, nullptr);
lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK);
@@ -312,7 +306,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
bt_accept->user_data = this;
lv_obj_set_event_cb(bt_accept, CallEventHandler);
lv_obj_set_size(bt_accept, 76, 76);
- lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
+ lv_obj_align(bt_accept, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
label_accept = lv_label_create(bt_accept, nullptr);
lv_label_set_text_static(label_accept, Symbols::phone);
lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::highlight);
@@ -321,7 +315,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
bt_reject->user_data = this;
lv_obj_set_event_cb(bt_reject, CallEventHandler);
lv_obj_set_size(bt_reject, 76, 76);
- lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
+ lv_obj_align(bt_reject, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
label_reject = lv_label_create(bt_reject, nullptr);
lv_label_set_text_static(label_reject, Symbols::phoneSlash);
lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED);
@@ -330,7 +324,7 @@ Notifications::NotificationItem::NotificationItem(const char* title,
bt_mute->user_data = this;
lv_obj_set_event_cb(bt_mute, CallEventHandler);
lv_obj_set_size(bt_mute, 76, 76);
- lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
+ lv_obj_align(bt_mute, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
label_mute = lv_label_create(bt_mute, nullptr);
lv_label_set_text_static(label_mute, Symbols::volumMute);
lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h
index f109e0f2..32ad40bd 100644
--- a/src/displayapp/screens/Steps.h
+++ b/src/displayapp/screens/Steps.h
@@ -29,7 +29,6 @@ namespace Pinetime {
uint32_t currentTripSteps = 0;
lv_obj_t* lSteps;
- lv_obj_t* lStepsIcon;
lv_obj_t* stepsArc;
lv_obj_t* resetBtn;
lv_obj_t* resetButtonLabel;
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index 01c35195..b5b17347 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -99,7 +99,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
auto batteryPercent = batteryController.PercentRemaining();
- auto resetReason = [this]() {
+ const auto* resetReason = [this]() {
switch (watchdog.ResetReason()) {
case Drivers::Watchdog::ResetReasons::Watchdog:
return "wtdg";
@@ -182,7 +182,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label, true);
- auto& bleAddr = bleController.Address();
+ const auto& bleAddr = bleController.Address();
lv_label_set_text_fmt(label,
"#808080 BLE MAC#\n"
" %02x:%02x:%02x:%02x:%02x:%02x"
diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp
index a60076ed..681f9c9f 100644
--- a/src/displayapp/screens/Tile.cpp
+++ b/src/displayapp/screens/Tile.cpp
@@ -51,8 +51,9 @@ Tile::Tile(uint8_t screenID,
uint8_t btIndex = 0;
for (uint8_t i = 0; i < 6; i++) {
- if (i == 3)
+ if (i == 3) {
btnmMap[btIndex++] = "\n";
+ }
if (applications[i].application == Apps::None) {
btnmMap[btIndex] = " ";
} else {
@@ -66,7 +67,7 @@ Tile::Tile(uint8_t screenID,
btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr);
lv_btnmatrix_set_map(btnm1, btnmMap);
lv_obj_set_size(btnm1, LV_HOR_RES - 16, LV_VER_RES - 60);
- lv_obj_align(btnm1, NULL, LV_ALIGN_CENTER, 0, 10);
+ lv_obj_align(btnm1, nullptr, LV_ALIGN_CENTER, 0, 10);
lv_obj_set_style_local_radius(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, 20);
lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, LV_OPA_50);
@@ -102,8 +103,9 @@ void Tile::UpdateScreen() {
}
void Tile::OnValueChangedEvent(lv_obj_t* obj, uint32_t buttonId) {
- if (obj != btnm1)
+ if (obj != btnm1) {
return;
+ }
app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up);
running = false;
diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h
index a6b60a17..306281d7 100644
--- a/src/displayapp/screens/Timer.h
+++ b/src/displayapp/screens/Timer.h
@@ -26,7 +26,6 @@ namespace Pinetime::Applications::Screens {
void UpdateMask();
Controllers::TimerController& timerController;
- lv_obj_t* msecTime;
lv_obj_t* btnPlayPause;
lv_obj_t* txtPlayPause;
@@ -40,7 +39,7 @@ namespace Pinetime::Applications::Screens {
Widgets::Counter secondCounter = Widgets::Counter(0, 59, jetbrains_mono_76);
bool buttonPressing = false;
- int maskPosition = 0;
- TickType_t pressTime;
+ lv_coord_t maskPosition = 0;
+ TickType_t pressTime = 0;
};
}
diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp
index 5e5317ee..b36c29d3 100644
--- a/src/displayapp/screens/WatchFaceAnalog.cpp
+++ b/src/displayapp/screens/WatchFaceAnalog.cpp
@@ -61,9 +61,9 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
sMinute = 99;
sSecond = 99;
- lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act(), NULL);
+ lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act(), nullptr);
lv_img_set_src(bg_clock_img, &bg_clock);
- lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0);
+ lv_obj_align(bg_clock_img, nullptr, LV_ALIGN_CENTER, 0, 0);
batteryIcon.Create(lv_scr_act());
lv_obj_align(batteryIcon.GetObject(), nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
@@ -72,24 +72,24 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app,
lv_label_set_text_static(plugIcon, Symbols::plug);
lv_obj_align(plugIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
- notificationIcon = lv_label_create(lv_scr_act(), NULL);
+ notificationIcon = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME);
lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false));
- lv_obj_align(notificationIcon, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0);
+ lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
// Date - Day / Week day
- label_date_day = lv_label_create(lv_scr_act(), NULL);
+ label_date_day = lv_label_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day());
lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER);
- lv_obj_align(label_date_day, NULL, LV_ALIGN_CENTER, 50, 0);
+ lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0);
- minute_body = lv_line_create(lv_scr_act(), NULL);
- minute_body_trace = lv_line_create(lv_scr_act(), NULL);
- hour_body = lv_line_create(lv_scr_act(), NULL);
- hour_body_trace = lv_line_create(lv_scr_act(), NULL);
- second_body = lv_line_create(lv_scr_act(), NULL);
+ minute_body = lv_line_create(lv_scr_act(), nullptr);
+ minute_body_trace = lv_line_create(lv_scr_act(), nullptr);
+ hour_body = lv_line_create(lv_scr_act(), nullptr);
+ hour_body_trace = lv_line_create(lv_scr_act(), nullptr);
+ second_body = lv_line_create(lv_scr_act(), nullptr);
lv_style_init(&second_line_style);
lv_style_set_line_width(&second_line_style, LV_STATE_DEFAULT, 3);
diff --git a/src/displayapp/screens/settings/SettingShakeThreshold.cpp b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
index de46f7de..e7edee9a 100644
--- a/src/displayapp/screens/settings/SettingShakeThreshold.cpp
+++ b/src/displayapp/screens/settings/SettingShakeThreshold.cpp
@@ -57,7 +57,7 @@ SettingShakeThreshold::SettingShakeThreshold(DisplayApp* app,
lv_obj_set_width(calButton, 200);
lv_obj_align(calButton, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btn_set_checkable(calButton, true);
- calLabel = lv_label_create(calButton, NULL);
+ calLabel = lv_label_create(calButton, nullptr);
lv_label_set_text_static(calLabel, "Calibrate");
lv_arc_set_value(positionArc, settingsController.GetShakeThreshold());
@@ -102,7 +102,7 @@ void SettingShakeThreshold::Refresh() {
}
if (xTaskGetTickCount() - vCalTime > pdMS_TO_TICKS(7500)) {
lv_btn_set_state(calButton, LV_STATE_DEFAULT);
- lv_event_send(calButton, LV_EVENT_VALUE_CHANGED, NULL);
+ lv_event_send(calButton, LV_EVENT_VALUE_CHANGED, nullptr);
}
}
if (motionController.currentShakeSpeed() - 300 > lv_arc_get_value(animArc)) {
diff --git a/src/heartratetask/HeartRateTask.cpp b/src/heartratetask/HeartRateTask.cpp
index bc227624..50833ab2 100644
--- a/src/heartratetask/HeartRateTask.cpp
+++ b/src/heartratetask/HeartRateTask.cpp
@@ -6,15 +6,16 @@
using namespace Pinetime::Applications;
HeartRateTask::HeartRateTask(Drivers::Hrs3300& heartRateSensor, Controllers::HeartRateController& controller)
- : heartRateSensor {heartRateSensor}, controller {controller}, ppg {} {
+ : heartRateSensor {heartRateSensor}, controller {controller} {
}
void HeartRateTask::Start() {
messageQueue = xQueueCreate(10, 1);
controller.SetHeartRateTask(this);
- if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle))
+ if (pdPASS != xTaskCreate(HeartRateTask::Process, "Heartrate", 500, this, 0, &taskHandle)) {
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
+ }
}
void HeartRateTask::Process(void* instance) {
@@ -25,17 +26,19 @@ void HeartRateTask::Process(void* instance) {
void HeartRateTask::Work() {
int lastBpm = 0;
while (true) {
- Messages msg;
- uint32_t delay;
+ auto delay = portMAX_DELAY;
if (state == States::Running) {
- if (measurementStarted)
+ if (measurementStarted) {
delay = 40;
- else
+ } else {
delay = 100;
- } else
+ }
+ } else {
delay = portMAX_DELAY;
+ }
- if (xQueueReceive(messageQueue, &msg, delay)) {
+ Messages msg;
+ if (xQueueReceive(messageQueue, &msg, delay) == pdTRUE) {
switch (msg) {
case Messages::GoToSleep:
StopMeasurement();
@@ -49,15 +52,17 @@ void HeartRateTask::Work() {
}
break;
case Messages::StartMeasurement:
- if (measurementStarted)
+ if (measurementStarted) {
break;
+ }
lastBpm = 0;
StartMeasurement();
measurementStarted = true;
break;
case Messages::StopMeasurement:
- if (!measurementStarted)
+ if (!measurementStarted) {
break;
+ }
StopMeasurement();
measurementStarted = false;
break;
@@ -68,8 +73,9 @@ void HeartRateTask::Work() {
ppg.Preprocess(static_cast<float>(heartRateSensor.ReadHrs()));
auto bpm = ppg.HeartRate();
- if (lastBpm == 0 && bpm == 0)
+ if (lastBpm == 0 && bpm == 0) {
controller.Update(Controllers::HeartRateController::States::NotEnoughData, 0);
+ }
if (bpm != 0) {
lastBpm = bpm;
controller.Update(Controllers::HeartRateController::States::Running, lastBpm);
@@ -79,10 +85,9 @@ void HeartRateTask::Work() {
}
void HeartRateTask::PushMessage(HeartRateTask::Messages msg) {
- BaseType_t xHigherPriorityTaskWoken;
- xHigherPriorityTaskWoken = pdFALSE;
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(messageQueue, &msg, &xHigherPriorityTaskWoken);
- if (xHigherPriorityTaskWoken) {
+ if (xHigherPriorityTaskWoken == pdTRUE) {
/* Actual macro used here is port specific. */
// TODO : should I do something here?
}
@@ -91,7 +96,7 @@ void HeartRateTask::PushMessage(HeartRateTask::Messages msg) {
void HeartRateTask::StartMeasurement() {
heartRateSensor.Enable();
vTaskDelay(100);
- ppg.SetOffset(static_cast<float>(heartRateSensor.ReadHrs()));
+ ppg.SetOffset(heartRateSensor.ReadHrs());
}
void HeartRateTask::StopMeasurement() {
diff --git a/src/main.cpp b/src/main.cpp
index ad7a07dc..b205f1e6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -45,7 +45,6 @@
#include "drivers/Cst816s.h"
#include "drivers/PinMap.h"
#include "systemtask/SystemTask.h"
-#include "drivers/PinMap.h"
#include "touchhandler/TouchHandler.h"
#include "buttonhandler/ButtonHandler.h"
@@ -210,29 +209,29 @@ void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void) {
}
}
-static void (*radio_isr_addr)(void);
-static void (*rng_isr_addr)(void);
-static void (*rtc0_isr_addr)(void);
+static void (*radio_isr_addr)();
+static void (*rng_isr_addr)();
+static void (*rtc0_isr_addr)();
/* Some interrupt handlers required for NimBLE radio driver */
extern "C" {
void RADIO_IRQHandler(void) {
- ((void (*)(void)) radio_isr_addr)();
+ ((void (*)()) radio_isr_addr)();
}
void RNG_IRQHandler(void) {
- ((void (*)(void)) rng_isr_addr)();
+ ((void (*)()) rng_isr_addr)();
}
void RTC0_IRQHandler(void) {
- ((void (*)(void)) rtc0_isr_addr)();
+ ((void (*)()) rtc0_isr_addr)();
}
void WDT_IRQHandler(void) {
nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT);
}
-void npl_freertos_hw_set_isr(int irqn, void (*addr)(void)) {
+void npl_freertos_hw_set_isr(int irqn, void (*addr)()) {
switch (irqn) {
case RADIO_IRQn:
radio_isr_addr = addr;
@@ -243,6 +242,8 @@ void npl_freertos_hw_set_isr(int irqn, void (*addr)(void)) {
case RTC0_IRQn:
rtc0_isr_addr = addr;
break;
+ default:
+ break;
}
}
@@ -253,7 +254,7 @@ uint32_t npl_freertos_hw_enter_critical(void) {
}
void npl_freertos_hw_exit_critical(uint32_t ctx) {
- if (!ctx) {
+ if (ctx == 0) {
__enable_irq();
}
}
@@ -265,15 +266,14 @@ struct ble_npl_eventq* nimble_port_get_dflt_eventq(void) {
}
void nimble_port_run(void) {
- struct ble_npl_event* ev;
-
- while (1) {
- ev = ble_npl_eventq_get(&g_eventq_dflt, BLE_NPL_TIME_FOREVER);
- ble_npl_event_run(ev);
+ struct ble_npl_event* event;
+ while (true) {
+ event = ble_npl_eventq_get(&g_eventq_dflt, BLE_NPL_TIME_FOREVER);
+ ble_npl_event_run(event);
}
}
-void BleHost(void*) {
+void BleHost(void* /*unused*/) {
nimble_port_run();
}
@@ -285,8 +285,7 @@ void nimble_port_init(void) {
ble_hs_init();
ble_store_ram_init();
- int res;
- res = hal_timer_init(5, NULL);
+ int res = hal_timer_init(5, nullptr);
ASSERT(res == 0);
res = os_cputime_init(32768);
ASSERT(res == 0);
@@ -301,17 +300,17 @@ void nimble_port_ll_task_func(void* args) {
}
}
-void calibrate_lf_clock_rc(nrf_drv_clock_evt_type_t event) {
+void calibrate_lf_clock_rc(nrf_drv_clock_evt_type_t /*event*/) {
// 16 * 0.25s = 4s calibration cycle
// Not recursive, call is deferred via internal calibration timer
nrf_drv_clock_calibration_start(16, calibrate_lf_clock_rc);
}
-int main(void) {
+int main() {
logger.Init();
nrf_drv_clock_init();
- nrf_drv_clock_lfclk_request(NULL);
+ nrf_drv_clock_lfclk_request(nullptr);
// When loading the firmware via the Wasp-OS reloader-factory, which uses the used internal LF RC oscillator,
// the LF clock has to be explicitly restarted because InfiniTime uses the external crystal oscillator if available.
diff --git a/src/systemtask/Messages.h b/src/systemtask/Messages.h
index 7a46e060..d730d74f 100644
--- a/src/systemtask/Messages.h
+++ b/src/systemtask/Messages.h
@@ -1,8 +1,8 @@
#pragma once
-
+#include <cstdint>
namespace Pinetime {
namespace System {
- enum class Messages {
+ enum class Messages : uint8_t {
GoToSleep,
GoToRunning,
TouchWakeUp,
diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp
index ef631af7..01056a9a 100644
--- a/src/systemtask/SystemTask.cpp
+++ b/src/systemtask/SystemTask.cpp
@@ -30,14 +30,14 @@ namespace {
void DimTimerCallback(TimerHandle_t xTimer) {
NRF_LOG_INFO("DimTimerCallback");
- auto sysTask = static_cast<SystemTask*>(pvTimerGetTimerID(xTimer));
+ auto* sysTask = static_cast<SystemTask*>(pvTimerGetTimerID(xTimer));
sysTask->OnDim();
}
void IdleTimerCallback(TimerHandle_t xTimer) {
NRF_LOG_INFO("IdleTimerCallback");
- auto sysTask = static_cast<SystemTask*>(pvTimerGetTimerID(xTimer));
+ auto* sysTask = static_cast<SystemTask*>(pvTimerGetTimerID(xTimer));
sysTask->OnIdle();
}
@@ -208,10 +208,9 @@ void SystemTask::Work() {
while (true) {
UpdateMotion();
- uint8_t msg;
- if (xQueueReceive(systemTasksMsgQueue, &msg, 100)) {
- Messages message = static_cast<Messages>(msg);
- switch (message) {
+ Messages msg;
+ if (xQueueReceive(systemTasksMsgQueue, &msg, 100) == pdTRUE) {
+ switch (msg) {
case Messages::EnableSleeping:
// Make sure that exiting an app doesn't enable sleeping,
// if the exiting was caused by a firmware update
@@ -348,7 +347,7 @@ void SystemTask::Work() {
displayApp.PushMessage(Pinetime::Applications::Display::Messages::TouchEvent);
break;
case Messages::HandleButtonEvent: {
- Controllers::ButtonActions action;
+ Controllers::ButtonActions action = Controllers::ButtonActions::None;
if (nrf_gpio_pin_read(Pinetime::PinMap::Button) == 0) {
action = buttonHandler.HandleEvent(Controllers::ButtonHandler::Events::Release);
} else {
@@ -459,7 +458,7 @@ 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) == 0) {
watchdog.Kick();
}
}
@@ -552,10 +551,9 @@ void SystemTask::PushMessage(System::Messages msg) {
}
if (in_isr()) {
- BaseType_t xHigherPriorityTaskWoken;
- xHigherPriorityTaskWoken = pdFALSE;
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken);
- if (xHigherPriorityTaskWoken) {
+ if (xHigherPriorityTaskWoken == pdTRUE) {
/* Actual macro used here is port specific. */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}