Merge pull request #1966 from thinkyhead/g4_dwell_message

G4 shows status message only if no message is set already
This commit is contained in:
Scott Lahteine 2015-04-24 22:02:37 -07:00
commit b275946a52
4 changed files with 22 additions and 14 deletions

View file

@ -890,8 +890,11 @@ void get_command() {
} }
bool code_has_value() { bool code_has_value() {
char c = strchr_pointer[1]; int i = 1;
return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.'; 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() { float code_value() {
@ -1744,14 +1747,15 @@ inline void gcode_G2_G3(bool clockwise) {
inline void gcode_G4() { inline void gcode_G4() {
millis_t codenum = 0; millis_t codenum = 0;
LCD_MESSAGEPGM(MSG_DWELL);
if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait
if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait
st_synchronize(); st_synchronize();
refresh_cmd_timeout(); refresh_cmd_timeout();
codenum += previous_cmd_ms; // keep track of when we started waiting codenum += previous_cmd_ms; // keep track of when we started waiting
if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
while (millis() < codenum) { while (millis() < codenum) {
manage_heater(); manage_heater();
manage_inactivity(); manage_inactivity();

View file

@ -273,22 +273,22 @@ static void lcd_status_screen() {
#endif #endif
#if PROGRESS_MSG_EXPIRE > 0 #if PROGRESS_MSG_EXPIRE > 0
// Handle message expire // Handle message expire
if (expireStatusMillis > 0) { if (expire_status_ms > 0) {
if (card.isFileOpen()) { if (card.isFileOpen()) {
// Expire the message when printing is active // Expire the message when printing is active
if (IS_SD_PRINTING) { if (IS_SD_PRINTING) {
// Expire the message when printing is active // Expire the message when printing is active
if (ms >= expireStatusMillis) { if (ms >= expire_status_ms) {
lcd_status_message[0] = '\0'; lcd_status_message[0] = '\0';
expireStatusMillis = 0; expire_status_ms = 0;
} }
} }
else { else {
expireStatusMillis += LCD_UPDATE_INTERVAL; expire_status_ms += LCD_UPDATE_INTERVAL;
} }
} }
else { else {
expireStatusMillis = 0; expire_status_ms = 0;
} }
} }
#endif #endif
@ -1394,7 +1394,7 @@ void lcd_finishstatus(bool persist=false) {
#ifdef LCD_PROGRESS_BAR #ifdef LCD_PROGRESS_BAR
progressBarTick = millis(); progressBarTick = millis();
#if PROGRESS_MSG_EXPIRE > 0 #if PROGRESS_MSG_EXPIRE > 0
expireStatusMillis = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE; expire_status_ms = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE;
#endif #endif
#endif #endif
lcdDrawUpdate = 2; lcdDrawUpdate = 2;
@ -1405,7 +1405,7 @@ void lcd_finishstatus(bool persist=false) {
} }
#if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0 #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
void dontExpireStatus() { expireStatusMillis = 0; } void dontExpireStatus() { expire_status_ms = 0; }
#endif #endif
void set_utf_strlen(char *s, uint8_t n) { 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; s[i] = 0;
} }
bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); }
void lcd_setstatus(const char* message, bool persist) { void lcd_setstatus(const char* message, bool persist) {
if (lcd_status_message_level > 0) return; if (lcd_status_message_level > 0) return;
strncpy(lcd_status_message, message, 3*LCD_WIDTH); strncpy(lcd_status_message, message, 3*LCD_WIDTH);

View file

@ -8,6 +8,7 @@
int lcd_strlen_P(const char *s); int lcd_strlen_P(const char *s);
void lcd_update(); void lcd_update();
void lcd_init(); void lcd_init();
bool lcd_hasstatus();
void lcd_setstatus(const char* message, const bool persist=false); void lcd_setstatus(const char* message, const bool persist=false);
void lcd_setstatuspgm(const char* message, const uint8_t level=0); void lcd_setstatuspgm(const char* message, const uint8_t level=0);
void lcd_setalertstatuspgm(const char* message); void lcd_setalertstatuspgm(const char* message);
@ -100,6 +101,7 @@
#else //no LCD #else //no LCD
FORCE_INLINE void lcd_update() {} FORCE_INLINE void lcd_update() {}
FORCE_INLINE void lcd_init() {} 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_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_setstatuspgm(const char* message, const uint8_t level=0) {}
FORCE_INLINE void lcd_buttons_update() {} FORCE_INLINE void lcd_buttons_update() {}
@ -107,8 +109,8 @@
FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {} FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
FORCE_INLINE bool lcd_detected(void) { return true; } FORCE_INLINE bool lcd_detected(void) { return true; }
#define LCD_MESSAGEPGM(x) #define LCD_MESSAGEPGM(x) do{}while(0)
#define LCD_ALERTMESSAGEPGM(x) #define LCD_ALERTMESSAGEPGM(x) do{}while(0)
#endif //ULTRA_LCD #endif //ULTRA_LCD

View file

@ -196,7 +196,7 @@
#ifdef LCD_PROGRESS_BAR #ifdef LCD_PROGRESS_BAR
static uint16_t progressBarTick = 0; static uint16_t progressBarTick = 0;
#if PROGRESS_MSG_EXPIRE > 0 #if PROGRESS_MSG_EXPIRE > 0
static uint16_t expireStatusMillis = 0; static uint16_t expire_status_ms = 0;
#endif #endif
#define LCD_STR_PROGRESS "\x03\x04\x05" #define LCD_STR_PROGRESS "\x03\x04\x05"
#endif #endif