Browse Source

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.
pull/1/head
Tobias Frost 5 years ago
committed by Scott Lahteine
parent
commit
60e82e3929
  1. 2
      Marlin/src/Marlin.cpp
  2. 2
      Marlin/src/Marlin.h
  3. 12
      Marlin/src/gcode/lcd/M0_M1.cpp
  4. 3
      Marlin/src/lcd/extensible_ui/lib/example.cpp
  5. 6
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  6. 4
      Marlin/src/lcd/extensible_ui/ui_api.h

2
Marlin/src/Marlin.cpp

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

2
Marlin/src/Marlin.h

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

12
Marlin/src/gcode/lcd/M0_M1.cpp

@ -31,6 +31,10 @@
#include "../../lcd/ultralcd.h"
#endif
#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extensible_ui/ui_api.h"
#endif
#include "../../sd/cardreader.h"
#if HAS_LEDS_OFF_FLAG
@ -74,6 +78,10 @@ void GcodeSuite::M0_M1() {
#endif
}
#elif ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired(has_message ? args : MSG_USERWAIT); // SRAM string
#else
if (has_message) {
@ -97,6 +105,10 @@ void GcodeSuite::M0_M1() {
else
while (wait_for_user) idle();
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired(nullptr);
#endif
#if HAS_LEDS_OFF_FLAG
printerEventLEDs.onResumeAfterWait();
#endif

3
Marlin/src/lcd/extensible_ui/lib/example.cpp

@ -46,7 +46,7 @@ namespace ExtUI {
*/
}
void onIdle() {}
void onPrinterKilled(const char* msg) {}
void onPrinterKilled(PGM_P const msg) {}
void onMediaInserted() {};
void onMediaError() {};
void onMediaRemoved() {};
@ -55,6 +55,7 @@ namespace ExtUI {
void onPrintTimerPaused() {}
void onPrintTimerStopped() {}
void onFilamentRunout() {}
void onUserConfirmRequired(const char * const msg) {}
void onStatusChanged(const char * const msg) {}
void onFactoryReset() {}
void onLoadSettings() {}

6
Marlin/src/lcd/extensible_ui/ui_api.cpp

@ -630,6 +630,12 @@ namespace ExtUI {
feedrate_percentage = clamp(value, 10, 500);
}
void setUserConfirmed(void) {
#if HAS_RESUME_CONTINUE
wait_for_user = false;
#endif
}
void printFile(const char *filename) {
IFSD(card.openAndPrintFile(filename), NOOP);
}

4
Marlin/src/lcd/extensible_ui/ui_api.h

@ -117,6 +117,7 @@ namespace ExtUI {
void setRetractAcceleration_mm_s2(const float);
void setTravelAcceleration_mm_s2(const float);
void setFeedrate_percent(const float);
void setUserConfirmed(void);
#if ENABLED(LIN_ADVANCE)
float getLinearAdvance_mm_mm_s(const extruder_t);
@ -239,11 +240,12 @@ namespace ExtUI {
void onMediaError();
void onMediaRemoved();
void onPlayTone(const uint16_t frequency, const uint16_t duration);
void onPrinterKilled(const char* msg);
void onPrinterKilled(PGM_P const msg);
void onPrintTimerStarted();
void onPrintTimerPaused();
void onPrintTimerStopped();
void onFilamentRunout(const extruder_t extruder);
void onUserConfirmRequired(const char * const msg);
void onStatusChanged(const char * const msg);
void onFactoryReset();
void onStoreSettings();

Loading…
Cancel
Save