Browse Source

M0-M1 Enhancements

Allow M0 and M1 to include a message string. Ignore clicks on “Wait for
user” so that the Info Screen stays up.
Scott Lahteine 10 years ago
parent
commit
cd769781a1
3 changed files with 49 additions and 5 deletions
  1. 19
    3
      Marlin/Marlin_main.cpp
  2. 28
    2
      Marlin/ultralcd.cpp
  3. 2
    0
      Marlin/ultralcd.h

+ 19
- 3
Marlin/Marlin_main.cpp View File

1841
     case 0: // M0 - Unconditional stop - Wait for user button press on LCD
1841
     case 0: // M0 - Unconditional stop - Wait for user button press on LCD
1842
     case 1: // M1 - Conditional stop - Wait for user button press on LCD
1842
     case 1: // M1 - Conditional stop - Wait for user button press on LCD
1843
     {
1843
     {
1844
-      LCD_MESSAGEPGM(MSG_USERWAIT);
1844
+      char *src = strchr_pointer + 2;
1845
+
1845
       codenum = 0;
1846
       codenum = 0;
1846
-      if(code_seen('P')) codenum = code_value(); // milliseconds to wait
1847
-      if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
1848
 
1847
 
1848
+      bool hasP = code_seen('P');
1849
+      if (hasP) codenum = code_value(); // milliseconds to wait
1850
+
1851
+      bool hasS = code_seen('S');
1852
+      if (hasS) codenum = code_value() * 1000; // seconds to wait
1853
+
1854
+      if (!hasP && !hasS && *src != '\0') {
1855
+        while (*src == ' ') ++src;
1856
+        starpos = strchr(src, '*');
1857
+        if (starpos != NULL) *(starpos) = '\0';
1858
+        lcd_setstatus(src);
1859
+      } else {
1860
+        LCD_MESSAGEPGM(MSG_USERWAIT);
1861
+      }
1862
+
1863
+      lcd_ignore_click();
1849
       st_synchronize();
1864
       st_synchronize();
1850
       previous_millis_cmd = millis();
1865
       previous_millis_cmd = millis();
1851
       if (codenum > 0){
1866
       if (codenum > 0){
1855
           manage_inactivity();
1870
           manage_inactivity();
1856
           lcd_update();
1871
           lcd_update();
1857
         }
1872
         }
1873
+        lcd_ignore_click(false);
1858
       }else{
1874
       }else{
1859
         while(!lcd_clicked()){
1875
         while(!lcd_clicked()){
1860
           manage_heater();
1876
           manage_heater();

+ 28
- 2
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;
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) */
166
 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
 
167
 
167
 //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
168
 //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 */
190
         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
     }
191
     }
191
 #ifdef ULTIPANEL
192
 #ifdef ULTIPANEL
192
-    if (LCD_CLICKED)
193
+
194
+    if (lcd_clicked())
193
     {
195
     {
194
         currentMenu = lcd_main_menu;
196
         currentMenu = lcd_main_menu;
195
         encoderPosition = 0;
197
         encoderPosition = 0;
1289
     }
1291
     }
1290
 }
1292
 }
1291
 
1293
 
1294
+void lcd_ignore_click(bool b)
1295
+{
1296
+    ignore_click = b;
1297
+}
1298
+
1292
 void lcd_setstatus(const char* message)
1299
 void lcd_setstatus(const char* message)
1293
 {
1300
 {
1294
     if (lcd_status_message_level > 0)
1301
     if (lcd_status_message_level > 0)
1418
 
1425
 
1419
 bool lcd_clicked()
1426
 bool lcd_clicked()
1420
 {
1427
 {
1421
-  return LCD_CLICKED;
1428
+  static bool wait_for_unclick = false;
1429
+  bool current_click = LCD_CLICKED;
1430
+
1431
+  if (ignore_click) {
1432
+    if (wait_for_unclick) {
1433
+      if (!current_click) {
1434
+        ignore_click = wait_for_unclick = false;
1435
+      }
1436
+      else {
1437
+        current_click = false;
1438
+      }
1439
+    }
1440
+    else if (current_click) {
1441
+      wait_for_unclick = true;
1442
+      current_click = false;
1443
+      lcd_quick_feedback();
1444
+    }
1445
+  }
1446
+
1447
+  return current_click;
1422
 }
1448
 }
1423
 #endif//ULTIPANEL
1449
 #endif//ULTIPANEL
1424
 
1450
 

+ 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