🩹 No PE_MAGNET_ON_STATE without PARKING_EXTRUDER

This commit is contained in:
Scott Lahteine 2022-03-22 18:14:17 -05:00 committed by Scott Lahteine
parent cc4c2c2f98
commit b0a400da72
5 changed files with 10 additions and 17 deletions

View file

@ -27,17 +27,11 @@
#include "solenoid.h" #include "solenoid.h"
#include "../module/motion.h" // for active_extruder #include "../module/motion.h" // for active_extruder
// PARKING_EXTRUDER options alter the default behavior of solenoids, this ensures compliance of M380-381
#if ENABLED(PARKING_EXTRUDER)
#include "../module/tool_change.h" #include "../module/tool_change.h"
#endif
// Used primarily with MANUAL_SOLENOID_CONTROL // Used primarily with MANUAL_SOLENOID_CONTROL
static void set_solenoid(const uint8_t num, const bool active) { static void set_solenoid(const uint8_t num, const uint8_t state) {
const uint8_t value = active ? PE_MAGNET_ON_STATE : !PE_MAGNET_ON_STATE; #define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, state)); break;
#define _SOL_CASE(N) case N: TERN_(HAS_SOLENOID_##N, OUT_WRITE(SOL##N##_PIN, value)); break;
switch (num) { switch (num) {
REPEAT(8, _SOL_CASE) REPEAT(8, _SOL_CASE)
default: SERIAL_ECHO_MSG(STR_INVALID_SOLENOID); break; default: SERIAL_ECHO_MSG(STR_INVALID_SOLENOID); break;
@ -49,9 +43,9 @@ static void set_solenoid(const uint8_t num, const bool active) {
#endif #endif
} }
void enable_solenoid(const uint8_t num) { set_solenoid(num, true); } // PARKING_EXTRUDER options alter the default behavior of solenoids to ensure compliance of M380-381
void disable_solenoid(const uint8_t num) { set_solenoid(num, false); } void enable_solenoid(const uint8_t num) { set_solenoid(num, TERN1(PARKING_EXTRUDER, PE_MAGNET_ON_STATE)); }
void enable_solenoid_on_active_extruder() { } void disable_solenoid(const uint8_t num) { set_solenoid(num, TERN0(PARKING_EXTRUDER, !PE_MAGNET_ON_STATE)); }
void disable_all_solenoids() { void disable_all_solenoids() {
#define _SOL_DISABLE(N) TERN_(HAS_SOLENOID_##N, disable_solenoid(N)); #define _SOL_DISABLE(N) TERN_(HAS_SOLENOID_##N, disable_solenoid(N));

View file

@ -21,7 +21,6 @@
*/ */
#pragma once #pragma once
void enable_solenoid_on_active_extruder();
void disable_all_solenoids(); void disable_all_solenoids();
void enable_solenoid(const uint8_t num); void enable_solenoid(const uint8_t num);
void disable_solenoid(const uint8_t num); void disable_solenoid(const uint8_t num);

View file

@ -37,7 +37,7 @@ void GcodeSuite::M380() {
#if ENABLED(MANUAL_SOLENOID_CONTROL) #if ENABLED(MANUAL_SOLENOID_CONTROL)
enable_solenoid(parser.intval('S', active_extruder)); enable_solenoid(parser.intval('S', active_extruder));
#else #else
enable_solenoid_on_active_extruder(); enable_solenoid(active_extruder);
#endif #endif
} }

View file

@ -219,8 +219,8 @@
* M350 - Set microstepping mode. (Requires digital microstepping pins.) * M350 - Set microstepping mode. (Requires digital microstepping pins.)
* M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.) * M351 - Toggle MS1 MS2 pins directly. (Requires digital microstepping pins.)
* M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN) * M355 - Set Case Light on/off and set brightness. (Requires CASE_LIGHT_PIN)
* M380 - Activate solenoid on active extruder. (Requires EXT_SOLENOID) * M380 - Activate solenoid on active tool (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL).
* M381 - Disable all solenoids. (Requires EXT_SOLENOID) * M381 - Disable solenoids on all tools (Requires EXT_SOLENOID) or the tool specified by 'S' (Requires MANUAL_SOLENOID_CONTROL).
* M400 - Finish all moves. * M400 - Finish all moves.
* M401 - Deploy and activate Z probe. (Requires a probe) * M401 - Deploy and activate Z probe. (Requires a probe)
* M402 - Deactivate and stow Z probe. (Requires a probe) * M402 - Deactivate and stow Z probe. (Requires a probe)

View file

@ -1292,7 +1292,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
#if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER) #if ENABLED(EXT_SOLENOID) && DISABLED(PARKING_EXTRUDER)
disable_all_solenoids(); disable_all_solenoids();
enable_solenoid_on_active_extruder(); enable_solenoid(active_extruder);
#endif #endif
#if HAS_PRUSA_MMU1 #if HAS_PRUSA_MMU1