Browse Source

status_message_level => alert_level

Scott Lahteine 6 years ago
parent
commit
10b85be405
2 changed files with 16 additions and 17 deletions
  1. 14
    15
      Marlin/src/lcd/ultralcd.cpp
  2. 2
    2
      Marlin/src/lcd/ultralcd.h

+ 14
- 15
Marlin/src/lcd/ultralcd.cpp View File

@@ -26,7 +26,7 @@
26 26
   #include "../feature/leds/leds.h"
27 27
 #endif
28 28
 
29
-// These displays all share the MarlinUI class
29
+// All displays share the MarlinUI class
30 30
 #if HAS_DISPLAY
31 31
   #include "ultralcd.h"
32 32
   #include "fontutils.h"
@@ -56,7 +56,7 @@
56 56
 #endif
57 57
 
58 58
 #ifdef MAX_MESSAGE_LENGTH
59
-  uint8_t MarlinUI::status_message_level; // = 0
59
+  uint8_t MarlinUI::alert_level; // = 0
60 60
   char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
61 61
 #endif
62 62
 
@@ -82,11 +82,11 @@
82 82
 #include "../Marlin.h"
83 83
 
84 84
 #if ENABLED(POWER_LOSS_RECOVERY)
85
- #include "../feature/power_loss_recovery.h"
85
+  #include "../feature/power_loss_recovery.h"
86 86
 #endif
87 87
 
88 88
 #if ENABLED(AUTO_BED_LEVELING_UBL)
89
- #include "../feature/bedlevel/bedlevel.h"
89
+  #include "../feature/bedlevel/bedlevel.h"
90 90
 #endif
91 91
 
92 92
 #if HAS_BUZZER
@@ -1316,7 +1316,7 @@ void MarlinUI::update() {
1316 1316
   bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
1317 1317
 
1318 1318
   void MarlinUI::set_status(const char * const message, const bool persist) {
1319
-    if (status_message_level > 0) return;
1319
+    if (alert_level) return;
1320 1320
 
1321 1321
     // Here we have a problem. The message is encoded in UTF8, so
1322 1322
     // arbitrarily cutting it will be a problem. We MUST be sure
@@ -1343,8 +1343,8 @@ void MarlinUI::update() {
1343 1343
   #include <stdarg.h>
1344 1344
 
1345 1345
   void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
1346
-    if (level < status_message_level) return;
1347
-    status_message_level = level;
1346
+    if (level < alert_level) return;
1347
+    alert_level = level;
1348 1348
     va_list args;
1349 1349
     va_start(args, fmt);
1350 1350
     vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
@@ -1353,19 +1353,18 @@ void MarlinUI::update() {
1353 1353
   }
1354 1354
 
1355 1355
   void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
1356
-    if (level < 0) level = status_message_level = 0;
1357
-    if (level < status_message_level) return;
1358
-    status_message_level = level;
1356
+    if (level < 0) level = alert_level = 0;
1357
+    if (level < alert_level) return;
1358
+    alert_level = level;
1359 1359
 
1360
-    // Here we have a problem. The message is encoded in UTF8, so
1361
-    // arbitrarily cutting it will be a problem. We MUST be sure
1362
-    // that there is no cutting in the middle of a multibyte character!
1360
+    // Since the message is encoded in UTF8 it must
1361
+    // only be cut on a character boundary.
1363 1362
 
1364 1363
     // Get a pointer to the null terminator
1365 1364
     PGM_P pend = message + strlen_P(message);
1366 1365
 
1367
-    //  If length of supplied UTF8 string is greater than
1368
-    // our buffer size, start cutting whole UTF8 chars
1366
+    // If length of supplied UTF8 string is greater than
1367
+    // the buffer size, start cutting whole UTF8 chars
1369 1368
     while ((pend - message) > MAX_MESSAGE_LENGTH) {
1370 1369
       --pend;
1371 1370
       while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend;

+ 2
- 2
Marlin/src/lcd/ultralcd.h View File

@@ -277,8 +277,8 @@ public:
277 277
     static char status_message[];
278 278
     static bool has_status();
279 279
 
280
-    static uint8_t status_message_level;      // Higher levels block lower levels
281
-    static inline void reset_alert_level() { status_message_level = 0; }
280
+    static uint8_t alert_level; // Higher levels block lower levels
281
+    static inline void reset_alert_level() { alert_level = 0; }
282 282
 
283 283
     #if ENABLED(STATUS_MESSAGE_SCROLLING)
284 284
       static uint8_t status_scroll_offset;

Loading…
Cancel
Save