Bläddra i källkod

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

Giuliano Zaro 3 år sedan
förälder
incheckning
4f840c211c
Inget konto är kopplat till bidragsgivarens mejladress

+ 8
- 24
Marlin/src/feature/mmu/mmu2.cpp Visa fil

@@ -62,29 +62,13 @@ MMU2 mmu2;
62 62
 #endif
63 63
 
64 64
 #define MMU_CMD_NONE 0
65
-#define MMU_CMD_T0   0x10
66
-#define MMU_CMD_T1   0x11
67
-#define MMU_CMD_T2   0x12
68
-#define MMU_CMD_T3   0x13
69
-#define MMU_CMD_T4   0x14
70
-#define MMU_CMD_L0   0x20
71
-#define MMU_CMD_L1   0x21
72
-#define MMU_CMD_L2   0x22
73
-#define MMU_CMD_L3   0x23
74
-#define MMU_CMD_L4   0x24
65
+#define MMU_CMD_T0   0x10  // up to supported filaments
66
+#define MMU_CMD_L0   0x20  // up to supported filaments
75 67
 #define MMU_CMD_C0   0x30
76 68
 #define MMU_CMD_U0   0x40
77
-#define MMU_CMD_E0   0x50
78
-#define MMU_CMD_E1   0x51
79
-#define MMU_CMD_E2   0x52
80
-#define MMU_CMD_E3   0x53
81
-#define MMU_CMD_E4   0x54
69
+#define MMU_CMD_E0   0x50  // up to supported filaments
82 70
 #define MMU_CMD_R0   0x60
83
-#define MMU_CMD_F0   0x70
84
-#define MMU_CMD_F1   0x71
85
-#define MMU_CMD_F2   0x72
86
-#define MMU_CMD_F3   0x73
87
-#define MMU_CMD_F4   0x74
71
+#define MMU_CMD_F0   0x70  // up to supported filaments
88 72
 
89 73
 #define MMU_REQUIRED_FW_BUILDNR TERN(MMU2_MODE_12V, 132, 126)
90 74
 
@@ -243,7 +227,7 @@ void MMU2::mmu_loop() {
243 227
 
244 228
     case 1:
245 229
       if (cmd) {
246
-        if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) {
230
+        if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T0 + EXTRUDERS - 1)) {
247 231
           // tool change
248 232
           int filament = cmd - MMU_CMD_T0;
249 233
           DEBUG_ECHOLNPAIR("MMU <= T", filament);
@@ -251,7 +235,7 @@ void MMU2::mmu_loop() {
251 235
           TERN_(MMU_EXTRUDER_SENSOR, mmu_idl_sens = 1); // enable idler sensor, if any
252 236
           state = 3; // wait for response
253 237
         }
254
-        else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) {
238
+        else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L0 + EXTRUDERS - 1)) {
255 239
           // load
256 240
           int filament = cmd - MMU_CMD_L0;
257 241
           DEBUG_ECHOLNPAIR("MMU <= L", filament);
@@ -271,7 +255,7 @@ void MMU2::mmu_loop() {
271 255
           MMU2_COMMAND("U0");
272 256
           state = 3; // wait for response
273 257
         }
274
-        else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) {
258
+        else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) {
275 259
           // eject filament
276 260
           int filament = cmd - MMU_CMD_E0;
277 261
           DEBUG_ECHOLNPAIR("MMU <= E", filament);
@@ -284,7 +268,7 @@ void MMU2::mmu_loop() {
284 268
           MMU2_COMMAND("R0");
285 269
           state = 3; // wait for response
286 270
         }
287
-        else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) {
271
+        else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) {
288 272
           // filament type
289 273
           int filament = cmd - MMU_CMD_F0;
290 274
           DEBUG_ECHOLNPAIR("MMU <= F", filament, " ", cmd_arg);

+ 1
- 1
Marlin/src/gcode/feature/prusa_MMU2/M403.cpp Visa fil

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

+ 1
- 1
Marlin/src/inc/Conditionals_LCD.h Visa fil

@@ -513,7 +513,7 @@
513 513
     #define HAS_PRUSA_MMU2 1
514 514
     #define HAS_PRUSA_MMU2S 1
515 515
   #endif
516
-  #if MMU_MODEL >= SMUFF_EMU_MMU2
516
+  #if MMU_MODEL == SMUFF_EMU_MMU2 || MMU_MODEL == SMUFF_EMU_MMU2S
517 517
     #define HAS_SMUFF 1
518 518
   #endif
519 519
 #endif

Laddar…
Avbryt
Spara