Bläddra i källkod

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 år sedan
förälder
incheckning
cd769781a1
3 ändrade filer med 49 tillägg och 5 borttagningar
  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 Visa fil

@@ -1841,11 +1841,26 @@ void process_commands()
1841 1841
     case 0: // M0 - Unconditional stop - Wait for user button press on LCD
1842 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 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 1864
       st_synchronize();
1850 1865
       previous_millis_cmd = millis();
1851 1866
       if (codenum > 0){
@@ -1855,6 +1870,7 @@ void process_commands()
1855 1870
           manage_inactivity();
1856 1871
           lcd_update();
1857 1872
         }
1873
+        lcd_ignore_click(false);
1858 1874
       }else{
1859 1875
         while(!lcd_clicked()){
1860 1876
           manage_heater();

+ 28
- 2
Marlin/ultralcd.cpp Visa fil

@@ -162,6 +162,7 @@ bool lcd_oldcardstatus;
162 162
 menuFunc_t currentMenu = lcd_status_screen; /* function pointer to the currently active menu */
163 163
 uint32_t lcd_next_update_millis;
164 164
 uint8_t lcd_status_update_delay;
165
+bool ignore_click = false;
165 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 168
 //prevMenu and prevEncoderPosition are used to store the previous menu location when editing settings.
@@ -189,7 +190,8 @@ static void lcd_status_screen()
189 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 192
 #ifdef ULTIPANEL
192
-    if (LCD_CLICKED)
193
+
194
+    if (lcd_clicked())
193 195
     {
194 196
         currentMenu = lcd_main_menu;
195 197
         encoderPosition = 0;
@@ -1289,6 +1291,11 @@ void lcd_update()
1289 1291
     }
1290 1292
 }
1291 1293
 
1294
+void lcd_ignore_click(bool b)
1295
+{
1296
+    ignore_click = b;
1297
+}
1298
+
1292 1299
 void lcd_setstatus(const char* message)
1293 1300
 {
1294 1301
     if (lcd_status_message_level > 0)
@@ -1418,7 +1425,26 @@ void lcd_buzz(long duration, uint16_t freq)
1418 1425
 
1419 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 1449
 #endif//ULTIPANEL
1424 1450
 

+ 2
- 0
Marlin/ultralcd.h Visa fil

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

Laddar…
Avbryt
Spara