123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- #pragma once
- #include "mmu2_protocol_logic.h"
- struct E_Step;
- namespace MMU2 {
- struct xyz_pos_t {
- float xyz[3];
- xyz_pos_t()=default;
- };
- enum : uint8_t {
- FILAMENT_UNKNOWN = 0xffU
- };
- class MMU2 {
- public:
- MMU2();
-
-
- void Start();
-
-
- void Stop();
-
-
-
-
-
-
-
-
- enum class xState : uint_fast8_t {
- Active,
- Connecting,
- Stopped
- };
-
- inline xState State() const { return state; }
-
-
- inline bool Enabled()const { return State() == xState::Active; }
-
- enum ResetForm : uint8_t {
- Software = 0,
- ResetPin = 1,
- CutThePower = 2
- };
-
-
-
- void Reset(ResetForm level);
-
-
- void PowerOff();
-
-
- void PowerOn();
-
-
-
- void mmu_loop();
-
-
-
- bool tool_change(uint8_t index);
-
-
- bool tool_change(const char *special);
-
-
-
- bool unload();
-
-
- bool load_filament(uint8_t index);
-
-
-
- bool load_filament_to_nozzle(uint8_t index);
-
-
- bool eject_filament(uint8_t index, bool recover);
-
-
-
- bool cut_filament(uint8_t index);
-
-
- uint8_t get_current_tool() const;
-
- bool set_filament_type(uint8_t index, uint8_t type);
-
-
- void Button(uint8_t index);
-
-
- void Home(uint8_t mode);
-
- inline bool FindaDetectsFilament()const { return logic.FindaPressed(); }
-
- private:
-
- void ResetX0();
-
-
- void TriggerResetPin();
-
-
-
- void PowerCycle();
-
-
- void StopKeepPowered();
-
-
- void manage_response(const bool move_axes, const bool turn_off_nozzle);
-
-
-
-
- StepStatus LogicStep();
-
- void filament_ramming();
- void execute_extruder_sequence(const E_Step *sequence, uint8_t steps);
- void SetActiveExtruder(uint8_t ex);
-
-
- void ReportError(ErrorCode ec);
-
-
- void ReportProgress(ProgressCode pc);
-
-
-
- void OnMMUProgressMsg(ProgressCode pc);
-
-
- void LogErrorEvent(const char *msg);
-
-
- void LogEchoEvent(const char *msg);
-
- void SaveAndPark(bool move_axes, bool turn_off_nozzle);
-
- void ResumeAndUnPark(bool move_axes, bool turn_off_nozzle);
-
- void CheckUserInput();
-
-
-
-
-
- bool WaitForMMUReady();
-
- ProtocolLogic logic;
- int extruder;
- xyz_pos_t resume_position;
- int16_t resume_hotend_temp;
-
- ProgressCode lastProgressCode = ProgressCode::OK;
- ErrorCode lastErrorCode = ErrorCode::MMU_NOT_RESPONDING;
- StepStatus logicStepLastStatus;
-
- enum xState state;
- bool mmu_print_saved;
- bool loadFilamentStarted;
-
- friend struct LoadingToNozzleRAII;
-
-
- bool loadingToNozzle;
- };
- extern MMU2 mmu2;
- }
|