From 7bc7f21fa52ad54d6faf44438bc2fecc1399a369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 29 Oct 2022 13:17:45 +0000 Subject: [PATCH] mmu: move RetryIfPossible outside the error screen This fixes issue where 'retryAttempts=3' may be spammed in the logs Change in memory: Flash: 0 bytes SRAM: 0 bytes --- Firmware/mmu2.cpp | 7 ++++++- Firmware/mmu2.h | 2 ++ Firmware/mmu2_reporting.cpp | 7 ------- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 714c833b7..a084a8839 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -839,7 +839,12 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) { LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) ); } - ReportErrorHook((uint16_t)ec); + if( !mmu2.RetryIfPossible((uint16_t)ec) ) { + // If retry attempts are all used up + // or if 'Retry' operation is not available + // raise the MMU error sceen and wait for user input + ReportErrorHook((uint16_t)ec); + } static_assert(mmu2Magic[0] == 'M' && mmu2Magic[1] == 'M' diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 6dfced7f4..d791a6b87 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -185,6 +185,8 @@ public: bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; } /// Automagically "press" a Retry button if we have any retry attempts left + /// @param ec ErrorCode enum value + /// @returns true if auto-retry is ongoing, false when retry is unavailable or retry attempts are all used up bool RetryIfPossible(uint16_t ec); /// Decrement the retry attempts, if in a retry. diff --git a/Firmware/mmu2_reporting.cpp b/Firmware/mmu2_reporting.cpp index df32fab21..c40497863 100644 --- a/Firmware/mmu2_reporting.cpp +++ b/Firmware/mmu2_reporting.cpp @@ -224,13 +224,6 @@ void ReportErrorHook(uint16_t ec) { // 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; - } else { - // attempt an automatic Retry button - if( ReportErrorHookState == ReportErrorHookStates::MONITOR_SELECTION ){ - if( mmu2.RetryIfPossible(ec) ){ - ReportErrorHookState = ReportErrorHookStates::DISMISS_ERROR_SCREEN; - } - } } const uint8_t ei = PrusaErrorCodeIndex(ec);