Преглед на файлове

Send notifications to ExtUI for M0/M1 (#13344)

- Send notifications to ExtUI for M0/M1

- wait_for_user can be non-volatile (not changed by interrupt)
  C / C++ compilers don't optimize away reads of non-volatile variables when a function call is used between accesses, because *any* variable could be changed by the function call. Since `wait_for_user` can't be changed without a function call, it should be non-volatile so the compiler can optimize away cases where it is read more than once without an intervening function call.
Tobias Frost преди 5 години
родител
ревизия
60e82e3929

+ 1
- 1
Marlin/src/Marlin.cpp Целия файл

@@ -183,7 +183,7 @@ volatile bool wait_for_heatup = true;
183 183
 
184 184
 // For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
185 185
 #if HAS_RESUME_CONTINUE
186
-  volatile bool wait_for_user; // = false;
186
+  bool wait_for_user; // = false;
187 187
 #endif
188 188
 
189 189
 #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)

+ 1
- 1
Marlin/src/Marlin.h Целия файл

@@ -333,7 +333,7 @@ inline bool IsStopped() { return !Running; }
333 333
 extern volatile bool wait_for_heatup;
334 334
 
335 335
 #if HAS_RESUME_CONTINUE
336
-  extern volatile bool wait_for_user;
336
+  extern bool wait_for_user;
337 337
 #endif
338 338
 
339 339
 #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)

+ 12
- 0
Marlin/src/gcode/lcd/M0_M1.cpp Целия файл

@@ -31,6 +31,10 @@
31 31
   #include "../../lcd/ultralcd.h"
32 32
 #endif
33 33
 
34
+#if ENABLED(EXTENSIBLE_UI)
35
+  #include "../../lcd/extensible_ui/ui_api.h"
36
+#endif
37
+
34 38
 #include "../../sd/cardreader.h"
35 39
 
36 40
 #if HAS_LEDS_OFF_FLAG
@@ -74,6 +78,10 @@ void GcodeSuite::M0_M1() {
74 78
       #endif
75 79
     }
76 80
 
81
+  #elif ENABLED(EXTENSIBLE_UI)
82
+
83
+    ExtUI::onUserConfirmRequired(has_message ? args : MSG_USERWAIT); // SRAM string
84
+
77 85
   #else
78 86
 
79 87
     if (has_message) {
@@ -97,6 +105,10 @@ void GcodeSuite::M0_M1() {
97 105
   else
98 106
     while (wait_for_user) idle();
99 107
 
108
+  #if ENABLED(EXTENSIBLE_UI)
109
+    ExtUI::onUserConfirmRequired(nullptr);
110
+  #endif
111
+
100 112
   #if HAS_LEDS_OFF_FLAG
101 113
     printerEventLEDs.onResumeAfterWait();
102 114
   #endif

+ 2
- 1
Marlin/src/lcd/extensible_ui/lib/example.cpp Целия файл

@@ -46,7 +46,7 @@ namespace ExtUI {
46 46
      */
47 47
   }
48 48
   void onIdle() {}
49
-  void onPrinterKilled(const char* msg) {}
49
+  void onPrinterKilled(PGM_P const msg) {}
50 50
   void onMediaInserted() {};
51 51
   void onMediaError() {};
52 52
   void onMediaRemoved() {};
@@ -55,6 +55,7 @@ namespace ExtUI {
55 55
   void onPrintTimerPaused() {}
56 56
   void onPrintTimerStopped() {}
57 57
   void onFilamentRunout() {}
58
+  void onUserConfirmRequired(const char * const msg) {}
58 59
   void onStatusChanged(const char * const msg) {}
59 60
   void onFactoryReset() {}
60 61
   void onLoadSettings() {}

+ 6
- 0
Marlin/src/lcd/extensible_ui/ui_api.cpp Целия файл

@@ -630,6 +630,12 @@ namespace ExtUI {
630 630
     feedrate_percentage = clamp(value, 10, 500);
631 631
   }
632 632
 
633
+  void setUserConfirmed(void) {
634
+    #if HAS_RESUME_CONTINUE
635
+      wait_for_user = false;
636
+    #endif
637
+  }
638
+
633 639
   void printFile(const char *filename) {
634 640
     IFSD(card.openAndPrintFile(filename), NOOP);
635 641
   }

+ 3
- 1
Marlin/src/lcd/extensible_ui/ui_api.h Целия файл

@@ -117,6 +117,7 @@ namespace ExtUI {
117 117
   void setRetractAcceleration_mm_s2(const float);
118 118
   void setTravelAcceleration_mm_s2(const float);
119 119
   void setFeedrate_percent(const float);
120
+  void setUserConfirmed(void);
120 121
 
121 122
   #if ENABLED(LIN_ADVANCE)
122 123
     float getLinearAdvance_mm_mm_s(const extruder_t);
@@ -239,11 +240,12 @@ namespace ExtUI {
239 240
   void onMediaError();
240 241
   void onMediaRemoved();
241 242
   void onPlayTone(const uint16_t frequency, const uint16_t duration);
242
-  void onPrinterKilled(const char* msg);
243
+  void onPrinterKilled(PGM_P const msg);
243 244
   void onPrintTimerStarted();
244 245
   void onPrintTimerPaused();
245 246
   void onPrintTimerStopped();
246 247
   void onFilamentRunout(const extruder_t extruder);
248
+  void onUserConfirmRequired(const char * const msg);
247 249
   void onStatusChanged(const char * const msg);
248 250
   void onFactoryReset();
249 251
   void onStoreSettings();

Loading…
Отказ
Запис