Browse Source

🏗️ Extend AXIS_CHAR to include E

Co-Authored-By: DerAndere <26200979+DerAndere1@users.noreply.github.com>
Scott Lahteine 3 years ago
parent
commit
8b8defeacc

+ 1
- 1
Marlin/src/core/utility.h View File

79
 
79
 
80
 // Axis names for G-code parsing, reports, etc.
80
 // Axis names for G-code parsing, reports, etc.
81
 const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
81
 const xyze_char_t axis_codes LOGICAL_AXIS_ARRAY('E', 'X', 'Y', 'Z', AXIS4_NAME, AXIS5_NAME, AXIS6_NAME, AXIS7_NAME, AXIS8_NAME, AXIS9_NAME);
82
-#if NUM_AXES <= XYZ
82
+#if NUM_AXES <= XYZ && !HAS_EXTRUDERS
83
   #define AXIS_CHAR(A) ((char)('X' + A))
83
   #define AXIS_CHAR(A) ((char)('X' + A))
84
   #define IAXIS_CHAR AXIS_CHAR
84
   #define IAXIS_CHAR AXIS_CHAR
85
 #else
85
 #else

+ 22
- 22
Marlin/src/feature/encoder_i2c.cpp View File

49
 
49
 
50
   initialized = true;
50
   initialized = true;
51
 
51
 
52
-  SERIAL_ECHOLNPGM("Setting up encoder on ", AS_CHAR(axis_codes[encoderAxis]), " axis, addr = ", address);
52
+  SERIAL_ECHOLNPGM("Setting up encoder on ", AS_CHAR(AXIS_CHAR(encoderAxis)), " axis, addr = ", address);
53
 
53
 
54
   position = get_position();
54
   position = get_position();
55
 }
55
 }
67
     /*
67
     /*
68
     if (trusted) { //commented out as part of the note below
68
     if (trusted) { //commented out as part of the note below
69
       trusted = false;
69
       trusted = false;
70
-      SERIAL_ECHOLNPGM("Fault detected on ", AS_CHAR(axis_codes[encoderAxis]), " axis encoder. Disengaging error correction until module is trusted again.");
70
+      SERIAL_ECHOLNPGM("Fault detected on ", AS_CHAR(AXIS_CHAR(encoderAxis)), " axis encoder. Disengaging error correction until module is trusted again.");
71
     }
71
     }
72
     */
72
     */
73
     return;
73
     return;
