Browse Source

Fix up LCD_PROGRESS_BAR

- Some messages should not expire with `PROGRESS_MSG_EXPIRE`.
- Simplify conditional for progress bar with sanity checks.
- Rename `messageTick` to `expireStatusMillis` and make it the expire
time.
Scott Lahteine 9 years ago
parent
commit
5519882eea

+ 7
- 3
Marlin/Marlin_main.cpp View File

846
         sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
846
         sprintf_P(time, PSTR("%i hours %i minutes"),hours, minutes);
847
         SERIAL_ECHO_START;
847
         SERIAL_ECHO_START;
848
         SERIAL_ECHOLN(time);
848
         SERIAL_ECHOLN(time);
849
-        lcd_setstatus(time);
849
+        lcd_setstatus(time, true);
850
         card.printingHasFinished();
850
         card.printingHasFinished();
851
         card.checkautostart(true);
851
         card.checkautostart(true);
852
 
852
 
2536
     if (starpos != NULL) *(starpos) = '\0';
2536
     if (starpos != NULL) *(starpos) = '\0';
2537
     while (*src == ' ') ++src;
2537
     while (*src == ' ') ++src;
2538
     if (!hasP && !hasS && *src != '\0')
2538
     if (!hasP && !hasS && *src != '\0')
2539
-      lcd_setstatus(src);
2540
-    else
2539
+      lcd_setstatus(src, true);
2540
+    else {
2541
       LCD_MESSAGEPGM(MSG_USERWAIT);
2541
       LCD_MESSAGEPGM(MSG_USERWAIT);
2542
+      #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
2543
+        dontExpireStatus();
2544
+      #endif
2545
+    }
2542
 
2546
 
2543
     lcd_ignore_click();
2547
     lcd_ignore_click();
2544
     st_synchronize();
2548
     st_synchronize();

+ 4
- 1
Marlin/SanityCheck.h View File

17
    * Progress Bar
17
    * Progress Bar
18
    */
18
    */
19
   #ifdef LCD_PROGRESS_BAR
19
   #ifdef LCD_PROGRESS_BAR
20
+    #ifndef SDSUPPORT
21
+      #error LCD_PROGRESS_BAR requires SDSUPPORT.
22
+    #endif
20
     #ifdef DOGLCD
23
     #ifdef DOGLCD
21
-      #warning LCD_PROGRESS_BAR does not apply to graphical displays.
24
+      #error LCD_PROGRESS_BAR does not apply to graphical displays.
22
     #endif
25
     #endif
23
     #ifdef FILAMENT_LCD_DISPLAY
26
     #ifdef FILAMENT_LCD_DISPLAY
24
       #error LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both.
27
       #error LCD_PROGRESS_BAR and FILAMENT_LCD_DISPLAY are not fully compatible. Comment out this line to use both.

+ 34
- 26
Marlin/ultralcd.cpp View File

252
     if (feedback) lcd_quick_feedback();
252
     if (feedback) lcd_quick_feedback();
253
 
253
 
254
     // For LCD_PROGRESS_BAR re-initialize the custom characters
254
     // For LCD_PROGRESS_BAR re-initialize the custom characters
255
-    #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
255
+    #ifdef LCD_PROGRESS_BAR
256
       lcd_set_custom_characters(menu == lcd_status_screen);
256
       lcd_set_custom_characters(menu == lcd_status_screen);
257
     #endif
257
     #endif
258
   }
258
   }
262
 static void lcd_status_screen()
262
 static void lcd_status_screen()
