Browse Source

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
Guðni Már Gilbert 2 years ago
parent
commit
7bc7f21fa5
3 changed files with 8 additions and 8 deletions
  1. 6 1
      Firmware/mmu2.cpp
  2. 2 0
      Firmware/mmu2.h
  3. 0 7
      Firmware/mmu2_reporting.cpp

+ 6 - 1
Firmware/mmu2.cpp

@@ -839,7 +839,12 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
         LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) );
         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' 
     static_assert(mmu2Magic[0] == 'M' 
         && mmu2Magic[1] == 'M' 
         && mmu2Magic[1] == 'M' 

+ 2 - 0
Firmware/mmu2.h

@@ -185,6 +185,8 @@ public:
     bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; }
     bool MMU_PRINT_SAVED() const { return mmu_print_saved != SavedState::None; }
 
 
     /// Automagically "press" a Retry button if we have any retry attempts left
     /// 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);
     bool RetryIfPossible(uint16_t ec);
 
 
     /// Decrement the retry attempts, if in a retry. 
     /// Decrement the retry attempts, if in a retry. 

+ 0 - 7
Firmware/mmu2_reporting.cpp

@@ -224,13 +224,6 @@ void ReportErrorHook(uint16_t ec) {
         // a button was pushed on the MMU and the LCD should
         // a button was pushed on the MMU and the LCD should
         // dismiss the error screen until MMU raises a new error
         // dismiss the error screen until MMU raises a new error
         ReportErrorHookState = ReportErrorHookStates::DISMISS_ERROR_SCREEN;
         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);
     const uint8_t ei = PrusaErrorCodeIndex(ec);