summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/SystemInfo.cpp
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2021-06-20 15:09:24 (GMT)
committerGitea <gitea@fake.local>2021-06-20 15:09:24 (GMT)
commitd96395c81021778af35b8b4bf965bfe8663eb081 (patch)
tree979e75d716bca8bcd69b86f24a2f2d0270a274d0 /src/displayapp/screens/SystemInfo.cpp
parentfb133a0167f7ea4281bca45be6efc928720d4f82 (diff)
parent20a24f8cf56551eae1202f8dc5733bd0cf61adbf (diff)
Merge branch 'develop' of JF/PineTime into master
Diffstat (limited to 'src/displayapp/screens/SystemInfo.cpp')
-rw-r--r--src/displayapp/screens/SystemInfo.cpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index e4ef691..0b16d63 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -7,22 +7,37 @@
#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";
+ }
+ 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> {
@@ -81,7 +96,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
__TIME__);
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(0, 5, app, label));
+ return std::make_unique<Screens::Label>(0, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
@@ -132,9 +147,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
// 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
- //
+ 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);
@@ -144,7 +157,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
"#444444 Uptime#\n %02lud %02lu:%02lu:%02lu\n"
"#444444 Battery# %d%%/%1i.%02iv\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(),
@@ -159,9 +173,10 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
batteryVoltageBytes[1],
batteryVoltageBytes[0],
brightnessController.ToString(),
- resetReason);
+ resetReason,
+ ToString(motionController.DeviceType()));
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(1, 4, app, label));
+ return std::make_unique<Screens::Label>(1, 5, app, label);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
@@ -175,8 +190,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
"#444444 BLE MAC#\n"
" %02x:%02x:%02x:%02x:%02x:%02x"
"\n"
- "#444444 Memory#\n"
+ "#444444 LVGL Memory#\n"
" #444444 used# %d (%d%%)\n"
+ " #444444 max used# %d\n"
" #444444 frag# %d%%\n"
" #444444 free# %d"
"\n"
@@ -189,14 +205,15 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
bleAddr[0],
(int) mon.total_size - mon.free_size,
mon.used_pct,
+ mon.max_used,
mon.frag_pct,
(int) mon.free_biggest_size,
0);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(2, 5, app, label));
+ return std::make_unique<Screens::Label>(2, 5, app, label);
}
-bool sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
+bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) {
return lhs.xTaskNumber < rhs.xTaskNumber;
}
@@ -227,7 +244,7 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_cell_value(infoTask, i + 1, 2, std::to_string(tasksStatus[i].usStackHighWaterMark).c_str());
}
}
- return std::unique_ptr<Screen>(new Screens::Label(3, 5, app, infoTask));
+ return std::make_unique<Screens::Label>(3, 5, app, infoTask);
}
std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
@@ -243,5 +260,5 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen5() {
"#FFFF00 JF002/InfiniTime#");
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
- return std::unique_ptr<Screen>(new Screens::Label(4, 5, app, label));
+ return std::make_unique<Screens::Label>(4, 5, app, label);
}