aboutsummaryrefslogtreecommitdiffstats
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.cpp70
1 files changed, 42 insertions, 28 deletions
diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp
index 511ecf50..2392f3be 100644
--- a/src/displayapp/screens/SystemInfo.cpp
+++ b/src/displayapp/screens/SystemInfo.cpp
@@ -38,15 +38,16 @@ SystemInfo::SystemInfo(Pinetime::Applications::DisplayApp* app,
const Pinetime::Controllers::Ble& bleController,
const Pinetime::Drivers::Watchdog& watchdog,
Pinetime::Controllers::MotionController& motionController,
- const Pinetime::Drivers::Cst816S& touchPanel)
- : app {app},
- dateTimeController {dateTimeController},
+ const Pinetime::Drivers::Cst816S& touchPanel,
+ const Pinetime::Drivers::SpiNorFlash& spiNorFlash)
+ : dateTimeController {dateTimeController},
batteryController {batteryController},
brightnessController {brightnessController},
bleController {bleController},
watchdog {watchdog},
motionController {motionController},
touchPanel {touchPanel},
+ spiNorFlash {spiNorFlash},
screens {app,
0,
{[this]() -> std::unique_ptr<Screen> {
@@ -101,24 +102,24 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
auto batteryPercent = batteryController.PercentRemaining();
const auto* resetReason = [this]() {
- switch (watchdog.ResetReason()) {
- case Drivers::Watchdog::ResetReasons::Watchdog:
+ switch (watchdog.GetResetReason()) {
+ case Drivers::Watchdog::ResetReason::Watchdog:
return "wtdg";
- case Drivers::Watchdog::ResetReasons::HardReset:
+ case Drivers::Watchdog::ResetReason::HardReset:
return "hardr";
- case Drivers::Watchdog::ResetReasons::NFC:
+ case Drivers::Watchdog::ResetReason::NFC:
return "nfc";
- case Drivers::Watchdog::ResetReasons::SoftReset:
+ case Drivers::Watchdog::ResetReason::SoftReset:
return "softr";
- case Drivers::Watchdog::ResetReasons::CpuLockup:
+ case Drivers::Watchdog::ResetReason::CpuLockup:
return "cpulock";
- case Drivers::Watchdog::ResetReasons::SystemOff:
+ case Drivers::Watchdog::ResetReason::SystemOff:
return "off";
- case Drivers::Watchdog::ResetReasons::LpComp:
+ case Drivers::Watchdog::ResetReason::LpComp:
return "lpcomp";
- case Drivers::Watchdog::ResetReasons::DebugInterface:
+ case Drivers::Watchdog::ResetReason::DebugInterface:
return "dbg";
- case Drivers::Watchdog::ResetReasons::ResetPin:
+ case Drivers::Watchdog::ResetReason::ResetPin:
return "rst";
default:
return "?";
@@ -177,6 +178,8 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen2() {
return std::make_unique<Screens::Label>(1, 5, label);
}
+extern int mallocFailedCount;
+extern int stackOverflowCount;
std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
lv_mem_monitor_t mon;
lv_mem_monitor(&mon);
@@ -184,26 +187,32 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen3() {
lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_recolor(label, true);
const auto& bleAddr = bleController.Address();
+ auto spiFlashId = spiNorFlash.GetIdentification();
lv_label_set_text_fmt(label,
"#808080 BLE MAC#\n"
- " %02x:%02x:%02x:%02x:%02x:%02x"
+ " %02x:%02x:%02x:%02x:%02x:%02x\n"
"\n"
- "#808080 LVGL Memory#\n"
- " #808080 used# %d (%d%%)\n"
- " #808080 max used# %lu\n"
- " #808080 frag# %d%%\n"
- " #808080 free# %d",
+ "#808080 SPI Flash# %02x-%02x-%02x\n"
+ "\n"
+ "#808080 Memory heap#\n"
+ " #808080 Free# %d/%d\n"
+ " #808080 Min free# %d\n"
+ " #808080 Alloc err# %d\n"
+ " #808080 Ovrfl err# %d",
bleAddr[5],
bleAddr[4],
bleAddr[3],
bleAddr[2],
bleAddr[1],
bleAddr[0],
- static_cast<int>(mon.total_size - mon.free_size),
- mon.used_pct,
- mon.max_used,
- mon.frag_pct,
- static_cast<int>(mon.free_biggest_size));
+ spiFlashId.manufacturer,
+ spiFlashId.type,
+ spiFlashId.density,
+ xPortGetFreeHeapSize(),
+ xPortGetHeapSize(),
+ xPortGetMinimumEverFreeHeapSize(),
+ mallocFailedCount,
+ stackOverflowCount);
lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0);
return std::make_unique<Screens::Label>(2, 5, label);
}
@@ -232,11 +241,16 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_col_width(infoTask, 3, 90);
auto nb = uxTaskGetSystemState(tasksStatus, maxTaskCount, nullptr);
+// g++ emits a spurious warning (and thus error because we compile with -Werror)
+// due to the way std::sort is implemented
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
std::sort(tasksStatus, tasksStatus + nb, sortById);
+#pragma GCC diagnostic pop
for (uint8_t i = 0; i < nb && i < maxTaskCount; i++) {
- char buffer[7] = {0};
+ char buffer[11] = {0};
- sprintf(buffer, "%lu", tasksStatus[i].xTaskNumber);
+ snprintf(buffer, sizeof(buffer), "%lu", tasksStatus[i].xTaskNumber);
lv_table_set_cell_value(infoTask, i + 1, 0, buffer);
switch (tasksStatus[i].eCurrentState) {
case eReady:
@@ -260,9 +274,9 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen4() {
lv_table_set_cell_value(infoTask, i + 1, 1, buffer);
lv_table_set_cell_value(infoTask, i + 1, 2, tasksStatus[i].pcTaskName);
if (tasksStatus[i].usStackHighWaterMark < 20) {
- sprintf(buffer, "%d low", tasksStatus[i].usStackHighWaterMark);
+ snprintf(buffer, sizeof(buffer), "%" PRIu16 " low", tasksStatus[i].usStackHighWaterMark);
} else {
- sprintf(buffer, "%d", tasksStatus[i].usStackHighWaterMark);
+ snprintf(buffer, sizeof(buffer), "%" PRIu16, tasksStatus[i].usStackHighWaterMark);
}
lv_table_set_cell_value(infoTask, i + 1, 3, buffer);
}