Merge pull request #3271 from thinkyhead/rc_blink_limiter

Keep blinking limited to LCD_UPDATE_INTERVAL
This commit is contained in:
Scott Lahteine 2016-03-28 20:05:56 -07:00
commit f83c03f594
4 changed files with 45 additions and 35 deletions

View file

@ -304,9 +304,11 @@ static void _draw_heater_status(int x, int heater) {
static void lcd_implementation_status_screen() {
u8g.setColorIndex(1); // black on white
bool blink = lcd_blink();
#if HAS_FAN0
// Symbols menu graphics, animated fan
u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, (blink % 2) && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp);
u8g.drawBitmapP(9, 1, STATUS_SCREENBYTEWIDTH, STATUS_SCREENHEIGHT, blink && fanSpeeds[0] ? status_screen0_bmp : status_screen1_bmp);
#endif
#if ENABLED(SDSUPPORT)
@ -375,18 +377,19 @@ static void lcd_implementation_status_screen() {
#endif
u8g.setColorIndex(0); // white on black
u8g.setPrintPos(2, XYZ_BASELINE);
if (blink & 1)
if (blink)
lcd_printPGM(PSTR("X"));
else {
if (!axis_homed[X_AXIS])
lcd_printPGM(PSTR("?"));
else
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[X_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR("X"));
}
}
u8g.drawPixel(8, XYZ_BASELINE - 5);
u8g.drawPixel(8, XYZ_BASELINE - 3);
@ -394,18 +397,19 @@ static void lcd_implementation_status_screen() {
lcd_print(ftostr31ns(current_position[X_AXIS]));
u8g.setPrintPos(43, XYZ_BASELINE);
if (blink & 1)
if (blink)
lcd_printPGM(PSTR("Y"));
else {
if (!axis_homed[Y_AXIS])
lcd_printPGM(PSTR("?"));
else
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Y_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR("Y"));
}
}
u8g.drawPixel(49, XYZ_BASELINE - 5);
u8g.drawPixel(49, XYZ_BASELINE - 3);
@ -413,18 +417,19 @@ static void lcd_implementation_status_screen() {
lcd_print(ftostr31ns(current_position[Y_AXIS]));
u8g.setPrintPos(83, XYZ_BASELINE);
if (blink & 1)
if (blink)
lcd_printPGM(PSTR("Z"));
else {
if (!axis_homed[Z_AXIS])
lcd_printPGM(PSTR("?"));
else
else {
#if DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[Z_AXIS])
lcd_printPGM(PSTR(" "));
else
#endif
lcd_printPGM(PSTR("Z"));
}
}
u8g.drawPixel(89, XYZ_BASELINE - 5);
u8g.drawPixel(89, XYZ_BASELINE - 3);

View file

@ -48,8 +48,6 @@
#define ENCODER_DIRECTION_MENUS() ;
#endif
uint8_t blink = 0; // Variable for animation
int8_t encoderDiff; // updated from interrupt context and added to encoderPosition every LCD update
bool encoderRateMultiplierEnabled;
@ -1807,6 +1805,16 @@ int lcd_strlen_P(const char* s) {
return j;
}
bool lcd_blink() {
static uint8_t blink = 0;
static millis_t next_blink_ms = 0;
if (millis() >= next_blink_ms) {
blink ^= 0xFF;
next_blink_ms = millis() + LCD_UPDATE_INTERVAL - 50;
}
return blink != 0;
}
/**
* Update the LCD, read encoder buttons, etc.
* - Read button states
@ -1923,25 +1931,23 @@ void lcd_update() {
lcd_status_update_delay--;
}
}
#if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display
if (lcdDrawUpdate) {
blink++; // Variable for animation and alive dot
u8g.firstPage();
do {
lcd_setFont(FONT_MENU);
u8g.setPrintPos(125, 0);
if (blink & 1) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
u8g.drawPixel(127, 63); // draw alive dot
u8g.setColorIndex(1); // black on white
(*currentMenu)();
} while (u8g.nextPage());
}
#else
if (lcdDrawUpdate) {
blink++; // Variable for animation
if (lcdDrawUpdate) {
#if ENABLED(DOGLCD) // Changes due to different driver architecture of the DOGM display
bool blink = lcd_blink();
u8g.firstPage();
do {
lcd_setFont(FONT_MENU);
u8g.setPrintPos(125, 0);
u8g.setColorIndex(blink ? 1 : 0); // Set color for the alive dot
u8g.drawPixel(127, 63); // draw alive dot
u8g.setColorIndex(1); // black on white
(*currentMenu)();
} while (u8g.nextPage());
#else
(*currentMenu)();
}
#endif
#endif
}
#if ENABLED(LCD_HAS_STATUS_INDICATORS)
lcd_implementation_update_indicators();
@ -1963,8 +1969,7 @@ void lcd_update() {
#endif // ULTIPANEL
if (lcdDrawUpdate == 2) lcd_implementation_clear();
if (lcdDrawUpdate) lcdDrawUpdate--;
if (lcdDrawUpdate && --lcdDrawUpdate) lcd_implementation_clear();
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
}
}

View file

@ -76,15 +76,13 @@
extern bool cancel_heatup;
extern uint8_t blink; // Variable for animation
#if ENABLED(FILAMENT_LCD_DISPLAY)
extern millis_t previous_lcd_status_ms;
#endif
void lcd_quick_feedback(); // Audible feedback for a button click - could also be visual
bool lcd_clicked();
void lcd_ignore_click(bool b=true);
bool lcd_blink();
#if ENABLED(NEWPANEL)
#define EN_C (_BV(BLEN_C))

View file

@ -626,6 +626,8 @@ static void lcd_implementation_status_screen() {
#if LCD_HEIGHT > 2
bool blink = lcd_blink();
#if LCD_WIDTH < 20
#if ENABLED(SDSUPPORT)
@ -654,7 +656,7 @@ static void lcd_implementation_status_screen() {
// When axis is homed but axis_known_position is false the axis letters are blinking 'X' <-> ' '.
// When everything is ok you see a constant 'X'.
if (blink & 1)
if (blink)
lcd_printPGM(PSTR("X"));
else {
if (!axis_homed[X_AXIS])
@ -671,7 +673,7 @@ static void lcd_implementation_status_screen() {
lcd.print(ftostr4sign(current_position[X_AXIS]));
lcd_printPGM(PSTR(" "));
if (blink & 1)
if (blink)
lcd_printPGM(PSTR("Y"));
else {
if (!axis_homed[Y_AXIS])
@ -691,7 +693,7 @@ static void lcd_implementation_status_screen() {
#endif // LCD_WIDTH >= 20
lcd.setCursor(LCD_WIDTH - 8, 1);
if (blink & 1)
if (blink)
lcd_printPGM(PSTR("Z"));
else {
if (!axis_homed[Z_AXIS])