diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 65290b3cb8..7f8159c51b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -890,8 +890,11 @@ void get_command() { } bool code_has_value() { - char c = strchr_pointer[1]; - return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'; + int i = 1; + char c = strchr_pointer[i]; + if (c == '-' || c == '+') c = strchr_pointer[++i]; + if (c == '.') c = strchr_pointer[++i]; + return (c >= '0' && c <= '9'); } float code_value() { @@ -1744,14 +1747,15 @@ inline void gcode_G2_G3(bool clockwise) { inline void gcode_G4() { millis_t codenum = 0; - LCD_MESSAGEPGM(MSG_DWELL); - if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait st_synchronize(); refresh_cmd_timeout(); codenum += previous_cmd_ms; // keep track of when we started waiting + + if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL); + while (millis() < codenum) { manage_heater(); manage_inactivity(); diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index c96f098994..a310db6143 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -273,22 +273,22 @@ static void lcd_status_screen() { #endif #if PROGRESS_MSG_EXPIRE > 0 // Handle message expire - if (expireStatusMillis > 0) { + if (expire_status_ms > 0) { if (card.isFileOpen()) { // Expire the message when printing is active if (IS_SD_PRINTING) { // Expire the message when printing is active - if (ms >= expireStatusMillis) { + if (ms >= expire_status_ms) { lcd_status_message[0] = '\0'; - expireStatusMillis = 0; + expire_status_ms = 0; } } else { - expireStatusMillis += LCD_UPDATE_INTERVAL; + expire_status_ms += LCD_UPDATE_INTERVAL; } } else { - expireStatusMillis = 0; + expire_status_ms = 0; } } #endif @@ -1394,7 +1394,7 @@ void lcd_finishstatus(bool persist=false) { #ifdef LCD_PROGRESS_BAR progressBarTick = millis(); #if PROGRESS_MSG_EXPIRE > 0 - expireStatusMillis = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE; + expire_status_ms = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE; #endif #endif lcdDrawUpdate = 2; @@ -1405,7 +1405,7 @@ void lcd_finishstatus(bool persist=false) { } #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 - void dontExpireStatus() { expireStatusMillis = 0; } + void dontExpireStatus() { expire_status_ms = 0; } #endif void set_utf_strlen(char *s, uint8_t n) { @@ -1418,6 +1418,8 @@ void set_utf_strlen(char *s, uint8_t n) { s[i] = 0; } +bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); } + void lcd_setstatus(const char* message, bool persist) { if (lcd_status_message_level > 0) return; strncpy(lcd_status_message, message, 3*LCD_WIDTH); diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index b8d5cba8ad..8f96f008ba 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -8,6 +8,7 @@ int lcd_strlen_P(const char *s); void lcd_update(); void lcd_init(); + bool lcd_hasstatus(); void lcd_setstatus(const char* message, const bool persist=false); void lcd_setstatuspgm(const char* message, const uint8_t level=0); void lcd_setalertstatuspgm(const char* message); @@ -100,6 +101,7 @@ #else //no LCD FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_init() {} + FORCE_INLINE bool lcd_hasstatus() { return false; } FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {} FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {} FORCE_INLINE void lcd_buttons_update() {} @@ -107,8 +109,8 @@ FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {} FORCE_INLINE bool lcd_detected(void) { return true; } - #define LCD_MESSAGEPGM(x) - #define LCD_ALERTMESSAGEPGM(x) + #define LCD_MESSAGEPGM(x) do{}while(0) + #define LCD_ALERTMESSAGEPGM(x) do{}while(0) #endif //ULTRA_LCD diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index f9ed56a7dc..50c6deb5e4 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -196,7 +196,7 @@ #ifdef LCD_PROGRESS_BAR static uint16_t progressBarTick = 0; #if PROGRESS_MSG_EXPIRE > 0 - static uint16_t expireStatusMillis = 0; + static uint16_t expire_status_ms = 0; #endif #define LCD_STR_PROGRESS "\x03\x04\x05" #endif