summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/SystemInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/displayapp/screens/SystemInfo.cpp')
-rw-r--r--src/displayapp/screens/SystemInfo.cpp110
1 files changed, 68 insertions, 42 deletions
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index 9ff28288..e7c5b65a 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -3,26 +3,44 @@
#include "../DisplayApp.h"
#include "Label.h"
#include "Version.h"
+#include "BootloaderVersion.h"
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "components/brightness/BrightnessController.h"
#include "components/datetime/DateTimeController.h"
+#include "components/motion/MotionController.h"
#include "drivers/Watchdog.h"
using namespace Pinetime::Applications::Screens;
+namespace {
+ const char* ToString(const Pinetime::Controllers::MotionController::DeviceTypes deviceType) {
+ switch (deviceType) {
+ case Pinetime::Controllers::MotionController::DeviceTypes::BMA421:
+ return "BMA421";
+ case Pinetime::Controllers::MotionController::DeviceTypes::BMA425:
+ return "BMA425";
+ case Pinetime::Controllers::MotionController::DeviceTypes::Unknown:
+ return "???";
+ }
+ return "???";
+ }
+}
+
SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
Pinetime::Controllers::DateTime& dateTimeController,
Pinetime::Controllers::Battery& batteryController,
Pinetime::Controllers::BrightnessController& brightnessController,
Pinetime::Controllers::Ble& bleController,
- Pinetime::Drivers::WatchdogView& watchdog)
+ Pinetime::Drivers::WatchdogView& watchdog,
+ Pinetime::Controllers::MotionController& motionController)
: Screen(app),
dateTimeController {dateTimeController},
batteryController {batteryController},
brightnessController {brightnessController},
bleController {bleController},
watchdog {watchdog},
+ motionController{motionController},
screens {app,
0,
{[this]() -> std::unique_ptr<Screen> {
@@ -54,11 +72,6 @@ bool SystemInfo::Refresh() {
return running;
}
-bool SystemInfo::OnButtonPushed() {
- running = false;
- return true;
-}
-
bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
return screens.OnTouchEvent(event);
}
@@ -68,26 +81,26 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
lv_label_set_recolor(label, true);
lv_label_set_text_fmt(label,
"#FFFF00 InfiniTime#\n\n"
- "#444444 Version# %ld.%ld.%ld\n\n"
- "#444444 Short Ref# %s\n\n"
+ "#444444 Version# %ld.%ld.%ld\n"
+ "#444444 Short Ref# %s\n"
"#444444 Build date#\n"
"%s\n"
- "%s\n",
+ "%s\n\n"
+ "#444444 Bootloader# %s",
Version::Major(),
Version::Minor(),
Version::Patch(),
Version::GitCommitHash(),
__DATE__,
- __TIME__);
+ __TIME__,
+ BootloaderVersion::VersionString());
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(0, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
- auto batteryPercent = static_cast<uint8_t>(batteryController.PercentRemaining());
- float batteryVoltage = batteryController.Voltage();
-
+ auto batteryPercent = batteryController.PercentRemaining();
auto resetReason = [this]() {
switch (watchdog.ResetReason()) {
case Drivers::Watchdog::ResetReasons::Watchdog:
@@ -126,25 +139,16 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
uptimeSeconds = uptimeSeconds % secondsInAMinute;
// TODO handle more than 100 days of uptime
- if (batteryPercent == -1)
- batteryPercent = 0;
-
- // hack to not use the flot functions from printf
- uint8_t batteryVoltageBytes[2];
- batteryVoltageBytes[1] = static_cast<uint8_t>(batteryVoltage); // truncate whole numbers
- batteryVoltageBytes[0] =
- static_cast<uint8_t>((batteryVoltage - batteryVoltageBytes[1]) * 100); // remove whole part of flt and shift 2 places over
- //
-
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"
"#444444 Time# %02d:%02d:%02d\n"
"#444444 Uptime#\n %02lud %02lu:%02lu:%02lu\n"
- "#444444 Battery# %d%%/%1i.%02iv\n"
+ "#444444 Battery# %d%%/%03imV\n"
"#444444 Backlight# %s\n"
- "#444444 Last reset# %s\n",
+ "#444444 Last reset# %s\n"
+ "#444444 Accel.# %s\n",
dateTimeController.Day(),
static_cast<uint8_t>(dateTimeController.Month()),
dateTimeController.Year(),
@@ -156,10 +160,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
uptimeMinutes,
uptimeSeconds,
batteryPercent,
- batteryVoltageBytes[1],
- batteryVoltageBytes[0],
+ batteryController.Voltage(),
brightnessController.ToString(),
- resetReason);
+ resetReason,
+ ToString(motionController.DeviceType()));
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(1, 5, app, label);
}
@@ -177,22 +181,22 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
"\n"
"#444444 LVGL Memory#\n"
" #444444 used# %d (%d%%)\n"
- " #444444 max used# %d\n"
+ " #444444 max used# %lu\n"
" #444444 frag# %d%%\n"
" #444444 free# %d"
"\n"
- "#444444 Steps# %li",
+ "#444444 Steps# %i",
bleAddr[5],
bleAddr[4],
bleAddr[3],
bleAddr[2],
bleAddr[1],
bleAddr[0],
- (int) mon.total_size - mon.free_size,
+ static_cast<int>(mon.total_size - mon.free_size),
mon.used_pct,
mon.max_used,
mon.frag_pct,
- (int) mon.free_biggest_size,
+ static_cast<int>(mon.free_biggest_size),
0);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(2, 5, app, label);
@@ -205,28 +209,50 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
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_col_cnt(infoTask, 4);
lv_table_set_row_cnt(infoTask, 8);
- lv_obj_set_pos(infoTask, 10, 10);
+ lv_obj_set_pos(infoTask, 0, 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);
+ lv_table_set_col_width(infoTask, 0, 30);
+ lv_table_set_cell_value(infoTask, 0, 1, "S"); // State
+ lv_table_set_col_width(infoTask, 1, 30);
+ lv_table_set_cell_value(infoTask, 0, 2, "Task");
+ lv_table_set_col_width(infoTask, 2, 80);
+ lv_table_set_cell_value(infoTask, 0, 3, "Free");
+ lv_table_set_col_width(infoTask, 3, 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);
+ char state[2] = {0};
+ switch (tasksStatus[i].eCurrentState) {
+ case eReady:
+ case eRunning:
+ state[0] = 'R';
+ break;
+ case eBlocked:
+ state[0] = 'B';
+ break;
+ case eSuspended:
+ state[0] = 'S';
+ break;
+ case eDeleted:
+ state[0] = 'D';
+ break;
+ default:
+ state[0] = 'I'; // Invalid
+ break;
+ }
+ lv_table_set_cell_value(infoTask, i + 1, 1, state);
+ lv_table_set_cell_value(infoTask, i + 1, 2, 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());
+ lv_table_set_cell_value(infoTask, i + 1, 3, str1.c_str());
} else {
- lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
+ lv_table_set_cell_value(infoTask, i + 1, 3, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
}
}
return std::make_unique<Screens::Label>(3, 5, app, infoTask);