[SMUFF] Use EXTRUDERS for extended commands (#21212)

This commit is contained in:
Giuliano Zaro 2021-02-27 20:23:00 +01:00 committed by Scott Lahteine
parent 3f9fe2dac4
commit 68e50a725a
3 changed files with 10 additions and 26 deletions

View File

@ -62,29 +62,13 @@ MMU2 mmu2;
#endif #endif
#define MMU_CMD_NONE 0 #define MMU_CMD_NONE 0
#define MMU_CMD_T0 0x10 #define MMU_CMD_T0 0x10 // up to supported filaments
#define MMU_CMD_T1 0x11 #define MMU_CMD_L0 0x20 // up to supported filaments
#define MMU_CMD_T2 0x12
#define MMU_CMD_T3 0x13
#define MMU_CMD_T4 0x14
#define MMU_CMD_L0 0x20
#define MMU_CMD_L1 0x21
#define MMU_CMD_L2 0x22
#define MMU_CMD_L3 0x23
#define MMU_CMD_L4 0x24
#define MMU_CMD_C0 0x30 #define MMU_CMD_C0 0x30
#define MMU_CMD_U0 0x40 #define MMU_CMD_U0 0x40
#define MMU_CMD_E0 0x50 #define MMU_CMD_E0 0x50 // up to supported filaments
#define MMU_CMD_E1 0x51
#define MMU_CMD_E2 0x52
#define MMU_CMD_E3 0x53
#define MMU_CMD_E4 0x54
#define MMU_CMD_R0 0x60 #define MMU_CMD_R0 0x60
#define MMU_CMD_F0 0x70 #define MMU_CMD_F0 0x70 // up to supported filaments
#define MMU_CMD_F1 0x71
#define MMU_CMD_F2 0x72
#define MMU_CMD_F3 0x73
#define MMU_CMD_F4 0x74
#define MMU_REQUIRED_FW_BUILDNR TERN(MMU2_MODE_12V, 132, 126) #define MMU_REQUIRED_FW_BUILDNR TERN(MMU2_MODE_12V, 132, 126)
@ -243,7 +227,7 @@ void MMU2::mmu_loop() {
case 1: case 1:
if (cmd) { if (cmd) {
if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) { if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T0 + EXTRUDERS - 1)) {
// tool change // tool change
int filament = cmd - MMU_CMD_T0; int filament = cmd - MMU_CMD_T0;
DEBUG_ECHOLNPAIR("MMU <= T", filament); DEBUG_ECHOLNPAIR("MMU <= T", filament);
@ -251,7 +235,7 @@ void MMU2::mmu_loop() {
TERN_(MMU_EXTRUDER_SENSOR, mmu_idl_sens = 1); // enable idler sensor, if any TERN_(MMU_EXTRUDER_SENSOR, mmu_idl_sens = 1); // enable idler sensor, if any
state = 3; // wait for response state = 3; // wait for response
} }
else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) { else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L0 + EXTRUDERS - 1)) {
// load // load
int filament = cmd - MMU_CMD_L0; int filament = cmd - MMU_CMD_L0;
DEBUG_ECHOLNPAIR("MMU <= L", filament); DEBUG_ECHOLNPAIR("MMU <= L", filament);
@ -271,7 +255,7 @@ void MMU2::mmu_loop() {
MMU2_COMMAND("U0"); MMU2_COMMAND("U0");
state = 3; // wait for response state = 3; // wait for response
} }
else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) { else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) {
// eject filament // eject filament
int filament = cmd - MMU_CMD_E0; int filament = cmd - MMU_CMD_E0;
DEBUG_ECHOLNPAIR("MMU <= E", filament); DEBUG_ECHOLNPAIR("MMU <= E", filament);
@ -284,7 +268,7 @@ void MMU2::mmu_loop() {
MMU2_COMMAND("R0"); MMU2_COMMAND("R0");
state = 3; // wait for response state = 3; // wait for response
} }
else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) { else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) {
// filament type // filament type
int filament = cmd - MMU_CMD_F0; int filament = cmd - MMU_CMD_F0;
DEBUG_ECHOLNPAIR("MMU <= F", filament, " ", cmd_arg); DEBUG_ECHOLNPAIR("MMU <= F", filament, " ", cmd_arg);

View File

@ -40,7 +40,7 @@ void GcodeSuite::M403() {
int8_t index = parser.intval('E', -1), int8_t index = parser.intval('E', -1),
type = parser.intval('F', -1); type = parser.intval('F', -1);
if (WITHIN(index, 0, 4) && WITHIN(type, 0, 2)) if (WITHIN(index, 0, EXTRUDERS - 1) && WITHIN(type, 0, 2))
mmu2.set_filament_type(index, type); mmu2.set_filament_type(index, type);
else else
SERIAL_ECHO_MSG("M403 - bad arguments."); SERIAL_ECHO_MSG("M403 - bad arguments.");

View File

@ -513,7 +513,7 @@
#define HAS_PRUSA_MMU2 1 #define HAS_PRUSA_MMU2 1
#define HAS_PRUSA_MMU2S 1 #define HAS_PRUSA_MMU2S 1
#endif #endif
#if MMU_MODEL >= SMUFF_EMU_MMU2 #if MMU_MODEL == SMUFF_EMU_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2S
#define HAS_SMUFF 1 #define HAS_SMUFF 1
#endif #endif
#endif #endif