Browse Source

Fix issue where error screen updates too slowly in manage_response

Guðni Már Gilbert 2 years ago
parent
commit
7b91e73c8b
4 changed files with 17 additions and 6 deletions
  1. 10 2
      Firmware/mmu2.cpp
  2. 3 0
      Firmware/mmu2.h
  3. 3 3
      Firmware/mmu2_reporting.cpp
  4. 1 1
      Firmware/mmu2_reporting.h

+ 10 - 2
Firmware/mmu2.cpp

@@ -91,6 +91,7 @@ MMU2::MMU2()
     , mmu_print_saved(false)
     , loadFilamentStarted(false)
     , loadingToNozzle(false)
+    , is_mmu_error_monitor_active(false)
 {
 }
 
@@ -166,7 +167,14 @@ void MMU2::mmu_loop() {
     avoidRecursion = true;
 
     logicStepLastStatus = LogicStep(); // it looks like the mmu_loop doesn't need to be a blocking call
-    
+
+    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);
+    }
+
     avoidRecursion = false;
 }
 
@@ -607,7 +615,7 @@ void MMU2::ReportError(ErrorCode ec) {
     // - report only changes of states (we can miss an error message)
     // - may be some combination of MMUAvailable + UseMMU flags and decide based on their state
     // Right now the filtering of MMU_NOT_RESPONDING is done in ReportErrorHook() as it is not a problem if mmu2.cpp
-    ReportErrorHook((CommandInProgress)logic.CommandInProgress(), (uint16_t)ec);
+    ReportErrorHook((uint16_t)ec);
 
     if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log
         lastErrorCode = ec;

+ 3 - 0
Firmware/mmu2.h

@@ -130,6 +130,9 @@ public:
         }
     }
 
+    // Helper variable to monitor knob in MMU error screen in blocking functions e.g. manage_response
+    bool is_mmu_error_monitor_active;
+
     /// Method to read-only mmu_print_saved
     bool MMU_PRINT_SAVED() const { return mmu_print_saved; }
 

+ 3 - 3
Firmware/mmu2_reporting.cpp

@@ -199,11 +199,9 @@ enum ReportErrorHookStates ReportErrorHookState;
 /**
  * @brief 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] cip Command in progress
  * @param[in] ec Error code
  */
-void ReportErrorHook(CommandInProgress cip, uint16_t ec) {
-    
+void ReportErrorHook(uint16_t ec) {
     switch ((uint8_t)ReportErrorHookState)
     {
     case (uint8_t)ReportErrorHookStates::RENDER_ERROR_SCREEN:
@@ -211,6 +209,7 @@ void ReportErrorHook(CommandInProgress cip, uint16_t ec) {
         ReportErrorHookState = ReportErrorHookStates::MONITOR_SELECTION;
         // Fall through
     case (uint8_t)ReportErrorHookStates::MONITOR_SELECTION:
+        mmu2.is_mmu_error_monitor_active = true;
         ReportErrorHookDynamicRender(); // Render dynamic characters
         switch (ReportErrorHookMonitor(ec))
         {
@@ -227,6 +226,7 @@ void ReportErrorHook(CommandInProgress cip, uint16_t ec) {
                 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:

+ 1 - 1
Firmware/mmu2_reporting.h

@@ -23,7 +23,7 @@ void BeginReport(CommandInProgress cip, uint16_t ec);
 void EndReport(CommandInProgress cip, uint16_t ec);
 
 /// Called when the MMU sends operation error (even repeatedly)
-void ReportErrorHook(CommandInProgress cip, uint16_t ec);
+void ReportErrorHook(uint16_t ec);
 
 /// Called when the MMU sends operation progress update
 void ReportProgressHook(CommandInProgress cip, uint16_t ec);