Button handling WIP
This commit is contained in:
parent
9a20c85a5d
commit
f9bedc3c94
|
|
@ -502,12 +502,13 @@ void MMU2::ResumeHotendTemp() {
|
|||
MMU2_ECHO_MSG("Restoring hotend temperature ");
|
||||
SERIAL_ECHOLN(resume_hotend_temp);
|
||||
setTargetHotend(resume_hotend_temp, active_extruder);
|
||||
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming temperature...")); // better report the event and let the GUI do its work somewhere else
|
||||
lcd_display_message_fullscreen_P(_i("MMU Retry: Restoring temperature...")); // better report the event and let the GUI do its work somewhere else
|
||||
ReportErrorHookSensorLineRender();
|
||||
waitForHotendTargetTemp(1000, []{
|
||||
ReportErrorHookDynamicRender();
|
||||
});
|
||||
LogEchoEvent("Hotend temperature reached");
|
||||
lcd_clear();
|
||||
lcd_update_enable(true); // temporary hack to stop this locking the printer...
|
||||
}
|
||||
}
|
||||
|
|
@ -532,6 +533,13 @@ void MMU2::ResumeUnpark()
|
|||
|
||||
void MMU2::CheckUserInput(){
|
||||
auto btn = ButtonPressed((uint16_t)lastErrorCode);
|
||||
|
||||
// Was a button pressed on the MMU itself instead of the LCD?
|
||||
if (btn == Buttons::NoButton && lastButton != Buttons::NoButton)
|
||||
{
|
||||
btn = lastButton;
|
||||
lastButton = Buttons::NoButton; // Clear it.
|
||||
}
|
||||
switch (btn) {
|
||||
case Left:
|
||||
case Middle:
|
||||
|
|
@ -629,6 +637,10 @@ StepStatus MMU2::LogicStep() {
|
|||
StopKeepPowered();
|
||||
ReportError(ErrorCode::VERSION_MISMATCH);
|
||||
CheckUserInput();
|
||||
case ButtonPushed:
|
||||
lastButton = logic.Button();
|
||||
LogEchoEvent("MMU Button pushed");
|
||||
CheckUserInput();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -225,6 +225,7 @@ private:
|
|||
|
||||
ProgressCode lastProgressCode = ProgressCode::OK;
|
||||
ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING;
|
||||
Buttons lastButton = Buttons::NoButton;
|
||||
|
||||
StepStatus logicStepLastStatus;
|
||||
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
|||
case 'F':
|
||||
case 'A':
|
||||
case 'R':
|
||||
case 'B':
|
||||
rspState = ResponseStates::ParamValue;
|
||||
responseMsg.paramCode = (ResponseMsgParamCodes)c;
|
||||
responseMsg.paramValue = 0;
|
||||
|
|
|
|||
|
|
@ -234,6 +234,11 @@ StepStatus Command::Step() {
|
|||
// - the MMU checks FINDA and fsensor even while recovering from errors
|
||||
SendAndUpdateFilamentSensor();
|
||||
return CommandError;
|
||||
case ResponseMsgParamCodes::Button:
|
||||
// The user pushed a button on the MMU. Save it, do what we need to do
|
||||
// to prepare, then pass it back to the MMU so it can work its magic.
|
||||
logic->buttonCode = static_cast<Buttons>(logic->rsp.paramValue);
|
||||
return ButtonPushed;
|
||||
case ResponseMsgParamCodes::Finished:
|
||||
logic->progressCode = ProgressCode::OK;
|
||||
state = State::Ready;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ public:
|
|||
|
||||
#include "mmu2/error_codes.h"
|
||||
#include "mmu2/progress_codes.h"
|
||||
#include "mmu2/buttons.h"
|
||||
#include "mmu2_protocol.h"
|
||||
|
||||
#include "mmu2_serial.h"
|
||||
|
|
@ -38,6 +39,7 @@ enum StepStatus : uint_fast8_t {
|
|||
CommandError, ///< the command in progress stopped due to unrecoverable error, user interaction required
|
||||
VersionMismatch, ///< the MMU reports its firmware version incompatible with our implementation
|
||||
CommunicationRecovered,
|
||||
ButtonPushed, ///< The MMU reported the user pushed one of its three buttons.
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -221,6 +223,9 @@ public:
|
|||
/// @returns the current/latest process code as reported by the MMU
|
||||
ProgressCode Progress() const { return progressCode; }
|
||||
|
||||
/// @returns the current/latest button code as reported by the MMU
|
||||
Buttons Button() const { return buttonCode; }
|
||||
|
||||
uint8_t CommandInProgress()const;
|
||||
|
||||
inline bool Running()const {
|
||||
|
|
@ -297,6 +302,7 @@ private:
|
|||
|
||||
ErrorCode errorCode; ///< last received error code from the MMU
|
||||
ProgressCode progressCode; ///< last received progress code from the MMU
|
||||
Buttons buttonCode; ///< Last received button from the MMU.
|
||||
|
||||
uint8_t lastFSensor; ///< last state of filament sensor
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue