瀏覽代碼

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

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

48
   #define ENCODER_DIRECTION_MENUS() ;
48
   #define ENCODER_DIRECTION_MENUS() ;
49
 #endif
49
 #endif
50
 
50
 
51
-uint8_t blink = 0; // Variable for animation
52
-
53
 int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
51
 int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
54
 
52
 
55
 bool encoderRateMultiplierEnabled;
53
 bool encoderRateMultiplierEnabled;
1807
   return j;
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
  * Update the LCD, read encoder buttons, etc.
1819
  * Update the LCD, read encoder buttons, etc.
1812
  *   - Read button states
1820
  *   - Read button states
1923
         lcd_status_update_delay--;
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
         (*currentMenu)();
1948
         (*currentMenu)();
1943
-      }
1944
-    #endif
1949
+      #endif
1950
+    }
1945
 
1951
 
1946
     #if ENABLED(LCD_HAS_STATUS_INDICATORS)
1952
     #if ENABLED(LCD_HAS_STATUS_INDICATORS)
1947
       lcd_implementation_update_indicators();
1953
       lcd_implementation_update_indicators();
1963
 
1969
 
1964
     #endif // ULTIPANEL
1970
     #endif // ULTIPANEL
1965
 
1971
 
1966
-    if (lcdDrawUpdate == 2) lcd_implementation_clear();
1967
-    if (lcdDrawUpdate) lcdDrawUpdate--;
1972
+    if (lcdDrawUpdate && --lcdDrawUpdate) lcd_implementation_clear();
1968
     next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
1973
     next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
1969
   }
1974
   }
1970
 }
1975
 }

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

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

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

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

Loading…
取消
儲存