0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-19 23:54:19 +00:00

🩹 Fix Extensible MMU for >8 colors (#25772)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Giuliano Zaro 2023-05-05 04:30:51 +02:00 committed by GitHub
parent e5dfb44fe0
commit 4e2b5b2523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 42 deletions

View file

@ -676,28 +676,9 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
&& ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS))
&& !planner.has_blocks_queued()
) {
#if HAS_SWITCHING_EXTRUDER
bool oldstatus;
switch (active_extruder) {
default: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 0); stepper.ENABLE_EXTRUDER(0); break;
#if E_STEPPERS > 1
case 2: case 3: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 1); stepper.ENABLE_EXTRUDER(1); break;
#if E_STEPPERS > 2
case 4: case 5: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 2); stepper.ENABLE_EXTRUDER(2); break;
#if E_STEPPERS > 3
case 6: case 7: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 3); stepper.ENABLE_EXTRUDER(3); break;
#endif // E_STEPPERS > 3
#endif // E_STEPPERS > 2
#endif // E_STEPPERS > 1
}
#else // !HAS_SWITCHING_EXTRUDER
bool oldstatus;
switch (active_extruder) {
default:
#define _CASE_EN(N) case N: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, N); stepper.ENABLE_EXTRUDER(N); break;
REPEAT(E_STEPPERS, _CASE_EN);
}
#endif
const int8_t e_stepper = TERN(HAS_SWITCHING_EXTRUDER, active_extruder >> 1, active_extruder);
const bool e_off = !stepper.AXIS_IS_ENABLED(E_AXIS, e_stepper);
if (e_off) stepper.ENABLE_EXTRUDER(e_stepper);
const float olde = current_position.e;
current_position.e += EXTRUDER_RUNOUT_EXTRUDE;
@ -706,22 +687,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
planner.set_e_position_mm(olde);
planner.synchronize();
#if HAS_SWITCHING_EXTRUDER
switch (active_extruder) {
default: if (oldstatus) stepper.ENABLE_EXTRUDER(0); else stepper.DISABLE_EXTRUDER(0); break;
#if E_STEPPERS > 1
case 2: case 3: if (oldstatus) stepper.ENABLE_EXTRUDER(1); else stepper.DISABLE_EXTRUDER(1); break;
#if E_STEPPERS > 2
case 4: case 5: if (oldstatus) stepper.ENABLE_EXTRUDER(2); else stepper.DISABLE_EXTRUDER(2); break;
#endif // E_STEPPERS > 2
#endif // E_STEPPERS > 1
}
#else // !HAS_SWITCHING_EXTRUDER
switch (active_extruder) {
#define _CASE_RESTORE(N) case N: if (oldstatus) stepper.ENABLE_EXTRUDER(N); else stepper.DISABLE_EXTRUDER(N); break;
REPEAT(E_STEPPERS, _CASE_RESTORE);
}
#endif // !HAS_SWITCHING_EXTRUDER
if (e_off) stepper.DISABLE_EXTRUDER(e_stepper);
gcode.reset_stepper_timeout(ms);
}

View file

@ -71,7 +71,7 @@ void do_enable(const stepper_flags_t to_enable) {
if (!shall_enable) return; // All specified axes already enabled?
ena_mask_t also_enabled = 0; // Track steppers enabled due to overlap
ena_mask_t also_enabled = 0; // Track steppers enabled due to overlap
// Enable all flagged axes
LOOP_NUM_AXES(a) {

View file

@ -255,8 +255,19 @@
// This does not account for the possibility of multi-stepping.
#define MIN_STEP_ISR_FREQUENCY (MAX_STEP_ISR_FREQUENCY_1X >> 1)
// TODO: Review and ensure proper handling for special E axes with commands like M17/M18, stepper timeout, etc.
#if ENABLED(MIXING_EXTRUDER)
#define E_STATES EXTRUDERS // All steppers are set together for each mixer. (Currently limited to 1.)
#elif HAS_SWITCHING_EXTRUDER
#define E_STATES E_STEPPERS // One stepper for every two EXTRUDERS. The last extruder can be non-switching.
#elif HAS_PRUSA_MMU2
#define E_STATES E_STEPPERS // One E stepper shared with all EXTRUDERS, so setting any only sets one.
#else
#define E_STATES E_STEPPERS // One stepper for each extruder, so each can be disabled individually.
#endif
// Number of axes that could be enabled/disabled. Dual/multiple steppers are combined.
#define ENABLE_COUNT (NUM_AXES + E_STEPPERS)
#define ENABLE_COUNT (NUM_AXES + E_STATES)
typedef bits_t(ENABLE_COUNT) ena_mask_t;
// Axis flags type, for enabled state or other simple state
@ -265,8 +276,8 @@ typedef struct {
ena_mask_t bits;
struct {
bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1);
#if HAS_EXTRUDERS
bool LIST_N(EXTRUDERS, E0:1, E1:1, E2:1, E3:1, E4:1, E5:1, E6:1, E7:1);
#if E_STATES
bool LIST_N(E_STATES, E0:1, E1:1, E2:1, E3:1, E4:1, E5:1, E6:1, E7:1);
#endif
};
};