263
 {
263
 {
264
 	encoderRateMultiplierEnabled = false;
264
 	encoderRateMultiplierEnabled = false;
265
-  #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
266
-    uint16_t mil = millis();
265
+
266
+  #ifdef LCD_PROGRESS_BAR
267
+    unsigned long ms = millis();
267
     #ifndef PROGRESS_MSG_ONCE
268
     #ifndef PROGRESS_MSG_ONCE
268
-      if (mil > progressBarTick + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) {
269
-        progressBarTick = mil;
269
+      if (ms > progressBarTick + PROGRESS_BAR_MSG_TIME + PROGRESS_BAR_BAR_TIME) {
270
+        progressBarTick = ms;
270
       }
271
       }
271
     #endif
272
     #endif
272
     #if PROGRESS_MSG_EXPIRE > 0
273
     #if PROGRESS_MSG_EXPIRE > 0
273
-      // keep the message alive if paused, count down otherwise
274
-      if (messageTick > 0) {
274
+      // Handle message expire
275
+      if (expireStatusMillis > 0) {
275
         if (card.isFileOpen()) {
276
         if (card.isFileOpen()) {
277
+          // Expire the message when printing is active
276
           if (IS_SD_PRINTING) {
278
           if (IS_SD_PRINTING) {
277
-            if ((mil-messageTick) >= PROGRESS_MSG_EXPIRE) {
279
+            // Expire the message when printing is active
280
+            if (ms >= expireStatusMillis) {
278
               lcd_status_message[0] = '\0';
281
               lcd_status_message[0] = '\0';
279
-              messageTick = 0;
282
+              expireStatusMillis = 0;
280
             }
283
             }
281
           }
284
           }
282
           else {
285
           else {
283
-            messageTick += LCD_UPDATE_INTERVAL;
286
+            expireStatusMillis += LCD_UPDATE_INTERVAL;
284
           }
287
           }
285
         }
288
         }
286
         else {
289
         else {
287
-          messageTick = 0;
290
+          expireStatusMillis = 0;
288
         }
291
         }
289
       }
292
       }
290
     #endif
293
     #endif
324
     {
327
     {
325
         lcd_goto_menu(lcd_main_menu);
328
         lcd_goto_menu(lcd_main_menu);
326
         lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
329
         lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
327
-          #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
330
+          #ifdef LCD_PROGRESS_BAR
328
             currentMenu == lcd_status_screen
331
             currentMenu == lcd_status_screen
329
           #endif
332
           #endif
330
         );
333
         );
380
   card.closefile();
383
   card.closefile();
381
   autotempShutdown();
384
   autotempShutdown();
382
   cancel_heatup = true;
385
   cancel_heatup = true;
383
-  lcd_setstatus(MSG_PRINT_ABORTED);
386
+  lcd_setstatus(MSG_PRINT_ABORTED, true);
384
 }
387
 }
385
 
388
 
386
 /* Menu implementation */
389
 /* Menu implementation */
1275
       lcdDrawUpdate = 2;
1278
       lcdDrawUpdate = 2;
1276
       lcd_oldcardstatus = IS_SD_INSERTED;
1279
       lcd_oldcardstatus = IS_SD_INSERTED;
1277
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
1280
       lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
1278
-        #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
1281
+        #ifdef LCD_PROGRESS_BAR
1279
           currentMenu == lcd_status_screen
1282
           currentMenu == lcd_status_screen
1280
         #endif
1283
         #endif
1281
       );
1284
       );
1393
   wait_for_unclick = false;
1396
   wait_for_unclick = false;
1394
 }
1397
 }
1395
 
1398
 
1396
-void lcd_finishstatus() {
1399
+void lcd_finishstatus(bool persist=false) {
1397
   int len = lcd_strlen(lcd_status_message);
1400
   int len = lcd_strlen(lcd_status_message);
1398
   if (len > 0) {
1401
   if (len > 0) {
1399
     while (len < LCD_WIDTH) {
1402
     while (len < LCD_WIDTH) {
1401
     }
1404
     }
1402
   }
1405
   }
1403
   lcd_status_message[LCD_WIDTH] = '\0';
1406
   lcd_status_message[LCD_WIDTH] = '\0';
1404
-  #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT) && !defined(DOGLCD)
1407
+  #ifdef LCD_PROGRESS_BAR
1408
+    progressBarTick = millis();
1405
     #if PROGRESS_MSG_EXPIRE > 0
1409
     #if PROGRESS_MSG_EXPIRE > 0
1406
-      messageTick =
1410
+      expireStatusMillis = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE;
1407
     #endif
1411
     #endif
1408
-    progressBarTick = millis();
1409
   #endif
1412
   #endif
1410
   lcdDrawUpdate = 2;
1413
   lcdDrawUpdate = 2;
1411
 
1414
 
1414
   #endif
1417
   #endif
1415
 }
1418
 }
1416
 
1419
 
1417
-void lcd_setstatus(const char* message) {
1420
+#if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
1421
+  void dontExpireStatus() { expireStatusMillis = 0; }
1422
+#endif
1423
+
1424
+void lcd_setstatus(const char* message, bool persist) {
1418
   if (lcd_status_message_level > 0) return;
1425
   if (lcd_status_message_level > 0) return;
1419
   strncpy(lcd_status_message, message, LCD_WIDTH);
1426
   strncpy(lcd_status_message, message, LCD_WIDTH);
1420
-  lcd_finishstatus();
1427
+  lcd_finishstatus(persist);
1421
 }
1428
 }
1422
 
1429
 
1423
-void lcd_setstatuspgm(const char* message) {
1424
-  if (lcd_status_message_level > 0) return;
1425
-  strncpy_P(lcd_status_message, message, LCD_WIDTH);
1426
-  lcd_finishstatus();
1430
+void lcd_setstatuspgm(const char* message, uint8_t level) {
1431
+  if (level >= lcd_status_message_level) {
1432
+    strncpy_P(lcd_status_message, message, LCD_WIDTH);
1433
+    lcd_status_message_level = level;
1434
+    lcd_finishstatus(level > 0);
1435
+  }
1427
 }
1436
 }
