Sync MK3<->MK4 MMU2 reporting
This commit is contained in:
parent
5235fe2480
commit
075858c9fa
|
|
@ -196,7 +196,7 @@ void __attribute__((noinline)) MMU2::mmu_loop_inner(bool reportErrors) {
|
||||||
if (isErrorScreenRunning()) {
|
if (isErrorScreenRunning()) {
|
||||||
// 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((CommandInProgress)logic.CommandInProgress(), (uint16_t)lastErrorCode, uint8_t(lastErrorSource));
|
ReportErrorHook((CommandInProgress)logic.CommandInProgress(), lastErrorCode, uint8_t(lastErrorSource));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,10 +218,10 @@ struct ReportingRAII {
|
||||||
CommandInProgress cip;
|
CommandInProgress cip;
|
||||||
explicit inline __attribute__((always_inline)) ReportingRAII(CommandInProgress cip)
|
explicit inline __attribute__((always_inline)) ReportingRAII(CommandInProgress cip)
|
||||||
: cip(cip) {
|
: cip(cip) {
|
||||||
BeginReport(cip, (uint16_t)ProgressCode::EngagingIdler);
|
BeginReport(cip, ProgressCode::EngagingIdler);
|
||||||
}
|
}
|
||||||
inline __attribute__((always_inline)) ~ReportingRAII() {
|
inline __attribute__((always_inline)) ~ReportingRAII() {
|
||||||
EndReport(cip, (uint16_t)ProgressCode::OK);
|
EndReport(cip, ProgressCode::OK);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1001,7 +1001,7 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
|
||||||
// If retry attempts are all used up
|
// If retry attempts are all used up
|
||||||
// or if 'Retry' operation is not available
|
// or if 'Retry' operation is not available
|
||||||
// raise the MMU error sceen and wait for user input
|
// raise the MMU error sceen and wait for user input
|
||||||
ReportErrorHook((CommandInProgress)logic.CommandInProgress(), (uint16_t)ec, uint8_t(lastErrorSource));
|
ReportErrorHook((CommandInProgress)logic.CommandInProgress(), ec, uint8_t(lastErrorSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert(mmu2Magic[0] == 'M'
|
static_assert(mmu2Magic[0] == 'M'
|
||||||
|
|
@ -1014,8 +1014,8 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMU2::ReportProgress(ProgressCode pc) {
|
void MMU2::ReportProgress(ProgressCode pc) {
|
||||||
ReportProgressHook((CommandInProgress)logic.CommandInProgress(), (uint16_t)pc);
|
ReportProgressHook((CommandInProgress)logic.CommandInProgress(), pc);
|
||||||
LogEchoEvent_P(_O(ProgressCodeToText((uint16_t)pc)));
|
LogEchoEvent_P(_O(ProgressCodeToText(pc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMU2::OnMMUProgressMsg(ProgressCode pc) {
|
void MMU2::OnMMUProgressMsg(ProgressCode pc) {
|
||||||
|
|
|
||||||
|
|
@ -62,10 +62,10 @@ static const char * const progressTexts[] PROGMEM = {
|
||||||
_R(MSG_PROGRESS_FEED_FSENSOR)
|
_R(MSG_PROGRESS_FEED_FSENSOR)
|
||||||
};
|
};
|
||||||
|
|
||||||
const char * ProgressCodeToText(uint16_t pc){
|
const char * ProgressCodeToText(ProgressCode pc){
|
||||||
// @@TODO ?? a better fallback option?
|
// @@TODO ?? a better fallback option?
|
||||||
return ( pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])) )
|
return ( (uint16_t)pc <= (sizeof(progressTexts) / sizeof(progressTexts[0])) )
|
||||||
? static_cast<const char *>(pgm_read_ptr(&progressTexts[pc]))
|
? static_cast<const char *>(pgm_read_ptr(&progressTexts[(uint16_t)pc]))
|
||||||
: static_cast<const char *>(pgm_read_ptr(&progressTexts[0]));
|
: static_cast<const char *>(pgm_read_ptr(&progressTexts[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#ifdef __AVR__
|
||||||
|
#include "mmu2/progress_codes.h"
|
||||||
|
#else
|
||||||
|
#include "../../../../../../Prusa-Firmware-MMU/src/logic/progress_codes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace MMU2 {
|
namespace MMU2 {
|
||||||
|
|
||||||
const char *ProgressCodeToText(uint16_t pc);
|
const char *ProgressCodeToText(ProgressCode pc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include "mmu2_log.h"
|
#include "mmu2_log.h"
|
||||||
#include "mmu2_reporting.h"
|
#include "mmu2_reporting.h"
|
||||||
#include "mmu2_error_converter.h"
|
#include "mmu2_error_converter.h"
|
||||||
|
#include "mmu2_progress_converter.h"
|
||||||
#include "mmu2/error_codes.h"
|
#include "mmu2/error_codes.h"
|
||||||
#include "mmu2/buttons.h"
|
#include "mmu2/buttons.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
|
@ -14,14 +15,12 @@
|
||||||
|
|
||||||
namespace MMU2 {
|
namespace MMU2 {
|
||||||
|
|
||||||
const char * ProgressCodeToText(uint16_t pc); // we may join progress convertor and reporter together
|
void BeginReport(CommandInProgress /*cip*/, ProgressCode ec) {
|
||||||
|
|
||||||
void BeginReport(CommandInProgress /*cip*/, uint16_t ec) {
|
|
||||||
custom_message_type = CustomMsg::MMUProgress;
|
custom_message_type = CustomMsg::MMUProgress;
|
||||||
lcd_setstatuspgm( _T(ProgressCodeToText(ec)) );
|
lcd_setstatuspgm( _T(ProgressCodeToText(ec)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndReport(CommandInProgress /*cip*/, uint16_t /*ec*/) {
|
void EndReport(CommandInProgress /*cip*/, ProgressCode /*ec*/) {
|
||||||
// clear the status msg line - let the printed filename get visible again
|
// clear the status msg line - let the printed filename get visible again
|
||||||
if (!printJobOngoing()) {
|
if (!printJobOngoing()) {
|
||||||
lcd_setstatuspgm(MSG_WELCOME);
|
lcd_setstatuspgm(MSG_WELCOME);
|
||||||
|
|
@ -231,7 +230,7 @@ bool TuneMenuEntered() {
|
||||||
return putErrorScreenToSleep;
|
return putErrorScreenToSleep;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
void ReportErrorHook(CommandInProgress /*cip*/, ErrorCode ec, uint8_t /*es*/) {
|
||||||
if (putErrorScreenToSleep) return;
|
if (putErrorScreenToSleep) return;
|
||||||
|
|
||||||
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) {
|
if (mmu2.MMUCurrentErrorCode() == ErrorCode::OK && mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) {
|
||||||
|
|
@ -289,7 +288,7 @@ void ReportErrorHook(CommandInProgress /*cip*/, uint16_t ec, uint8_t /*es*/) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportProgressHook(CommandInProgress cip, uint16_t ec) {
|
void ReportProgressHook(CommandInProgress cip, ProgressCode ec) {
|
||||||
if (cip != CommandInProgress::NoCommand) {
|
if (cip != CommandInProgress::NoCommand) {
|
||||||
custom_message_type = CustomMsg::MMUProgress;
|
custom_message_type = CustomMsg::MMUProgress;
|
||||||
lcd_setstatuspgm( _T(ProgressCodeToText(ec)) );
|
lcd_setstatuspgm( _T(ProgressCodeToText(ec)) );
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,19 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#ifdef __AVR__
|
||||||
|
#include "mmu2/error_codes.h"
|
||||||
|
#include "mmu2/progress_codes.h"
|
||||||
|
#else
|
||||||
|
#include "../../../../../../Prusa-Firmware-MMU/src/logic/error_codes.h"
|
||||||
|
#include "../../../../../../Prusa-Firmware-MMU/src/logic/progress_codes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace MMU2 {
|
namespace MMU2 {
|
||||||
|
|
||||||
enum CommandInProgress : uint8_t {
|
enum CommandInProgress : uint8_t {
|
||||||
NoCommand = 0,
|
NoCommand = 0,
|
||||||
CutFilament = 'C',
|
CutFilament = 'K',
|
||||||
EjectFilament = 'E',
|
EjectFilament = 'E',
|
||||||
Homing = 'H',
|
Homing = 'H',
|
||||||
LoadFilament = 'L',
|
LoadFilament = 'L',
|
||||||
|
|
@ -17,10 +24,10 @@ enum CommandInProgress : uint8_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Called at the begin of every MMU operation
|
/// Called at the begin of every MMU operation
|
||||||
void BeginReport(CommandInProgress cip, uint16_t ec);
|
void BeginReport(CommandInProgress cip, ProgressCode ec);
|
||||||
|
|
||||||
/// Called at the end of every MMU operation
|
/// Called at the end of every MMU operation
|
||||||
void EndReport(CommandInProgress cip, uint16_t ec);
|
void EndReport(CommandInProgress cip, ProgressCode ec);
|
||||||
|
|
||||||
/// Return true if the printer's LCD is drawing the error screen
|
/// Return true if the printer's LCD is drawing the error screen
|
||||||
bool isErrorScreenRunning();
|
bool isErrorScreenRunning();
|
||||||
|
|
@ -35,10 +42,10 @@ bool TuneMenuEntered();
|
||||||
/// 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] es error source
|
/// @param[in] es error source
|
||||||
void ReportErrorHook(CommandInProgress cip, uint16_t ec, uint8_t es);
|
void ReportErrorHook(CommandInProgress cip, ErrorCode ec, uint8_t es);
|
||||||
|
|
||||||
/// 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, ProgressCode ec);
|
||||||
|
|
||||||
/// @brief Clear the status line and setup the LCD cursor
|
/// @brief Clear the status line and setup the LCD cursor
|
||||||
void TryLoadUnloadProgressbarInit();
|
void TryLoadUnloadProgressbarInit();
|
||||||
|
|
@ -96,4 +103,4 @@ void ScreenClear();
|
||||||
|
|
||||||
void tuneIdlerStallguardThreshold();
|
void tuneIdlerStallguardThreshold();
|
||||||
|
|
||||||
} // namespace
|
} // namespace MMU2
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue