Browse Source

Merge pull request #1966 from thinkyhead/g4_dwell_message

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

+ 8
- 4
Marlin/Marlin_main.cpp View File

@@ -890,8 +890,11 @@ void get_command() {
890 890
 }
891 891
 
892 892
 bool code_has_value() {
893
-  char c = strchr_pointer[1];
894
-  return (c >= '0' && c <= '9') || c == '-' || c == '+' || c == '.';
893
+  int i = 1;
894
+  char c = strchr_pointer[i];
895
+  if (c == '-' || c == '+') c = strchr_pointer[++i];
896
+  if (c == '.') c = strchr_pointer[++i];
897
+  return (c >= '0' && c <= '9');
895 898
 }
896 899
 
897 900
 float code_value() {
@@ -1744,14 +1747,15 @@ inline void gcode_G2_G3(bool clockwise) {
1744 1747
 inline void gcode_G4() {
1745 1748
   millis_t codenum = 0;
1746 1749
 
1747
-  LCD_MESSAGEPGM(MSG_DWELL);
1748
-
1749 1750
   if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait
1750 1751
   if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait
1751 1752
 
1752 1753
   st_synchronize();
1753 1754
   refresh_cmd_timeout();
1754 1755
   codenum += previous_cmd_ms;  // keep track of when we started waiting
1756
+
1757
+  if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
1758
+
1755 1759
   while (millis() < codenum) {
1756 1760
     manage_heater();
1757 1761
     manage_inactivity();

+ 9
- 7
Marlin/ultralcd.cpp View File

@@ -273,22 +273,22 @@ static void lcd_status_screen() {
273 273
     #endif
274 274
     #if PROGRESS_MSG_EXPIRE > 0
275 275
       // Handle message expire
276
-      if (expireStatusMillis > 0) {
276
+      if (expire_status_ms > 0) {
277 277
         if (card.isFileOpen()) {
278 278
           // Expire the message when printing is active
279 279
           if (IS_SD_PRINTING) {
280 280
             // Expire the message when printing is active
281
-            if (ms >= expireStatusMillis) {
281
+            if (ms >= expire_status_ms) {
282 282
               lcd_status_message[0] = '\0';
283
-              expireStatusMillis = 0;
283
+              expire_status_ms = 0;
284 284
             }
285 285
           }
286 286
           else {
287
-            expireStatusMillis += LCD_UPDATE_INTERVAL;
287
+            expire_status_ms += LCD_UPDATE_INTERVAL;
288 288
           }
289 289
         }
290 290
         else {
291
-          expireStatusMillis = 0;
291
+          expire_status_ms = 0;
292 292
         }
293 293
       }
294 294
     #endif
@@ -1394,7 +1394,7 @@ void lcd_finishstatus(bool persist=false) {
1394 1394
   #ifdef LCD_PROGRESS_BAR
1395 1395
     progressBarTick = millis();
1396 1396
     #if PROGRESS_MSG_EXPIRE > 0
1397
-      expireStatusMillis = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE;
1397
+      expire_status_ms = persist ? 0 : progressBarTick + PROGRESS_MSG_EXPIRE;
1398 1398
     #endif
1399 1399
   #endif
1400 1400
   lcdDrawUpdate = 2;
@@ -1405,7 +1405,7 @@ void lcd_finishstatus(bool persist=false) {
1405 1405
 }
1406 1406
 
1407 1407
 #if defined(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
1408
-  void dontExpireStatus() { expireStatusMillis = 0; }
1408
+  void dontExpireStatus() { expire_status_ms = 0; }
1409 1409
 #endif
1410 1410
 
1411 1411
 void set_utf_strlen(char *s, uint8_t n) {
@@ -1418,6 +1418,8 @@ void set_utf_strlen(char *s, uint8_t n) {
1418 1418
   s[i] = 0;
1419 1419
 }
1420 1420
 
1421
+bool lcd_hasstatus() { return (lcd_status_message[0] != '\0'); }
1422
+
1421 1423
 void lcd_setstatus(const char* message, bool persist) {
1422 1424
   if (lcd_status_message_level > 0) return;
1423 1425
   strncpy(lcd_status_message, message, 3*LCD_WIDTH);

+ 4
- 2
Marlin/ultralcd.h View File

@@ -8,6 +8,7 @@
8 8
   int lcd_strlen_P(const char *s);
9 9
   void lcd_update();
10 10
   void lcd_init();
11
+  bool lcd_hasstatus();
11 12
   void lcd_setstatus(const char* message, const bool persist=false);
12 13
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
13 14
   void lcd_setalertstatuspgm(const char* message);
@@ -100,6 +101,7 @@
100 101
 #else //no LCD
101 102
   FORCE_INLINE void lcd_update() {}
102 103
   FORCE_INLINE void lcd_init() {}
104
+  FORCE_INLINE bool lcd_hasstatus() { return false; }
103 105
   FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {}
104 106
   FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {}
105 107
   FORCE_INLINE void lcd_buttons_update() {}
@@ -107,8 +109,8 @@
107 109
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
108 110
   FORCE_INLINE bool lcd_detected(void) { return true; }
109 111
 
110
-  #define LCD_MESSAGEPGM(x) 
111
-  #define LCD_ALERTMESSAGEPGM(x) 
112
+  #define LCD_MESSAGEPGM(x) do{}while(0)
113
+  #define LCD_ALERTMESSAGEPGM(x) do{}while(0)
112 114
 
113 115
 #endif //ULTRA_LCD
114 116
 

+ 1
- 1
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

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

Loading…
Cancel
Save