1428
 
1437
 
1429
 void lcd_setalertstatuspgm(const char* message) {
1438
 void lcd_setalertstatuspgm(const char* message) {
1430
-  lcd_setstatuspgm(message);
1431
-  lcd_status_message_level = 1;
1439
+  lcd_setstatuspgm(message, 1);
1432
   #ifdef ULTIPANEL
1440
   #ifdef ULTIPANEL
1433
     lcd_return_to_status();
1441
     lcd_return_to_status();
1434
   #endif
1442
   #endif

+ 6
- 2
Marlin/ultralcd.h View File

8
   int lcd_strlen_P(const char *s);
8
   int lcd_strlen_P(const char *s);
9
   void lcd_update();
9
   void lcd_update();
10
   void lcd_init();
10
   void lcd_init();
11
-  void lcd_setstatus(const char* message);
12
-  void lcd_setstatuspgm(const char* message);
11
+  void lcd_setstatus(const char* message, const bool persist=false);
12
+  void lcd_setstatuspgm(const char* message, const uint8_t level=0);
13
   void lcd_setalertstatuspgm(const char* message);
13
   void lcd_setalertstatuspgm(const char* message);
14
   void lcd_reset_alert_level();
14
   void lcd_reset_alert_level();
15
   bool lcd_detected(void);
15
   bool lcd_detected(void);
16
 
16
 
17
+  #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
18
+    void dontExpireStatus();
19
+  #endif
20
+
17
   #ifdef DOGLCD
21
   #ifdef DOGLCD
18
     extern int lcd_contrast;
22
     extern int lcd_contrast;
19
     void lcd_setcontrast(uint8_t value);
23
     void lcd_setcontrast(uint8_t value);

+ 7
- 7
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

193
 
193
 
194
 #include "utf_mapper.h"
194
 #include "utf_mapper.h"
195
 
195
 
196
-#if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
196
+#ifdef LCD_PROGRESS_BAR
197
   static uint16_t progressBarTick = 0;
197
   static uint16_t progressBarTick = 0;
198
   #if PROGRESS_MSG_EXPIRE > 0
198
   #if PROGRESS_MSG_EXPIRE > 0
199
-    static uint16_t messageTick = 0;
199
+    static uint16_t expireStatusMillis = 0;
200
   #endif
200
   #endif
201
   #define LCD_STR_PROGRESS  "\x03\x04\x05"
201
   #define LCD_STR_PROGRESS  "\x03\x04\x05"
202
 #endif
202
 #endif
214
 #define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
214
 #define LCD_STR_ARROW_RIGHT ">"  /* from the default character set */
215
 
215
 
216
 static void lcd_set_custom_characters(
216
 static void lcd_set_custom_characters(
217
-  #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
217
+  #ifdef LCD_PROGRESS_BAR
218
     bool progress_bar_set=true
218
     bool progress_bar_set=true
219
   #endif
219
   #endif
220
 ) {
220
 ) {
299
     B00000
299
     B00000
300
   }; //thanks Sonny Mounicou
300
   }; //thanks Sonny Mounicou
301
 
301
 
302
-  #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
302
+  #ifdef LCD_PROGRESS_BAR
303
     static bool char_mode = false;
303
     static bool char_mode = false;
304
     byte progress[3][8] = { {
304
     byte progress[3][8] = { {
305
       B00000,
305
       B00000,
360
 }
360
 }
361
 
361
 
362
 static void lcd_implementation_init(
362
 static void lcd_implementation_init(
363
-  #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
363
+  #ifdef LCD_PROGRESS_BAR
364
     bool progress_bar_set=true
364
     bool progress_bar_set=true
365
   #endif
365
   #endif
366
 ) {
366
 ) {
390
 #endif
390
 #endif
391
 
391
 
392
     lcd_set_custom_characters(
392
     lcd_set_custom_characters(
393
-        #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
393
+        #ifdef LCD_PROGRESS_BAR
394
             progress_bar_set
394
             progress_bar_set
395
         #endif
395
         #endif
396
     );
396
     );
583
   // Status message line at the bottom
583
   // Status message line at the bottom
584
   lcd.setCursor(0, LCD_HEIGHT - 1);
584
   lcd.setCursor(0, LCD_HEIGHT - 1);
585
 
585
 
586
-  #if defined(LCD_PROGRESS_BAR) && defined(SDSUPPORT)
586
+  #ifdef LCD_PROGRESS_BAR
587
 
587
 
588
     if (card.isFileOpen()) {
588
     if (card.isFileOpen()) {
589
       uint16_t mil = millis(), diff = mil - progressBarTick;
589
       uint16_t mil = millis(), diff = mil - progressBarTick;

Loading…
Cancel
Save