Browse Source

Merge pull request #1155 from thinkyhead/lcd_wait_better

M0-M1 Enhancements
nothinman 10 years ago
parent
commit
5a8b3a84ae
3 changed files with 58 additions and 8 deletions
  1. 28
    7
      Marlin/Marlin_main.cpp
  2. 28
    1
      Marlin/ultralcd.cpp
  3. 2
    0
      Marlin/ultralcd.h

+ 28
- 7
Marlin/Marlin_main.cpp View File

1385
       st_synchronize();
1385
       st_synchronize();
1386
       codenum += millis();  // keep track of when we started waiting
1386
       codenum += millis();  // keep track of when we started waiting
1387
       previous_millis_cmd = millis();
1387
       previous_millis_cmd = millis();
1388
-      while(millis()  < codenum ){
1388
+      while(millis() < codenum) {
1389
         manage_heater();
1389
         manage_heater();
1390
         manage_inactivity();
1390
         manage_inactivity();
1391
         lcd_update();
1391
         lcd_update();
1413
       plan_bed_level_matrix.set_to_identity();  //Reset the plane ("erase" all leveling data)
1413
       plan_bed_level_matrix.set_to_identity();  //Reset the plane ("erase" all leveling data)
1414
 #endif //ENABLE_AUTO_BED_LEVELING
1414
 #endif //ENABLE_AUTO_BED_LEVELING
1415
 
1415
 
1416
-
1417
       saved_feedrate = feedrate;
1416
       saved_feedrate = feedrate;
1418
       saved_feedmultiply = feedmultiply;
1417
       saved_feedmultiply = feedmultiply;
1419
       feedmultiply = 100;
1418
       feedmultiply = 100;
1863
     case 0: // M0 - Unconditional stop - Wait for user button press on LCD
1862
     case 0: // M0 - Unconditional stop - Wait for user button press on LCD
1864
     case 1: // M1 - Conditional stop - Wait for user button press on LCD
1863
     case 1: // M1 - Conditional stop - Wait for user button press on LCD
1865
     {
1864
     {
1866
-      LCD_MESSAGEPGM(MSG_USERWAIT);
1865
+      char *src = strchr_pointer + 2;
1866
+
1867
       codenum = 0;
1867
       codenum = 0;
1868
-      if(code_seen('P')) codenum = code_value(); // milliseconds to wait
1869
-      if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
1870
 
1868
 
1869
+      bool hasP = false, hasS = false;
1870
+      if (code_seen('P')) {
1871
+        codenum = code_value(); // milliseconds to wait
1872
+        hasP = codenum > 0;
1873
+      }
1874
+      if (code_seen('S')) {
1875
+        codenum = code_value() * 1000; // seconds to wait
1876
+        hasS = codenum > 0;
1877
+      }
1878
+      if (!hasP && !hasS && *src != '\0') {
1879
+        starpos = strchr(src, '*');
1880
+        if (starpos != NULL) *(starpos) = '\0';
1881
+        while (*src == ' ') ++src;
1882
+        lcd_setstatus(src);
1883
+      } else {
1884
+        LCD_MESSAGEPGM(MSG_USERWAIT);
1885
+      }
1886
+
1887
+      lcd_ignore_click();
1871
       st_synchronize();
1888
       st_synchronize();
1872
       previous_millis_cmd = millis();
1889
       previous_millis_cmd = millis();
1873
       if (codenum > 0){
1890
       if (codenum > 0){
1874
         codenum += millis();  // keep track of when we started waiting
1891
         codenum += millis();  // keep track of when we started waiting
1875
-        while(millis()  < codenum && !lcd_clicked()){
1892
+        while(millis() < codenum && !lcd_clicked()){
1876
           manage_heater();
1893
           manage_heater();
1877
           manage_inactivity();
1894
           manage_inactivity();
1878
           lcd_update();
1895
           lcd_update();
1879
         }
1896
         }
1897
+        lcd_ignore_click(false);
1880
       }else{
1898
       }else{
1881
         while(!lcd_clicked()){
1899
         while(!lcd_clicked()){
1882
           manage_heater();
1900
           manage_heater();
1884
           lcd_update();
1902
           lcd_update();
1885
         }
1903
         }
1886
       }
1904
       }
1887
-      LCD_MESSAGEPGM(MSG_RESUMING);
1905
+      if (IS_SD_PRINTING)
1906
+        LCD_MESSAGEPGM(MSG_RESUMING);
1907
+      else
1908
+        LCD_MESSAGEPGM(WELCOME_MSG);
1888
     }
1909
     }
1889
     break;
1910
     break;
1890
 #endif
1911
 #endif

+ 28
- 1
Marlin/ultralcd.cpp View File

162
 menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
162
 menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
163
 uint32_t lcd_next_update_millis;
163
 uint32_t lcd_next_update_millis;
164
 uint8_t lcd_status_update_delay;
164
 uint8_t lcd_status_update_delay;
165
+bool ignore_click = false;
166
+bool wait_for_unclick;
165
 uint8_t lcdDrawUpdate = 2;                  /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) */
167
 uint8_t lcdDrawUpdate = 2;                  /* Set to none-zero when the LCD needs to draw, decreased after every draw. Set to 2 in LCD routines so the LCD gets at least 1 full redraw (first redraw is partial) */
166
 
168
 
167
 //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
169
 //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
189
         lcd_status_update_delay = 10;   /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
191
         lcd_status_update_delay = 10;   /* redraw the main screen every second. This is easier then trying keep track of all things that change on the screen */
190
     }
192
     }
191
 #ifdef ULTIPANEL
193
 #ifdef ULTIPANEL
192
-    if (LCD_CLICKED)
194
+
195
+    bool current_click = LCD_CLICKED;
196
+
197
+    if (ignore_click) {
198
+        if (wait_for_unclick) {
199
+          if (!current_click) {
200
+              ignore_click = wait_for_unclick = false;
201
+          }
202
+          else {
203
+              current_click = false;
204
+          }
205
+        }
206
+        else if (current_click) {
207
+            lcd_quick_feedback();
208
+            wait_for_unclick = true;
209
+            current_click = false;
210
+        }
211
+    }
212
+
213
+    if (current_click)
193
     {
214
     {
194
         currentMenu = lcd_main_menu;
215
         currentMenu = lcd_main_menu;
195
         encoderPosition = 0;
216
         encoderPosition = 0;
1315
     }
1336
     }
1316
 }
1337
 }
1317
 
1338
 
1339
+void lcd_ignore_click(bool b)
1340
+{
1341
+    ignore_click = b;
1342
+    wait_for_unclick = false;
1343
+}
1344
+
1318
 void lcd_setstatus(const char* message)
1345
 void lcd_setstatus(const char* message)
1319
 {
1346
 {
1320
     if (lcd_status_message_level > 0)
1347
     if (lcd_status_message_level > 0)

+ 2
- 0
Marlin/ultralcd.h View File

48
   void lcd_buzz(long duration,uint16_t freq);
48
   void lcd_buzz(long duration,uint16_t freq);
49
   bool lcd_clicked();
49
   bool lcd_clicked();
50
 
50
 
51
+  void lcd_ignore_click(bool b=true);
52
+
51
   #ifdef NEWPANEL
53
   #ifdef NEWPANEL
52
     #define EN_C (1<<BLEN_C)
54
     #define EN_C (1<<BLEN_C)
53
     #define EN_B (1<<BLEN_B)
55
     #define EN_B (1<<BLEN_B)

Loading…
Cancel
Save