Skip to content

Commit d5ca47d

Browse files
authored
Merge pull request prusa3d#3646 from gudnimg/fix-mmu-buttons-v2
PFW-1403 Fix issue where physical MMU buttons do not dismiss error screen
2 parents 8882d8f + d6e0f47 commit d5ca47d

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

Firmware/mmu2.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void MMU2::mmu_loop() {
216216
if (is_mmu_error_monitor_active){
217217
// Call this every iteration to keep the knob rotation responsive
218218
// This includes when mmu_loop is called within manage_response
219-
ReportErrorHook((uint16_t)lastErrorCode, mmu2.MMUCurrentErrorCode() == ErrorCode::OK ? ErrorSourcePrinter : ErrorSourceMMU);
219+
ReportErrorHook((uint16_t)lastErrorCode);
220220
}
221221

222222
avoidRecursion = false;
@@ -798,7 +798,7 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) {
798798
}
799799
}
800800

801-
void MMU2::ReportError(ErrorCode ec, uint8_t res) {
801+
void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
802802
// Due to a potential lossy error reporting layers linked to this hook
803803
// we'd better report everything to make sure especially the error states
804804
// do not get lost.
@@ -824,13 +824,14 @@ void MMU2::ReportError(ErrorCode ec, uint8_t res) {
824824
break;
825825
}
826826

827-
ReportErrorHook((uint16_t)ec, res);
828-
829827
if( ec != lastErrorCode ){ // deduplicate: only report changes in error codes into the log
830828
lastErrorCode = ec;
829+
lastErrorSource = res;
831830
LogErrorEvent_P( _O(PrusaErrorTitle(PrusaErrorCodeIndex((uint16_t)ec))) );
832831
}
833832

833+
ReportErrorHook((uint16_t)ec);
834+
834835
static_assert(mmu2Magic[0] == 'M'
835836
&& mmu2Magic[1] == 'M'
836837
&& mmu2Magic[2] == 'U'

Firmware/mmu2.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ class MMU2 {
7070
};
7171

7272
/// Source of operation error
73-
enum ReportErrorSource: uint8_t {
73+
enum ErrorSource: uint8_t {
7474
ErrorSourcePrinter = 0,
7575
ErrorSourceMMU = 1,
76+
ErrorSourceNone = 0xFF,
7677
};
7778

7879
/// Perform a reset of the MMU
@@ -164,6 +165,9 @@ class MMU2 {
164165
/// @returns Current error code
165166
inline ErrorCode MMUCurrentErrorCode() const { return logic.Error(); }
166167

168+
/// @returns Last error source
169+
inline ErrorSource MMULastErrorSource() const { return lastErrorSource; }
170+
167171
/// @returns the version of the connected MMU FW.
168172
/// In the future we'll return the trully detected FW version
169173
Version GetMMUFWVersion()const {
@@ -218,7 +222,7 @@ class MMU2 {
218222
/// Reports an error into attached ExtUIs
219223
/// @param ec error code, see ErrorCode
220224
/// @param res reporter error source, is either Printer (0) or MMU (1)
221-
void ReportError(ErrorCode ec, uint8_t res);
225+
void ReportError(ErrorCode ec, ErrorSource res);
222226

223227
/// Reports progress of operations into attached ExtUIs
224228
/// @param pc progress code, see ProgressCode
@@ -264,6 +268,7 @@ class MMU2 {
264268

265269
ProgressCode lastProgressCode = ProgressCode::OK;
266270
ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING;
271+
ErrorSource lastErrorSource = ErrorSource::ErrorSourceNone;
267272
Buttons lastButton = Buttons::NoButton;
268273

269274
StepStatus logicStepLastStatus;

Firmware/mmu2_reporting.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ enum class ReportErrorHookStates : uint8_t {
217217

218218
enum ReportErrorHookStates ReportErrorHookState = ReportErrorHookStates::RENDER_ERROR_SCREEN;
219219

220-
void ReportErrorHook(uint16_t ec, uint8_t res) {
221-
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && res == MMU2::ErrorSourceMMU)
220+
void ReportErrorHook(uint16_t ec) {
221+
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU)
222222
{
223223
// If the error code suddenly changes to OK, that means
224224
// a button was pushed on the MMU and the LCD should

Firmware/mmu2_reporting.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ void EndReport(CommandInProgress cip, uint16_t ec);
2727
* Render MMU error screen on the LCD. This must be non-blocking
2828
* and allow the MMU and printer to communicate with each other.
2929
* @param[in] ec error code
30-
* @param[in] res reporter error source, is either Printer (0) or MMU (1)
3130
*/
32-
void ReportErrorHook(uint16_t ec, uint8_t res);
31+
void ReportErrorHook(uint16_t ec);
3332

3433
/// Called when the MMU sends operation progress update
3534
void ReportProgressHook(CommandInProgress cip, uint16_t ec);

0 commit comments

Comments
 (0)