瀏覽代碼

Merge pull request #3271 from thinkyhead/rc_blink_limiter

Keep blinking limited to LCD_UPDATE_INTERVAL
Scott Lahteine 9 年之前
父節點
當前提交
f83c03f594
共有 4 個檔案被更改,包括 45 行新增35 行删除
  1. 12
    7
      Marlin/dogm_lcd_implementation.h
  2. 27
    22
      Marlin/ultralcd.cpp
  3. 1
    3
      Marlin/ultralcd.h
  4. 5
    3
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 12
- 7
Marlin/dogm_lcd_implementation.h 查看文件

@@ -304,9 +304,11 @@ static void _draw_heater_status(int x, int heater) {
304 304
 static void lcd_implementation_status_screen() {
305 305
   u8g.setColorIndex(1); // black on white
306 306
 
307
+  bool blink = lcd_blink();
308
+
307 309
   #if HAS_FAN0
308 310
     // Symbols menu graphics, animated fan
309
-    u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, (blink % 2) && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp);
311
+    u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, blink && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp);
310 312
   #endif
311 313
 
312 314
   #if ENABLED(SDSUPPORT)
@@ -375,18 +377,19 @@ static void lcd_implementation_status_screen() {
375 377
   #endif
376 378
   u8g.setColorIndex(0); // white on black
377 379
   u8g.setPrintPos(2, XYZ_BASELINE);
378
-  if (blink & 1)
380
+  if (blink)
379 381
     lcd_printPGM(PSTR("X"));
380 382
   else {
381 383
     if (!axis_homed[X_AXIS])
382 384
       lcd_printPGM(PSTR("?"));
383
-    else
385
+    else {
384 386
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
385 387
         if (!axis_known_position[X_AXIS])
386 388
           lcd_printPGM(PSTR(" "));
387 389
         else
388 390
       #endif
389 391
       lcd_printPGM(PSTR("X"));
392
+    }
390 393
   }
391 394
   u8g.drawPixel(8, XYZ_BASELINE - 5);
392 395
   u8g.drawPixel(8, XYZ_BASELINE - 3);
@@ -394,18 +397,19 @@ static void lcd_implementation_status_screen() {
394 397
   lcd_print(ftostr31ns(current_position[X_AXIS]));
395 398
 
396 399
   u8g.setPrintPos(43, XYZ_BASELINE);
397
-  if (blink & 1)
400
+  if (blink)
398 401
     lcd_printPGM(PSTR("Y"));
399 402
   else {
400 403
     if (!axis_homed[Y_AXIS])
401 404
       lcd_printPGM(PSTR("?"));
402
-    else
405
+    else {
403 406
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
404 407
         if (!axis_known_position[Y_AXIS])
405 408
           lcd_printPGM(PSTR(" "));
406 409
         else
407 410
       #endif
408 411
       lcd_printPGM(PSTR("Y"));
412
+    }
409 413
   }
410 414
   u8g.drawPixel(49, XYZ_BASELINE - 5);
411 415
   u8g.drawPixel(49, XYZ_BASELINE - 3);
@@ -413,18 +417,19 @@ static void lcd_implementation_status_screen() {
413 417
   lcd_print(ftostr31ns(current_position[Y_AXIS]));
414 418
 
415 419
   u8g.setPrintPos(83, XYZ_BASELINE);
416
-  if (blink & 1)
420
+  if (blink)
417 421
     lcd_printPGM(PSTR("Z"));
418 422
   else {
419 423
     if (!axis_homed[Z_AXIS])
420 424
       lcd_printPGM(PSTR("?"));
421
-    else
425
+    else {
422 426
       #if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
423 427
         if (!axis_known_position[Z_AXIS])
424 428
           lcd_printPGM(PSTR(" "));
425 429
         else
426 430
       #endif
427 431
       lcd_printPGM(PSTR("Z"));
432
+    }
428 433
   }
429 434
   u8g.drawPixel(89, XYZ_BASELINE - 5);
430 435
   u8g.drawPixel(89, XYZ_BASELINE - 3);

+ 27
- 22
Marlin/ultralcd.cpp 查看文件

@@ -48,8 +48,6 @@
48 48
   #define ENCODER_DIRECTION_MENUS() ;
49 49
 #endif
50 50
 
51
-uint8_t blink = 0; // Variable for animation
52
-
53 51
 int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
54 52
 
55 53
 bool encoderRateMultiplierEnabled;
@@ -1807,6 +1805,16 @@ int lcd_strlen_P(const char* s) {
1807 1805
   return j;
1808 1806
 }
1809 1807
 
1808
+bool lcd_blink() {
1809
+  static uint8_t blink = 0;
1810
+  static millis_t next_blink_ms = 0;
1811
+  if (millis() >= next_blink_ms) {
1812
+    blink ^= 0xFF;
1813
+    next_blink_ms = millis() + LCD_UPDATE_INTERVAL - 50;
1814
+  }
1815
+  return blink != 0;
1816
+}
1817
+
1810 1818
 /**
1811 1819
  * Update the LCD, read encoder buttons, etc.
1812 1820
  *   - Read button states
@@ -1923,25 +1931,23 @@ void lcd_update() {
1923 1931
         lcd_status_update_delay--;
1924 1932
       }
1925 1933
     }
1926
-    #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
1927
-        if (lcdDrawUpdate) {
1928
-          blink++;     // Variable for animation and alive dot
1929
-          u8g.firstPage();
1930
-          do {
1931
-            lcd_setFont(FONT_MENU);
1932
-            u8g.setPrintPos(125, 0);
1933
-            if (blink & 1) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
1934
-            u8g.drawPixel(127, 63); // draw alive dot
1935
-            u8g.setColorIndex(1); // black on white
1936
-            (*currentMenu)();
1937
-          } while (u8g.nextPage());
1938
-        }
1939
-    #else
1940
-      if (lcdDrawUpdate) {
1941
-        blink++;     // Variable for animation
1934
+
1935
+    if (lcdDrawUpdate) {
1936
+      #if ENABLED(DOGLCD)  // Changes due to different driver architecture of the DOGM display
1937
+        bool blink = lcd_blink();
1938
+        u8g.firstPage();
1939
+        do {
1940
+          lcd_setFont(FONT_MENU);
1941
+          u8g.setPrintPos(125, 0);
1942
+          u8g.setColorIndex(blink ? 1 : 0); // Set color for the alive dot
1943
+          u8g.drawPixel(127, 63); // draw alive dot
1944
+          u8g.setColorIndex(1); // black on white
1945
+          (*currentMenu)();
1946
+        } while (u8g.nextPage());
1947
+      #else
1942 1948
         (*currentMenu)();
1943
-      }
1944
-    #endif
1949
+      #endif
1950
+    }
1945 1951
 
1946 1952
     #if ENABLED(LCD_HAS_STATUS_INDICATORS)
1947 1953
       lcd_implementation_update_indicators();
@@ -1963,8 +1969,7 @@ void lcd_update() {
1963 1969
 
1964 1970
     #endif // ULTIPANEL
1965 1971
 
1966
-    if (lcdDrawUpdate == 2) lcd_implementation_clear();
1967
-    if (lcdDrawUpdate) lcdDrawUpdate--;
1972
+    if (lcdDrawUpdate && --lcdDrawUpdate) lcd_implementation_clear();
1968 1973
     next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
1969 1974
   }
1970 1975
 }

+ 1
- 3
Marlin/ultralcd.h 查看文件

@@ -76,15 +76,13 @@
76 76
 
77 77
   extern bool cancel_heatup;
78 78
 
79
-  extern uint8_t blink; // Variable for animation
80
-
81 79
   #if ENABLED(FILAMENT_LCD_DISPLAY)
82 80
     extern millis_t previous_lcd_status_ms;
83 81
   #endif
84 82
   void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
85 83
   bool lcd_clicked();
86
-
87 84
   void lcd_ignore_click(bool b=true);
85
+  bool lcd_blink();
88 86
 
89 87
   #if ENABLED(NEWPANEL)
90 88
     #define EN_C (_BV(BLEN_C))

+ 5
- 3
Marlin/ultralcd_implementation_hitachi_HD44780.h 查看文件

@@ -626,6 +626,8 @@ static void lcd_implementation_status_screen() {
626 626
 
627 627
   #if LCD_HEIGHT > 2
628 628
 
629
+    bool blink = lcd_blink();
630
+
629 631
     #if LCD_WIDTH < 20
630 632
 
631 633
       #if ENABLED(SDSUPPORT)
@@ -654,7 +656,7 @@ static void lcd_implementation_status_screen() {
654 656
         // When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
655 657
         // When everything is ok you see a constant 'X'.
656 658
 
657
-        if (blink & 1)
659
+        if (blink)
658 660
           lcd_printPGM(PSTR("X"));
659 661
         else {
660 662
           if (!axis_homed[X_AXIS])
@@ -671,7 +673,7 @@ static void lcd_implementation_status_screen() {
671 673
         lcd.print(ftostr4sign(current_position[X_AXIS]));
672 674
 
673 675
         lcd_printPGM(PSTR(" "));
674
-        if (blink & 1)
676
+        if (blink)
675 677
           lcd_printPGM(PSTR("Y"));
676 678
         else {
677 679
           if (!axis_homed[Y_AXIS])
@@ -691,7 +693,7 @@ static void lcd_implementation_status_screen() {
691 693
     #endif // LCD_WIDTH >= 20
692 694
 
693 695
     lcd.setCursor(LCD_WIDTH - 8, 1);
694
-    if (blink & 1)
696
+    if (blink)
695 697
       lcd_printPGM(PSTR("Z"));
696 698
     else {
697 699
       if (!axis_homed[Z_AXIS])

Loading…
取消
儲存