From d49e858cf740c28dd76a2401f4b68c65277851f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 4 Jun 2022 17:32:09 +0000 Subject: [PATCH] PFW-1323 Fix MMU error screen doesn't disappear when error resolved on the MMU --- Firmware/mmu2.h | 5 ++++- Firmware/mmu2_reporting.cpp | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index f4fa41772..1870c9933 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -119,7 +119,10 @@ public: /// @returns current state of FINDA (true=filament present, false=filament not present) inline bool FindaDetectsFilament()const { return logic.FindaPressed(); } - + + /// @returns Current error code + inline ErrorCode MMUCurrentErrorCode() const { return logic.Error(); } + /// @returns the version of the connected MMU FW. /// In the future we'll return the trully detected FW version Version GetMMUFWVersion()const { diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index 69bcc9b66..25d463e14 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -190,8 +190,9 @@ static uint8_t ReportErrorHookMonitor(uint16_t ec) { } enum class ReportErrorHookStates : uint8_t { - RENDER_ERROR_SCREEN = 0, - MONITOR_SELECTION = 1, + RENDER_ERROR_SCREEN = 0, + MONITOR_SELECTION = 1, + DISMISS_ERROR_SCREEN = 2, }; enum ReportErrorHookStates ReportErrorHookState; @@ -202,6 +203,14 @@ enum ReportErrorHookStates ReportErrorHookState; * @param[in] ec Error code */ void ReportErrorHook(uint16_t ec) { + if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK) + { + // If the error code suddenly changes to OK, that means + // a button was pushed on the MMU and the LCD should + // dismiss the error screen until MMU raises a new error + ReportErrorHookState = ReportErrorHookStates::DISMISS_ERROR_SCREEN; + } + switch ((uint8_t)ReportErrorHookState) { case (uint8_t)ReportErrorHookStates::RENDER_ERROR_SCREEN: @@ -234,6 +243,14 @@ void ReportErrorHook(uint16_t ec) { } return; // Always return to loop() to let MMU trigger a call to ReportErrorHook again break; + case (uint8_t)ReportErrorHookStates::DISMISS_ERROR_SCREEN: + lcd_set_custom_characters(); + lcd_update_enable(true); + lcd_return_to_status(); + // Reset the state in case a new error is reported + mmu2.is_mmu_error_monitor_active = false; + ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN; + break; default: break; }