🎨 Add MMU2 enabled() accessor

This commit is contained in:
Scott Lahteine 2021-07-17 03:10:54 -05:00
parent 40b99d8084
commit b57f73a488
3 changed files with 17 additions and 16 deletions

View File

@ -75,7 +75,7 @@ MMU2 mmu2;
#define MMU2_NO_TOOL 99 #define MMU2_NO_TOOL 99
#define MMU_BAUD 115200 #define MMU_BAUD 115200
bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved; bool MMU2::_enabled, MMU2::ready, MMU2::mmu_print_saved;
#if HAS_PRUSA_MMU2S #if HAS_PRUSA_MMU2S
bool MMU2::mmu2s_triggered; bool MMU2::mmu2s_triggered;
#endif #endif
@ -219,7 +219,7 @@ void MMU2::mmu_loop() {
DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED"); DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED");
enabled = true; _enabled = true;
state = 1; state = 1;
TERN_(HAS_PRUSA_MMU2S, mmu2s_triggered = false); TERN_(HAS_PRUSA_MMU2S, mmu2s_triggered = false);
} }
@ -480,7 +480,7 @@ static void mmu2_not_responding() {
*/ */
void MMU2::tool_change(const uint8_t index) { void MMU2::tool_change(const uint8_t index) {
if (!enabled) return; if (!_enabled) return;
set_runout_valid(false); set_runout_valid(false);
@ -512,7 +512,7 @@ static void mmu2_not_responding() {
* Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated.
*/ */
void MMU2::tool_change(const char *special) { void MMU2::tool_change(const char *special) {
if (!enabled) return; if (!_enabled) return;
set_runout_valid(false); set_runout_valid(false);
@ -561,7 +561,7 @@ static void mmu2_not_responding() {
* Handle tool change * Handle tool change
*/ */
void MMU2::tool_change(const uint8_t index) { void MMU2::tool_change(const uint8_t index) {
if (!enabled) return; if (!_enabled) return;
set_runout_valid(false); set_runout_valid(false);
@ -599,7 +599,7 @@ static void mmu2_not_responding() {
* Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated.
*/ */
void MMU2::tool_change(const char *special) { void MMU2::tool_change(const char *special) {
if (!enabled) return; if (!_enabled) return;
set_runout_valid(false); set_runout_valid(false);
@ -665,7 +665,7 @@ static void mmu2_not_responding() {
* Handle tool change * Handle tool change
*/ */
void MMU2::tool_change(const uint8_t index) { void MMU2::tool_change(const uint8_t index) {
if (!enabled) return; if (!_enabled) return;
set_runout_valid(false); set_runout_valid(false);
@ -693,7 +693,7 @@ static void mmu2_not_responding() {
* Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated.
*/ */
void MMU2::tool_change(const char *special) { void MMU2::tool_change(const char *special) {
if (!enabled) return; if (!_enabled) return;
set_runout_valid(false); set_runout_valid(false);
@ -744,7 +744,7 @@ static void mmu2_not_responding() {
* Set next command * Set next command
*/ */
void MMU2::command(const uint8_t mmu_cmd) { void MMU2::command(const uint8_t mmu_cmd) {
if (!enabled) return; if (!_enabled) return;
cmd = mmu_cmd; cmd = mmu_cmd;
ready = false; ready = false;
} }
@ -833,7 +833,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
} }
void MMU2::set_filament_type(const uint8_t index, const uint8_t filamentType) { void MMU2::set_filament_type(const uint8_t index, const uint8_t filamentType) {
if (!enabled) return; if (!_enabled) return;
cmd_arg = filamentType; cmd_arg = filamentType;
command(MMU_CMD_F0 + index); command(MMU_CMD_F0 + index);
@ -892,7 +892,7 @@ void MMU2::filament_runout() {
// Load filament into MMU2 // Load filament into MMU2
void MMU2::load_filament(const uint8_t index) { void MMU2::load_filament(const uint8_t index) {
if (!enabled) return; if (!_enabled) return;
command(MMU_CMD_L0 + index); command(MMU_CMD_L0 + index);
manage_response(false, false); manage_response(false, false);
@ -904,7 +904,7 @@ void MMU2::load_filament(const uint8_t index) {
*/ */
bool MMU2::load_filament_to_nozzle(const uint8_t index) { bool MMU2::load_filament_to_nozzle(const uint8_t index) {
if (!enabled) return false; if (!_enabled) return false;
if (thermalManager.tooColdToExtrude(active_extruder)) { if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404); BUZZ(200, 404);
@ -940,7 +940,7 @@ void MMU2::load_to_nozzle() {
bool MMU2::eject_filament(const uint8_t index, const bool recover) { bool MMU2::eject_filament(const uint8_t index, const bool recover) {
if (!enabled) return false; if (!_enabled) return false;
if (thermalManager.tooColdToExtrude(active_extruder)) { if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404); BUZZ(200, 404);
@ -989,7 +989,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
*/ */
bool MMU2::unload() { bool MMU2::unload() {
if (!enabled) return false; if (!_enabled) return false;
if (thermalManager.tooColdToExtrude(active_extruder)) { if (thermalManager.tooColdToExtrude(active_extruder)) {
BUZZ(200, 404); BUZZ(200, 404);

View File

@ -43,6 +43,7 @@ public:
static void init(); static void init();
static void reset(); static void reset();
static inline bool enabled() { return _enabled; }
static void mmu_loop(); static void mmu_loop();
static void tool_change(const uint8_t index); static void tool_change(const uint8_t index);
static void tool_change(const char *special); static void tool_change(const char *special);
@ -88,7 +89,7 @@ private:
static void mmu_continue_loading(); static void mmu_continue_loading();
#endif #endif
static bool enabled, ready, mmu_print_saved; static bool _enabled, ready, mmu_print_saved;
static uint8_t cmd, cmd_arg, last_cmd, extruder; static uint8_t cmd, cmd_arg, last_cmd, extruder;
static int8_t state; static int8_t state;

View File

@ -166,7 +166,7 @@
#define DOGLCD_SCK PB13 #define DOGLCD_SCK PB13
#define FORCE_SOFT_SPI #define FORCE_SOFT_SPI
#define SOFTWARE_SPI #define SOFTWARE_SPI
#else #else
#define LCD_PINS_D4 PA6 #define LCD_PINS_D4 PA6