Prusa3d Marlin fork
Public Types | Public Member Functions | List of all members
MMU2::MMU2 Class Reference

#include <mmu2.h>

Public Types

enum  ResetForm : uint8_t { Software = 0 , ResetPin = 1 , CutThePower = 2 , EraseEEPROM = 42 }
 Different levels of resetting the MMU. More...
 
enum  SavedState : uint8_t { None = 0 , ParkExtruder = 1 , Cooldown = 2 , CooldownPending = 4 }
 Saved print state on error.
 
enum  ErrorSource : uint8_t { ErrorSourcePrinter = 0 , ErrorSourceMMU = 1 , ErrorSourceNone = 0xFF }
 Source of operation error.
 

Public Member Functions

void Start ()
 Powers ON the MMU, then initializes the UART and protocol logic.
 
void Stop ()
 Stops the protocol logic, closes the UART, powers OFF the MMU.
 
void Status ()
 Serial output of MMU state.
 
xState State () const
 
bool Enabled () const
 
void Tune ()
 
void Reset (ResetForm level)
 
void PowerOff ()
 Power off the MMU (cut the power)
 
void PowerOn ()
 Power on the MMU.
 
bool ReadRegister (uint8_t address)
 
bool WriteRegister (uint8_t address, uint16_t data)
 
void mmu_loop ()
 
bool tool_change (uint8_t slot)
 
bool tool_change (char code, uint8_t slot)
 Handling of special Tx, Tc, T? commands. More...
 
bool unload ()
 
bool load_filament (uint8_t slot)
 
bool load_filament_to_nozzle (uint8_t slot)
 
bool eject_filament (uint8_t slot, bool enableFullScreenMsg=true)
 
bool cut_filament (uint8_t slot, bool enableFullScreenMsg=true)
 
void get_statistics ()
 Issue a planned request for statistics data from MMU.
 
bool loading_test (uint8_t slot)
 
uint8_t get_current_tool () const
 
uint8_t get_tool_change_tool () const
 
bool set_filament_type (uint8_t slot, uint8_t type)
 
void Button (uint8_t index)
 
void Home (uint8_t mode)
 Issue an explicit "homing" command into the MMU.
 
bool FindaDetectsFilament () const
 
uint16_t TotalFailStatistics () const
 
ErrorCode MMUCurrentErrorCode () const
 
uint8_t GetCommandInProgress () const
 
ErrorSource MMULastErrorSource () const
 
ErrorCode GetLastErrorCode () const
 
Version GetMMUFWVersion () const
 
bool MMU_PRINT_SAVED () const
 Method to read-only mmu_print_saved.
 
bool RetryIfPossible (ErrorCode ec)
 
uint16_t ToolChangeCounter () const
 
void ClearToolChangeCounter ()
 Set toolchange counter to zero.
 
uint16_t TMCFailures () const
 
void IncrementTMCFailures ()
 
void ClearTMCFailures ()
 
uint16_t GetLastReadRegisterValue () const
 
void InvokeErrorScreen (ErrorCode ec)
 
void ClearPrinterError ()
 
void SetPrinterButtonOperation (Buttons btn)
 Queue a button operation which the printer can act upon. More...
 
Buttons GetPrinterButtonOperation ()
 Get the printer button operation. More...
 
void ClearPrinterButtonOperation ()
 

Detailed Description

Top-level interface between Logic and Marlin. Intentionally named MMU2 to be (almost) a drop-in replacement for the previous implementation. Most of the public methods share the original naming convention as well.

Member Enumeration Documentation

◆ ResetForm

enum MMU2::MMU2::ResetForm : uint8_t
Enumerator
Software 

sends a X0 command into the MMU, the MMU will watchdog-reset itself

ResetPin 

trigger the reset pin of the MMU

CutThePower 

power off and power on (that includes +5V and +24V power lines)

EraseEEPROM 

erase MMU EEPROM and then perform a software reset

Member Function Documentation

◆ Button()

void MMU2::MMU2::Button ( uint8_t  index)

Issue a "button" click into the MMU - to be used from Error screens of the MMU to select one of the 3 possible options to resolve the issue

◆ cut_filament()

bool MMU2::MMU2::cut_filament ( uint8_t  slot,
bool  enableFullScreenMsg = true 
)

Issue a Cut command into the MMU Requires unloaded filament from the printer (obviously)

Returns
false if the operation cannot be performed (Stopped)

◆ eject_filament()

bool MMU2::MMU2::eject_filament ( uint8_t  slot,
bool  enableFullScreenMsg = true 
)

Move MMU's selector aside and push the selected filament forward. Usable for improving filament's tip or pulling the remaining piece of filament out completely.

◆ FindaDetectsFilament()

bool MMU2::MMU2::FindaDetectsFilament ( ) const
inline
Returns
current state of FINDA (true=filament present, false=filament not present)

◆ get_current_tool()

