Quellcode durchsuchen

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 vor 5 Jahren
Ursprung
Commit
60e82e3929

+ 1
- 1
Marlin/src/Marlin.cpp Datei anzeigen

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

+ 1
- 1
Marlin/src/Marlin.h Datei anzeigen

333
 extern volatile bool wait_for_heatup;
333
 extern volatile bool wait_for_heatup;
334
 
334
 
335
 #if HAS_RESUME_CONTINUE
335
 #if HAS_RESUME_CONTINUE
336
-  extern volatile bool wait_for_user;
336
+  extern bool wait_for_user;
337
 #endif
337
 #endif
338
 
338
 
339
 #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
339
 #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)

+ 12
- 0
Marlin/src/gcode/lcd/M0_M1.cpp Datei anzeigen

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

+ 2
- 1
Marlin/src/lcd/extensible_ui/lib/example.cpp Datei anzeigen

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

+ 6
- 0
Marlin/src/lcd/extensible_ui/ui_api.cpp Datei anzeigen

630
     feedrate_percentage = clamp(value, 10, 500);
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
   void printFile(const char *filename) {
639
   void printFile(const char *filename) {
634
     IFSD(card.openAndPrintFile(filename), NOOP);
640
     IFSD(card.openAndPrintFile(filename), NOOP);
635
   }
641
   }

+ 3
- 1
Marlin/src/lcd/extensible_ui/ui_api.h Datei anzeigen

117
   void setRetractAcceleration_mm_s2(const float);
117
   void setRetractAcceleration_mm_s2(const float);
118
   void setTravelAcceleration_mm_s2(const float);
118
   void setTravelAcceleration_mm_s2(const float);
119
   void setFeedrate_percent(const float);
119
   void setFeedrate_percent(const float);
120
+  void setUserConfirmed(void);
120
 
121
 
121
   #if ENABLED(LIN_ADVANCE)
122
   #if ENABLED(LIN_ADVANCE)
122
     float getLinearAdvance_mm_mm_s(const extruder_t);
123
     float getLinearAdvance_mm_mm_s(const extruder_t);
239
   void onMediaError();
240
   void onMediaError();
240
   void onMediaRemoved();
241
   void onMediaRemoved();
241
   void onPlayTone(const uint16_t frequency, const uint16_t duration);
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
   void onPrintTimerStarted();
244
   void onPrintTimerStarted();
244
   void onPrintTimerPaused();
245
   void onPrintTimerPaused();
245
   void onPrintTimerStopped();
246
   void onPrintTimerStopped();
246
   void onFilamentRunout(const extruder_t extruder);
247
   void onFilamentRunout(const extruder_t extruder);
248
+  void onUserConfirmRequired(const char * const msg);
247
   void onStatusChanged(const char * const msg);
249
   void onStatusChanged(const char * const msg);
248
   void onFactoryReset();
250
   void onFactoryReset();
249
   void onStoreSettings();
251
   void onStoreSettings();

Laden…
Abbrechen
Speichern