⚡️ Handle shared enable pins (#22824)
This commit is contained in:
committed by
Scott Lahteine
parent
25a131b942
commit
021ceeba0b
@ -25,7 +25,7 @@
|
||||
#if ENABLED(USE_CONTROLLER_FAN)
|
||||
|
||||
#include "controllerfan.h"
|
||||
#include "../module/stepper/indirection.h"
|
||||
#include "../module/stepper.h"
|
||||
#include "../module/temperature.h"
|
||||
|
||||
ControllerFan controllerFan;
|
||||
@ -54,33 +54,12 @@ void ControllerFan::update() {
|
||||
if (ELAPSED(ms, nextMotorCheck)) {
|
||||
nextMotorCheck = ms + 2500UL; // Not a time critical function, so only check every 2.5s
|
||||
|
||||
#define MOTOR_IS_ON(A,B) (A##_ENABLE_READ() == bool(B##_ENABLE_ON))
|
||||
#define _OR_ENABLED_E(N) || MOTOR_IS_ON(E##N,E)
|
||||
|
||||
const bool motor_on = (
|
||||
( DISABLED(CONTROLLER_FAN_IGNORE_Z) &&
|
||||
( MOTOR_IS_ON(Z,Z)
|
||||
|| TERN0(HAS_Z2_ENABLE, MOTOR_IS_ON(Z2,Z))
|
||||
|| TERN0(HAS_Z3_ENABLE, MOTOR_IS_ON(Z3,Z))
|
||||
|| TERN0(HAS_Z4_ENABLE, MOTOR_IS_ON(Z4,Z))
|
||||
)
|
||||
) || (
|
||||
DISABLED(CONTROLLER_FAN_USE_Z_ONLY) &&
|
||||
( MOTOR_IS_ON(X,X) || MOTOR_IS_ON(Y,Y)
|
||||
|| TERN0(HAS_X2_ENABLE, MOTOR_IS_ON(X2,X))
|
||||
|| TERN0(HAS_Y2_ENABLE, MOTOR_IS_ON(Y2,Y))
|
||||
#if E_STEPPERS
|
||||
REPEAT(E_STEPPERS, _OR_ENABLED_E)
|
||||
#endif
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// If any triggers for the controller fan are true...
|
||||
// - At least one stepper driver is enabled
|
||||
// - The heated bed is enabled
|
||||
// - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP
|
||||
if ( motor_on
|
||||
const ena_mask_t axis_mask = TERN(CONTROLLER_FAN_USE_Z_ONLY, _BV(Z_AXIS), ~TERN0(CONTROLLER_FAN_IGNORE_Z, _BV(Z_AXIS)));
|
||||
if ( (stepper.axis_enabled.bits & axis_mask)
|
||||
|| TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0)
|
||||
|| TERN0(HAS_CONTROLLER_FAN_MIN_BOARD_TEMP, thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP)
|
||||
) lastMotorOn = ms; //... set time to NOW so the fan will turn on
|
||||
|
@ -75,7 +75,7 @@ void FWRetract::reset() {
|
||||
|
||||
LOOP_L_N(i, EXTRUDERS) {
|
||||
retracted[i] = false;
|
||||
TERN_(HAS_MULTI_EXTRUDER, retracted_swap[i] = false);
|
||||
E_TERN_(retracted_swap[i] = false);
|
||||
current_retract[i] = 0.0;
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ void FWRetract::reset() {
|
||||
* Note: Auto-retract will apply the set Z hop in addition to any Z hop
|
||||
* included in the G-code. Use M207 Z0 to to prevent double hop.
|
||||
*/
|
||||
void FWRetract::retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping/*=false*/)) {
|
||||
void FWRetract::retract(const bool retracting E_OPTARG(bool swapping/*=false*/)) {
|
||||
// Prevent two retracts or recovers in a row
|
||||
if (retracted[active_extruder] == retracting) return;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
static void retract(const bool retracting OPTARG(HAS_MULTI_EXTRUDER, bool swapping = false));
|
||||
static void retract(const bool retracting E_OPTARG(bool swapping=false));
|
||||
|
||||
static void M207_report();
|
||||
static void M207();
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "../MarlinCore.h"
|
||||
#include "../module/planner.h"
|
||||
#include "../module/stepper.h"
|
||||
|
||||
void mmu_init() {
|
||||
SET_OUTPUT(E_MUX0_PIN);
|
||||
@ -35,7 +36,7 @@ void mmu_init() {
|
||||
|
||||
void select_multiplexed_stepper(const uint8_t e) {
|
||||
planner.synchronize();
|
||||
disable_e_steppers();
|
||||
stepper.disable_e_steppers();
|
||||
WRITE(E_MUX0_PIN, TEST(e, 0) ? HIGH : LOW);
|
||||
WRITE(E_MUX1_PIN, TEST(e, 1) ? HIGH : LOW);
|
||||
WRITE(E_MUX2_PIN, TEST(e, 2) ? HIGH : LOW);
|
||||
|
@ -35,7 +35,7 @@ MMU2 mmu2;
|
||||
#include "../../libs/nozzle.h"
|
||||
#include "../../module/temperature.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../module/stepper/indirection.h"
|
||||
#include "../../module/stepper.h"
|
||||
#include "../../MarlinCore.h"
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
@ -486,7 +486,7 @@ static void mmu2_not_responding() {
|
||||
|
||||
if (index != extruder) {
|
||||
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
||||
|
||||
command(MMU_CMD_T0 + index);
|
||||
@ -495,7 +495,7 @@ static void mmu2_not_responding() {
|
||||
if (load_to_gears()) {
|
||||
extruder = index; // filament change is finished
|
||||
active_extruder = 0;
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
|
||||
}
|
||||
ui.reset_status();
|
||||
@ -531,13 +531,13 @@ static void mmu2_not_responding() {
|
||||
#if ENABLED(MMU2_MENUS)
|
||||
planner.synchronize();
|
||||
const uint8_t index = mmu2_choose_filament();
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
command(MMU_CMD_T0 + index);
|
||||
manage_response(true, true);
|
||||
|
||||
if (load_to_gears()) {
|
||||
mmu_loop();
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
extruder = index;
|
||||
active_extruder = 0;
|
||||
}
|
||||
@ -566,7 +566,7 @@ static void mmu2_not_responding() {
|
||||
set_runout_valid(false);
|
||||
|
||||
if (index != extruder) {
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
if (FILAMENT_PRESENT()) {
|
||||
DEBUG_ECHOLNPGM("Unloading\n");
|
||||
mmu_loading_flag = false;
|
||||
@ -582,7 +582,7 @@ static void mmu2_not_responding() {
|
||||
extruder = index;
|
||||
active_extruder = 0;
|
||||
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
|
||||
|
||||
ui.reset_status();
|
||||
@ -620,14 +620,14 @@ static void mmu2_not_responding() {
|
||||
#if ENABLED(MMU2_MENUS)
|
||||
planner.synchronize();
|
||||
uint8_t index = mmu2_choose_filament();
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
command(MMU_CMD_T0 + index);
|
||||
manage_response(true, true);
|
||||
mmu_continue_loading();
|
||||
command(MMU_CMD_C0);
|
||||
mmu_loop();
|
||||
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
extruder = index;
|
||||
active_extruder = 0;
|
||||
#else
|
||||
@ -670,14 +670,14 @@ static void mmu2_not_responding() {
|
||||
set_runout_valid(false);
|
||||
|
||||
if (index != extruder) {
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
||||
command(MMU_CMD_T0 + index);
|
||||
manage_response(true, true);
|
||||
command(MMU_CMD_C0);
|
||||
extruder = index; //filament change is finished
|
||||
active_extruder = 0;
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder);
|
||||
ui.reset_status();
|
||||
}
|
||||
@ -714,13 +714,13 @@ static void mmu2_not_responding() {
|
||||
#if ENABLED(MMU2_MENUS)
|
||||
planner.synchronize();
|
||||
uint8_t index = mmu2_choose_filament();
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
command(MMU_CMD_T0 + index);
|
||||
manage_response(true, true);
|
||||
command(MMU_CMD_C0);
|
||||
mmu_loop();
|
||||
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
extruder = index;
|
||||
active_extruder = 0;
|
||||
#else
|
||||
@ -912,7 +912,7 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
command(MMU_CMD_T0 + index);
|
||||
manage_response(true, true);
|
||||
|
||||
@ -950,7 +950,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
|
||||
|
||||
LCD_MESSAGEPGM(MSG_MMU2_EJECTING_FILAMENT);
|
||||
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
current_position.e -= MMU2_FILAMENTCHANGE_EJECT_FEED;
|
||||
line_to_current_position(MMM_TO_MMS(2500));
|
||||
planner.synchronize();
|
||||
@ -979,7 +979,7 @@ bool MMU2::eject_filament(const uint8_t index, const bool recover) {
|
||||
|
||||
BUZZ(200, 404);
|
||||
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1016,7 +1016,7 @@ bool MMU2::unload() {
|
||||
void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) {
|
||||
|
||||
planner.synchronize();
|
||||
ENABLE_AXIS_E0();
|
||||
stepper.enable_extruder();
|
||||
|
||||
const E_Step* step = sequence;
|
||||
|
||||
@ -1034,7 +1034,7 @@ void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) {
|
||||
step++;
|
||||
}
|
||||
|
||||
DISABLE_AXIS_E0();
|
||||
stepper.disable_extruder();
|
||||
}
|
||||
|
||||
#endif // HAS_PRUSA_MMU2
|
||||
|
@ -302,8 +302,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
|
||||
* send current back to their board, potentially frying it.
|
||||
*/
|
||||
inline void disable_active_extruder() {
|
||||
#if HAS_E_STEPPER_ENABLE
|
||||
disable_e_stepper(active_extruder);
|
||||
#if HAS_EXTRUDERS
|
||||
stepper.DISABLE_EXTRUDER(active_extruder);
|
||||
safe_delay(100);
|
||||
#endif
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#include "power.h"
|
||||
#include "../module/stepper/indirection.h"
|
||||
#include "../module/stepper.h"
|
||||
#include "../MarlinCore.h"
|
||||
|
||||
#if ENABLED(PS_OFF_SOUND)
|
||||
@ -120,6 +120,9 @@ void Power::power_off() {
|
||||
*/
|
||||
bool Power::is_power_needed() {
|
||||
|
||||
// If any of the stepper drivers are enabled...
|
||||
if (stepper.axis_enabled.bits) return true;
|
||||
|
||||
if (printJobOngoing() || printingIsPaused()) return true;
|
||||
|
||||
#if ENABLED(AUTO_POWER_FANS)
|
||||
@ -140,23 +143,6 @@ void Power::power_off() {
|
||||
if (TERN0(AUTO_POWER_COOLER_FAN, thermalManager.coolerfan_speed))
|
||||
return true;
|
||||
|
||||
// If any of the drivers or the bed are enabled...
|
||||
if (X_ENABLE_READ() == X_ENABLE_ON || Y_ENABLE_READ() == Y_ENABLE_ON || Z_ENABLE_READ() == Z_ENABLE_ON
|
||||
#if HAS_X2_ENABLE
|
||||
|| X2_ENABLE_READ() == X_ENABLE_ON
|
||||
#endif
|
||||
#if HAS_Y2_ENABLE
|
||||
|| Y2_ENABLE_READ() == Y_ENABLE_ON
|
||||
#endif
|
||||
#if HAS_Z2_ENABLE
|
||||
|| Z2_ENABLE_READ() == Z_ENABLE_ON
|
||||
#endif
|
||||
#if E_STEPPERS
|
||||
#define _OR_ENABLED_E(N) || E##N##_ENABLE_READ() == E_ENABLE_ON
|
||||
REPEAT(E_STEPPERS, _OR_ENABLED_E)
|
||||
#endif
|
||||
) return true;
|
||||
|
||||
#if HAS_HOTEND
|
||||
HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0 || thermalManager.temp_hotend[e].soft_pwm_amount > 0) return true;
|
||||
#endif
|
||||
|
@ -186,7 +186,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
|
||||
TERN_(GCODE_REPEAT_MARKERS, info.stored_repeat = repeat);
|
||||
TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset);
|
||||
TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift);
|
||||
TERN_(HAS_MULTI_EXTRUDER, info.active_extruder = active_extruder);
|
||||
E_TERN_(info.active_extruder = active_extruder);
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
info.flag.volumetric_enabled = parser.volumetric_enabled;
|
||||
|
Reference in New Issue
Block a user