4 #include "mmu2_state.h"
8 #include "mmu2_protocol_logic.h"
9 typedef float feedRate_t;
12 #include "protocol_logic.h"
22 FILAMENT_UNKNOWN = 0xffU
26 uint8_t major, minor, build;
45 inline xState State()
const {
return state; }
67 ErrorSourcePrinter = 0,
69 ErrorSourceNone = 0xFF,
78 void Reset(ResetForm level);
89 bool ReadRegister(uint8_t address);
105 bool tool_change(uint8_t slot);
108 bool tool_change(
char code, uint8_t slot);
117 bool load_filament(uint8_t slot);
121 bool load_filament_to_nozzle(uint8_t slot);
125 bool eject_filament(uint8_t slot,
bool enableFullScreenMsg =
true);
130 bool cut_filament(uint8_t slot,
bool enableFullScreenMsg =
true);
133 void get_statistics();
141 bool loading_test(uint8_t slot);
149 bool set_filament_type(uint8_t slot, uint8_t type);
153 void Button(uint8_t index);
156 void Home(uint8_t mode);
161 inline uint16_t TotalFailStatistics()
const {
return logic.FailStatistics(); }
179 return { logic.MmuFwVersionMajor(), logic.MmuFwVersionMinor(), logic.MmuFwVersionRevision() };
191 bool RetryIfPossible(ErrorCode ec);
199 inline uint16_t TMCFailures()
const {
return tmcFailures; }
200 inline void IncrementTMCFailures() { ++tmcFailures; }
201 inline void ClearTMCFailures() { tmcFailures = 0; }
206 return lastReadRegisterValue;
208 inline void InvokeErrorScreen(ErrorCode ec) {
210 if (!logic.CommandInProgress()
211 && MMUCurrentErrorCode() == ErrorCode::OK
212 && lastErrorCode != ec)
214 ReportError(ec, ErrorSource::ErrorSourcePrinter);
218 void ClearPrinterError() {
219 logic.ClearPrinterError();
220 lastErrorCode = ErrorCode::OK;
221 lastErrorSource = ErrorSource::ErrorSourceNone;
227 printerButtonOperation = btn;
233 return printerButtonOperation;
236 inline void ClearPrinterButtonOperation() {
237 printerButtonOperation = Buttons::NoButton;
250 void TriggerResetPin();
257 void StopKeepPowered();
262 [[nodiscard]]
bool manage_response(
const bool move_axes,
const bool turn_off_nozzle);
267 void mmu_loop_inner(
bool reportErrors);
275 void filament_ramming();
276 void execute_extruder_sequence(
const E_Step *sequence, uint8_t steps);
277 void execute_load_to_nozzle_sequence();
282 void ReportError(ErrorCode ec, ErrorSource res);
286 void ReportProgress(ProgressCode pc);
295 void OnMMUProgressMsg(ProgressCode pc);
297 void OnMMUProgressMsgChanged(ProgressCode pc);
299 void OnMMUProgressMsgSame(ProgressCode pc);
303 void SaveHotendTemp(
bool turn_off_nozzle);
306 void SaveAndPark(
bool move_axes);
309 void ResumeHotendTemp();
315 void CheckUserInput();
320 void CheckFINDARunout();
326 bool WaitForMMUReady();
333 bool VerifyFilamentEnteredPTFE();
336 void ToolChangeCommon(uint8_t slot);
337 bool ToolChangeCommonOnce(uint8_t slot);
339 void HelpUnloadToFinda();
341 void CutFilamentInner(uint8_t slot);
343 void SetCurrentTool(uint8_t ex);
347 uint8_t tool_change_extruder;
349 pos3d resume_position;
350 int16_t resume_hotend_temp;
352 ProgressCode lastProgressCode = ProgressCode::OK;
353 ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING;
354 ErrorSource lastErrorSource = ErrorSource::ErrorSourceNone;
355 Buttons lastButton = Buttons::NoButton;
356 uint16_t lastReadRegisterValue = 0;
357 Buttons printerButtonOperation = Buttons::NoButton;
363 uint8_t mmu_print_saved;
364 bool loadFilamentStarted;
365 bool unloadFilamentStarted;
367 uint16_t toolchange_counter;
368 uint16_t tmcFailures;
ResetForm
Different levels of resetting the MMU.
Definition: mmu2.h:50
void SetPrinterButtonOperation(Buttons btn)
Queue a button operation which the printer can act upon.
Definition: mmu2.h:226
ErrorSource
Source of operation error.
Definition: mmu2.h:66
uint16_t ToolChangeCounter() const
Definition: mmu2.h:194
bool WriteRegister(uint8_t address, uint16_t data)
ErrorSource MMULastErrorSource() const
Definition: mmu2.h:170
bool FindaDetectsFilament() const
Definition: mmu2.h:159
ErrorCode GetLastErrorCode() const
Definition: mmu2.h:173
void ClearToolChangeCounter()
Set toolchange counter to zero.
Definition: mmu2.h:197
SavedState
Saved print state on error.
Definition: mmu2.h:58
uint16_t GetLastReadRegisterValue() const
Definition: mmu2.h:205
uint8_t GetCommandInProgress() const
Definition: mmu2.h:167
uint8_t get_tool_change_tool() const
bool MMU_PRINT_SAVED() const
Method to read-only mmu_print_saved.
Definition: mmu2.h:186
Buttons GetPrinterButtonOperation()
Get the printer button operation.
Definition: mmu2.h:232
Version GetMMUFWVersion() const
Definition: mmu2.h:177
uint8_t get_current_tool() const
ErrorCode MMUCurrentErrorCode() const
Definition: mmu2.h:164
New MMU2 protocol logic.
Definition: mmu2.cpp:26
xState
Definition: mmu2_state.h:15
@ Active
MMU has been detected, connected, communicates and is ready to be worked with.
MMU2 mmu2
Definition: mmu2.cpp:41
StepStatus
ProtocolLogic stepping statuses.
Definition: mmu2_protocol_logic.h:53