uint8_t MMU2::MMU2::get_current_tool ( ) const
Returns
the active filament slot index (0-4) or 0xff in case of no active tool

◆ get_tool_change_tool()

uint8_t MMU2::MMU2::get_tool_change_tool ( ) const
Returns
The filament slot index (0 to 4) that will be loaded next, 0xff in case of no active tool change

◆ GetCommandInProgress()

uint8_t MMU2::MMU2::GetCommandInProgress ( ) const
inline
Returns
Command in progress

◆ GetLastErrorCode()

ErrorCode MMU2::MMU2::GetLastErrorCode ( ) const
inline
Returns
Last error code

◆ GetLastReadRegisterValue()

uint16_t MMU2::MMU2::GetLastReadRegisterValue ( ) const
inline

Retrieve cached value parsed from ReadRegister() or using M707

◆ GetMMUFWVersion()

Version MMU2::MMU2::GetMMUFWVersion ( ) const
inline
Returns
the version of the connected MMU FW. In the future we'll return the trully detected FW version

◆ GetPrinterButtonOperation()

Buttons MMU2::MMU2::GetPrinterButtonOperation ( )
inline
Returns
currently set printer button operation, it can be NoButton if nothing is queued

◆ load_filament()

bool MMU2::MMU2::load_filament ( uint8_t  slot)

Load (insert) filament just into the MMU (not into printer's nozzle)

Returns
false if the operation cannot be performed (Stopped)

◆ load_filament_to_nozzle()

bool MMU2::MMU2::load_filament_to_nozzle ( uint8_t  slot)

Load (push) filament from the MMU into the printer's nozzle

Returns
false if the operation cannot be performed (Stopped or cold extruder)

◆ loading_test()

bool MMU2::MMU2::loading_test ( uint8_t  slot)

Issue a Try-Load command It behaves very similarly like a ToolChange, but it doesn't load the filament all the way down to the nozzle. The sole purpose of this operation is to check, that the filament will be ready for printing.

Parameters
slotindex of slot to be tested
Returns
true

◆ mmu_loop()

void MMU2::MMU2::mmu_loop ( )

The main loop of MMU processing. Doesn't loop (block) inside, performs just one step of logic state machines. Also, internally it prevents recursive entries.

◆ MMUCurrentErrorCode()

ErrorCode MMU2::MMU2::MMUCurrentErrorCode ( ) const
inline
Returns
Current error code

◆ MMULastErrorSource()

ErrorSource MMU2::MMU2::MMULastErrorSource ( ) const
inline
Returns
Last error source

◆ ReadRegister()

bool MMU2::MMU2::ReadRegister ( uint8_t  address)

Read from a MMU register (See gcode M707)

Parameters
addressAddress of register in hexidecimal
Returns
true upon success

◆ Reset()

void MMU2::MMU2::Reset ( ResetForm  level)

Perform a reset of the MMU

Parameters
levelphysical form of the reset

◆ RetryIfPossible()

bool MMU2::MMU2::RetryIfPossible ( ErrorCode  ec)

Automagically "press" a Retry button if we have any retry attempts left

Parameters
ecErrorCode enum value
Returns
true if auto-retry is ongoing, false when retry is unavailable or retry attempts are all used up

◆ SetPrinterButtonOperation()

void MMU2::MMU2::SetPrinterButtonOperation ( Buttons  btn)
inline
Parameters
btnButton operation

◆ tool_change() [1/2]

bool MMU2::MMU2::tool_change ( char  code,
uint8_t  slot 
)

Handle special T?/Tx/Tc commands

  • T? Gcode to extrude shouldn't have to follow, load to extruder wheels is done automatically
  • Tx Same as T?, except nozzle doesn't have to be preheated. Tc must be placed after extruder nozzle is preheated to finish filament load.
  • Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated.

◆ tool_change() [2/2]

bool MMU2::MMU2::tool_change ( uint8_t  slot)

The main MMU command - select a different slot

Parameters
slotof the slot to be selected
Returns
false if the operation cannot be performed (Stopped)

IS_SD_PRINTING && !usb_timer.running()

◆ ToolChangeCounter()

uint16_t MMU2::MMU2::ToolChangeCounter ( ) const
inline
Returns
count for toolchange in current print

◆ Tune()

void MMU2::MMU2::Tune ( )

Tune value in MMU registers as a way to recover from errors e.g. Idler Stallguard threshold

◆ unload()

bool MMU2::MMU2::unload ( )

Unload of filament in collaboration with the MMU. That includes rotating the printer's extruder in order to release filament.

Returns
false if the operation cannot be performed (Stopped or cold extruder)

◆ WriteRegister()

bool MMU2::MMU2::WriteRegister ( uint8_t  address,
uint16_t  data 
)

Write from a MMU register (See gcode M708)

Parameters
addressAddress of register in hexidecimal
dataData to write to register
Returns
true upon success

The documentation for this class was generated from the following files: