Переглянути джерело

Merge pull request #1747 from thinkyhead/progress_bar_tweak

Fix up LCD_PROGRESS_BAR
Scott Lahteine 10 роки тому
джерело
коміт
a117b6bff6

+ 7
- 3
Marlin/Marlin_main.cpp Переглянути файл

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

+ 4
- 1
Marlin/SanityCheck.h Переглянути файл

@@ -17,8 +17,11 @@
17 17
    * Progress Bar
18 18
    */
19 19
   #ifdef LCD_PROGRESS_BAR
20
+    #ifndef SDSUPPORT
21
+      #error LCD_PROGRESS_BAR requires SDSUPPORT.
22
+    #endif
20 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 25
     #endif
23 26
     #ifdef FILAMENT_LCD_DISPLAY
24 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 Переглянути файл

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

+ 6
- 2
Marlin/ultralcd.h Переглянути файл

@@ -8,12 +8,16 @@
8 8
   int lcd_strlen_P(const char *s);
9 9
   void lcd_update();
10 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 13
   void lcd_setalertstatuspgm(const char* message);
14 14
   void lcd_reset_alert_level();
15 15
   bool lcd_detected(void);
16 16
 
17
+  #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
18
+    void dontExpireStatus();
19
+  #endif
20
+
17 21
   #ifdef DOGLCD
18 22
     extern int lcd_contrast;
19 23
     void lcd_setcontrast(uint8_t value);

+ 7
- 7
Marlin/ultralcd_implementation_hitachi_HD44780.h Переглянути файл

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

Завантаження…
Відмінити
Зберегти