|
@@ -31,7 +31,7 @@ int absPreheatFanSpeed;
|
31
|
31
|
typedef void (*menuFunc_t)();
|
32
|
32
|
|
33
|
33
|
uint8_t lcd_status_message_level;
|
34
|
|
-char lcd_status_message[LCD_WIDTH+1] = WELCOME_MSG;
|
|
34
|
+char lcd_status_message[3*LCD_WIDTH+1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
|
35
|
35
|
|
36
|
36
|
#ifdef DOGLCD
|
37
|
37
|
#include "dogm_lcd_implementation.h"
|
|
@@ -1402,13 +1402,6 @@ void lcd_ignore_click(bool b) {
|
1402
|
1402
|
}
|
1403
|
1403
|
|
1404
|
1404
|
void lcd_finishstatus(bool persist=false) {
|
1405
|
|
- int len = lcd_strlen(lcd_status_message);
|
1406
|
|
- if (len > 0) {
|
1407
|
|
- while (len < LCD_WIDTH) {
|
1408
|
|
- lcd_status_message[len++] = ' ';
|
1409
|
|
- }
|
1410
|
|
- }
|
1411
|
|
- lcd_status_message[LCD_WIDTH] = '\0';
|
1412
|
1405
|
#ifdef LCD_PROGRESS_BAR
|
1413
|
1406
|
progressBarTick = millis();
|
1414
|
1407
|
#if PROGRESS_MSG_EXPIRE > 0
|
|
@@ -1426,15 +1419,27 @@ void lcd_finishstatus(bool persist=false) {
|
1426
|
1419
|
void dontExpireStatus() { expireStatusMillis = 0; }
|
1427
|
1420
|
#endif
|
1428
|
1421
|
|
|
1422
|
+void set_utf_strlen(char *s, uint8_t n) {
|
|
1423
|
+ uint8_t i = 0, j = 0;
|
|
1424
|
+ while (s[i] && (j < n)) {
|
|
1425
|
+ if ((s[i] & 0xc0u) != 0x80u) j++;
|
|
1426
|
+ i++;
|
|
1427
|
+ }
|
|
1428
|
+ while (j++ < n) s[i++] = ' ';
|
|
1429
|
+ s[i] = 0;
|
|
1430
|
+}
|
|
1431
|
+
|
1429
|
1432
|
void lcd_setstatus(const char* message, bool persist) {
|
1430
|
1433
|
if (lcd_status_message_level > 0) return;
|
1431
|
|
- strncpy(lcd_status_message, message, LCD_WIDTH);
|
|
1434
|
+ strncpy(lcd_status_message, message, 3*LCD_WIDTH);
|
|
1435
|
+ set_utf_strlen(lcd_status_message, LCD_WIDTH);
|
1432
|
1436
|
lcd_finishstatus(persist);
|
1433
|
1437
|
}
|
1434
|
1438
|
|
1435
|
1439
|
void lcd_setstatuspgm(const char* message, uint8_t level) {
|
1436
|
1440
|
if (level >= lcd_status_message_level) {
|
1437
|
|
- strncpy_P(lcd_status_message, message, LCD_WIDTH);
|
|
1441
|
+ strncpy_P(lcd_status_message, message, 3*LCD_WIDTH);
|
|
1442
|
+ set_utf_strlen(lcd_status_message, LCD_WIDTH);
|
1438
|
1443
|
lcd_status_message_level = level;
|
1439
|
1444
|
lcd_finishstatus(level > 0);
|
1440
|
1445
|
}
|