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
92e21d3ee2
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

1863
     case 0: // M0 - Unconditional stop - Wait for user button press on LCD
1863
     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
1864
     case 1: // M1 - Conditional stop - Wait for user button press on LCD
1865
     {
1865
     {
1866
-      LCD_MESSAGEPGM(MSG_USERWAIT);
1866
+      char *src = strchr_pointer + 2;
1867
+
1867
       codenum = 0;
1868
       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
 
1869
 
1870
+      bool hasP = code_seen('P');
1871
+      if (hasP) codenum = code_value(); // milliseconds to wait
1872
+
1873
+      bool hasS = code_seen('S');
1874
+      if (hasS) codenum = code_value() * 1000; // seconds to wait
1875
+
1876
+      if (!hasP && !hasS && *src != '\0') {
1877
+        while (*src == ' ') ++src;
1878
+        starpos = strchr(src, '*');
1879
+        if (starpos != NULL) *(starpos) = '\0';
1880
+        lcd_setstatus(src);
1881
+      } else {
1882
+        LCD_MESSAGEPGM(MSG_USERWAIT);
1883
+      }
1884
+
1885
+      lcd_ignore_click();
1871
       st_synchronize();
1886
       st_synchronize();
1872
       previous_millis_cmd = millis();
1887
       previous_millis_cmd = millis();
1873
       if (codenum > 0){
1888
       if (codenum > 0){
1877
           manage_inactivity();
1892
           manage_inactivity();
1878
           lcd_update();
1893
           lcd_update();
1879
         }
1894
         }
1895
+        lcd_ignore_click(false);
1880
       }else{
1896
       }else{
1881
         while(!lcd_clicked()){
1897
         while(!lcd_clicked()){
1882
           manage_heater();
1898
           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;
1315
     }
1317
     }
1316
 }
1318
 }
1317
 
1319
 
1320
+void lcd_ignore_click(bool b)
1321
+{
1322
+    ignore_click = b;
1323
+}
1324
+
1318
 void lcd_setstatus(const char* message)
1325
 void lcd_setstatus(const char* message)
1319
 {
1326
 {
1320
     if (lcd_status_message_level > 0)
1327
     if (lcd_status_message_level > 0)
1444
 
1451
 
1445
 bool lcd_clicked()
1452
 bool lcd_clicked()
1446
 {
1453
 {
1447
-  return LCD_CLICKED;
1454
+  static bool wait_for_unclick = false;
1455
+  bool current_click = LCD_CLICKED;
1456
+
1457
+  if (ignore_click) {
1458
+    if (wait_for_unclick) {
1459
+      if (!current_click) {
1460
+        ignore_click = wait_for_unclick = false;
1461
+      }
1462
+      else {
1463
+        current_click = false;
1464
+      }
1465
+    }
1466
+    else if (current_click) {
1467
+      wait_for_unclick = true;
1468
+      current_click = false;
1469
+      lcd_quick_feedback();
1470
+    }
1471
+  }
1472
+
1473
+  return current_click;
1448
 }
1474
 }
1449
 #endif//ULTIPANEL
1475
 #endif//ULTIPANEL
1450
 
1476
 

+ 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