From 13da1e38f019ef8989df1423164bd080768a7e04 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 14:53:11 +0300 Subject: [PATCH 01/28] Switched from NULL to nullptr --- src/displayapp/screens/Brightness.cpp | 6 ++--- src/displayapp/screens/Clock.cpp | 22 +++++++++---------- src/displayapp/screens/DropDownDemo.cpp | 4 ++-- src/displayapp/screens/FirmwareUpdate.cpp | 10 ++++----- src/displayapp/screens/FirmwareValidation.cpp | 20 ++++++++--------- src/displayapp/screens/Gauge.cpp | 4 ++-- src/displayapp/screens/Label.cpp | 2 +- src/displayapp/screens/Meter.cpp | 4 ++-- src/displayapp/screens/Modal.cpp | 6 ++--- src/displayapp/screens/Tile.cpp | 2 +- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp index 9e3416c0..8ea9a771 100644 --- a/src/displayapp/screens/Brightness.cpp +++ b/src/displayapp/screens/Brightness.cpp @@ -11,15 +11,15 @@ void slider_event_cb(lv_obj_t * slider, lv_event_t event) { } Brightness::Brightness(Pinetime::Applications::DisplayApp *app, Controllers::BrightnessController& brightness) : Screen(app), brightness{brightness} { - slider = lv_slider_create(lv_scr_act(), NULL); + slider = lv_slider_create(lv_scr_act(), nullptr); lv_obj_set_user_data(slider, this); lv_obj_set_width(slider, LV_DPI * 2); - lv_obj_align(slider, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(slider, nullptr, LV_ALIGN_CENTER, 0, 0); lv_obj_set_event_cb(slider, slider_event_cb); lv_slider_set_range(slider, 0, 2); lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF); - slider_label = lv_label_create(lv_scr_act(), NULL); + slider_label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(slider_label, LevelToString(brightness.Level())); lv_obj_set_auto_realign(slider_label, true); lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 243d4c04..bb14d520 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -29,28 +29,28 @@ Clock::Clock(DisplayApp* app, displayedChar[3] = 0; displayedChar[4] = 0; - batteryIcon = lv_label_create(lv_scr_act(), NULL); + batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(batteryIcon, Symbols::batteryFull); lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, -5, 2); - batteryPlug = lv_label_create(lv_scr_act(), NULL); + batteryPlug = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(batteryPlug, Symbols::plug); lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); - bleIcon = lv_label_create(lv_scr_act(), NULL); + bleIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(bleIcon, Symbols::bluetooth); lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); - label_date = lv_label_create(lv_scr_act(), NULL); + label_date = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60); - label_time = lv_label_create(lv_scr_act(), NULL); + label_time = lv_label_create(lv_scr_act(), nullptr); lv_label_set_style(label_time, LV_LABEL_STYLE_MAIN, LabelBigStyle); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 0); - backgroundLabel = lv_label_create(lv_scr_act(), NULL); + backgroundLabel = lv_label_create(lv_scr_act(), nullptr); backgroundLabel->user_data = this; lv_obj_set_click(backgroundLabel, true); lv_obj_set_event_cb(backgroundLabel, event_handler); @@ -60,23 +60,23 @@ Clock::Clock(DisplayApp* app, lv_label_set_text(backgroundLabel, ""); - heartbeatIcon = lv_label_create(lv_scr_act(), NULL); + heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(heartbeatIcon, Symbols::heartBeat); lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2); - heartbeatValue = lv_label_create(lv_scr_act(), NULL); + heartbeatValue = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(heartbeatValue, "0"); lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); - heartbeatBpm = lv_label_create(lv_scr_act(), NULL); + heartbeatBpm = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(heartbeatBpm, "BPM"); lv_obj_align(heartbeatBpm, heartbeatValue, LV_ALIGN_OUT_RIGHT_MID, 5, 0); - stepValue = lv_label_create(lv_scr_act(), NULL); + stepValue = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(stepValue, "0"); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2); - stepIcon = lv_label_create(lv_scr_act(), NULL); + stepIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(stepIcon, Symbols::shoe); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); } diff --git a/src/displayapp/screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp index 735a0cce..ce3acd53 100644 --- a/src/displayapp/screens/DropDownDemo.cpp +++ b/src/displayapp/screens/DropDownDemo.cpp @@ -9,7 +9,7 @@ extern lv_font_t jetbrains_mono_bold_20; DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp *app) : Screen(app) { // Create the dropdown object, with many item, and fix its height - ddlist = lv_ddlist_create(lv_scr_act(), NULL); + ddlist = lv_ddlist_create(lv_scr_act(), nullptr); lv_ddlist_set_options(ddlist, "Apple\n" "Banana\n" "Orange\n" @@ -24,7 +24,7 @@ DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp *app) : Screen(app lv_ddlist_set_fix_width(ddlist, 150); lv_ddlist_set_draw_arrow(ddlist, true); lv_ddlist_set_fix_height(ddlist, 150); - lv_obj_align(ddlist, NULL, LV_ALIGN_IN_TOP_MID, 0, 20); + lv_obj_align(ddlist, nullptr, LV_ALIGN_IN_TOP_MID, 0, 20); } DropDownDemo::~DropDownDemo() { diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp index e831114d..778409eb 100644 --- a/src/displayapp/screens/FirmwareUpdate.cpp +++ b/src/displayapp/screens/FirmwareUpdate.cpp @@ -10,19 +10,19 @@ extern lv_font_t jetbrains_mono_bold_20; FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::Ble& bleController) : Screen(app), bleController{bleController} { - titleLabel = lv_label_create(lv_scr_act(), NULL); + titleLabel = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(titleLabel, "Firmware update"); lv_obj_set_auto_realign(titleLabel, true); - lv_obj_align(titleLabel, NULL, LV_ALIGN_IN_TOP_MID, 0, 50); + lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50); - bar1 = lv_bar_create(lv_scr_act(), NULL); + bar1 = lv_bar_create(lv_scr_act(), nullptr); lv_obj_set_size(bar1, 200, 30); - lv_obj_align(bar1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(bar1, nullptr, LV_ALIGN_CENTER, 0, 0); lv_bar_set_anim_time(bar1, 10); lv_bar_set_range(bar1, 0, 100); lv_bar_set_value(bar1, 0, LV_ANIM_OFF); - percentLabel = lv_label_create(lv_scr_act(), NULL); + percentLabel = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(percentLabel, ""); lv_obj_set_auto_realign(percentLabel, true); lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60); diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index 2300b41d..4ac399ff 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -20,20 +20,20 @@ namespace { FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::FirmwareValidator &validator) : Screen{app}, validator{validator} { - labelVersionInfo = lv_label_create(lv_scr_act(), NULL); - lv_obj_align(labelVersionInfo, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); + labelVersionInfo = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(labelVersionInfo, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); lv_label_set_text(labelVersionInfo, "Version : "); lv_label_set_align(labelVersionInfo, LV_LABEL_ALIGN_LEFT); - labelVersionValue = lv_label_create(lv_scr_act(), NULL); + labelVersionValue = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(labelVersionValue, labelVersionInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0); lv_label_set_recolor(labelVersionValue, true); sprintf(version, "%ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch()); lv_label_set_text(labelVersionValue, version); - labelIsValidated = lv_label_create(lv_scr_act(), NULL); - lv_obj_align(labelIsValidated, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 50); + labelIsValidated = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 50); lv_label_set_recolor(labelIsValidated, true); lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_BREAK); lv_obj_set_width(labelIsValidated, 240); @@ -44,21 +44,21 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp *app, lv_label_set_text(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version."); - buttonValidate = lv_btn_create(lv_scr_act(), NULL); + buttonValidate = lv_btn_create(lv_scr_act(), nullptr); lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); buttonValidate->user_data = this; lv_obj_set_event_cb(buttonValidate, ButtonEventHandler); - labelButtonValidate = lv_label_create(buttonValidate, NULL); + labelButtonValidate = lv_label_create(buttonValidate, nullptr); lv_label_set_recolor(labelButtonValidate, true); lv_label_set_text(labelButtonValidate, "#00ff00 Validate#"); - buttonReset = lv_btn_create(lv_scr_act(), NULL); + buttonReset = lv_btn_create(lv_scr_act(), nullptr); buttonReset->user_data = this; - lv_obj_align(buttonReset, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); + lv_obj_align(buttonReset, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); lv_obj_set_event_cb(buttonReset, ButtonEventHandler); - labelButtonReset = lv_label_create(buttonReset, NULL); + labelButtonReset = lv_label_create(buttonReset, nullptr); lv_label_set_recolor(labelButtonReset, true); lv_label_set_text(labelButtonReset, "#ff0000 Reset#"); } diff --git a/src/displayapp/screens/Gauge.cpp b/src/displayapp/screens/Gauge.cpp index fd905231..81c283ca 100644 --- a/src/displayapp/screens/Gauge.cpp +++ b/src/displayapp/screens/Gauge.cpp @@ -25,11 +25,11 @@ Gauge::Gauge(Pinetime::Applications::DisplayApp *app) : Screen(app) { needle_colors[0] = LV_COLOR_ORANGE; /*Create a gauge*/ - gauge1 = lv_gauge_create(lv_scr_act(), NULL); + gauge1 = lv_gauge_create(lv_scr_act(), nullptr); lv_gauge_set_style(gauge1, LV_GAUGE_STYLE_MAIN, &style); lv_gauge_set_needle_count(gauge1, 1, needle_colors); lv_obj_set_size(gauge1, 180, 180); - lv_obj_align(gauge1, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(gauge1, nullptr, LV_ALIGN_CENTER, 0, 0); lv_gauge_set_scale(gauge1, 360, 60, 0); lv_gauge_set_range(gauge1, 0, 59); diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp index 780ee88e..540776cc 100644 --- a/src/displayapp/screens/Label.cpp +++ b/src/displayapp/screens/Label.cpp @@ -4,7 +4,7 @@ using namespace Pinetime::Applications::Screens; Label::Label(Pinetime::Applications::DisplayApp *app, const char *text) : Screen(app), text{text} { - label = lv_label_create(lv_scr_act(), NULL); + label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_align(label, LV_LABEL_ALIGN_LEFT); lv_obj_set_size(label, 240, 240); lv_label_set_text(label, text); diff --git a/src/displayapp/screens/Meter.cpp b/src/displayapp/screens/Meter.cpp index c74b8bdf..273e111d 100644 --- a/src/displayapp/screens/Meter.cpp +++ b/src/displayapp/screens/Meter.cpp @@ -17,14 +17,14 @@ Meter::Meter(Pinetime::Applications::DisplayApp *app) : Screen(app) { style_lmeter.body.padding.left = 16; /*Line length*/ /*Create a line meter */ - lmeter = lv_lmeter_create(lv_scr_act(), NULL); + lmeter = lv_lmeter_create(lv_scr_act(), nullptr); lv_lmeter_set_range(lmeter, 0, 60); /*Set the range*/ lv_lmeter_set_value(lmeter, value); /*Set the current value*/ lv_lmeter_set_angle_offset(lmeter, 180); lv_lmeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/ lv_lmeter_set_style(lmeter, LV_LMETER_STYLE_MAIN, &style_lmeter); /*Apply the new style*/ lv_obj_set_size(lmeter, 150, 150); - lv_obj_align(lmeter, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0); } diff --git a/src/displayapp/screens/Modal.cpp b/src/displayapp/screens/Modal.cpp index 63ae70c0..29f7bfa7 100644 --- a/src/displayapp/screens/Modal.cpp +++ b/src/displayapp/screens/Modal.cpp @@ -54,7 +54,7 @@ void Modal::Show(const char* msg) { modal_style.body.main_color = modal_style.body.grad_color = LV_COLOR_BLACK; modal_style.body.opa = LV_OPA_50; - obj = lv_obj_create(lv_scr_act(), NULL); + obj = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_style(obj, &modal_style); lv_obj_set_pos(obj, 0, 0); lv_obj_set_size(obj, LV_HOR_RES, LV_VER_RES); @@ -63,10 +63,10 @@ void Modal::Show(const char* msg) { static const char * btns2[] = {"Ok", ""}; /* Create the message box as a child of the modal background */ - mbox = lv_mbox_create(obj, NULL); + mbox = lv_mbox_create(obj, nullptr); lv_mbox_add_btns(mbox, btns2); lv_mbox_set_text(mbox, msg); - lv_obj_align(mbox, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(mbox, nullptr, LV_ALIGN_CENTER, 0, 0); lv_obj_set_event_cb(mbox, Modal::mbox_event_cb); mbox->user_data = this; diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index deb88472..75fa6ef5 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -30,7 +30,7 @@ Tile::Tile(DisplayApp* app, std::array& applications) : Screen( } modal.reset(new Modal(app)); - btnm1 = lv_btnm_create(lv_scr_act(), NULL); + btnm1 = lv_btnm_create(lv_scr_act(), nullptr); lv_btnm_set_map(btnm1, btnm_map1); lv_obj_set_size(btnm1, LV_HOR_RES, LV_VER_RES); From e85d1ffc625c73dcbb30c783707bfb6110af6a41 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 15:09:17 +0300 Subject: [PATCH 02/28] Replaced NULL with nullptr --- src/systemtask/SystemMonitor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemtask/SystemMonitor.h b/src/systemtask/SystemMonitor.h index ec1fd817..029a1364 100644 --- a/src/systemtask/SystemMonitor.h +++ b/src/systemtask/SystemMonitor.h @@ -27,7 +27,7 @@ namespace Pinetime { void Process() const { if(xTaskGetTickCount() - lastTick > 10000) { NRF_LOG_INFO("---------------------------------------\nFree heap : %d", xPortGetFreeHeapSize()); - auto nb = uxTaskGetSystemState(tasksStatus, 10, NULL); + auto nb = uxTaskGetSystemState(tasksStatus, 10, nullptr); for (uint32_t i = 0; i < nb; i++) { NRF_LOG_INFO("Task [%s] - %d", tasksStatus[i].pcTaskName, tasksStatus[i].usStackHighWaterMark); if (tasksStatus[i].usStackHighWaterMark < 20) From 1d96758acd4e3bf03c3e733a3a95d0deb74f6042 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 15:11:21 +0300 Subject: [PATCH 03/28] Minor #include improvements --- src/displayapp/screens/Tab.cpp | 4 ++-- src/systemtask/SystemTask.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/displayapp/screens/Tab.cpp b/src/displayapp/screens/Tab.cpp index adc32578..44b806c0 100644 --- a/src/displayapp/screens/Tab.cpp +++ b/src/displayapp/screens/Tab.cpp @@ -1,13 +1,13 @@ #include #include -#include +#include "components/datetime/DateTimeController.h" #include #include #include #include #include #include "Tab.h" -#include +#include "displayapp/DisplayApp.h" using namespace Pinetime::Applications::Screens; diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 68f8ab53..0ed99f86 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "../main.h" +#include "main.h" #include "components/ble/NimbleController.h" using namespace Pinetime::System; @@ -36,7 +36,7 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, bleController{bleController}, dateTimeController{dateTimeController}, watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager}, nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash) { - systemTaksMsgQueue = xQueueCreate(10, 1); + systemTasksMsgQueue = xQueueCreate(10, 1); } void SystemTask::Start() { @@ -102,7 +102,7 @@ void SystemTask::Work() { while(true) { uint8_t msg; - if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?2500 : 1000)) { + if (xQueueReceive(systemTasksMsgQueue, &msg, isSleeping ? 2500 : 1000)) { Messages message = static_cast(msg); switch(message) { case Messages::GoToRunning: @@ -191,6 +191,8 @@ void SystemTask::Work() { if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); } + // Clear diagnostic suppression + #pragma clang diagnostic pop } void SystemTask::OnButtonPushed() { @@ -228,7 +230,7 @@ void SystemTask::PushMessage(SystemTask::Messages msg) { } BaseType_t xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE; - xQueueSendFromISR(systemTaksMsgQueue, &msg, &xHigherPriorityTaskWoken); + xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken); if (xHigherPriorityTaskWoken) { /* Actual macro used here is port specific. */ // TODO : should I do something here? From 9b7ba7b5b84072e5abbb0c77c7ea5c52cbbb1098 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 15:13:01 +0300 Subject: [PATCH 04/28] Fixed a typo in SystemTask --- src/systemtask/SystemTask.cpp | 6 +++--- src/systemtask/SystemTask.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 68f8ab53..bb3a7728 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -36,7 +36,7 @@ SystemTask::SystemTask(Drivers::SpiMaster &spi, Drivers::St7789 &lcd, bleController{bleController}, dateTimeController{dateTimeController}, watchdog{}, watchdogView{watchdog}, notificationManager{notificationManager}, nimbleController(*this, bleController,dateTimeController, notificationManager, batteryController, spiNorFlash) { - systemTaksMsgQueue = xQueueCreate(10, 1); + systemTasksMsgQueue = xQueueCreate(10, 1); } void SystemTask::Start() { @@ -102,7 +102,7 @@ void SystemTask::Work() { while(true) { uint8_t msg; - if (xQueueReceive(systemTaksMsgQueue, &msg, isSleeping?2500 : 1000)) { + if (xQueueReceive(systemTasksMsgQueue, &msg, isSleeping?2500 : 1000)) { Messages message = static_cast(msg); switch(message) { case Messages::GoToRunning: @@ -228,7 +228,7 @@ void SystemTask::PushMessage(SystemTask::Messages msg) { } BaseType_t xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE; - xQueueSendFromISR(systemTaksMsgQueue, &msg, &xHigherPriorityTaskWoken); + xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken); if (xHigherPriorityTaskWoken) { /* Actual macro used here is port specific. */ // TODO : should I do something here? diff --git a/src/systemtask/SystemTask.h b/src/systemtask/SystemTask.h index 1be28e3f..6ef0cfbf 100644 --- a/src/systemtask/SystemTask.h +++ b/src/systemtask/SystemTask.h @@ -54,7 +54,7 @@ namespace Pinetime { std::unique_ptr displayApp; Pinetime::Controllers::Ble& bleController; Pinetime::Controllers::DateTime& dateTimeController; - QueueHandle_t systemTaksMsgQueue; + QueueHandle_t systemTasksMsgQueue; std::atomic isSleeping{false}; std::atomic isGoingToSleep{false}; std::atomic isWakingUp{false}; From 77f4d5448bb05287a3802ce3511817fc27a825ab Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 15:14:09 +0300 Subject: [PATCH 05/28] Fixed a small warning with Screen's constructor --- src/displayapp/screens/Screen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index dbf81a44..0a17b4da 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -9,7 +9,7 @@ namespace Pinetime { namespace Screens { class Screen { public: - Screen(DisplayApp* app) : app{app} {} + explicit Screen(DisplayApp* app) : app{app} {} virtual ~Screen() = default; // Return false if the app can be closed, true if it must continue to run From cc3a9f3c793b943eb633f7c914e654ae19b77b9b Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 18:46:34 +0300 Subject: [PATCH 06/28] Removed an incomplete message() call from CMakeLists.txt --- src/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f38ec58..961dedb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -747,7 +747,6 @@ elseif (USE_OPENOCD) COMMENT "flashing ${EXECUTABLE_NAME}.hex" ) else () - message() add_custom_target(FLASH_ERASE COMMAND ${OPENOCD_BIN_PATH} -f interface/stlink.cfg -c 'transport select hla_swd' -f target/nrf52.cfg -c init -c halt -c 'nrf5 mass_erase' -c reset -c shutdown COMMENT "erasing flashing" From c4599dbf90d10cf140579388a400b2d5ffd9ff58 Mon Sep 17 00:00:00 2001 From: Maarten de Jong <35239587+arteeh@users.noreply.github.com> Date: Tue, 6 Oct 2020 21:10:51 +0200 Subject: [PATCH 07/28] Fix typo GCC output file is .out instead of .bin --- doc/filesInReleaseNotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/filesInReleaseNotes.md b/doc/filesInReleaseNotes.md index d2930513..2fdfadf4 100644 --- a/doc/filesInReleaseNotes.md +++ b/doc/filesInReleaseNotes.md @@ -42,7 +42,7 @@ This firmware is intended to be used with our [MCUBoot-based bootloader](../boot The following files are not directly usable by the bootloader: - - **pinetime-mcuboot-app.bin** : Output file of GCC containing debug symbols, useful is you want to debug the firmware using GDB. + - **pinetime-mcuboot-app.out** : Output file of GCC containing debug symbols, useful is you want to debug the firmware using GDB. - **pinetime-mcuboot-app.hex** : Firmware in Intel HEX file format. - **pinetime-mcuboot-app.bin** : Firmware in binary format. - **pinetime-mcuboot-app.map** : Map file containing all the symbols, addresses in memory,... From f68c7b65b31f0bb7ff729740a29d5796b2c04f01 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 15:08:48 +0300 Subject: [PATCH 08/28] Minor formatting, diagnostic and documentation changes --- src/CMakeLists.txt | 2 +- src/displayapp/screens/InfiniPaint.cpp | 12 ++++++------ src/displayapp/screens/Screen.h | 18 +++++++++++++++--- src/logging/NrfLogger.cpp | 5 +++++ src/systemtask/SystemTask.cpp | 5 ++++- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 961dedb4..cd37810f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -552,7 +552,7 @@ link_directories( ) -set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -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) +set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -Wall -Wno-unknown-pragmas -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) add_definitions(-DCONFIG_GPIO_AS_PINRESET) add_definitions(-DDEBUG) add_definitions(-DNIMBLE_CFG_CONTROLLER) diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index b340f5d8..312bb93a 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -7,9 +7,9 @@ using namespace Pinetime::Applications::Screens; extern lv_font_t jetbrains_mono_extrabold_compressed; extern lv_font_t jetbrains_mono_bold_20; -InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp *app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl{lvgl} { +InfiniPaint::InfiniPaint(Pinetime::Applications::DisplayApp *app, Pinetime::Components::LittleVgl &lvgl) : Screen(app), lvgl{lvgl} { app->SetTouchMode(DisplayApp::TouchModes::Polling); - std::fill(b, b+bufferSize, LV_COLOR_WHITE); + std::fill(b, b + bufferSize, LV_COLOR_WHITE); } InfiniPaint::~InfiniPaint() { @@ -33,10 +33,10 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool InfiniPaint::OnTouchEvent(uint16_t x, uint16_t y) { lv_area_t area; - area.x1 = x-(width/2); - area.y1 = y-(height/2); - area.x2 = x+(width/2)-1; - area.y2 = y+(height/2)-1; + area.x1 = x - (width / 2); + area.y1 = y - (height / 2); + area.x2 = x + (width / 2) - 1; + area.y2 = y + (height / 2) - 1; lvgl.SetFullRefresh(Components::LittleVgl::FullRefreshDirections::None); lvgl.FlushDisplay(&area, b); return true; diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index 0a17b4da..6b1d0eec 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -12,13 +12,25 @@ namespace Pinetime { explicit Screen(DisplayApp* app) : app{app} {} virtual ~Screen() = default; - // Return false if the app can be closed, true if it must continue to run + /** + * Most of the time, apps only react to events (touch events, for example). + * In this case you don't need to do anything in this method. + * + * For example, InfiniPaint does nothing in Refresh(). + * But, if you want to update your display periodically, draw an animation... + * you cannot do it in a touch event handler because these handlers are not + * called if the user does not touch the screen. + * + * That's why Refresh() is there: update the display periodically. + * + * @return false if the app can be closed, true if it must continue to run + **/ virtual bool Refresh() = 0; - // Return false if the button hasn't been handled by the app, true if it has been handled + /** @return false if the button hasn't been handled by the app, true if it has been handled */ virtual bool OnButtonPushed() { return false; } - // Return false if the event hasn't been handled by the app, true if it has been handled + /** @return false if the event hasn't been handled by the app, true if it has been handled */ virtual bool OnTouchEvent(TouchEvents event) { return false; } virtual bool OnTouchEvent(uint16_t x, uint16_t y) { return false; } diff --git a/src/logging/NrfLogger.cpp b/src/logging/NrfLogger.cpp index 7ccacc82..0d95c06a 100644 --- a/src/logging/NrfLogger.cpp +++ b/src/logging/NrfLogger.cpp @@ -19,10 +19,15 @@ void NrfLogger::Init() { void NrfLogger::Process(void*) { NRF_LOG_INFO("Logger task started!"); + // Suppress endless loop diagnostic + #pragma clang diagnostic push + #pragma ide diagnostic ignored "EndlessLoop" while (1) { NRF_LOG_FLUSH(); vTaskDelay(100); // Not good for power consumption, it will wake up every 100ms... } + // Clear diagnostic suppression + #pragma clang diagnostic pop } void NrfLogger::Resume() { diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index c0552d53..01942daf 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -100,6 +100,9 @@ void SystemTask::Work() { idleTimer = xTimerCreate ("idleTimer", idleTime, pdFALSE, this, IdleTimerCallback); xTimerStart(idleTimer, 0); + // Suppress endless loop diagnostic + #pragma clang diagnostic push + #pragma ide diagnostic ignored "EndlessLoop" while(true) { uint8_t msg; if (xQueueReceive(systemTasksMsgQueue, &msg, isSleeping ? 2500 : 1000)) { @@ -231,7 +234,7 @@ void SystemTask::PushMessage(SystemTask::Messages msg) { xQueueSendFromISR(systemTasksMsgQueue, &msg, &xHigherPriorityTaskWoken); if (xHigherPriorityTaskWoken) { /* Actual macro used here is port specific. */ - // TODO : should I do something here? + // TODO: should I do something here? } } From 189c5a83b2599dd843b06d2cccdc1f28a89d404f Mon Sep 17 00:00:00 2001 From: Avamander Date: Sun, 4 Oct 2020 16:24:52 +0300 Subject: [PATCH 09/28] Made sure to unsuppress the diagnostic check after the infinite loop declaration --- src/systemtask/SystemTask.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 01942daf..3efe21b8 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -194,6 +194,8 @@ void SystemTask::Work() { if(!nrf_gpio_pin_read(pinButton)) watchdog.Kick(); } + // Clear diagnostic suppression + #pragma clang diagnostic pop } void SystemTask::OnButtonPushed() { From 1c645b776a7c13ea03caba5d0547e073ed0faeae Mon Sep 17 00:00:00 2001 From: Avamander Date: Fri, 9 Oct 2020 11:34:28 +0300 Subject: [PATCH 10/28] Improved code formatting rules --- .idea/codeStyles/Project.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index b3b93deb..7bdfbcb1 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -7,6 +7,10 @@