diff --git a/src/common/app_metrics.cpp b/src/common/app_metrics.cpp index 9f25018e39..3d9329ffc3 100644 --- a/src/common/app_metrics.cpp +++ b/src/common/app_metrics.cpp @@ -133,6 +133,8 @@ void buddy::metrics::RecordRuntimeStats() { METRIC_DEF(heap, "heap", METRIC_VALUE_CUSTOM, 503, METRIC_HANDLER_ENABLE_ALL); metric_record_custom(&heap, " free=%zui,total=%zui", xPortGetFreeHeapSize(), static_cast(heap_total_size)); + + RecordUptime(); } void buddy::metrics::RecordMarlinVariables() { @@ -352,4 +354,9 @@ void buddy::metrics::record_dwarf_internal_temperatures() { } } } + +void buddy::metrics::RecordUptime() { + METRIC_DEF(uptime, "uptime", METRIC_VALUE_INTEGER, 1000, METRIC_HANDLER_ENABLE_ALL); + metric_record_integer(&uptime, ticks_s() / 3600); +} #endif diff --git a/src/common/appmain.cpp b/src/common/appmain.cpp index 08d535e996..e66260ab49 100644 --- a/src/common/appmain.cpp +++ b/src/common/appmain.cpp @@ -233,6 +233,7 @@ void app_run(void) { loop(); } marlin_server::loop(); + buddy::metrics::RecordUptime(); // Pa465 } } diff --git a/src/gui/screen_menu_statistics.cpp b/src/gui/screen_menu_statistics.cpp index 442f758bc9..ddee229580 100644 --- a/src/gui/screen_menu_statistics.cpp +++ b/src/gui/screen_menu_statistics.cpp @@ -4,11 +4,14 @@ #include "screen_menu_statistics.hpp" #include "DialogMoveZ.hpp" #include "img_resources.hpp" +#include "app_metrics.h" ScreenMenuStatistics::ScreenMenuStatistics() : ScreenMenuStatistics__(_(label)) { EnableLongHoldScreenAction(); header.SetIcon(&img::info_16x16); + AddItem(&uptime_label); + updateUptime(); } void ScreenMenuStatistics::windowEvent(window_t *sender, GUI_event_t event, void *param) { @@ -19,3 +22,9 @@ void ScreenMenuStatistics::windowEvent(window_t *sender, GUI_event_t event, void ScreenMenu::windowEvent(sender, event, param); } + +void ScreenMenuStatistics::updateUptime() { + char buffer[32]; + snprintf(buffer, sizeof(buffer), "Uptime: %lu hours", ticks_s() / 3600); + uptime_label.SetText(buffer); +} diff --git a/src/gui/screen_menu_statistics.hpp b/src/gui/screen_menu_statistics.hpp index 01d161ea53..a8e44668ad 100644 --- a/src/gui/screen_menu_statistics.hpp +++ b/src/gui/screen_menu_statistics.hpp @@ -23,4 +23,6 @@ class ScreenMenuStatistics : public ScreenMenuStatistics__ { private: virtual void windowEvent(window_t *sender, GUI_event_t event, void *param) override; + void updateUptime(); + IWindowMenuItem uptime_label; };