summaryrefslogtreecommitdiff
path: root/src/displayapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp')
-rw-r--r--src/displayapp/Apps.h2
-rw-r--r--src/displayapp/DisplayApp.cpp5
-rw-r--r--src/displayapp/lv_pinetime_theme.c10
-rw-r--r--src/displayapp/screens/ApplicationList.cpp2
-rw-r--r--src/displayapp/screens/Tasks.cpp77
-rw-r--r--src/displayapp/screens/Tasks.h31
-rw-r--r--src/displayapp/screens/WatchFaceDigital.cpp12
7 files changed, 124 insertions, 15 deletions
diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h
index 358ea1f7..5daa82ff 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,
+ Music, Paint, Paddle, Twos, HeartRate, Navigation, StopWatch, Motion, Tasks,
QuickSettings, Settings, SettingWatchFace, SettingTimeFormat, SettingDisplay, SettingWakeUp
};
}
diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp
index 9aaf77a6..eab4e3b3 100644
--- a/src/displayapp/DisplayApp.cpp
+++ b/src/displayapp/DisplayApp.cpp
@@ -24,6 +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"
@@ -307,6 +308,10 @@ void DisplayApp::LoadApp(Apps app, DisplayApp::FullRefreshDirections direction)
case Apps::Motion:
currentScreen = std::make_unique<Screens::Motion>(this, motionController);
break;
+ case Apps::Tasks:
+ currentScreen = std::make_unique<Screens::Tasks>(this);
+ returnApp(Apps::Launcher, FullRefreshDirections::Down, TouchEvents::SwipeDown);
+ break;
}
currentApp = app;
diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c
index 99ea9c8a..c153e42d 100644
--- a/src/displayapp/lv_pinetime_theme.c
+++ b/src/displayapp/lv_pinetime_theme.c
@@ -246,10 +246,10 @@ static void basic_init(void)
lv_style_set_border_color(&style_table_cell, LV_STATE_DEFAULT, LV_PINETIME_GRAY);
lv_style_set_border_width(&style_table_cell, LV_STATE_DEFAULT, 1);
lv_style_set_border_side(&style_table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL);
- lv_style_set_pad_left(&style_table_cell, LV_STATE_DEFAULT, 12);
- lv_style_set_pad_right(&style_table_cell, LV_STATE_DEFAULT, 12);
- lv_style_set_pad_top(&style_table_cell, LV_STATE_DEFAULT, 12);
- lv_style_set_pad_bottom(&style_table_cell, LV_STATE_DEFAULT, 12);
+ lv_style_set_pad_left(&style_table_cell, LV_STATE_DEFAULT, 5);
+ lv_style_set_pad_right(&style_table_cell, LV_STATE_DEFAULT, 5);
+ lv_style_set_pad_top(&style_table_cell, LV_STATE_DEFAULT, 2);
+ lv_style_set_pad_bottom(&style_table_cell, LV_STATE_DEFAULT, 2);
style_init_reset(&style_pad_small);
lv_style_int_t pad_small_value = 10;
@@ -356,6 +356,7 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN);
list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN);
_lv_style_list_add_style(list, &style_bg);
+ _lv_style_list_add_style(list, &style_label_white);
break;
case LV_THEME_OBJ:
@@ -499,6 +500,7 @@ static void theme_apply(lv_obj_t * obj, lv_theme_style_t name)
for(; idx <= LV_TABLE_CELL_STYLE_CNT; idx ++) {
list = lv_obj_get_style_list(obj, idx);
_lv_style_list_add_style(list, &style_table_cell);
+ _lv_style_list_add_style(list, &style_label_white);
}
break;
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<Screen> 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 <FreeRTOS.h>
+#include <task.h>
+#include "Tasks.h"
+#include <lvgl/lvgl.h>
+#include "../DisplayApp.h"
+#include <string>
+#include <algorithm>
+
+using namespace Pinetime::Applications::Screens;
+
+static void lv_update_task(struct _lv_task_t *task) {
+ auto user_data = static_cast<Tasks *>(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 <FreeRTOS.h>
+#include <task.h>
+#include <cstdint>
+#include <lvgl/lvgl.h>
+#include <timers.h>
+#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);