Limit scope of is_mmu_error_monitor_active
Move the variable to mmu2_reporting Change in memory: Flash: -6 bytes SRAM: 0 bytes
This commit is contained in:
parent
1f9fc4ef3f
commit
02676fc888
|
|
@ -38,8 +38,7 @@ void WaitForHotendTargetTempBeep() {
|
||||||
MMU2 mmu2;
|
MMU2 mmu2;
|
||||||
|
|
||||||
MMU2::MMU2()
|
MMU2::MMU2()
|
||||||
: is_mmu_error_monitor_active(false)
|
: logic(&mmu2Serial, MMU2_TOOL_CHANGE_LOAD_LENGTH, MMU2_LOAD_TO_NOZZLE_FEED_RATE)
|
||||||
, logic(&mmu2Serial, MMU2_TOOL_CHANGE_LOAD_LENGTH, MMU2_LOAD_TO_NOZZLE_FEED_RATE)
|
|
||||||
, extruder(MMU2_NO_TOOL)
|
, extruder(MMU2_NO_TOOL)
|
||||||
, tool_change_extruder(MMU2_NO_TOOL)
|
, tool_change_extruder(MMU2_NO_TOOL)
|
||||||
, resume_position()
|
, resume_position()
|
||||||
|
|
@ -171,7 +170,7 @@ void MMU2::mmu_loop() {
|
||||||
void __attribute__((noinline)) MMU2::mmu_loop_inner(bool reportErrors) {
|
void __attribute__((noinline)) MMU2::mmu_loop_inner(bool reportErrors) {
|
||||||
logicStepLastStatus = LogicStep(reportErrors); // it looks like the mmu_loop doesn't need to be a blocking call
|
logicStepLastStatus = LogicStep(reportErrors); // it looks like the mmu_loop doesn't need to be a blocking call
|
||||||
|
|
||||||
if (is_mmu_error_monitor_active) {
|
if (isErrorScreenRunning()) {
|
||||||
// Call this every iteration to keep the knob rotation responsive
|
// Call this every iteration to keep the knob rotation responsive
|
||||||
// This includes when mmu_loop is called within manage_response
|
// This includes when mmu_loop is called within manage_response
|
||||||
ReportErrorHook((CommandInProgress)logic.CommandInProgress(), (uint16_t)lastErrorCode, uint8_t(lastErrorSource));
|
ReportErrorHook((CommandInProgress)logic.CommandInProgress(), (uint16_t)lastErrorCode, uint8_t(lastErrorSource));
|
||||||
|
|
|
||||||
|
|
@ -172,9 +172,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper variable to monitor knob in MMU error screen in blocking functions e.g. manage_response
|
|
||||||
bool is_mmu_error_monitor_active;
|
|
||||||
|
|
||||||
/// Method to read-only mmu_print_saved
|
/// Method to read-only mmu_print_saved
|
||||||
inline bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; }
|
inline bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,13 @@ enum class ReportErrorHookStates : uint8_t {
|
||||||
|
|
||||||
enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
||||||
|
|
||||||
|
// Helper variable to monitor knob in MMU error screen in blocking functions e.g. manage_response
|
||||||
|
static bool is_mmu_error_monitor_active;
|
||||||
|
|
||||||
|
bool isErrorScreenRunning() {
|
||||||
|
return is_mmu_error_monitor_active;
|
||||||
|
}
|
||||||
|
|
||||||
void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
||||||
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) {
|
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) {
|
||||||
// If the error code suddenly changes to OK, that means
|
// If the error code suddenly changes to OK, that means
|
||||||
|
|
@ -228,7 +235,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
||||||
ReportErrorHookState = ReportErrorHookStates::MONITOR_SELECTION;
|
ReportErrorHookState = ReportErrorHookStates::MONITOR_SELECTION;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case (uint8_t)ReportErrorHookStates::MONITOR_SELECTION:
|
case (uint8_t)ReportErrorHookStates::MONITOR_SELECTION:
|
||||||
mmu2.is_mmu_error_monitor_active = true;
|
is_mmu_error_monitor_active = true;
|
||||||
ReportErrorHookDynamicRender(); // Render dynamic characters
|
ReportErrorHookDynamicRender(); // Render dynamic characters
|
||||||
sound_wait_for_user();
|
sound_wait_for_user();
|
||||||
switch (ReportErrorHookMonitor(ei)) {
|
switch (ReportErrorHookMonitor(ei)) {
|
||||||
|
|
@ -246,7 +253,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
sound_wait_for_user_reset();
|
sound_wait_for_user_reset();
|
||||||
// Reset the state in case a new error is reported
|
// Reset the state in case a new error is reported
|
||||||
mmu2.is_mmu_error_monitor_active = false;
|
is_mmu_error_monitor_active = false;
|
||||||
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -260,7 +267,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
||||||
lcd_return_to_status();
|
lcd_return_to_status();
|
||||||
sound_wait_for_user_reset();
|
sound_wait_for_user_reset();
|
||||||
// Reset the state in case a new error is reported
|
// Reset the state in case a new error is reported
|
||||||
mmu2.is_mmu_error_monitor_active = false;
|
is_mmu_error_monitor_active = false;
|
||||||
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ void BeginReport(CommandInProgress cip, uint16_t ec);
|
||||||
/// Called at the end of every MMU operation
|
/// Called at the end of every MMU operation
|
||||||
void EndReport(CommandInProgress cip, uint16_t ec);
|
void EndReport(CommandInProgress cip, uint16_t ec);
|
||||||
|
|
||||||
|
/// Return true if the printer's LCD is drawing the error screen
|
||||||
|
bool isErrorScreenRunning();
|
||||||
|
|
||||||
/// @brief Called when the MMU or MK3S sends operation error (even repeatedly).
|
/// @brief Called when the MMU or MK3S sends operation error (even repeatedly).
|
||||||
/// Render MMU error screen on the LCD. This must be non-blocking
|
/// Render MMU error screen on the LCD. This must be non-blocking
|
||||||
/// and allow the MMU and printer to communicate with each other.
|
/// and allow the MMU and printer to communicate with each other.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue