From 236098dbca814c920b7653d0873f94b84399c3c5 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Fri, 10 Jun 2022 09:00:51 +0200 Subject: [PATCH] Make init MMU error screens send buttons (Idle mode) --- Firmware/mmu2.cpp | 5 ++++- Firmware/mmu2_error_converter.cpp | 2 ++ Firmware/mmu2_protocol_logic.cpp | 6 ++++-- Firmware/mmu2_reporting.cpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 1917383c8..0c0abc9e2 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -510,7 +510,7 @@ void MMU2::CheckUserInput(){ Button(btn); break; case RestartMMU: - Reset(CutThePower); + Reset(ResetPin); // we cannot do power cycle on the MK3 break; case StopPrint: // @@TODO not sure if we shall handle this high level operation at this spot @@ -576,14 +576,17 @@ StepStatus MMU2::LogicStep() { break; case CommandError: ReportError(logic.Error()); + CheckUserInput(); break; case CommunicationTimeout: state = xState::Connecting; ReportError(ErrorCode::MMU_NOT_RESPONDING); + CheckUserInput(); break; case ProtocolError: state = xState::Connecting; ReportError(ErrorCode::PROTOCOL_ERROR); + CheckUserInput(); break; case VersionMismatch: StopKeepPowered(); diff --git a/Firmware/mmu2_error_converter.cpp b/Firmware/mmu2_error_converter.cpp index f0d08912c..0ff906699 100644 --- a/Firmware/mmu2_error_converter.cpp +++ b/Firmware/mmu2_error_converter.cpp @@ -189,7 +189,9 @@ Buttons ButtonPressed(uint16_t ec) { } break; case ERR_MECHANICAL_SELECTOR_CANNOT_HOME: + case ERR_MECHANICAL_SELECTOR_CANNOT_MOVE: case ERR_MECHANICAL_IDLER_CANNOT_HOME: + case ERR_MECHANICAL_IDLER_CANNOT_MOVE: case ERR_MECHANICAL_PULLEY_CANNOT_MOVE: switch (buttonSelectedOperation) { // may be allow move selector right and left in the future diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index 12134d010..45fc741fc 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -271,8 +271,7 @@ StepStatus Idle::Step() { switch (state) { case State::Ready: // check timeout if (logic->Elapsed(heartBeatPeriod)) { - logic->SendMsg(RequestMsg(RequestMsgCodes::Query, 0)); - state = State::QuerySent; + SendQuery(); return Processing; } break; @@ -397,6 +396,9 @@ void ProtocolLogic::PlanGenericRequest(RequestMsg rq) { bool ProtocolLogic::ActivatePlannedRequest(){ if( plannedRq.code == RequestMsgCodes::Button ){ // only issue the button to the MMU and do not restart the state machines + // @@TODO - this is not completely correct, but it does the job. + // In Idle mode the command part is not active, but we still need button handling in Idle mode (resolve MMU init errors) + // -> command.SendButton is not correct, but it sends the message and everything works (for now) command.SendButton(plannedRq.value); plannedRq = RequestMsg(RequestMsgCodes::unknown, 0); return true; diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 0e5c12d67..38a14d108 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -191,7 +191,7 @@ enum class ReportErrorHookStates : uint8_t { DISMISS_ERROR_SCREEN = 2, }; -enum ReportErrorHookStates ReportErrorHookState; +enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN; /** * @brief Render MMU error screen on the LCD. This must be non-blocking