From 33690b927ae59563215caf345b4bdb30bff19068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 2 Oct 2022 08:49:00 +0000 Subject: [PATCH] PFW-1403 Fix issue where physical MMU buttons do not dismiss error screen --- Firmware/mmu2.cpp | 9 +++++---- Firmware/mmu2.h | 7 ++++++- Firmware/mmu2_reporting.cpp | 4 ++-- Firmware/mmu2_reporting.h | 3 +-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 365ac4b71..c3a735a00 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -216,7 +216,7 @@ void MMU2::mmu_loop() { if (is_mmu_error_monitor_active){ // Call this every iteration to keep the knob rotation responsive // This includes when mmu_loop is called within manage_response - ReportErrorHook((uint16_t)lastErrorCode, mmu2.MMUCurrentErrorCode() == ErrorCode::OK ? ErrorSourcePrinter : ErrorSourceMMU); + ReportErrorHook((uint16_t)lastErrorCode); } avoidRecursion = false; @@ -795,7 +795,7 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { } } -void MMU2::ReportError(ErrorCode ec, uint8_t res) { +void MMU2::ReportError(ErrorCode ec, ReportErrorSource res) { // Due to a potential lossy error reporting layers linked to this hook // we'd better report everything to make sure especially the error states // do not get lost. @@ -821,13 +821,14 @@ void MMU2::ReportError(ErrorCode ec, uint8_t res) { break; } - ReportErrorHook((uint16_t)ec, res); - if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log lastErrorCode = ec; + lastErrorSource = res; LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) ); } + ReportErrorHook((uint16_t)ec); + static_assert(mmu2Magic[0] == 'M' && mmu2Magic[1] == 'M' && mmu2Magic[2] == 'U' diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 08fde19c0..bad1d49e9 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -73,6 +73,7 @@ public: enum ReportErrorSource: uint8_t { ErrorSourcePrinter = 0, ErrorSourceMMU = 1, + ErrorSourceNone = 0xFF, }; /// Perform a reset of the MMU @@ -164,6 +165,9 @@ public: /// @returns Current error code inline ErrorCode MMUCurrentErrorCode() const { return logic.Error(); } + /// @returns Last error source + inline ReportErrorSource MMULastErrorSource() const { return lastErrorSource; } + /// @returns the version of the connected MMU FW. /// In the future we'll return the trully detected FW version Version GetMMUFWVersion()const { @@ -218,7 +222,7 @@ private: /// Reports an error into attached ExtUIs /// @param ec error code, see ErrorCode /// @param res reporter error source, is either Printer (0) or MMU (1) - void ReportError(ErrorCode ec, uint8_t res); + void ReportError(ErrorCode ec, ReportErrorSource res); /// Reports progress of operations into attached ExtUIs /// @param pc progress code, see ProgressCode @@ -264,6 +268,7 @@ private: ProgressCode lastProgressCode = ProgressCode::OK; ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING; + ReportErrorSource lastErrorSource = ReportErrorSource::ErrorSourceNone; Buttons lastButton = Buttons::NoButton; StepStatus logicStepLastStatus; diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index d63bb681e..e04522261 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -216,8 +216,8 @@ enum class ReportErrorHookStates : uint8_t { enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN; -void ReportErrorHook(uint16_t ec, uint8_t res) { - if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && res == MMU2::ErrorSourceMMU) +void ReportErrorHook(uint16_t ec) { + if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) { // If the error code suddenly changes to OK, that means // a button was pushed on the MMU and the LCD should diff --git a/Firmware/mmu2_reporting.h b/Firmware/mmu2_reporting.h index 7e9fa587f..e361bd3f2 100644 --- a/Firmware/mmu2_reporting.h +++ b/Firmware/mmu2_reporting.h @@ -27,9 +27,8 @@ void EndReport(CommandInProgress cip, uint16_t ec); * Render MMU error screen on the LCD. This must be non-blocking * and allow the MMU and printer to communicate with each other. * @param[in] ec error code - * @param[in] res reporter error source, is either Printer (0) or MMU (1) */ -void ReportErrorHook(uint16_t ec, uint8_t res); +void ReportErrorHook(uint16_t ec); /// Called when the MMU sends operation progress update void ReportProgressHook(CommandInProgress cip, uint16_t ec);