Browse Source

XYZ_CHAR macro

Scott Lahteine 4 years ago
parent
commit
c4db8e49a7

+ 1
- 0
Marlin/src/core/types.h View File

@@ -483,3 +483,4 @@ struct XYZEval {
483 483
 #undef FI
484 484
 
485 485
 const xyze_char_t axis_codes { 'X', 'Y', 'Z', 'E' };
486
+#define XYZ_CHAR(A) ('X' + char(A))

+ 12
- 12
Marlin/src/core/utility.cpp View File

@@ -139,17 +139,17 @@ void safe_delay(millis_t ms) {
139 139
     #endif
140 140
 
141 141
     #if HAS_ABL_OR_UBL
142
-      SERIAL_ECHOLNPGM("Auto Bed Leveling: "
143
-        #if ENABLED(AUTO_BED_LEVELING_LINEAR)
144
-          "LINEAR"
145
-        #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
146
-          "BILINEAR"
147
-        #elif ENABLED(AUTO_BED_LEVELING_3POINT)
148
-          "3POINT"
149
-        #elif ENABLED(AUTO_BED_LEVELING_UBL)
150
-          "UBL"
151
-        #endif
152
-      );
142
+      SERIAL_ECHOPGM("Auto Bed Leveling: ");
143
+      #if ENABLED(AUTO_BED_LEVELING_LINEAR)
144
+        SERIAL_ECHOLNPGM("LINEAR");
145
+      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
146
+        SERIAL_ECHOLNPGM("BILINEAR");
147
+      #elif ENABLED(AUTO_BED_LEVELING_3POINT)
148
+        SERIAL_ECHOLNPGM("3POINT");
149
+      #elif ENABLED(AUTO_BED_LEVELING_UBL)
150
+        SERIAL_ECHOLNPGM("UBL");
151
+      #endif
152
+
153 153
       if (planner.leveling_active) {
154 154
         SERIAL_ECHOLNPGM(" (enabled)");
155 155
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
@@ -160,7 +160,7 @@ void safe_delay(millis_t ms) {
160 160
           SERIAL_ECHOPGM("ABL Adjustment X");
161 161
           LOOP_XYZ(a) {
162 162
             float v = planner.get_axis_position_mm(AxisEnum(a)) - current_position[a];
163
-            SERIAL_CHAR(' ', 'X' + char(a));
163
+            SERIAL_CHAR(' ', XYZ_CHAR(a));
164 164
             if (v > 0) SERIAL_CHAR('+');
165 165
             SERIAL_ECHO(v);
166 166
           }

+ 3
- 3
Marlin/src/gcode/calibrate/M425.cpp View File

@@ -47,7 +47,7 @@ void GcodeSuite::M425() {
47 47
   bool noArgs = true;
48 48
 
49 49
   LOOP_XYZ(a) {
50
-    if (parser.seen(axis_codes[a])) {
50
+    if (parser.seen(XYZ_CHAR(a))) {
51 51
       planner.synchronize();
52 52
       backlash.distance_mm[a] = parser.has_value() ? parser.value_linear_units() : backlash.get_measurement(AxisEnum(a));
53 53
       noArgs = false;
@@ -75,7 +75,7 @@ void GcodeSuite::M425() {
75 75
     SERIAL_ECHOLNPAIR("  Correction Amount/Fade-out:     F", backlash.get_correction(), " (F1.0 = full, F0.0 = none)");
76 76
     SERIAL_ECHOPGM("  Backlash Distance (mm):        ");
77 77
     LOOP_XYZ(a) {
78
-      SERIAL_CHAR(' ', axis_codes[a]);
78
+      SERIAL_CHAR(' ', XYZ_CHAR(a));
79 79
       SERIAL_ECHO(backlash.distance_mm[a]);
80 80
       SERIAL_EOL();
81 81
     }
@@ -88,7 +88,7 @@ void GcodeSuite::M425() {
88 88
       SERIAL_ECHOPGM("  Average measured backlash (mm):");
89 89
       if (backlash.has_any_measurement()) {
90 90
         LOOP_XYZ(a) if (backlash.has_measurement(AxisEnum(a))) {
91
-          SERIAL_CHAR(' ', axis_codes[a]);
91
+          SERIAL_CHAR(' ', XYZ_CHAR(a));
92 92
           SERIAL_ECHO(backlash.get_measurement(AxisEnum(a)));
93 93
         }
94 94
       }

+ 2
- 2
Marlin/src/gcode/calibrate/M666.cpp View File

@@ -40,10 +40,10 @@
40 40
   void GcodeSuite::M666() {
41 41
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(">>> M666");
42 42
     LOOP_XYZ(i) {
43
-      if (parser.seen(axis_codes[i])) {
43
+      if (parser.seen(XYZ_CHAR(i))) {
44 44
         const float v = parser.value_linear_units();
45 45
         if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
46
-        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", axis_codes[i], "] = ", delta_endstop_adj[i]);
46
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", XYZ_CHAR(i), "] = ", delta_endstop_adj[i]);
47 47
       }
48 48
     }
49 49
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< M666");

+ 1
- 1
Marlin/src/gcode/control/M605.cpp View File

@@ -138,7 +138,7 @@
138 138
 
139 139
         HOTEND_LOOP() {
140 140
           DEBUG_ECHOPAIR_P(SP_T_STR, int(e));
141
-          LOOP_XYZ(a) DEBUG_ECHOPAIR("  hotend_offset[", int(e), "].", axis_codes[a] | 0x20, "=", hotend_offset[e][a]);
141
+          LOOP_XYZ(a) DEBUG_ECHOPAIR("  hotend_offset[", int(e), "].", XYZ_CHAR(a) | 0x20, "=", hotend_offset[e][a]);
142 142
           DEBUG_EOL();
143 143
         }
144 144
         DEBUG_EOL();

+ 2
- 2
Marlin/src/gcode/feature/pause/G61.cpp View File

@@ -56,10 +56,10 @@ void GcodeSuite::G61(void) {
56 56
 
57 57
   SERIAL_ECHOPAIR(STR_RESTORING_POS " S", int(slot));
58 58
   LOOP_XYZ(i) {
59
-    destination[i] = parser.seen(axis_codes[i])
59
+    destination[i] = parser.seen(XYZ_CHAR(i))
60 60
       ? stored_position[slot][i] + parser.value_axis_units((AxisEnum)i)
61 61
       : current_position[i];
62
-    SERIAL_CHAR(' ', axis_codes[i]);
62
+    SERIAL_CHAR(' ', XYZ_CHAR(i));
63 63
     SERIAL_ECHO_F(destination[i]);
64 64
   }
65 65
   SERIAL_EOL();

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

@@ -348,7 +348,7 @@
348 348
 
349 349
     bool report = true;
350 350
     const uint8_t index = parser.byteval('I');
351
-    LOOP_XYZ(i) if (parser.seen(axis_codes[i])) {
351
+    LOOP_XYZ(i) if (parser.seen(XYZ_CHAR(i))) {
352 352
       const int16_t value = parser.value_int();
353 353
       report = false;
354 354
       switch (i) {

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

@@ -135,7 +135,7 @@ void GcodeSuite::get_destination_from_command() {
135 135
 
136 136
   // Get new XYZ position, whether absolute or relative
137 137
   LOOP_XYZ(i) {
138
-    if ( (seen[i] = parser.seenval(axis_codes[i])) ) {
138
+    if ( (seen[i] = parser.seenval(XYZ_CHAR(i))) ) {
139 139
       const float v = parser.value_axis_units((AxisEnum)i);
140 140
       if (skip_move)
141 141
         destination[i] = current_position[i];

+ 1
- 1
Marlin/src/gcode/geometry/M206_M428.cpp View File

@@ -38,7 +38,7 @@
38 38
  */
39 39
 void GcodeSuite::M206() {
40 40
   LOOP_XYZ(i)
41
-    if (parser.seen(axis_codes[i]))
41
+    if (parser.seen(XYZ_CHAR(i)))
42 42
       set_home_offset((AxisEnum)i, parser.value_linear_units());
43 43
 
44 44
   #if ENABLED(MORGAN_SCARA)

+ 2
- 2
Marlin/src/gcode/host/M114.cpp View File

@@ -45,8 +45,8 @@
45 45
 
46 46
   void report_xyz(const xyz_pos_t &pos, const uint8_t precision=3) {
47 47
     char str[12];
48
-    for (uint8_t a = X_AXIS; a <= Z_AXIS; a++) {
49
-      SERIAL_CHAR(' ', axis_codes[a], ':');
48
+    LOOP_XYZ(a) {
49
+      SERIAL_CHAR(' ', XYZ_CHAR(a), ':');
50 50
       SERIAL_ECHO(dtostrf(pos[a], 1, precision, str));
51 51
     }
52 52
     SERIAL_EOL();

+ 2
- 2
Marlin/src/gcode/motion/M290.cpp View File

@@ -76,8 +76,8 @@
76 76
  */
77 77
 void GcodeSuite::M290() {
78 78
   #if ENABLED(BABYSTEP_XY)
79
-    for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
80
-      if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
79
+    LOOP_XYZ(a)
80
+      if (parser.seenval(XYZ_CHAR(a)) || (a == Z_AXIS && parser.seenval('S'))) {
81 81
         const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
82 82
         babystep.add_mm((AxisEnum)a, offs);
83 83
         #if ENABLED(BABYSTEP_ZPROBE_OFFSET)

+ 2
- 2
Marlin/src/module/motion.cpp View File

@@ -587,7 +587,7 @@ void restore_feedrate_and_scaling() {
587 587
     #endif
588 588
 
589 589
   if (DEBUGGING(LEVELING))
590
-    SERIAL_ECHOLNPAIR("Axis ", axis_codes[axis], " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]);
590
+    SERIAL_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " min:", soft_endstop.min[axis], " max:", soft_endstop.max[axis]);
591 591
 }
592 592
 
593 593
   /**
@@ -1779,7 +1779,7 @@ void homeaxis(const AxisEnum axis) {
1779 1779
 #if HAS_WORKSPACE_OFFSET
1780 1780
   void update_workspace_offset(const AxisEnum axis) {
1781 1781
     workspace_offset[axis] = home_offset[axis] + position_shift[axis];
1782
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", axis_codes[axis], " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]);
1782
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", XYZ_CHAR(axis), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]);
1783 1783
   }
1784 1784
 #endif
1785 1785
 

Loading…
Cancel
Save