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){
// 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;
@ -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
// we'd better report everything to make sure especially the error states
// do not get lost.
@ -824,13 +824,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'

View File

@ -70,9 +70,10 @@ public:
};
/// Source of operation error
enum ReportErrorSource: uint8_t {
enum ErrorSource: 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 ErrorSource 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, ErrorSource 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;
ErrorSource lastErrorSource = ErrorSource::ErrorSourceNone;
Buttons lastButton = Buttons::NoButton;
StepStatus logicStepLastStatus;

View File

@ -217,8 +217,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

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
* 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);