Merge pull request #1966 from thinkyhead/g4_dwell_message

G4 shows status message only if no message is set already
master
Scott Lahteine 10 years ago
commit b275946a52

@ -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();

@ -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);

@ -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

@ -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

Loading…
Cancel
Save