Merge pull request #3646 from gudnimg/fix-mmu-buttons-v2

PFW-1403 Fix issue where physical MMU buttons do not dismiss error screen
This commit is contained in:
3d-gussner 2022-10-11 13:42:39 +02:00 committed by GitHub
commit d5ca47d1a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 10 deletions

View File

@ -216,7 +216,7 @@ void MMU2::mmu_loop() {
if (is_mmu_error_monitor_active){ if (is_mmu_error_monitor_active){
// Call this every iteration to keep the knob rotation responsive // Call this every iteration to keep the knob rotation responsive
// This includes when mmu_loop is called within manage_response // 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; avoidRecursion = false;
@ -798,7 +798,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, ErrorSource res) {
// Due to a potential lossy error reporting layers linked to this hook // Due to a potential lossy error reporting layers linked to this hook
// we'd better report everything to make sure especially the error states // we'd better report everything to make sure especially the error states
// do not get lost. // do not get lost.
@ -824,13 +824,14 @@ void MMU2::ReportError(ErrorCode ec, uint8_t res) {
break; break;
} }
ReportErrorHook((uint16_t)ec, res);
if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log
lastErrorCode = ec; lastErrorCode = ec;
lastErrorSource = res;
LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) ); LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) );
} }
ReportErrorHook((uint16_t)ec);
static_assert(mmu2Magic[0] == 'M' static_assert(mmu2Magic[0] == 'M'
&& mmu2Magic[1] == 'M' && mmu2Magic[1] == 'M'
&& mmu2Magic[2] == 'U' && mmu2Magic[2] == 'U'

View File

@ -70,9 +70,10 @@ public:
}; };
/// Source of operation error /// Source of operation error
enum ReportErrorSource: uint8_t { enum ErrorSource: uint8_t {
ErrorSourcePrinter = 0, ErrorSourcePrinter = 0,
ErrorSourceMMU = 1, ErrorSourceMMU = 1,
ErrorSourceNone = 0xFF,
}; };
/// Perform a reset of the MMU /// Perform a reset of the MMU
@ -164,6 +165,9 @@ public:
/// @returns Current error code /// @returns Current error code
inline ErrorCode MMUCurrentErrorCode() const { return logic.Error(); } inline ErrorCode MMUCurrentErrorCode() const { return logic.Error(); }
/// @returns Last error source
inline ErrorSource MMULastErrorSource() const { return lastErrorSource; }
/// @returns the version of the connected MMU FW. /// @returns the version of the connected MMU FW.
/// In the future we'll return the trully detected FW version /// In the future we'll return the trully detected FW version
Version GetMMUFWVersion()const { Version GetMMUFWVersion()const {
@ -218,7 +222,7 @@ private:
/// Reports an error into attached ExtUIs /// Reports an error into attached ExtUIs
/// @param ec error code, see ErrorCode /// @param ec error code, see ErrorCode
/// @param res reporter error source, is either Printer (0) or MMU (1) /// @param res reporter error source, is either Printer (0) or MMU (1)
void ReportError(ErrorCode ec, uint8_t res); void ReportError(ErrorCode ec, ErrorSource res);
/// Reports progress of operations into attached ExtUIs /// Reports progress of operations into attached ExtUIs
/// @param pc progress code, see ProgressCode /// @param pc progress code, see ProgressCode
@ -264,6 +268,7 @@ private:
ProgressCode lastProgressCode = ProgressCode::OK; ProgressCode lastProgressCode = ProgressCode::OK;
ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING; ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING;
ErrorSource lastErrorSource = ErrorSource::ErrorSourceNone;
Buttons lastButton = Buttons::NoButton; Buttons lastButton = Buttons::NoButton;
StepStatus logicStepLastStatus; StepStatus logicStepLastStatus;

View File

@ -217,8 +217,8 @@ enum class ReportErrorHookStates : uint8_t {
enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN; enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
void ReportErrorHook(uint16_t ec, uint8_t res) { void ReportErrorHook(uint16_t ec) {
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && res == MMU2::ErrorSourceMMU) if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU)
{ {
// If the error code suddenly changes to OK, that means // If the error code suddenly changes to OK, that means
// a button was pushed on the MMU and the LCD should // a button was pushed on the MMU and the LCD should

View File

@ -27,9 +27,8 @@ void EndReport(CommandInProgress cip, uint16_t ec);
* Render MMU error screen on the LCD. This must be non-blocking * Render MMU error screen on the LCD. This must be non-blocking
* and allow the MMU and printer to communicate with each other. * and allow the MMU and printer to communicate with each other.
* @param[in] ec error code * @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 /// Called when the MMU sends operation progress update
void ReportProgressHook(CommandInProgress cip, uint16_t ec); void ReportProgressHook(CommandInProgress cip, uint16_t ec);