From 012c246e401c0745d4b6765217ce7137680070da Mon Sep 17 00:00:00 2001 From: Joaquim Date: Sat, 10 Apr 2021 19:09:33 +0100 Subject: 0.16.0 TWI problems fix More memory for freertos heap and timer stack Fix warning in watchface Fix number of bytes read by cst816 Debug app to show freertos tasks Increased the number of bytes of the twi write buffer --- src/displayapp/screens/ApplicationList.cpp | 2 +- src/displayapp/screens/Tasks.cpp | 77 +++++++++++++++++++++++++++++ src/displayapp/screens/Tasks.h | 31 ++++++++++++ src/displayapp/screens/WatchFaceDigital.cpp | 12 ++--- 4 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 src/displayapp/screens/Tasks.cpp create mode 100644 src/displayapp/screens/Tasks.h (limited to 'src/displayapp/screens') diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index 056d128c..ccbd8ca4 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -49,7 +49,7 @@ std::unique_ptr ApplicationList::CreateScreen1() { {Symbols::map, Apps::Navigation}, {Symbols::shoe, Apps::Motion}, {Symbols::heartBeat, Apps::HeartRate}, - {"", Apps::None}, + {"Tasks", Apps::Tasks}, } }; diff --git a/src/displayapp/screens/Tasks.cpp b/src/displayapp/screens/Tasks.cpp new file mode 100644 index 00000000..7bd6c09d --- /dev/null +++ b/src/displayapp/screens/Tasks.cpp @@ -0,0 +1,77 @@ +#include +#include +#include "Tasks.h" +#include +#include "../DisplayApp.h" +#include +#include + +using namespace Pinetime::Applications::Screens; + +static void lv_update_task(struct _lv_task_t *task) { + auto user_data = static_cast(task->user_data); + user_data->UpdateScreen(); +} + +Tasks::Tasks( + Pinetime::Applications::DisplayApp *app) : + Screen(app) +{ + + table = lv_table_create(lv_scr_act(), NULL); + lv_table_set_col_cnt(table, 3); + lv_table_set_row_cnt(table, 8); + //lv_obj_align(table, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_size(table, 240, 240); + lv_obj_set_pos(table, 0, 0); + + /*lv_table_set_cell_type(table, 0, 0, 1); + lv_table_set_cell_type(table, 0, 1, 1); + lv_table_set_cell_type(table, 0, 2, 1); + lv_table_set_cell_type(table, 0, 3, 1);*/ + + lv_table_set_cell_value(table, 0, 0, "#"); + lv_table_set_col_width(table, 0, 50); + lv_table_set_cell_value(table, 0, 1, "Task"); + lv_table_set_col_width(table, 1, 80); + lv_table_set_cell_value(table, 0, 2, "Free"); + lv_table_set_col_width(table, 2, 80); + + lv_obj_t * backgroundLabel = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_set_size(backgroundLabel, 240, 240); + lv_obj_set_pos(backgroundLabel, 0, 0); + lv_label_set_text_static(backgroundLabel, ""); + + UpdateScreen(); + taskUpdate = lv_task_create(lv_update_task, 100000, LV_TASK_PRIO_LOW, this); + +} + +Tasks::~Tasks() { + lv_task_del(taskUpdate); + lv_obj_clean(lv_scr_act()); +} + +bool sortById(const TaskStatus_t &lhs, const TaskStatus_t &rhs) { return lhs.xTaskNumber < rhs.xTaskNumber; } + +void Tasks::UpdateScreen() { + auto nb = uxTaskGetSystemState(tasksStatus, 7, nullptr); + std::sort(tasksStatus, tasksStatus + nb, sortById); + for (uint8_t i = 0; i < nb; i++) { + + lv_table_set_cell_value(table, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str()); + lv_table_set_cell_value(table, i + 1, 1, tasksStatus[i].pcTaskName); + if (tasksStatus[i].usStackHighWaterMark < 20) { + std::string str1 = std::to_string(tasksStatus[i].usStackHighWaterMark) + " low"; + lv_table_set_cell_value(table, i + 1, 2, str1.c_str()); + } else { + lv_table_set_cell_value(table, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str()); + } + + } +} + +bool Tasks::Refresh() { + return running; +} \ No newline at end of file diff --git a/src/displayapp/screens/Tasks.h b/src/displayapp/screens/Tasks.h new file mode 100644 index 00000000..e9a49db4 --- /dev/null +++ b/src/displayapp/screens/Tasks.h @@ -0,0 +1,31 @@ +#pragma once +#include +#include +#include +#include +#include +#include "Screen.h" + +namespace Pinetime { + + namespace Applications { + namespace Screens { + + class Tasks : public Screen{ + public: + Tasks(DisplayApp* app); + ~Tasks() override; + + bool Refresh() override; + void UpdateScreen(); + + private: + mutable TaskStatus_t tasksStatus[7]; + + lv_task_t* taskUpdate; + lv_obj_t * table; + + }; + } + } +} diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index c085b0b4..b1e21924 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -227,12 +227,10 @@ bool WatchFaceDigital::Refresh() { heartbeat = heartRateController.HeartRate(); heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; if(heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { - char heartbeatBuffer[4]; if(heartbeatRunning.Get()) - sprintf(heartbeatBuffer, "%d", heartbeat.Get()); + lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); else - sprintf(heartbeatBuffer, "---"); - + lv_label_set_text_static(heartbeatValue, "---"); lv_label_set_text(heartbeatValue, heartbeatBuffer); lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2); lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); @@ -242,11 +240,7 @@ bool WatchFaceDigital::Refresh() { stepCount = motionController.NbSteps(); motionSensorOk = motionController.IsSensorOk(); if(stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { - char stepBuffer[5]; - if(motionSensorOk.Get()) - sprintf(stepBuffer, "%lu", stepCount.Get()); - else - sprintf(stepBuffer, "---", stepCount.Get()); + lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_label_set_text(stepValue, stepBuffer); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); -- cgit v1.2.3-70-g09d2 From f5e43a16680d1a71c08b02da9a7fef7d6c83abeb Mon Sep 17 00:00:00 2001 From: Joaquim Date: Sun, 11 Apr 2021 17:20:15 +0100 Subject: Move Task info to about menu fix build error in WatchFaceDigital --- src/CMakeLists.txt | 1 - src/displayapp/Apps.h | 2 +- src/displayapp/DisplayApp.cpp | 7 +-- src/displayapp/screens/ApplicationList.cpp | 2 +- src/displayapp/screens/SystemInfo.cpp | 85 +++++++++++++++++------------ src/displayapp/screens/SystemInfo.h | 6 +- src/displayapp/screens/Tasks.cpp | 77 -------------------------- src/displayapp/screens/Tasks.h | 31 ----------- src/displayapp/screens/WatchFaceDigital.cpp | 5 +- 9 files changed, 58 insertions(+), 158 deletions(-) delete mode 100644 src/displayapp/screens/Tasks.cpp delete mode 100644 src/displayapp/screens/Tasks.h (limited to 'src/displayapp/screens') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d8d92432..9dacf378 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -406,7 +406,6 @@ list(APPEND SOURCE_FILES displayapp/screens/FlashLight.cpp displayapp/screens/List.cpp displayapp/screens/BatteryInfo.cpp - displayapp/screens/Tasks.cpp ## Settings displayapp/screens/settings/QuickSettings.cpp diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 5daa82ff..358ea1f7 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -4,7 +4,7 @@ namespace Pinetime { namespace Applications { enum class Apps { None, Launcher, Clock, SysInfo, FirmwareUpdate, FirmwareValidation, NotificationsPreview, Notifications, FlashLight, BatteryInfo, - Music, Paint, Paddle, Twos, HeartRate, Navigation, StopWatch, Motion, Tasks, + Music, Paint, Paddle, Twos, HeartRate, Navigation, StopWatch, Motion, QuickSettings, Settings, SettingWatchFace, SettingTimeFormat, SettingDisplay, SettingWakeUp }; } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index eab4e3b3..773ae9c0 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -24,7 +24,7 @@ #include "displayapp/screens/Twos.h" #include "displayapp/screens/FlashLight.h" #include "displayapp/screens/BatteryInfo.h" -#include "displayapp/screens/Tasks.h" + #include "drivers/Cst816s.h" #include "drivers/St7789.h" #include "drivers/Watchdog.h" @@ -308,11 +308,6 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction) case Apps::Motion: currentScreen = std::make_unique(this, motionController); break; - case Apps::Tasks: - currentScreen = std::make_unique(this); - returnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown); - break; - } currentApp = app; } diff --git a/src/displayapp/screens/ApplicationList.cpp b/src/displayapp/screens/ApplicationList.cpp index ccbd8ca4..056d128c 100644 --- a/src/displayapp/screens/ApplicationList.cpp +++ b/src/displayapp/screens/ApplicationList.cpp @@ -49,7 +49,7 @@ std::unique_ptr ApplicationList::CreateScreen1() { {Symbols::map, Apps::Navigation}, {Symbols::shoe, Apps::Motion}, {Symbols::heartBeat, Apps::HeartRate}, - {"Tasks", Apps::Tasks}, + {"", Apps::None}, } }; diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index f3ac7490..48dba547 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -26,7 +26,8 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp *app, [this]() -> std::unique_ptr { return CreateScreen1(); }, [this]() -> std::unique_ptr { return CreateScreen2(); }, [this]() -> std::unique_ptr { return CreateScreen3(); }, - [this]() -> std::unique_ptr { return CreateScreen4(); } + [this]() -> std::unique_ptr { return CreateScreen4(); }, + [this]() -> std::unique_ptr { return CreateScreen5(); } }, Screens::ScreenListModes::UpDown } {} @@ -37,7 +38,9 @@ SystemInfo::~SystemInfo() { } bool SystemInfo::Refresh() { - screens.Refresh(); + if (running) { + screens.Refresh(); + } return running; } @@ -50,27 +53,8 @@ bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) { return screens.OnTouchEvent(event); } -void SystemInfo::CreateContainer() { - - if ( container1 ) { - container1 = lv_cont_create(lv_scr_act(), nullptr); - - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); - - lv_obj_set_pos(container1, 0, 0); - lv_obj_set_width(container1, LV_HOR_RES - 10); - lv_obj_set_height(container1, LV_VER_RES); - lv_cont_set_layout(container1, LV_LAYOUT_CENTER); - } -} - std::unique_ptr SystemInfo::CreateScreen1() { - CreateContainer(); - - lv_obj_t * label = lv_label_create(container1, nullptr); + lv_obj_t * label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label, true); lv_label_set_text_fmt(label, "#FFFF00 InfiniTime#\n\n" @@ -81,12 +65,11 @@ std::unique_ptr SystemInfo::CreateScreen1() { Version::Major(), Version::Minor(), Version::Patch(), __DATE__, __TIME__); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - return std::unique_ptr(new Screens::Label(0, 4, app, label)); + lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + return std::unique_ptr(new Screens::Label(0, 5, app, label)); } std::unique_ptr SystemInfo::CreateScreen2() { - CreateContainer(); - auto batteryPercent = static_cast(batteryController.PercentRemaining()); float batteryVoltage = batteryController.Voltage(); @@ -126,7 +109,7 @@ std::unique_ptr SystemInfo::CreateScreen2() { batteryVoltageBytes[0] = static_cast((batteryVoltage - batteryVoltageBytes[1]) * 100); //remove whole part of flt and shift 2 places over // - lv_obj_t * label = lv_label_create(container1, nullptr); + lv_obj_t * label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label, true); lv_label_set_text_fmt(label, "#444444 Date# %02d/%02d/%04d\n" @@ -140,6 +123,7 @@ std::unique_ptr SystemInfo::CreateScreen2() { uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds, batteryPercent, batteryVoltageBytes[1], batteryVoltageBytes[0], brightnessController.ToString(), resetReason ); + lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); return std::unique_ptr(new Screens::Label(1, 4, app, label)); } @@ -147,9 +131,8 @@ std::unique_ptr SystemInfo::CreateScreen2() { std::unique_ptr SystemInfo::CreateScreen3() { lv_mem_monitor_t mon; lv_mem_monitor(&mon); - CreateContainer(); - - lv_obj_t * label = lv_label_create(container1, nullptr); + + lv_obj_t * label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label, true); auto& bleAddr = bleController.Address(); lv_label_set_text_fmt(label, @@ -169,13 +152,46 @@ std::unique_ptr SystemInfo::CreateScreen3() { (int)mon.free_biggest_size, 0 ); - - return std::unique_ptr(new Screens::Label(2, 4, app, label)); + lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + return std::unique_ptr(new Screens::Label(2, 5, app, label)); } + +bool sortById(const TaskStatus_t &lhs, const TaskStatus_t &rhs) { return lhs.xTaskNumber < rhs.xTaskNumber; } + std::unique_ptr SystemInfo::CreateScreen4() { - CreateContainer(); - lv_obj_t * label = lv_label_create(container1, nullptr); + TaskStatus_t tasksStatus[7]; + lv_obj_t * infoTask = lv_table_create(lv_scr_act(), NULL); + lv_table_set_col_cnt(infoTask, 3); + lv_table_set_row_cnt(infoTask, 8); + lv_obj_set_pos(infoTask, 10, 10); + + lv_table_set_cell_value(infoTask, 0, 0, "#"); + lv_table_set_col_width(infoTask, 0, 50); + lv_table_set_cell_value(infoTask, 0, 1, "Task"); + lv_table_set_col_width(infoTask, 1, 80); + lv_table_set_cell_value(infoTask, 0, 2, "Free"); + lv_table_set_col_width(infoTask, 2, 90); + + auto nb = uxTaskGetSystemState(tasksStatus, 7, nullptr); + std::sort(tasksStatus, tasksStatus + nb, sortById); + for (uint8_t i = 0; i < nb; i++) { + + lv_table_set_cell_value(infoTask, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str()); + lv_table_set_cell_value(infoTask, i + 1, 1, tasksStatus[i].pcTaskName); + if (tasksStatus[i].usStackHighWaterMark < 20) { + std::string str1 = std::to_string(tasksStatus[i].usStackHighWaterMark) + " low"; + lv_table_set_cell_value(infoTask, i + 1, 2, str1.c_str()); + } else { + lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str()); + } + + } + return std::unique_ptr(new Screens::Label(3, 5, app, infoTask)); +} + +std::unique_ptr SystemInfo::CreateScreen5() { + lv_obj_t * label = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(label, true); lv_label_set_text_static(label, "Software Licensed\n" @@ -186,5 +202,6 @@ std::unique_ptr SystemInfo::CreateScreen4() { "#FFFF00 https://github.com/#\n" "#FFFF00 JF002/InfiniTime#"); lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - return std::unique_ptr(new Screens::Label(3, 4, app, label)); + lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + return std::unique_ptr(new Screens::Label(4, 5, app, label)); } \ No newline at end of file diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index 574ded74..f5f50a42 100644 --- a/src/displayapp/screens/SystemInfo.h +++ b/src/displayapp/screens/SystemInfo.h @@ -35,21 +35,19 @@ namespace Pinetime { private: bool running = true; - lv_obj_t* container1; - Pinetime::Controllers::DateTime& dateTimeController; Pinetime::Controllers::Battery& batteryController; Pinetime::Controllers::BrightnessController& brightnessController; Pinetime::Controllers::Ble& bleController; Pinetime::Drivers::WatchdogView& watchdog; - ScreenList<4> screens; + ScreenList<5> screens; std::unique_ptr CreateScreen1(); std::unique_ptr CreateScreen2(); std::unique_ptr CreateScreen3(); std::unique_ptr CreateScreen4(); + std::unique_ptr CreateScreen5(); - void CreateContainer(); }; } } diff --git a/src/displayapp/screens/Tasks.cpp b/src/displayapp/screens/Tasks.cpp deleted file mode 100644 index 7bd6c09d..00000000 --- a/src/displayapp/screens/Tasks.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include "Tasks.h" -#include -#include "../DisplayApp.h" -#include -#include - -using namespace Pinetime::Applications::Screens; - -static void lv_update_task(struct _lv_task_t *task) { - auto user_data = static_cast(task->user_data); - user_data->UpdateScreen(); -} - -Tasks::Tasks( - Pinetime::Applications::DisplayApp *app) : - Screen(app) -{ - - table = lv_table_create(lv_scr_act(), NULL); - lv_table_set_col_cnt(table, 3); - lv_table_set_row_cnt(table, 8); - //lv_obj_align(table, NULL, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_size(table, 240, 240); - lv_obj_set_pos(table, 0, 0); - - /*lv_table_set_cell_type(table, 0, 0, 1); - lv_table_set_cell_type(table, 0, 1, 1); - lv_table_set_cell_type(table, 0, 2, 1); - lv_table_set_cell_type(table, 0, 3, 1);*/ - - lv_table_set_cell_value(table, 0, 0, "#"); - lv_table_set_col_width(table, 0, 50); - lv_table_set_cell_value(table, 0, 1, "Task"); - lv_table_set_col_width(table, 1, 80); - lv_table_set_cell_value(table, 0, 2, "Free"); - lv_table_set_col_width(table, 2, 80); - - lv_obj_t * backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); - lv_obj_set_size(backgroundLabel, 240, 240); - lv_obj_set_pos(backgroundLabel, 0, 0); - lv_label_set_text_static(backgroundLabel, ""); - - UpdateScreen(); - taskUpdate = lv_task_create(lv_update_task, 100000, LV_TASK_PRIO_LOW, this); - -} - -Tasks::~Tasks() { - lv_task_del(taskUpdate); - lv_obj_clean(lv_scr_act()); -} - -bool sortById(const TaskStatus_t &lhs, const TaskStatus_t &rhs) { return lhs.xTaskNumber < rhs.xTaskNumber; } - -void Tasks::UpdateScreen() { - auto nb = uxTaskGetSystemState(tasksStatus, 7, nullptr); - std::sort(tasksStatus, tasksStatus + nb, sortById); - for (uint8_t i = 0; i < nb; i++) { - - lv_table_set_cell_value(table, i + 1, 0, std::to_string(tasksStatus[i].xTaskNumber).c_str()); - lv_table_set_cell_value(table, i + 1, 1, tasksStatus[i].pcTaskName); - if (tasksStatus[i].usStackHighWaterMark < 20) { - std::string str1 = std::to_string(tasksStatus[i].usStackHighWaterMark) + " low"; - lv_table_set_cell_value(table, i + 1, 2, str1.c_str()); - } else { - lv_table_set_cell_value(table, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str()); - } - - } -} - -bool Tasks::Refresh() { - return running; -} \ No newline at end of file diff --git a/src/displayapp/screens/Tasks.h b/src/displayapp/screens/Tasks.h deleted file mode 100644 index e9a49db4..00000000 --- a/src/displayapp/screens/Tasks.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include "Screen.h" - -namespace Pinetime { - - namespace Applications { - namespace Screens { - - class Tasks : public Screen{ - public: - Tasks(DisplayApp* app); - ~Tasks() override; - - bool Refresh() override; - void UpdateScreen(); - - private: - mutable TaskStatus_t tasksStatus[7]; - - lv_task_t* taskUpdate; - lv_obj_t * table; - - }; - } - } -} diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index b1e21924..15f73e8b 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -228,10 +228,10 @@ bool WatchFaceDigital::Refresh() { heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; if(heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { if(heartbeatRunning.Get()) - lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); + lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); else lv_label_set_text_static(heartbeatValue, "---"); - lv_label_set_text(heartbeatValue, heartbeatBuffer); + lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 5, -2); lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); lv_obj_align(heartbeatBpm, heartbeatValue, LV_ALIGN_OUT_RIGHT_MID, 5, 0); @@ -241,7 +241,6 @@ bool WatchFaceDigital::Refresh() { motionSensorOk = motionController.IsSensorOk(); if(stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); - lv_label_set_text(stepValue, stepBuffer); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, -5, -2); lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); } -- cgit v1.2.3-70-g09d2 From 969bb8e721efc21cc12a16621c705da74425e493 Mon Sep 17 00:00:00 2001 From: Joaquim José Almeida Pereira Date: Thu, 15 Apr 2021 15:55:01 +0100 Subject: Change animation direction in menus --- src/displayapp/screens/List.cpp | 2 +- src/displayapp/screens/Tile.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/displayapp/screens') diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index 87cfa6db..82da4d4c 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -116,7 +116,7 @@ void List::OnButtonEvent(lv_obj_t * object, lv_event_t event) { if ( event == LV_EVENT_RELEASED ) { for(int i = 0; i < MAXLISTITEMS; i++) { if ( apps[i] != Apps::None && object == itemApps[i] ) { - app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Down); + app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up); running = false; return; } diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 8fa7fd07..b1dfaf76 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -128,7 +128,7 @@ bool Tile::Refresh() { void Tile::OnObjectEvent(lv_obj_t *obj, lv_event_t event, uint32_t buttonId) { if(event == LV_EVENT_VALUE_CHANGED) { - app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Down); + app->StartApp(apps[buttonId], DisplayApp::FullRefreshDirections::Up); running = false; } } -- cgit v1.2.3-70-g09d2 From 2f1ddad4033ab37b2acf2b6f6dd45f0ca331d052 Mon Sep 17 00:00:00 2001 From: petter <39340152+petterhs@users.noreply.github.com> Date: Fri, 16 Apr 2021 01:18:32 +0200 Subject: fix style formatting in 2048 game --- src/displayapp/screens/Twos.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/displayapp/screens') diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp index 7a3ed1e4..bbee5e11 100644 --- a/src/displayapp/screens/Twos.cpp +++ b/src/displayapp/screens/Twos.cpp @@ -21,28 +21,33 @@ Twos::Twos(Pinetime::Applications::DisplayApp *app) : Screen(app) { lv_style_set_border_width(&style_cell1, LV_STATE_DEFAULT, 3); lv_style_set_bg_opa(&style_cell1, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&style_cell1, LV_STATE_DEFAULT, lv_color_hex(0xcdc0b4)); + lv_style_set_pad_top(&style_cell1, LV_STATE_DEFAULT, 25); + lv_style_set_text_color(&style_cell1, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_style_set_border_color(&style_cell2, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); lv_style_set_border_width(&style_cell2, LV_STATE_DEFAULT, 3); lv_style_set_bg_opa(&style_cell2, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&style_cell2, LV_STATE_DEFAULT, lv_color_hex(0xefdfc6)); + lv_style_set_pad_top(&style_cell2, LV_STATE_DEFAULT, 25); + lv_style_set_text_color(&style_cell2, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_style_set_border_color(&style_cell3, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); lv_style_set_border_width(&style_cell3, LV_STATE_DEFAULT, 3); lv_style_set_bg_opa(&style_cell3, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&style_cell3, LV_STATE_DEFAULT, lv_color_hex(0xef9263)); + lv_style_set_pad_top(&style_cell3, LV_STATE_DEFAULT, 25); lv_style_set_border_color(&style_cell4, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); lv_style_set_border_width(&style_cell4, LV_STATE_DEFAULT, 3); lv_style_set_bg_opa(&style_cell4, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&style_cell4, LV_STATE_DEFAULT, lv_color_hex(0xf76142)); - //lv_style_set_text_color(&style_cell4, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_pad_top(&style_cell4, LV_STATE_DEFAULT, 25); lv_style_set_border_color(&style_cell5, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); lv_style_set_border_width(&style_cell5, LV_STATE_DEFAULT, 3); lv_style_set_bg_opa(&style_cell5, LV_STATE_DEFAULT, LV_OPA_COVER); lv_style_set_bg_color(&style_cell5, LV_STATE_DEFAULT, lv_color_hex(0x007dc5)); - //lv_style_set_text_color(&style_cell5, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_style_set_pad_top(&style_cell5, LV_STATE_DEFAULT, 25); // format grid display -- cgit v1.2.3-70-g09d2 From 3c413bdd5283f6ef95d23a4b7274722da680f039 Mon Sep 17 00:00:00 2001 From: Joaquim Date: Fri, 16 Apr 2021 16:15:38 +0100 Subject: In order to stabilize the battery reading, I modified the process to make 5 consecutive readings, as the process is asynchronous, there is no interference in the main process. --- src/components/battery/BatteryController.cpp | 23 +++++++++++++++++------ src/components/battery/BatteryController.h | 7 +++++-- src/displayapp/DisplayApp.cpp | 2 +- src/displayapp/screens/BatteryInfo.cpp | 15 ++++++++++----- src/systemtask/SystemTask.cpp | 9 +++++++-- 5 files changed, 40 insertions(+), 16 deletions(-) (limited to 'src/displayapp/screens') diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp index 4a7a2345..99afa55c 100644 --- a/src/components/battery/BatteryController.cpp +++ b/src/components/battery/BatteryController.cpp @@ -23,12 +23,20 @@ void Battery::Update() { isCharging = !nrf_gpio_pin_read(chargingPin); isPowerPresent = !nrf_gpio_pin_read(powerPresentPin); + if ( isReading ) return; // Non blocking read - SaadcInit(); - nrfx_saadc_sample(); + samples = 0; + isReading = true; + SaadcInit(); + + nrfx_saadc_sample(); } +void Battery::adcCallbackStatic(nrfx_saadc_evt_t const *event) { + instance->SaadcEventHandler(event); +} + void Battery::SaadcInit() { nrfx_saadc_config_t adcConfig = NRFX_SAADC_DEFAULT_CONFIG; APP_ERROR_CHECK(nrfx_saadc_init(&adcConfig, adcCallbackStatic)); @@ -68,10 +76,13 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const * p_event) { percentRemainingBuffer.insert(percentRemaining); - nrfx_saadc_uninit(); + samples++; + if ( samples > percentRemainingSamples ) { + nrfx_saadc_uninit(); + isReading = false; + } else { + nrfx_saadc_sample(); + } } } -void Battery::adcCallbackStatic(nrfx_saadc_evt_t const *event) { - instance->SaadcEventHandler(event); -} diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h index 2776687b..47d7a6d1 100644 --- a/src/components/battery/BatteryController.h +++ b/src/components/battery/BatteryController.h @@ -52,13 +52,13 @@ namespace Pinetime { float Voltage() const { return voltage; } bool IsCharging() const { return isCharging; } - bool IsPowerPresent() const { return isPowerPresent; } + bool IsPowerPresent() const { return isPowerPresent; } private: static Battery *instance; nrf_saadc_value_t saadc_value; - static constexpr uint8_t percentRemainingSamples = 10; + static constexpr uint8_t percentRemainingSamples = 5; CircBuffer percentRemainingBuffer {}; static constexpr uint32_t chargingPin = 12; @@ -74,6 +74,9 @@ namespace Pinetime { void SaadcEventHandler(nrfx_saadc_evt_t const * p_event); static void adcCallbackStatic(nrfx_saadc_evt_t const *event); + + bool isReading = false; + uint8_t samples = 0; }; } } \ No newline at end of file diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 773ae9c0..36f93a91 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -132,7 +132,7 @@ void DisplayApp::Refresh() { // clockScreen.SetBleConnectionState(bleController.IsConnected() ? Screens::Clock::BleConnectionStates::Connected : Screens::Clock::BleConnectionStates::NotConnected); break; case Messages::UpdateBatteryLevel: -// clockScreen.SetBatteryPercentRemaining(batteryController.PercentRemaining()); + batteryController.Update(); break; case Messages::NewNotification: LoadApp( Apps::NotificationsPreview, DisplayApp::FullRefreshDirections::Down ); diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index ae39138f..e616d67f 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -84,7 +84,7 @@ void BatteryInfo::UpdateAnim() { batteryPercent = batteryController.PercentRemaining(); if ( batteryPercent >= 0 ) { - if ( batteryController.IsCharging() ) { + if ( batteryController.IsCharging() and batteryPercent < 100 ) { animation +=1; if (animation >= 100) { animation = 0; @@ -111,12 +111,17 @@ void BatteryInfo::UpdateScreen() { batteryVoltage = batteryController.Voltage(); if ( batteryPercent >= 0 ) { - if ( batteryController.IsCharging() ) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, lv_color_hex(0xFF0000)); + if ( batteryController.IsCharging() and batteryPercent < 100 ) { + lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_RED); lv_label_set_text_static(status,"Battery charging"); - + } else if ( batteryPercent == 100 ) { + lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_BLUE); + lv_label_set_text_static(status,"Battery is fully charged"); + } else if ( batteryPercent < 10 ) { + lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_YELLOW); + lv_label_set_text_static(status,"Battery is low"); } else { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC , LV_STATE_DEFAULT, LV_COLOR_GREEN); lv_label_set_text_static(status,"Battery discharging"); } diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index 42a4e844..b540fcd8 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -98,7 +98,6 @@ void SystemTask::Work() { heartRateController, settingsController, motionController); displayApp->Start(); - batteryController.Update(); displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); heartRateSensor.Init(); @@ -106,7 +105,6 @@ void SystemTask::Work() { heartRateApp = std::make_unique(heartRateSensor, heartRateController); heartRateApp->Start(); - nrf_gpio_cfg_sense_input(pinButton, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pulldown, (nrf_gpio_pin_sense_t)GPIO_PIN_CNF_SENSE_High); nrf_gpio_cfg_output(15); nrf_gpio_pin_set(15); @@ -141,7 +139,14 @@ void SystemTask::Work() { uint8_t msg; if (xQueueReceive(systemTasksMsgQueue, &msg, 100)) { + + // call the battery controller or use the MSG in DisplayApp to get the battery status ??? + // it is necessary to validate which is the most efficient batteryController.Update(); + //displayApp->PushMessage(Pinetime::Applications::Display::Messages::UpdateBatteryLevel); + // analyze a more efficient way to do this refreshment + // this and the UpdateMotion(); can be called on a timer to be independent of the main process ??? + Messages message = static_cast(msg); switch(message) { case Messages::EnableSleeping: -- cgit v1.2.3-70-g09d2