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
 }
890
 }
891
 
891
 
892
 bool code_has_value() {
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
 float code_value() {
900
 float code_value() {
1744
 inline void gcode_G4() {
1747
 inline void gcode_G4() {
1745
   millis_t codenum = 0;
1748
   millis_t codenum = 0;
1746
 
1749
 
1747
-  LCD_MESSAGEPGM(MSG_DWELL);
1748
-
1749
   if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait
1750
   if (code_seen('P')) codenum = code_value_long(); // milliseconds to wait
1750
   if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait
1751
   if (code_seen('S')) codenum = code_value_long() * 1000; // seconds to wait
1751
 
1752
 
1752
   st_synchronize();
1753
   st_synchronize();
1753
   refresh_cmd_timeout();
1754
   refresh_cmd_timeout();
1754
   codenum += previous_cmd_ms;  // keep track of when we started waiting
1755
   codenum += previous_cmd_ms;  // keep track of when we started waiting
1756
+
1757
+  if (!lcd_hasstatus()) LCD_MESSAGEPGM(MSG_DWELL);
1758
+
1755
   while (millis() < codenum) {
1759
   while (millis() < codenum) {
1756
     manage_heater();
1760
     manage_heater();
1757
     manage_inactivity();
1761
     manage_inactivity();

+ 9
- 7
Marlin/ultralcd.cpp View File

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

+ 4
- 2
Marlin/ultralcd.h View File

8
   int lcd_strlen_P(const char *s);
8
   int lcd_strlen_P(const char *s);
9
   void lcd_update();
9
   void lcd_update();
10
   void lcd_init();
10
   void lcd_init();
11
+  bool lcd_hasstatus();
11
   void lcd_setstatus(const char* message, const bool persist=false);
12
   void lcd_setstatus(const char* message, const bool persist=false);
12
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
13
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
13
   void lcd_setalertstatuspgm(const char* message);
14
   void lcd_setalertstatuspgm(const char* message);
100
 #else //no LCD
101
 #else //no LCD
101
   FORCE_INLINE void lcd_update() {}
102
   FORCE_INLINE void lcd_update() {}
102
   FORCE_INLINE void lcd_init() {}
103
   FORCE_INLINE void lcd_init() {}
104
+  FORCE_INLINE bool lcd_hasstatus() { return false; }
103
   FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {}
105
   FORCE_INLINE void lcd_setstatus(const char* message, const bool persist=false) {}
104
   FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {}
106
   FORCE_INLINE void lcd_setstatuspgm(const char* message, const uint8_t level=0) {}
105
   FORCE_INLINE void lcd_buttons_update() {}
107
   FORCE_INLINE void lcd_buttons_update() {}
107
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
109
   FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
108
   FORCE_INLINE bool lcd_detected(void) { return true; }
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
 #endif //ULTRA_LCD
115
 #endif //ULTRA_LCD
114
 
116
 

+ 1
- 1
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

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

Loading…
Cancel
Save