@@ -25,16 +25,30 @@ static const uint8_t meshcore_logo [] PROGMEM = {
2525 0xe3 , 0xe3 , 0x8f , 0xff , 0x1f , 0xfc , 0x3c , 0x0e , 0x1f , 0xf8 , 0xff , 0xf8 , 0x70 , 0x3c , 0x7f , 0xf8 ,
2626};
2727
28- void UITask::begin (DisplayDriver* display, const char * node_name, const char * build_date, uint32_t pin_code) {
28+ void UITask::begin (DisplayDriver* display, const char * node_name, const char * build_date, const char * firmware_version, uint32_t pin_code) {
2929 _display = display;
3030 _auto_off = millis () + AUTO_OFF_MILLIS ;
3131 clearMsgPreview ();
3232 _node_name = node_name;
33- _build_date = build_date;
3433 _pin_code = pin_code;
3534 if (_display != NULL ) {
3635 _display->turnOn ();
3736 }
37+
38+ // strip off dash and commit hash by changing dash to null terminator
39+ // e.g: v1.2.3-abcdef -> v1.2.3
40+ char *version = strdup (firmware_version);
41+ char *dash = strchr (version, ' -' );
42+ if (dash){
43+ *dash = 0 ;
44+ }
45+
46+ #ifdef PIN_USER_BTN
47+ pinMode (PIN_USER_BTN , INPUT );
48+ #endif
49+
50+ // v1.2.3 (1 Jan 2025)
51+ sprintf (_version_info, " %s (%s)" , version, build_date);
3852}
3953
4054void UITask::msgRead (int msgcount) {
@@ -47,6 +61,7 @@ void UITask::msgRead(int msgcount) {
4761void UITask::clearMsgPreview () {
4862 _origin[0 ] = 0 ;
4963 _msg[0 ] = 0 ;
64+ _need_refresh = true ;
5065}
5166
5267void UITask::newMsg (uint8_t path_len, const char * from_name, const char * text, int msgcount) {
@@ -62,6 +77,7 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
6277 if (_display != NULL ) {
6378 if (!_display->isOn ()) _display->turnOn ();
6479 _auto_off = millis () + AUTO_OFF_MILLIS ; // extend the auto-off timer
80+ _need_refresh = true ;
6581 }
6682}
6783
@@ -73,38 +89,46 @@ void UITask::renderCurrScreen() {
7389 // render message preview
7490 _display->setCursor (0 , 0 );
7591 _display->setTextSize (1 );
92+ _display->setColor (DisplayDriver::GREEN );
7693 _display->print (_node_name);
7794
7895 _display->setCursor (0 , 12 );
96+ _display->setColor (DisplayDriver::YELLOW );
7997 _display->print (_origin);
8098 _display->setCursor (0 , 24 );
99+ _display->setColor (DisplayDriver::LIGHT );
81100 _display->print (_msg);
82101
83- _display->setCursor (100 , 9 );
102+ _display->setCursor (_display-> width () - 28 , 9 );
84103 _display->setTextSize (2 );
104+ _display->setColor (DisplayDriver::ORANGE );
85105 sprintf (tmp, " %d" , _msgcount);
86106 _display->print (tmp);
87107 } else {
88108 // render 'home' screen
109+ _display->setColor (DisplayDriver::BLUE );
89110 _display->drawXbm (0 , 0 , meshcore_logo, 128 , 13 );
90111 _display->setCursor (0 , 20 );
91112 _display->setTextSize (1 );
92- _display->print (_node_name);
93113
94- sprintf (tmp, " Build: %s" , _build_date);
114+ _display->setColor (DisplayDriver::LIGHT );
115+ _display->print (_node_name);
116+
95117 _display->setCursor (0 , 32 );
96- _display->print (tmp );
118+ _display->print (_version_info );
97119
98120 if (_connected) {
99121 // _display->printf("freq : %03.2f sf %d\n", _prefs.freq, _prefs.sf);
100122 // _display->printf("bw : %03.2f cr %d\n", _prefs.bw, _prefs.cr);
101123 } else if (_pin_code != 0 ) {
124+ _display->setColor (DisplayDriver::RED );
102125 _display->setTextSize (2 );
103126 _display->setCursor (0 , 43 );
104127 sprintf (tmp, " Pin:%d" , _pin_code);
105128 _display->print (tmp);
106129 }
107130 }
131+ _need_refresh = false ;
108132}
109133
110134void UITask::userLedHandler () {
@@ -148,6 +172,7 @@ void UITask::buttonHandler() {
148172 clearMsgPreview ();
149173 } else {
150174 _display->turnOn ();
175+ _need_refresh = true ;
151176 }
152177 _auto_off = cur_time + AUTO_OFF_MILLIS ; // extend auto-off timer
153178 }
@@ -173,7 +198,7 @@ void UITask::loop() {
173198 userLedHandler ();
174199
175200 if (_display != NULL && _display->isOn ()) {
176- if (millis () >= _next_refresh) {
201+ if (millis () >= _next_refresh && _need_refresh ) {
177202 _display->startFrame ();
178203 renderCurrScreen ();
179204 _display->endFrame ();
0 commit comments