From 28aa94b899ba88de8fccaaf2348d58f04dcd7064 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 8 Apr 2025 22:58:17 +1200 Subject: [PATCH 1/4] show firmware version and build date on companion screen --- examples/companion_radio/UITask.cpp | 19 +++++++++++++++---- examples/companion_radio/UITask.h | 4 +++- examples/companion_radio/main.cpp | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index c42bb094..cfe08cf7 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -25,16 +25,28 @@ static const uint8_t meshcore_logo [] PROGMEM = { 0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8, }; -void UITask::begin(DisplayDriver* display, const char* node_name, const char* build_date, uint32_t pin_code) { +void UITask::begin(DisplayDriver* display, const char* node_name, const char* build_date, const char* firmware_version, uint32_t pin_code) { _display = display; _auto_off = millis() + AUTO_OFF_MILLIS; clearMsgPreview(); _node_name = node_name; _build_date = build_date; + _firmware_version = firmware_version; _pin_code = pin_code; if (_display != NULL) { _display->turnOn(); } + + // strip off dash and commit hash by changing dash to null terminator + // e.g: v1.2.3-abcdef -> v1.2.3 + char *version = strdup(_firmware_version); + char *dash = strchr(version, '-'); + if(dash){ + *dash = 0; + } + + // v1.2.3 (1 Jan 2025) + sprintf(_version_info, "%s (%s)", version, _build_date); } void UITask::msgRead(int msgcount) { @@ -90,10 +102,9 @@ void UITask::renderCurrScreen() { _display->setCursor(0, 20); _display->setTextSize(1); _display->print(_node_name); - - sprintf(tmp, "Build: %s", _build_date); + _display->setCursor(0, 32); - _display->print(tmp); + _display->print(_version_info); if (_connected) { //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); diff --git a/examples/companion_radio/UITask.h b/examples/companion_radio/UITask.h index a0c60186..8fe0145e 100644 --- a/examples/companion_radio/UITask.h +++ b/examples/companion_radio/UITask.h @@ -12,6 +12,8 @@ class UITask { uint32_t _pin_code; const char* _node_name; const char* _build_date; + const char* _firmware_version; + char _version_info[32]; char _origin[62]; char _msg[80]; int _msgcount; @@ -26,7 +28,7 @@ public: _next_refresh = 0; _connected = false; } - void begin(DisplayDriver* display, const char* node_name, const char* build_date, uint32_t pin_code); + void begin(DisplayDriver* display, const char* node_name, const char* build_date, const char* firmware_version, uint32_t pin_code); void setHasConnection(bool connected) { _connected = connected; } bool hasDisplay() const { return _display != NULL; } diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index e2640543..30e492ce 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -1505,7 +1505,7 @@ void setup() { #endif #ifdef HAS_UI - ui_task.begin(disp, the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, the_mesh.getBLEPin()); + ui_task.begin(disp, the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION, the_mesh.getBLEPin()); #endif } From 4a51cb98c6c1b0405c8f6f929736f5f9466da903 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 8 Apr 2025 23:05:27 +1200 Subject: [PATCH 2/4] show firmware version and build date on repeater screen --- examples/simple_repeater/UITask.cpp | 17 +++++++++++++---- examples/simple_repeater/UITask.h | 3 ++- examples/simple_repeater/main.cpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/simple_repeater/UITask.cpp b/examples/simple_repeater/UITask.cpp index e8a204e3..4597a344 100644 --- a/examples/simple_repeater/UITask.cpp +++ b/examples/simple_repeater/UITask.cpp @@ -20,25 +20,34 @@ static const uint8_t meshcore_logo [] PROGMEM = { 0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8, }; -void UITask::begin(const char* node_name, const char* build_date) { +void UITask::begin(const char* node_name, const char* build_date, const char* firmware_version) { _prevBtnState = HIGH; _auto_off = millis() + AUTO_OFF_MILLIS; _node_name = node_name; _build_date = build_date; _display->turnOn(); + + // strip off dash and commit hash by changing dash to null terminator + // e.g: v1.2.3-abcdef -> v1.2.3 + char *version = strdup(firmware_version); + char *dash = strchr(version, '-'); + if(dash){ + *dash = 0; + } + + // v1.2.3 (1 Jan 2025) + sprintf(_version_info, "%s (%s)", version, _build_date); } void UITask::renderCurrScreen() { - char tmp[80]; // render 'home' screen _display->drawXbm(0, 0, meshcore_logo, 128, 13); _display->setCursor(0, 20); _display->setTextSize(1); _display->print(_node_name); - sprintf(tmp, "Build: %s", _build_date); _display->setCursor(0, 32); - _display->print(tmp); + _display->print(_version_info); _display->setCursor(0, 43); _display->print("< Repeater >"); //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); diff --git a/examples/simple_repeater/UITask.h b/examples/simple_repeater/UITask.h index e58d6111..e087b86c 100644 --- a/examples/simple_repeater/UITask.h +++ b/examples/simple_repeater/UITask.h @@ -8,11 +8,12 @@ class UITask { int _prevBtnState; const char* _node_name; const char* _build_date; + char _version_info[32]; void renderCurrScreen(); public: UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; } - void begin(const char* node_name, const char* build_date); + void begin(const char* node_name, const char* build_date, const char* firmware_version); void loop(); }; \ No newline at end of file diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 79194e96..1d8cac6e 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -658,7 +658,7 @@ void setup() { the_mesh.begin(fs); #ifdef DISPLAY_CLASS - ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE); + ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION); #endif // send out initial Advertisement to the mesh From bc820ae93e375f9cf57da65463e0d0425b2f20a2 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 8 Apr 2025 23:09:55 +1200 Subject: [PATCH 3/4] show firmware version and build date on room server screen --- examples/simple_room_server/UITask.cpp | 17 +++++++++++++---- examples/simple_room_server/UITask.h | 3 ++- examples/simple_room_server/main.cpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/simple_room_server/UITask.cpp b/examples/simple_room_server/UITask.cpp index 2f1d8ae5..eb2e4a00 100644 --- a/examples/simple_room_server/UITask.cpp +++ b/examples/simple_room_server/UITask.cpp @@ -20,25 +20,34 @@ static const uint8_t meshcore_logo [] PROGMEM = { 0xe3, 0xe3, 0x8f, 0xff, 0x1f, 0xfc, 0x3c, 0x0e, 0x1f, 0xf8, 0xff, 0xf8, 0x70, 0x3c, 0x7f, 0xf8, }; -void UITask::begin(const char* node_name, const char* build_date) { +void UITask::begin(const char* node_name, const char* build_date, const char* firmware_version) { _prevBtnState = HIGH; _auto_off = millis() + AUTO_OFF_MILLIS; _node_name = node_name; _build_date = build_date; _display->turnOn(); + + // strip off dash and commit hash by changing dash to null terminator + // e.g: v1.2.3-abcdef -> v1.2.3 + char *version = strdup(firmware_version); + char *dash = strchr(version, '-'); + if(dash){ + *dash = 0; + } + + // v1.2.3 (1 Jan 2025) + sprintf(_version_info, "%s (%s)", version, _build_date); } void UITask::renderCurrScreen() { - char tmp[80]; // render 'home' screen _display->drawXbm(0, 0, meshcore_logo, 128, 13); _display->setCursor(0, 20); _display->setTextSize(1); _display->print(_node_name); - sprintf(tmp, "Build: %s", _build_date); _display->setCursor(0, 32); - _display->print(tmp); + _display->print(_version_info); _display->setCursor(0, 43); _display->print("< Room Server >"); //_display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf); diff --git a/examples/simple_room_server/UITask.h b/examples/simple_room_server/UITask.h index e58d6111..e087b86c 100644 --- a/examples/simple_room_server/UITask.h +++ b/examples/simple_room_server/UITask.h @@ -8,11 +8,12 @@ class UITask { int _prevBtnState; const char* _node_name; const char* _build_date; + char _version_info[32]; void renderCurrScreen(); public: UITask(DisplayDriver& display) : _display(&display) { _next_read = _next_refresh = 0; } - void begin(const char* node_name, const char* build_date); + void begin(const char* node_name, const char* build_date, const char* firmware_version); void loop(); }; \ No newline at end of file diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 405c8f7f..235638f8 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -887,7 +887,7 @@ void setup() { the_mesh.begin(fs); #ifdef DISPLAY_CLASS - ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE); + ui_task.begin(the_mesh.getNodeName(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION); #endif // send out initial Advertisement to the mesh From c4d32eba7416954d6db8b372a3f59434e5fa27d8 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 8 Apr 2025 23:17:22 +1200 Subject: [PATCH 4/4] remove unused variables --- examples/companion_radio/UITask.cpp | 6 ++---- examples/companion_radio/UITask.h | 2 -- examples/simple_repeater/UITask.cpp | 3 +-- examples/simple_repeater/UITask.h | 1 - examples/simple_room_server/UITask.cpp | 3 +-- examples/simple_room_server/UITask.h | 1 - 6 files changed, 4 insertions(+), 12 deletions(-) diff --git a/examples/companion_radio/UITask.cpp b/examples/companion_radio/UITask.cpp index cfe08cf7..2d2e95a6 100644 --- a/examples/companion_radio/UITask.cpp +++ b/examples/companion_radio/UITask.cpp @@ -30,8 +30,6 @@ void UITask::begin(DisplayDriver* display, const char* node_name, const char* bu _auto_off = millis() + AUTO_OFF_MILLIS; clearMsgPreview(); _node_name = node_name; - _build_date = build_date; - _firmware_version = firmware_version; _pin_code = pin_code; if (_display != NULL) { _display->turnOn(); @@ -39,14 +37,14 @@ void UITask::begin(DisplayDriver* display, const char* node_name, const char* bu // strip off dash and commit hash by changing dash to null terminator // e.g: v1.2.3-abcdef -> v1.2.3 - char *version = strdup(_firmware_version); + char *version = strdup(firmware_version); char *dash = strchr(version, '-'); if(dash){ *dash = 0; } // v1.2.3 (1 Jan 2025) - sprintf(_version_info, "%s (%s)", version, _build_date); + sprintf(_version_info, "%s (%s)", version, build_date); } void UITask::msgRead(int msgcount) { diff --git a/examples/companion_radio/UITask.h b/examples/companion_radio/UITask.h index 8fe0145e..4cba1fca 100644 --- a/examples/companion_radio/UITask.h +++ b/examples/companion_radio/UITask.h @@ -11,8 +11,6 @@ class UITask { bool _connected; uint32_t _pin_code; const char* _node_name; - const char* _build_date; - const char* _firmware_version; char _version_info[32]; char _origin[62]; char _msg[80]; diff --git a/examples/simple_repeater/UITask.cpp b/examples/simple_repeater/UITask.cpp index 4597a344..6fff675e 100644 --- a/examples/simple_repeater/UITask.cpp +++ b/examples/simple_repeater/UITask.cpp @@ -24,7 +24,6 @@ void UITask::begin(const char* node_name, const char* build_date, const char* fi _prevBtnState = HIGH; _auto_off = millis() + AUTO_OFF_MILLIS; _node_name = node_name; - _build_date = build_date; _display->turnOn(); // strip off dash and commit hash by changing dash to null terminator @@ -36,7 +35,7 @@ void UITask::begin(const char* node_name, const char* build_date, const char* fi } // v1.2.3 (1 Jan 2025) - sprintf(_version_info, "%s (%s)", version, _build_date); + sprintf(_version_info, "%s (%s)", version, build_date); } void UITask::renderCurrScreen() { diff --git a/examples/simple_repeater/UITask.h b/examples/simple_repeater/UITask.h index e087b86c..13005957 100644 --- a/examples/simple_repeater/UITask.h +++ b/examples/simple_repeater/UITask.h @@ -7,7 +7,6 @@ class UITask { unsigned long _next_read, _next_refresh, _auto_off; int _prevBtnState; const char* _node_name; - const char* _build_date; char _version_info[32]; void renderCurrScreen(); diff --git a/examples/simple_room_server/UITask.cpp b/examples/simple_room_server/UITask.cpp index eb2e4a00..eb7be78e 100644 --- a/examples/simple_room_server/UITask.cpp +++ b/examples/simple_room_server/UITask.cpp @@ -24,7 +24,6 @@ void UITask::begin(const char* node_name, const char* build_date, const char* fi _prevBtnState = HIGH; _auto_off = millis() + AUTO_OFF_MILLIS; _node_name = node_name; - _build_date = build_date; _display->turnOn(); // strip off dash and commit hash by changing dash to null terminator @@ -36,7 +35,7 @@ void UITask::begin(const char* node_name, const char* build_date, const char* fi } // v1.2.3 (1 Jan 2025) - sprintf(_version_info, "%s (%s)", version, _build_date); + sprintf(_version_info, "%s (%s)", version, build_date); } void UITask::renderCurrScreen() { diff --git a/examples/simple_room_server/UITask.h b/examples/simple_room_server/UITask.h index e087b86c..13005957 100644 --- a/examples/simple_room_server/UITask.h +++ b/examples/simple_room_server/UITask.h @@ -7,7 +7,6 @@ class UITask { unsigned long _next_read, _next_refresh, _auto_off; int _prevBtnState; const char* _node_name; - const char* _build_date; char _version_info[32]; void renderCurrScreen();