92
       if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) {
92
       if (millis() - lastErrorTime > I2CPE_TIME_TRUSTED) {
93
         trusted = true;
93
         trusted = true;
94
 
94
 
95
-        SERIAL_ECHOLNPGM("Untrusted encoder module on ", AS_CHAR(axis_codes[encoderAxis]), " axis has been fault-free for set duration, reinstating error correction.");
95
+        SERIAL_ECHOLNPGM("Untrusted encoder module on ", AS_CHAR(AXIS_CHAR(encoderAxis)), " axis has been fault-free for set duration, reinstating error correction.");
96
 
96
 
97
         //the encoder likely lost its place when the error occurred, so we'll reset and use the printer's
97
         //the encoder likely lost its place when the error occurred, so we'll reset and use the printer's
98
         //idea of where it the axis is to re-initialize
98
         //idea of where it the axis is to re-initialize
172
             float sumP = 0;
172
             float sumP = 0;
173
             LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
173
             LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
174
             const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
174
             const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
175
-            SERIAL_CHAR(axis_codes[encoderAxis]);
175
+            SERIAL_CHAR(AXIS_CHAR(encoderAxis));
176
             SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm");
176
             SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm");
177
             babystep.add_steps(encoderAxis, -LROUND(errorP));
177
             babystep.add_steps(encoderAxis, -LROUND(errorP));
178
             errPrstIdx = 0;
178
             errPrstIdx = 0;
192
     if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) {
192
     if (ABS(error) > I2CPE_ERR_CNT_THRESH * planner.settings.axis_steps_per_mm[encoderAxis]) {
193
       const millis_t ms = millis();
193
       const millis_t ms = millis();
194
       if (ELAPSED(ms, nextErrorCountTime)) {
194
       if (ELAPSED(ms, nextErrorCountTime)) {
195
-        SERIAL_CHAR(axis_codes[encoderAxis]);
195
+        SERIAL_CHAR(AXIS_CHAR(encoderAxis));
196
         SERIAL_ECHOLNPGM(" : LARGE ERR ", error, "; diffSum=", diffSum);
196
         SERIAL_ECHOLNPGM(" : LARGE ERR ", error, "; diffSum=", diffSum);
197
         errorCount++;
197
         errorCount++;
198
         nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS;
198
         nextErrorCountTime = ms + I2CPE_ERR_CNT_DEBOUNCE_MS;
212
     homed = trusted = true;
212
     homed = trusted = true;
213
 
213
 
214
     #ifdef I2CPE_DEBUG
214
     #ifdef I2CPE_DEBUG
215
-      SERIAL_CHAR(axis_codes[encoderAxis]);
215
+      SERIAL_CHAR(AXIS_CHAR(encoderAxis));
216
       SERIAL_ECHOLNPGM(" axis encoder homed, offset of ", zeroOffset, " ticks.");
216
       SERIAL_ECHOLNPGM(" axis encoder homed, offset of ", zeroOffset, " ticks.");
217
     #endif
217
     #endif
218
   }
218
   }
223
   homed = trusted = false;
223
   homed = trusted = false;
224
 
224
 
225
   #ifdef I2CPE_DEBUG
225
   #ifdef I2CPE_DEBUG
226
-    SERIAL_CHAR(axis_codes[encoderAxis]);
226
+    SERIAL_CHAR(AXIS_CHAR(encoderAxis));
227
     SERIAL_ECHOLNPGM(" axis encoder unhomed.");
227
     SERIAL_ECHOLNPGM(" axis encoder unhomed.");
228
   #endif
228
   #endif
229
 }
229
 }
231
 bool I2CPositionEncoder::passes_test(const bool report) {
231
 bool I2CPositionEncoder::passes_test(const bool report) {
232
   if (report) {
232
   if (report) {
233
     if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
233
     if (H != I2CPE_MAG_SIG_GOOD) SERIAL_ECHOPGM("Warning. ");
234
-    SERIAL_CHAR(axis_codes[encoderAxis]);
234
+    SERIAL_CHAR(AXIS_CHAR(encoderAxis));
235
     serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder "));
235
     serial_ternary(H == I2CPE_MAG_SIG_BAD, F(" axis "), F("magnetic strip "), F("encoder "));
236
     switch (H) {
236
     switch (H) {
237
       case I2CPE_MAG_SIG_GOOD:
237
       case I2CPE_MAG_SIG_GOOD:
252
               error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading
252
               error = ABS(diff) > 10000 ? 0 : diff; // Huge error is a bad reading
253
 
253
 
254
   if (report) {
254
   if (report) {
255
-    SERIAL_CHAR(axis_codes[encoderAxis]);
255
+    SERIAL_CHAR(AXIS_CHAR(encoderAxis));
256
     SERIAL_ECHOLNPGM(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm");
256
     SERIAL_ECHOLNPGM(" axis target=", target, "mm; actual=", actual, "mm; err=", error, "mm");
257
   }
257
   }
258
 
258
 
262
 int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
262
 int32_t I2CPositionEncoder::get_axis_error_steps(const bool report) {
263
   if (!active) {
263
   if (!active) {
264
     if (report) {
264
     if (report) {
265
-      SERIAL_CHAR(axis_codes[encoderAxis]);
265
+      SERIAL_CHAR(AXIS_CHAR(encoderAxis));
266
       SERIAL_ECHOLNPGM(" axis encoder not active!");
266
       SERIAL_ECHOLNPGM(" axis encoder not active!");
267
     }
267
     }
268
     return 0;
268
     return 0;
287
   errorPrev = error;
287
   errorPrev = error;
288
 
288
 
289
   if (report) {
289
   if (report) {
290
-    SERIAL_CHAR(axis_codes[encoderAxis]);
290
+    SERIAL_CHAR(AXIS_CHAR(encoderAxis));
291
     SERIAL_ECHOLNPGM(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error);
291
     SERIAL_ECHOLNPGM(" axis target=", target, "; actual=", encoderCountInStepperTicksScaled, "; err=", error);
292
   }
292
   }
293
 
293
 
657
   else {
657
   else {
658
     if (noOffset) {
658
     if (noOffset) {
659
       const int32_t raw_count = encoders[idx].get_raw_count();
659
       const int32_t raw_count = encoders[idx].get_raw_count();
660
-      SERIAL_CHAR(axis_codes[encoders[idx].get_axis()], ' ');
660
+      SERIAL_CHAR(AXIS_CHAR(encoders[idx).get_axis()], ' ');
661
 
661
 
662
       for (uint8_t j = 31; j > 0; j--)
662
       for (uint8_t j = 31; j > 0; j--)
663
         SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j)));
663
         SERIAL_ECHO((bool)(0x00000001 & (raw_count >> j)));
712
   // and enable it (it will likely have failed initialization on power-up, before the address change).
712
   // and enable it (it will likely have failed initialization on power-up, before the address change).
713
   const int8_t idx = idx_from_addr(newaddr);
713
   const int8_t idx = idx_from_addr(newaddr);
714
   if (idx >= 0 && !encoders[idx].get_active()) {
714
   if (idx >= 0 && !encoders[idx].get_active()) {
715
-    SERIAL_CHAR(axis_codes[encoders[idx].get_axis()]);
715
+    SERIAL_CHAR(AXIS_CHAR(encoders[idx).get_axis()]);
716
     SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again.");
716
     SERIAL_ECHOLNPGM(" axis encoder was not detected on printer startup. Trying again.");
717
     encoders[idx].set_active(encoders[idx].passes_test(true));
717
     encoders[idx].set_active(encoders[idx].passes_test(true));
718
   }
718
   }
814
 
814
 
815
   if (I2CPE_idx == 0xFF) {
815
   if (I2CPE_idx == 0xFF) {
816
     LOOP_LOGICAL_AXES(i) {
816
     LOOP_LOGICAL_AXES(i) {
817
-      if (!I2CPE_anyaxis || parser.seen_test(axis_codes[i])) {
817
+      if (!I2CPE_anyaxis || parser.seen_test(AXIS_CHAR(i))) {
818
         const uint8_t idx = idx_from_axis(AxisEnum(i));
818
         const uint8_t idx = idx_from_axis(AxisEnum(i));
819
         if ((int8_t)idx >= 0) report_position(idx, hasU, hasO);
819
         if ((int8_t)idx >= 0) report_position(idx, hasU, hasO);
820
       }
820
       }
841
 
841
 
842
   if (I2CPE_idx == 0xFF) {
842
   if (I2CPE_idx == 0xFF) {
843
     LOOP_LOGICAL_AXES(i) {
843
     LOOP_LOGICAL_AXES(i) {
844
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
844
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
845
         const uint8_t idx = idx_from_axis(AxisEnum(i));
845
         const uint8_t idx = idx_from_axis(AxisEnum(i));
846
         if ((int8_t)idx >= 0) report_status(idx);
846
         if ((int8_t)idx >= 0) report_status(idx);
847
       }
847
       }
869
 
869
 
870
   if (I2CPE_idx == 0xFF) {
870
   if (I2CPE_idx == 0xFF) {
871
     LOOP_LOGICAL_AXES(i) {
871
     LOOP_LOGICAL_AXES(i) {
872
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
872
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
873
         const uint8_t idx = idx_from_axis(AxisEnum(i));
873
         const uint8_t idx = idx_from_axis(AxisEnum(i));
874
         if ((int8_t)idx >= 0) test_axis(idx);
874
         if ((int8_t)idx >= 0) test_axis(idx);
875
       }
875
       }
900
 
900
 
901
   if (I2CPE_idx == 0xFF) {
901
   if (I2CPE_idx == 0xFF) {
902
     LOOP_LOGICAL_AXES(i) {
902
     LOOP_LOGICAL_AXES(i) {
903
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
903
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
904
         const uint8_t idx = idx_from_axis(AxisEnum(i));
904
         const uint8_t idx = idx_from_axis(AxisEnum(i));
905
         if ((int8_t)idx >= 0) calibrate_steps_mm(idx, iterations);
905
         if ((int8_t)idx >= 0) calibrate_steps_mm(idx, iterations);
906
       }
906
       }
976
 
976
 
977
   if (!I2CPE_addr) {
977
   if (!I2CPE_addr) {
978
     LOOP_LOGICAL_AXES(i) {
978
     LOOP_LOGICAL_AXES(i) {
979
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
979
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
980
         const uint8_t idx = idx_from_axis(AxisEnum(i));
980
         const uint8_t idx = idx_from_axis(AxisEnum(i));
981
         if ((int8_t)idx >= 0) report_module_firmware(encoders[idx].get_address());
981
         if ((int8_t)idx >= 0) report_module_firmware(encoders[idx].get_address());
982
       }
982
       }
1007
 
1007
 
1008
   if (I2CPE_idx == 0xFF) {
1008
   if (I2CPE_idx == 0xFF) {
1009
     LOOP_LOGICAL_AXES(i) {
1009
     LOOP_LOGICAL_AXES(i) {
1010
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
1010
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
1011
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1011
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1012
         if ((int8_t)idx >= 0) {
1012
         if ((int8_t)idx >= 0) {
1013
           if (hasR)
1013
           if (hasR)
1045
 
1045
 
1046
   if (I2CPE_idx == 0xFF) {
1046
   if (I2CPE_idx == 0xFF) {
1047
     LOOP_LOGICAL_AXES(i) {
1047
     LOOP_LOGICAL_AXES(i) {
1048
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
1048
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
1049
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1049
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1050
         if ((int8_t)idx >= 0) {
1050
         if ((int8_t)idx >= 0) {
1051
           const bool ena = onoff == -1 ? !encoders[I2CPE_idx].get_ec_enabled() : !!onoff;
1051
           const bool ena = onoff == -1 ? !encoders[I2CPE_idx].get_ec_enabled() : !!onoff;
1081
 
1081
 
1082
   if (I2CPE_idx == 0xFF) {
1082
   if (I2CPE_idx == 0xFF) {
1083
     LOOP_LOGICAL_AXES(i) {
1083
     LOOP_LOGICAL_AXES(i) {
1084
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
1084
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
1085
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1085
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1086
         if ((int8_t)idx >= 0) {
1086
         if ((int8_t)idx >= 0) {
1087
           if (newThreshold != -9999)
1087
           if (newThreshold != -9999)
1115
 
1115
 
1116
   if (I2CPE_idx == 0xFF) {
1116
   if (I2CPE_idx == 0xFF) {
1117
     LOOP_LOGICAL_AXES(i) {
1117
     LOOP_LOGICAL_AXES(i) {
1118
-      if (!I2CPE_anyaxis || parser.seen(axis_codes[i])) {
1118
+      if (!I2CPE_anyaxis || parser.seen(AXIS_CHAR(i))) {
1119
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1119
         const uint8_t idx = idx_from_axis(AxisEnum(i));
1120
         if ((int8_t)idx >= 0) report_error(idx);
1120
         if ((int8_t)idx >= 0) report_error(idx);
1121
       }
1121
       }

+ 5
- 5
Marlin/src/feature/encoder_i2c.h View File

261
 
261
 
262
     static void report_error_count(const int8_t idx, const AxisEnum axis) {
262
     static void report_error_count(const int8_t idx, const AxisEnum axis) {
263
       CHECK_IDX();
263
       CHECK_IDX();
264
-      SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(axis_codes[axis]), " axis is ", encoders[idx].get_error_count());
264
+      SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(AXIS_CHAR(axis)), " axis is ", encoders[idx].get_error_count());
265
     }
265
     }
266
 
266
 
267
     static void reset_error_count(const int8_t idx, const AxisEnum axis) {
267
     static void reset_error_count(const int8_t idx, const AxisEnum axis) {
268
       CHECK_IDX();
268
       CHECK_IDX();
269
       encoders[idx].set_error_count(0);
269
       encoders[idx].set_error_count(0);
270
-      SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(axis_codes[axis]), " axis has been reset.");
270
+      SERIAL_ECHOLNPGM("Error count on ", AS_CHAR(AXIS_CHAR(axis)), " axis has been reset.");
271
     }
271
     }
272
 
272
 
273
     static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) {
273
     static void enable_ec(const int8_t idx, const bool enabled, const AxisEnum axis) {
274
       CHECK_IDX();
274
       CHECK_IDX();
275
       encoders[idx].set_ec_enabled(enabled);
275
       encoders[idx].set_ec_enabled(enabled);
276
-      SERIAL_ECHOPGM("Error correction on ", AS_CHAR(axis_codes[axis]));
276
+      SERIAL_ECHOPGM("Error correction on ", AS_CHAR(AXIS_CHAR(axis)));
277
       SERIAL_ECHO_TERNARY(encoders[idx].get_ec_enabled(), " axis is ", "en", "dis", "abled.\n");
277
       SERIAL_ECHO_TERNARY(encoders[idx].get_ec_enabled(), " axis is ", "en", "dis", "abled.\n");
278
     }
278
     }
279
 
279
 
280
     static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
280
     static void set_ec_threshold(const int8_t idx, const float newThreshold, const AxisEnum axis) {
281
       CHECK_IDX();
281
       CHECK_IDX();
282
       encoders[idx].set_ec_threshold(newThreshold);
282
       encoders[idx].set_ec_threshold(newThreshold);
283
-      SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis set to ", newThreshold, "mm.");
283
+      SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(AXIS_CHAR(axis)), " axis set to ", newThreshold, "mm.");
284
     }
284
     }
285
 
285
 
286
     static void get_ec_threshold(const int8_t idx, const AxisEnum axis) {
286
     static void get_ec_threshold(const int8_t idx, const AxisEnum axis) {
287
       CHECK_IDX();
287
       CHECK_IDX();
288
       const float threshold = encoders[idx].get_ec_threshold();
288
       const float threshold = encoders[idx].get_ec_threshold();
289
-      SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(axis_codes[axis]), " axis is ", threshold, "mm.");
289
+      SERIAL_ECHOLNPGM("Error correct threshold for ", AS_CHAR(AXIS_CHAR(axis)), " axis is ", threshold, "mm.");
290
     }
290
     }
291
 
291
 
292
     static int8_t idx_from_axis(const AxisEnum axis) {
292
     static int8_t idx_from_axis(const AxisEnum axis) {

+ 2
- 2
Marlin/src/gcode/config/M200-M205.cpp View File

125
   #endif
125
   #endif
126
 
126
 
127
   LOOP_LOGICAL_AXES(i) {
127
   LOOP_LOGICAL_AXES(i) {
128
-    if (parser.seenval(axis_codes[i])) {
128
+    if (parser.seenval(AXIS_CHAR(i))) {
129
       const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
129
       const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
130
       planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
130
       planner.set_max_acceleration(a, parser.value_axis_units((AxisEnum)a));
131
     }
131
     }
174
   if (target_extruder < 0) return;
174
   if (target_extruder < 0) return;
175
 
175
 
176
   LOOP_LOGICAL_AXES(i)
176
   LOOP_LOGICAL_AXES(i)
177
-    if (parser.seenval(axis_codes[i])) {
177
+    if (parser.seenval(AXIS_CHAR(i))) {
178
       const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
178
       const uint8_t a = TERN(HAS_EXTRUDERS, (i == E_AXIS ? uint8_t(E_AXIS_N(target_extruder)) : i), i);
179
       planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
179
       planner.set_max_feedrate(a, parser.value_axis_units((AxisEnum)a));
180
     }
180
     }

+ 1
- 1
Marlin/src/gcode/config/M92.cpp View File

47
     return M92_report(true, target_extruder);
47
     return M92_report(true, target_extruder);
48
 
48
 
49
   LOOP_LOGICAL_AXES(i) {
49
   LOOP_LOGICAL_AXES(i) {
50
-    if (parser.seenval(axis_codes[i])) {
50
+    if (parser.seenval(AXIS_CHAR(i))) {
51
       if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
51
       if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
52
         planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i);
52
         planner.settings.axis_steps_per_mm[i] = parser.value_per_axis_units((AxisEnum)i);
53
       else {
53
       else {

+ 3
- 3
Marlin/src/gcode/control/M17_M18_M84.cpp View File

75
   LOOP_NUM_AXES(a) {
75
   LOOP_NUM_AXES(a) {
76
     if (TEST(shall_enable, a)) {
76
     if (TEST(shall_enable, a)) {
77
       stepper.enable_axis(AxisEnum(a));         // Mark and enable the requested axis
77
       stepper.enable_axis(AxisEnum(a));         // Mark and enable the requested axis
78
-      DEBUG_ECHOLNPGM("Enabled ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits));
78
+      DEBUG_ECHOLNPGM("Enabled ", AXIS_CHAR(a), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... Enabled: ", hex_word(stepper.axis_enabled.bits));
79
       also_enabled |= enable_overlap[a];
79
       also_enabled |= enable_overlap[a];
80
     }
80
     }
81
   }
81
   }
157
   // Attempt to disable all flagged axes
157
   // Attempt to disable all flagged axes
158
   LOOP_NUM_AXES(a)
158
   LOOP_NUM_AXES(a)
159
     if (TEST(to_disable.bits, a)) {
159
     if (TEST(to_disable.bits, a)) {
160
-      DEBUG_ECHOPGM("Try to disable ", axis_codes[a], " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... ");
160
+      DEBUG_ECHOPGM("Try to disable ", AXIS_CHAR(a), " (", a, ") with overlap ", hex_word(enable_overlap[a]), " ... ");
161
       if (stepper.disable_axis(AxisEnum(a))) {            // Mark the requested axis and request to disable
161
       if (stepper.disable_axis(AxisEnum(a))) {            // Mark the requested axis and request to disable
162
         DEBUG_ECHOPGM("OK");
162
         DEBUG_ECHOPGM("OK");
163
         still_enabled &= ~(_BV(a) | enable_overlap[a]);   // If actually disabled, clear one or more tracked bits
163
         still_enabled &= ~(_BV(a) | enable_overlap[a]);   // If actually disabled, clear one or more tracked bits
195
   // If any of the requested axes are still enabled, give a warning
195
   // If any of the requested axes are still enabled, give a warning
196
   LOOP_NUM_AXES(a) {
196
   LOOP_NUM_AXES(a) {
197
     if (TEST(still_enabled, a)) {
197
     if (TEST(still_enabled, a)) {
198
-      SERIAL_CHAR(axis_codes[a]);
198
+      SERIAL_CHAR(AXIS_CHAR(a));
199
       overlap_warning(stepper.axis_enabled.bits & enable_overlap[a]);
199
       overlap_warning(stepper.axis_enabled.bits & enable_overlap[a]);
200
     }
200
     }
201
   }
201
   }

+ 4
- 4
Marlin/src/gcode/control/M350_M351.cpp View File

40
 }
40
 }
41
 
41
 
42
 /**
42
 /**
43
- * M351: Toggle MS1 MS2 pins directly with axis codes X Y Z E B
43
+ * M351: Toggle MS1 MS2 pins directly with axis codes X Y Z . . . E [B]
44
  *       S# determines MS1, MS2 or MS3, X# sets the pin high/low.
44
  *       S# determines MS1, MS2 or MS3, X# sets the pin high/low.
45
  */
45
  */
46
 void GcodeSuite::M351() {
46
 void GcodeSuite::M351() {
47
   if (parser.seenval('S')) switch (parser.value_byte()) {
47
   if (parser.seenval('S')) switch (parser.value_byte()) {
48
     case 1:
48
     case 1:
49
-      LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
49
+      LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, parser.value_byte(), -1, -1);
50
       if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1);
50
       if (parser.seenval('B')) stepper.microstep_ms(4, parser.value_byte(), -1, -1);
51
       break;
51
       break;
52
     case 2:
52
     case 2:
53
-      LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
53
+      LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, parser.value_byte(), -1);
54
       if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1);
54
       if (parser.seenval('B')) stepper.microstep_ms(4, -1, parser.value_byte(), -1);
55
       break;
55
       break;
56
     case 3:
56
     case 3:
57
-      LOOP_LOGICAL_AXES(i) if (parser.seenval(axis_codes[i])) stepper.microstep_ms(i, -1, -1, parser.value_byte());
57
+      LOOP_LOGICAL_AXES(i) if (parser.seenval(AXIS_CHAR(i))) stepper.microstep_ms(i, -1, -1, parser.value_byte());
58
       if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte());
58
       if (parser.seenval('B')) stepper.microstep_ms(4, -1, -1, parser.value_byte());
59
       break;
59
       break;
60
   }
60
   }

+ 2
- 2
Marlin/src/gcode/feature/L6470/M906.cpp View File

211
  *     1 - monitor only X2, Y2, Z2
211
  *     1 - monitor only X2, Y2, Z2
212
  *     2 - monitor only Z3
212
  *     2 - monitor only Z3
213
  *     3 - monitor only Z4
213
  *     3 - monitor only Z4
214
- * Xxxx, Yxxx, Zxxx, Exxx - axis to change (optional)
214
+ * Xxxx, Yxxx, Zxxx, Axxx, Bxxx, Cxxx, Uxxx, Vxxx, Wxxx, Exxx - axis to change (optional)
215
  *     L6474 - current in mA (4A max)
215
  *     L6474 - current in mA (4A max)
216
  *     All others - 0-255
216
  *     All others - 0-255
217
  *
217
  *
236
     constexpr int8_t index = -1;
236
     constexpr int8_t index = -1;
237
   #endif
237
   #endif
238
 
238
 
239
-  LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) {
239
+  LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) {
240
 
240
 
241
     report_current = false;
241
     report_current = false;
242
 
242
 

+ 1
- 1
Marlin/src/gcode/feature/trinamic/M122.cpp View File

35
   xyze_bool_t print_axis = ARRAY_N_1(LOGICAL_AXES, false);
35
   xyze_bool_t print_axis = ARRAY_N_1(LOGICAL_AXES, false);
36
 
36
 
37
   bool print_all = true;
37
   bool print_all = true;
38
-  LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) { print_axis[i] = true; print_all = false; }
38
+  LOOP_LOGICAL_AXES(i) if (parser.seen_test(AXIS_CHAR(i))) { print_axis[i] = true; print_all = false; }
39
 
39
 
40
   if (print_all) LOOP_LOGICAL_AXES(i) print_axis[i] = true;
40
   if (print_all) LOOP_LOGICAL_AXES(i) print_axis[i] = true;
41
 
41
 

+ 1
- 1
Marlin/src/gcode/feature/trinamic/M569.cpp View File

53
     constexpr int8_t index = -1;
53
     constexpr int8_t index = -1;
54
   #endif
54
   #endif
55
 
55
 
56
-  LOOP_LOGICAL_AXES(i) if (parser.seen(axis_codes[i])) {
56
+  LOOP_LOGICAL_AXES(i) if (parser.seen(AXIS_CHAR(i))) {
57
     switch (i) {
57
     switch (i) {
58
       case X_AXIS:
58
       case X_AXIS:
59
         TERN_(X_HAS_STEALTHCHOP,  if (index < 0 || index == 0) TMC_SET_STEALTH(X));
59
         TERN_(X_HAS_STEALTHCHOP,  if (index < 0 || index == 0) TMC_SET_STEALTH(X));

+ 1
- 1
Marlin/src/gcode/feature/trinamic/M906.cpp View File

66
     constexpr int8_t index = -1;
66
     constexpr int8_t index = -1;
67
   #endif
67
   #endif
68
 
68
 
69
-  LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(axis_codes[i])) {
69
+  LOOP_LOGICAL_AXES(i) if (uint16_t value = parser.intval(AXIS_CHAR(i))) {
70
     report = false;
70
     report = false;
71
     switch (i) {
71
     switch (i) {
72
       #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)
72
       #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)

+ 1
- 1
Marlin/src/gcode/feature/trinamic/M911-M914.cpp View File

288
     #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z)
288
     #elif AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z)
289
       constexpr int8_t index = -1;
289
       constexpr int8_t index = -1;
290
     #endif
290
     #endif
291
-    LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(axis_codes[i])) {
291
+    LOOP_LOGICAL_AXES(i) if (int32_t value = parser.longval(AXIS_CHAR(i))) {
292
       report = false;
292
       report = false;
293
       switch (i) {
293
       switch (i) {
294
         #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP
294
         #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP

+ 2
- 2
Marlin/src/gcode/feature/trinamic/M919.cpp View File

112
     int8_t eindex = -1;
112
     int8_t eindex = -1;
113
   #endif
113
   #endif
114
   bool report = true;
114
   bool report = true;
115
-  LOOP_LOGICAL_AXES(i) if (parser.seen_test(axis_codes[i])) {
115
+  LOOP_LOGICAL_AXES(i) if (parser.seen_test(AXIS_CHAR(i))) {
116
     report = false;
116
     report = false;
117
 
117
 
118
     // Get the chopper timing for the specified axis and index
118
     // Get the chopper timing for the specified axis and index
119
     switch (i) {
119
     switch (i) {
120
       default: // A specified axis isn't Trinamic
120
       default: // A specified axis isn't Trinamic
121
-        SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(axis_codes[i]), " has no TMC drivers.");
121
+        SERIAL_ECHOLNPGM("?Axis ", AS_CHAR(AXIS_CHAR(i)), " has no TMC drivers.");
122
         break;
122
         break;
123
 
123
 
124
       #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)
124
       #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)

+ 2
- 2
Marlin/src/gcode/geometry/G92.cpp View File

74
     #if ENABLED(POWER_LOSS_RECOVERY)
74
     #if ENABLED(POWER_LOSS_RECOVERY)
75
       case 9:                                                         // G92.9 - Set Current Position directly (like Marlin 1.0)
75
       case 9:                                                         // G92.9 - Set Current Position directly (like Marlin 1.0)
76
         LOOP_LOGICAL_AXES(i) {
76
         LOOP_LOGICAL_AXES(i) {
77
-          if (parser.seenval(axis_codes[i])) {
77
+          if (parser.seenval(AXIS_CHAR(i))) {
78
             if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
78
             if (TERN1(HAS_EXTRUDERS, i != E_AXIS))
79
               sync_XYZE = true;
79
               sync_XYZE = true;
80
             else {
80
             else {
88
 
88
 
89
     case 0:
89
     case 0:
90
       LOOP_LOGICAL_AXES(i) {
90
       LOOP_LOGICAL_AXES(i) {
91
-        if (parser.seenval(axis_codes[i])) {
91
+        if (parser.seenval(AXIS_CHAR(i))) {
92
           const float l = parser.value_axis_units((AxisEnum)i),       // Given axis coordinate value, converted to millimeters
92
           const float l = parser.value_axis_units((AxisEnum)i),       // Given axis coordinate value, converted to millimeters
93
                       v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i),  // Axis position in NATIVE space (applying the existing offset)
93
                       v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i),  // Axis position in NATIVE space (applying the existing offset)
94
                       d = v - current_position[i];                    // How much is the current axis position altered by?
94
                       d = v - current_position[i];                    // How much is the current axis position altered by?

+ 1
- 1
Marlin/src/lcd/dogm/status_screen_DOGM.cpp View File

432
   const bool is_inch = parser.using_inch_units();
432
   const bool is_inch = parser.using_inch_units();
433
   const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
433
   const AxisEnum a = TERN(LCD_SHOW_E_TOTAL, axis == E_AXIS ? X_AXIS : axis, axis);
434
   const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING);
434
   const uint8_t offs = a * (is_inch ? XYZ_SPACING_IN : XYZ_SPACING);
435
-  lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, axis_codes[axis]);
435
+  lcd_put_wchar((is_inch ? X_LABEL_POS_IN : X_LABEL_POS) + offs, XYZ_BASELINE, AXIS_CHAR(axis));
436
   lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE);
436
   lcd_moveto((is_inch ? X_VALUE_POS_IN : X_VALUE_POS) + offs, XYZ_BASELINE);
437
 
437
 
438
   if (blink)
438
   if (blink)

+ 1
- 1
Marlin/src/lcd/e3v2/marlinui/dwin_string.cpp View File

70
     else if (ch == '$' && itemString)
70
     else if (ch == '$' && itemString)
71
       add(itemString);
71
       add(itemString);
72
     else if (ch == '@')
72
     else if (ch == '@')
73
-      add_character(axis_codes[index]);
73
+      add_character(AXIS_CHAR(index));
74
     else
74
     else
75
       add_character(ch);
75
       add_character(ch);
76
   }
76
   }

+ 1
- 1
Marlin/src/lcd/lcdprint.cpp View File

75
       n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
75
       n -= lcd_put_u8str_max_P(inStr, n * (MENU_FONT_WIDTH)) / (MENU_FONT_WIDTH);
76
     }
76
     }
77
     else if (ch == '@') {
77
     else if (ch == '@') {
78
-      lcd_put_wchar(axis_codes[ind]);
78
+      lcd_put_wchar(AXIS_CHAR(ind));
79
       n--;
79
       n--;
80
     }
80
     }
81
     else {
81
     else {

+ 2
- 2
Marlin/src/lcd/marlinui.cpp View File

831
             TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder
831
             TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder
832
           );
832
           );
833
 
833
 
834
-          //SERIAL_ECHOLNPGM("Add planner.move with Axis ", AS_CHAR(axis_codes[axis]), " at FR ", fr_mm_s);
834
+          //SERIAL_ECHOLNPGM("Add planner.move with Axis ", AS_CHAR(AXIS_CHAR(axis)), " at FR ", fr_mm_s);
835
 
835
 
836
           axis = NO_AXIS_ENUM;
836
           axis = NO_AXIS_ENUM;
837
 
837
 
848
       TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex);
848
       TERN_(MULTI_E_MANUAL, if (move_axis == E_AXIS) e_index = eindex);
849
       start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
849
       start_time = millis() + (menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
850
       axis = move_axis;
850
       axis = move_axis;
851
-      //SERIAL_ECHOLNPGM("Post Move with Axis ", AS_CHAR(axis_codes[axis]), " soon.");
851
+      //SERIAL_ECHOLNPGM("Post Move with Axis ", AS_CHAR(AXIS_CHAR(axis)), " soon.");
852
     }
852
     }
853
 
853
 
854
     #if ENABLED(AUTO_BED_LEVELING_UBL)
854
     #if ENABLED(AUTO_BED_LEVELING_UBL)

+ 1
- 1
Marlin/src/lcd/tft/tft_string.cpp View File

116
     else if (ch == '$' && itemString)
116
     else if (ch == '$' && itemString)
117
       add(itemString);
117
       add(itemString);
118
     else if (ch == '@')
118
     else if (ch == '@')
119
-      add_character(axis_codes[index]);
119
+      add_character(AXIS_CHAR(index));
120
     else
120
     else
121
       add_character(ch);
121
       add_character(ch);
122
   }
122
   }

+ 3
- 3
Marlin/src/libs/L64XX/L64XX_Marlin.cpp View File

412
   }
412
   }
413
 
413
 
414
   uint8_t found_displacement = false;
414
   uint8_t found_displacement = false;
415
-  LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(axis_codes[i])) {
415
+  LOOP_LOGICAL_AXES(i) if (uint16_t _displacement = parser.intval(AXIS_CHAR(i))) {
416
     found_displacement = true;
416
     found_displacement = true;
417
     displacement = _displacement;
417
     displacement = _displacement;
418
     const uint8_t axis_offset = parser.byteval('J');
418
     const uint8_t axis_offset = parser.byteval('J');
419
-    axis_mon[0][0] = axis_codes[i];         // Axis first character, one of XYZ...E
419
+    axis_mon[0][0] = AXIS_CHAR(i);          // Axis first character, one of XYZ...E
420
     const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E',
420
     const bool single_or_e = axis_offset >= 2 || axis_mon[0][0] == 'E',
421
                one_or_more = !single_or_e && axis_offset == 0;
421
                one_or_more = !single_or_e && axis_offset == 0;
422
     uint8_t driver_count_local = 0;         // Can't use "driver_count" directly as a subscript because it's passed by reference
422
     uint8_t driver_count_local = 0;         // Can't use "driver_count" directly as a subscript because it's passed by reference
667
     static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
667
     static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE;
668
     const uint8_t num_feedrates = COUNT(default_max_feedrate);
668
     const uint8_t num_feedrates = COUNT(default_max_feedrate);
669
     for (j = 0; j < num_feedrates; j++) {
669
     for (j = 0; j < num_feedrates; j++) {
670
-      if (axis_codes[j] == axis_mon[0][0]) {
670
+      if (AXIS_CHAR(j) == axis_mon[0][0]) {
671
         final_feedrate = default_max_feedrate[j];
671
         final_feedrate = default_max_feedrate[j];
672
         break;
672
         break;
673
       }
673
       }

Loading…
Cancel
Save