Browse Source

Move extended_axis_codes to PROGMEM

Scott Lahteine 7 years ago
parent
commit
e28e3bb532

+ 48
- 39
Marlin/src/feature/tmc_util.cpp View File

37
 #endif
37
 #endif
38
 
38
 
39
 bool report_tmc_status = false;
39
 bool report_tmc_status = false;
40
-char extended_axis_codes[11][3] = { "X", "X2", "Y", "Y2", "Z", "Z2", "E0", "E1", "E2", "E3", "E4" };
41
 
40
 
42
 /**
41
 /**
43
  * Check for over temperature or short to ground error flags.
42
  * Check for over temperature or short to ground error flags.
96
   #endif
95
   #endif
97
 
96
 
98
   template<typename TMC>
97
   template<typename TMC>
99
-  void monitor_tmc_driver(TMC &st, const char * const axisName, uint8_t &otpw_cnt) {
98
+  void monitor_tmc_driver(TMC &st, const TMC_AxisEnum axis, uint8_t &otpw_cnt) {
100
     TMC_driver_data data = get_driver_data(st);
99
     TMC_driver_data data = get_driver_data(st);
101
 
100
 
102
     #if ENABLED(STOP_ON_ERROR)
101
     #if ENABLED(STOP_ON_ERROR)
103
       if (data.is_error) {
102
       if (data.is_error) {
104
         SERIAL_EOL();
103
         SERIAL_EOL();
105
-        SERIAL_ECHO(axisName);
106
-        SERIAL_ECHOPGM(" driver error detected:");
107
-        if (data.is_ot) SERIAL_ECHOPGM("\novertemperature");
108
-        if (st.s2ga()) SERIAL_ECHOPGM("\nshort to ground (coil A)");
109
-        if (st.s2gb()) SERIAL_ECHOPGM("\nshort to ground (coil B)");
110
-        SERIAL_EOL();
104
+        _tmc_say_axis(axis);
105
+        SERIAL_ECHOLNPGM(" driver error detected:");
106
+        if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature");
107
+        if (st.s2ga()) SERIAL_ECHOLNPGM("short to ground (coil A)");
108
+        if (st.s2gb()) SERIAL_ECHOLNPGM("short to ground (coil B)");
111
         #if ENABLED(TMC_DEBUG)
109
         #if ENABLED(TMC_DEBUG)
112
           tmc_report_all();
110
           tmc_report_all();
113
         #endif
111
         #endif
124
       SERIAL_EOL();
122
       SERIAL_EOL();
125
       SERIAL_ECHO(timestamp);
123
       SERIAL_ECHO(timestamp);
126
       SERIAL_ECHOPGM(": ");
124
       SERIAL_ECHOPGM(": ");
127
-      SERIAL_ECHO(axisName);
125
+      _tmc_say_axis(axis);
128
       SERIAL_ECHOPGM(" driver overtemperature warning! (");
126
       SERIAL_ECHOPGM(" driver overtemperature warning! (");
129
       SERIAL_ECHO(st.getCurrent());
127
       SERIAL_ECHO(st.getCurrent());
130
       SERIAL_ECHOLNPGM("mA)");
128
       SERIAL_ECHOLNPGM("mA)");
134
       if (data.is_otpw && !st.isEnabled() && otpw_cnt > 4) {
132
       if (data.is_otpw && !st.isEnabled() && otpw_cnt > 4) {
135
         st.setCurrent(st.getCurrent() - CURRENT_STEP_DOWN, R_SENSE, HOLD_MULTIPLIER);
133
         st.setCurrent(st.getCurrent() - CURRENT_STEP_DOWN, R_SENSE, HOLD_MULTIPLIER);
136
         #if ENABLED(REPORT_CURRENT_CHANGE)
134
         #if ENABLED(REPORT_CURRENT_CHANGE)
137
-          SERIAL_ECHO(axisName);
135
+          _tmc_say_axis(axis);
138
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent());
136
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent());
139
         #endif
137
         #endif
140
       }
138
       }
148
 
146
 
149
     if (report_tmc_status) {
147
     if (report_tmc_status) {
150
       const uint32_t pwm_scale = get_pwm_scale(st);
148
       const uint32_t pwm_scale = get_pwm_scale(st);
151
-      SERIAL_ECHO(axisName);
149
+      _tmc_say_axis(axis);
152
       SERIAL_ECHOPAIR(":", pwm_scale);
150
       SERIAL_ECHOPAIR(":", pwm_scale);
153
       SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
151
       SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
154
       SERIAL_ECHOPGM("| ");
152
       SERIAL_ECHOPGM("| ");
169
       next_cOT = millis() + 500;
167
       next_cOT = millis() + 500;
170
       #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS)
168
       #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS)
171
         static uint8_t x_otpw_cnt = 0;
169
         static uint8_t x_otpw_cnt = 0;
172
-        monitor_tmc_driver(stepperX, extended_axis_codes[TMC_X], x_otpw_cnt);
170
+        monitor_tmc_driver(stepperX, TMC_X, x_otpw_cnt);
173
       #endif
171
       #endif
174
       #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS)
172
       #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS)
175
         static uint8_t y_otpw_cnt = 0;
173
         static uint8_t y_otpw_cnt = 0;
176
-        monitor_tmc_driver(stepperY, extended_axis_codes[TMC_Y], y_otpw_cnt);
174
+        monitor_tmc_driver(stepperY, TMC_Y, y_otpw_cnt);
177
       #endif
175
       #endif
178
       #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS)
176
       #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS)
179
         static uint8_t z_otpw_cnt = 0;
177
         static uint8_t z_otpw_cnt = 0;
180
-        monitor_tmc_driver(stepperZ, extended_axis_codes[TMC_Z], z_otpw_cnt);
178
+        monitor_tmc_driver(stepperZ, TMC_Z, z_otpw_cnt);
181
       #endif
179
       #endif
182
       #if HAS_HW_COMMS(X2)
180
       #if HAS_HW_COMMS(X2)
183
         static uint8_t x2_otpw_cnt = 0;
181
         static uint8_t x2_otpw_cnt = 0;
184
-        monitor_tmc_driver(stepperX2, extended_axis_codes[TMC_X], x2_otpw_cnt);
182
+        monitor_tmc_driver(stepperX2, TMC_X, x2_otpw_cnt);
185
       #endif
183
       #endif
186
       #if HAS_HW_COMMS(Y2)
184
       #if HAS_HW_COMMS(Y2)
187
         static uint8_t y2_otpw_cnt = 0;
185
         static uint8_t y2_otpw_cnt = 0;
188
-        monitor_tmc_driver(stepperY2, extended_axis_codes[TMC_Y], y2_otpw_cnt);
186
+        monitor_tmc_driver(stepperY2, TMC_Y, y2_otpw_cnt);
189
       #endif
187
       #endif
190
       #if HAS_HW_COMMS(Z2)
188
       #if HAS_HW_COMMS(Z2)
191
         static uint8_t z2_otpw_cnt = 0;
189
         static uint8_t z2_otpw_cnt = 0;
192
-        monitor_tmc_driver(stepperZ2, extended_axis_codes[TMC_Z], z2_otpw_cnt);
190
+        monitor_tmc_driver(stepperZ2, TMC_Z, z2_otpw_cnt);
193
       #endif
191
       #endif
194
       #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS)
192
       #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS)
195
         static uint8_t e0_otpw_cnt = 0;
193
         static uint8_t e0_otpw_cnt = 0;
196
-        monitor_tmc_driver(stepperE0, extended_axis_codes[TMC_E0], e0_otpw_cnt);
194
+        monitor_tmc_driver(stepperE0, TMC_E0, e0_otpw_cnt);
197
       #endif
195
       #endif
198
       #if HAS_HW_COMMS(E1)
196
       #if HAS_HW_COMMS(E1)
199
         static uint8_t e1_otpw_cnt = 0;
197
         static uint8_t e1_otpw_cnt = 0;
200
-        monitor_tmc_driver(stepperE1, extended_axis_codes[TMC_E1], e1_otpw_cnt);
198
+        monitor_tmc_driver(stepperE1, TMC_E1, e1_otpw_cnt);
201
       #endif
199
       #endif
202
       #if HAS_HW_COMMS(E2)
200
       #if HAS_HW_COMMS(E2)
203
         static uint8_t e2_otpw_cnt = 0;
201
         static uint8_t e2_otpw_cnt = 0;
204
-        monitor_tmc_driver(stepperE2, extended_axis_codes[TMC_E2], e2_otpw_cnt);
202
+        monitor_tmc_driver(stepperE2, TMC_E2, e2_otpw_cnt);
205
       #endif
203
       #endif
206
       #if HAS_HW_COMMS(E3)
204
       #if HAS_HW_COMMS(E3)
207
         static uint8_t e3_otpw_cnt = 0;
205
         static uint8_t e3_otpw_cnt = 0;
208
-        monitor_tmc_driver(stepperE3, extended_axis_codes[TMC_E3], e3_otpw_cnt);
206
+        monitor_tmc_driver(stepperE3, TMC_E3, e3_otpw_cnt);
209
       #endif
207
       #endif
210
       #if HAS_HW_COMMS(E4)
208
       #if HAS_HW_COMMS(E4)
211
         static uint8_t e4_otpw_cnt = 0;
209
         static uint8_t e4_otpw_cnt = 0;
212
-        monitor_tmc_driver(stepperE4, extended_axis_codes[TMC_E4], e4_otpw_cnt);
210
+        monitor_tmc_driver(stepperE4, TMC_E4, e4_otpw_cnt);
213
       #endif
211
       #endif
214
 
212
 
215
       if (report_tmc_status) SERIAL_EOL();
213
       if (report_tmc_status) SERIAL_EOL();
218
 
216
 
219
 #endif // MONITOR_DRIVER_STATUS
217
 #endif // MONITOR_DRIVER_STATUS
220
 
218
 
221
-void _tmc_say_current(const char name[], const uint16_t curr) {
222
-  SERIAL_ECHO(name);
219
+void _tmc_say_axis(const TMC_AxisEnum axis) {
220
+  const static char ext_X[]  PROGMEM = "X",  ext_X2[] PROGMEM = "X2",
221
+                    ext_Y[]  PROGMEM = "Y",  ext_Y2[] PROGMEM = "Y2",
222
+                    ext_Z[]  PROGMEM = "Z",  ext_Z2[] PROGMEM = "Z2",
223
+                    ext_E0[] PROGMEM = "E0", ext_E1[] PROGMEM = "E1",
224
+                    ext_E2[] PROGMEM = "E2", ext_E3[] PROGMEM = "E3",
225
+                    ext_E4[] PROGMEM = "E4";
226
+  const static char* const tmc_axes[] PROGMEM = { ext_X, ext_X2, ext_Y, ext_Y2, ext_Z, ext_Z2, ext_E0, ext_E1, ext_E2, ext_E3, ext_E4 };
227
+  serialprintPGM(tmc_axes[axis]);
228
+}
229
+
230
+void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr) {
231
+  _tmc_say_axis(axis);
223
   SERIAL_ECHOLNPAIR(" axis driver current: ", curr);
232
   SERIAL_ECHOLNPAIR(" axis driver current: ", curr);
224
 }
233
 }
225
-void _tmc_say_otpw(const char name[], const bool otpw) {
226
-  SERIAL_ECHO(name);
234
+void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw) {
235
+  _tmc_say_axis(axis);
227
   SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
236
   SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
228
   serialprintPGM(otpw ? PSTR("true") : PSTR("false"));
237
   serialprintPGM(otpw ? PSTR("true") : PSTR("false"));
229
   SERIAL_EOL();
238
   SERIAL_EOL();
230
 }
239
 }
231
-void _tmc_say_otpw_cleared(const char name[]) {
232
-  SERIAL_ECHO(name);
240
+void _tmc_say_otpw_cleared(const TMC_AxisEnum axis) {
241
+  _tmc_say_axis(axis);
233
   SERIAL_ECHOLNPGM(" prewarn flag cleared");
242
   SERIAL_ECHOLNPGM(" prewarn flag cleared");
234
 }
243
 }
235
-void _tmc_say_pwmthrs(const char name[], const uint32_t thrs) {
236
-  SERIAL_ECHO(name);
244
+void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs) {
245
+  _tmc_say_axis(axis);
237
   SERIAL_ECHOLNPAIR(" stealthChop max speed set to ", thrs);
246
   SERIAL_ECHOLNPAIR(" stealthChop max speed set to ", thrs);
238
 }
247
 }
239
-void _tmc_say_sgt(const char name[], const int8_t sgt) {
240
-  SERIAL_ECHO(name);
248
+void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
249
+  _tmc_say_axis(axis);
241
   SERIAL_ECHOPGM(" driver homing sensitivity set to ");
250
   SERIAL_ECHOPGM(" driver homing sensitivity set to ");
242
   SERIAL_PRINTLN(sgt, DEC);
251
   SERIAL_PRINTLN(sgt, DEC);
243
 }
252
 }
290
     TMC_S2VSB,
299
     TMC_S2VSB,
291
     TMC_S2VSA
300
     TMC_S2VSA
292
   };
301
   };
293
-  static void drv_status_print_hex(const char name[], const uint32_t drv_status) {
294
-    SERIAL_ECHO(name);
302
+  static void drv_status_print_hex(const TMC_AxisEnum axis, const uint32_t drv_status) {
303
+    _tmc_say_axis(axis);
295
     SERIAL_ECHOPGM(" = 0x");
304
     SERIAL_ECHOPGM(" = 0x");
296
     for (int B = 24; B >= 8; B -= 8){
305
     for (int B = 24; B >= 8; B -= 8){
297
       SERIAL_PRINT((drv_status >> (B + 4)) & 0xF, HEX);
306
       SERIAL_PRINT((drv_status >> (B + 4)) & 0xF, HEX);
345
   #endif
354
   #endif
346
 
355
 
347
   template <typename TMC>
356
   template <typename TMC>
348
-  static void tmc_status(TMC &st, TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) {
357
+  static void tmc_status(TMC &st, const TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) {
349
     SERIAL_ECHO('\t');
358
     SERIAL_ECHO('\t');
350
     switch(i) {
359
     switch(i) {
351
-      case TMC_CODES: SERIAL_ECHO(extended_axis_codes[axis]); break;
360
+      case TMC_CODES: _tmc_say_axis(axis); break;
352
       case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
361
       case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
353
       case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break;
362
       case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break;
354
       case TMC_RMS_CURRENT: SERIAL_PROTOCOL(st.rms_current()); break;
363
       case TMC_RMS_CURRENT: SERIAL_PROTOCOL(st.rms_current()); break;
390
   }
399
   }
391
 
400
 
392
   template <typename TMC>
401
   template <typename TMC>
393
-  static void tmc_parse_drv_status(TMC &st, TMC_AxisEnum axis, const TMC_drv_status_enum i) {
402
+  static void tmc_parse_drv_status(TMC &st, const TMC_AxisEnum axis, const TMC_drv_status_enum i) {
394
     SERIAL_CHAR('\t');
403
     SERIAL_CHAR('\t');
395
     switch(i) {
404
     switch(i) {
396
-      case TMC_DRV_CODES:     SERIAL_ECHO(extended_axis_codes[axis]);  break;
405
+      case TMC_DRV_CODES:     _tmc_say_axis(axis);  break;
397
       case TMC_STST:          if (st.stst())         SERIAL_CHAR('X'); break;
406
       case TMC_STST:          if (st.stst())         SERIAL_CHAR('X'); break;
398
       case TMC_OLB:           if (st.olb())          SERIAL_CHAR('X'); break;
407
       case TMC_OLB:           if (st.olb())          SERIAL_CHAR('X'); break;
399
       case TMC_OLA:           if (st.ola())          SERIAL_CHAR('X'); break;
408
       case TMC_OLA:           if (st.ola())          SERIAL_CHAR('X'); break;
402
       case TMC_DRV_OTPW:      if (st.otpw())         SERIAL_CHAR('X'); break;
411
       case TMC_DRV_OTPW:      if (st.otpw())         SERIAL_CHAR('X'); break;
403
       case TMC_OT:            if (st.ot())           SERIAL_CHAR('X'); break;
412
       case TMC_OT:            if (st.ot())           SERIAL_CHAR('X'); break;
404
       case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC);       break;
413
       case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC);       break;
405
-      case TMC_DRV_STATUS_HEX:drv_status_print_hex(extended_axis_codes[axis], st.DRV_STATUS()); break;
414
+      case TMC_DRV_STATUS_HEX:drv_status_print_hex(axis, st.DRV_STATUS()); break;
406
       default: tmc_parse_drv_status(st, i); break;
415
       default: tmc_parse_drv_status(st, i); break;
407
     }
416
     }
408
   }
417
   }

+ 23
- 26
Marlin/src/feature/tmc_util.h View File

28
 #include "../inc/MarlinConfig.h"
28
 #include "../inc/MarlinConfig.h"
29
 
29
 
30
 extern bool report_tmc_status;
30
 extern bool report_tmc_status;
31
-extern char extended_axis_codes[11][3];
32
 
31
 
33
-enum TMC_AxisEnum {
34
-  TMC_X, TMC_X2, TMC_Y, TMC_Y2, TMC_Z, TMC_Z2,
35
-  TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4
36
-};
32
+enum TMC_AxisEnum { TMC_X, TMC_X2, TMC_Y, TMC_Y2, TMC_Z, TMC_Z2, TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4 };
37
 
33
 
38
 constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
34
 constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
39
   return 12650000UL * msteps / (256 * thrs * spmm);
35
   return 12650000UL * msteps / (256 * thrs * spmm);
40
 }
36
 }
41
 
37
 
42
-void _tmc_say_current(const char name[], const uint16_t curr);
43
-void _tmc_say_otpw(const char name[], const bool otpw);
44
-void _tmc_say_otpw_cleared(const char name[]);
45
-void _tmc_say_pwmthrs(const char name[], const uint32_t thrs);
46
-void _tmc_say_sgt(const char name[], const int8_t sgt);
38
+void _tmc_say_axis(const TMC_AxisEnum axis);
39
+void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr);
40
+void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw);
41
+void _tmc_say_otpw_cleared(const TMC_AxisEnum axis);
42
+void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs);
43
+void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt);
47
 
44
 
48
 template<typename TMC>
45
 template<typename TMC>
49
-void tmc_get_current(TMC &st, const char name[]) {
50
-  _tmc_say_current(name, st.getCurrent());
46
+void tmc_get_current(TMC &st, const TMC_AxisEnum axis) {
47
+  _tmc_say_current(axis, st.getCurrent());
51
 }
48
 }
52
 template<typename TMC>
49
 template<typename TMC>
53
-void tmc_set_current(TMC &st, const char name[], const int mA) {
50
+void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) {
54
   st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
51
   st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
55
-  tmc_get_current(st, name);
52
+  tmc_get_current(st, axis);
56
 }
53
 }
57
 template<typename TMC>
54
 template<typename TMC>
58
-void tmc_report_otpw(TMC &st, const char name[]) {
59
-  _tmc_say_otpw(name, st.getOTPW());
55
+void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) {
56
+  _tmc_say_otpw(axis, st.getOTPW());
60
 }
57
 }
61
 template<typename TMC>
58
 template<typename TMC>
62
-void tmc_clear_otpw(TMC &st, const char name[]) {
59
+void tmc_clear_otpw(TMC &st, const TMC_AxisEnum axis) {
63
   st.clear_otpw();
60
   st.clear_otpw();
64
-  _tmc_say_otpw_cleared(name);
61
+  _tmc_say_otpw_cleared(axis);
65
 }
62
 }
66
 template<typename TMC>
63
 template<typename TMC>
67
-void tmc_get_pwmthrs(TMC &st, const char name[], const uint16_t spmm) {
68
-  _tmc_say_pwmthrs(name, _tmc_thrs(st.microsteps(), st.TPWMTHRS(), spmm));
64
+void tmc_get_pwmthrs(TMC &st, const TMC_AxisEnum axis, const uint16_t spmm) {
65
+  _tmc_say_pwmthrs(axis, _tmc_thrs(st.microsteps(), st.TPWMTHRS(), spmm));
69
 }
66
 }
70
 template<typename TMC>
67
 template<typename TMC>
71
-void tmc_set_pwmthrs(TMC &st, const char name[], const int32_t thrs, const uint32_t spmm) {
68
+void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) {
72
   st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
69
   st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
73
-  tmc_get_pwmthrs(st, name, spmm);
70
+  tmc_get_pwmthrs(st, axis, spmm);
74
 }
71
 }
75
 template<typename TMC>
72
 template<typename TMC>
76
-void tmc_get_sgt(TMC &st, const char name[]) {
77
-  _tmc_say_sgt(name, st.sgt());
73
+void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
74
+  _tmc_say_sgt(axis, st.sgt());
78
 }
75
 }
79
 template<typename TMC>
76
 template<typename TMC>
80
-void tmc_set_sgt(TMC &st, const char name[], const int8_t sgt_val) {
77
+void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) {
81
   st.sgt(sgt_val);
78
   st.sgt(sgt_val);
82
-  tmc_get_sgt(st, name);
79
+  tmc_get_sgt(st, axis);
83
 }
80
 }
84
 
81
 
85
 void monitor_tmc_driver();
82
 void monitor_tmc_driver();

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

37
   LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
37
   LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
38
 
38
 
39
   #define TMC_SET_GET_CURRENT(P,Q) do { \
39
   #define TMC_SET_GET_CURRENT(P,Q) do { \
40
-    if (values[P##_AXIS]) tmc_set_current(stepper##Q, extended_axis_codes[TMC_##Q], values[P##_AXIS]); \
41
-    else tmc_get_current(stepper##Q, extended_axis_codes[TMC_##Q]); } while(0)
40
+    if (values[P##_AXIS]) tmc_set_current(stepper##Q, TMC_##Q, values[P##_AXIS]); \
41
+    else tmc_get_current(stepper##Q, TMC_##Q); } while(0)
42
 
42
 
43
   #if X_IS_TRINAMIC
43
   #if X_IS_TRINAMIC
44
     TMC_SET_GET_CURRENT(X,X);
44
     TMC_SET_GET_CURRENT(X,X);

+ 13
- 13
Marlin/src/gcode/feature/trinamic/M911-M915.cpp View File

36
  */
36
  */
37
 void GcodeSuite::M911() {
37
 void GcodeSuite::M911() {
38
   #if ENABLED(X_IS_TMC2130) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX)) || ENABLED(IS_TRAMS)
38
   #if ENABLED(X_IS_TMC2130) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX)) || ENABLED(IS_TRAMS)
39
-    tmc_report_otpw(stepperX, extended_axis_codes[TMC_X]);
39
+    tmc_report_otpw(stepperX, TMC_X);
40
   #endif
40
   #endif
41
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX)) || ENABLED(IS_TRAMS)
41
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX)) || ENABLED(IS_TRAMS)
42
-    tmc_report_otpw(stepperY, extended_axis_codes[TMC_Y]);
42
+    tmc_report_otpw(stepperY, TMC_Y);
43
   #endif
43
   #endif
44
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX)) || ENABLED(IS_TRAMS)
44
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX)) || ENABLED(IS_TRAMS)
45
-    tmc_report_otpw(stepperZ, extended_axis_codes[TMC_Z]);
45
+    tmc_report_otpw(stepperZ, TMC_Z);
46
   #endif
46
   #endif
47
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX)) || ENABLED(IS_TRAMS)
47
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX)) || ENABLED(IS_TRAMS)
48
-    tmc_report_otpw(stepperE0, extended_axis_codes[TMC_E0]);
48
+    tmc_report_otpw(stepperE0, TMC_E0);
49
   #endif
49
   #endif
50
 }
50
 }
51
 
51
 
56
   const bool clearX = parser.seen(axis_codes[X_AXIS]), clearY = parser.seen(axis_codes[Y_AXIS]), clearZ = parser.seen(axis_codes[Z_AXIS]), clearE = parser.seen(axis_codes[E_AXIS]),
56
   const bool clearX = parser.seen(axis_codes[X_AXIS]), clearY = parser.seen(axis_codes[Y_AXIS]), clearZ = parser.seen(axis_codes[Z_AXIS]), clearE = parser.seen(axis_codes[E_AXIS]),
57
            clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
57
            clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
58
   #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
58
   #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) || (ENABLED(X_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
59
-    if (clearX || clearAll) tmc_clear_otpw(stepperX, extended_axis_codes[TMC_X]);
59
+    if (clearX || clearAll) tmc_clear_otpw(stepperX, TMC_X);
60
   #endif
60
   #endif
61
   #if ENABLED(X2_IS_TMC2130) || (ENABLED(X2_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
61
   #if ENABLED(X2_IS_TMC2130) || (ENABLED(X2_IS_TMC2208) && PIN_EXISTS(X_SERIAL_RX))
62
-    if (clearX || clearAll) tmc_clear_otpw(stepperX, extended_axis_codes[TMC_X]);
62
+    if (clearX || clearAll) tmc_clear_otpw(stepperX, TMC_X);
63
   #endif
63
   #endif
64
 
64
 
65
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX))
65
   #if ENABLED(Y_IS_TMC2130) || (ENABLED(Y_IS_TMC2208) && PIN_EXISTS(Y_SERIAL_RX))
66
-    if (clearY || clearAll) tmc_clear_otpw(stepperY, extended_axis_codes[TMC_Y]);
66
+    if (clearY || clearAll) tmc_clear_otpw(stepperY, TMC_Y);
67
   #endif
67
   #endif
68
 
68
 
69
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX))
69
   #if ENABLED(Z_IS_TMC2130) || (ENABLED(Z_IS_TMC2208) && PIN_EXISTS(Z_SERIAL_RX))
70
-    if (clearZ || clearAll) tmc_clear_otpw(stepperZ, extended_axis_codes[TMC_Z]);
70
+    if (clearZ || clearAll) tmc_clear_otpw(stepperZ, TMC_Z);
71
   #endif
71
   #endif
72
 
72
 
73
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX))
73
   #if ENABLED(E0_IS_TMC2130) || (ENABLED(E0_IS_TMC2208) && PIN_EXISTS(E0_SERIAL_RX))
74
-    if (clearE || clearAll) tmc_clear_otpw(stepperE0, extended_axis_codes[TMC_E0]);
74
+    if (clearE || clearAll) tmc_clear_otpw(stepperE0, TMC_E0);
75
   #endif
75
   #endif
76
 }
76
 }
77
 
77
 
84
     LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
84
     LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
85
 
85
 
86
     #define TMC_SET_GET_PWMTHRS(P,Q) do { \
86
     #define TMC_SET_GET_PWMTHRS(P,Q) do { \
87
-      if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, extended_axis_codes[TMC_##Q], values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \
88
-      else tmc_get_pwmthrs(stepper##Q, extended_axis_codes[TMC_##Q], planner.axis_steps_per_mm[P##_AXIS]); } while(0)
87
+      if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, TMC_##Q, values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \
88
+      else tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS]); } while(0)
89
 
89
 
90
     #if X_IS_TRINAMIC
90
     #if X_IS_TRINAMIC
91
       TMC_SET_GET_PWMTHRS(X,X);
91
       TMC_SET_GET_PWMTHRS(X,X);
129
 #if ENABLED(SENSORLESS_HOMING)
129
 #if ENABLED(SENSORLESS_HOMING)
130
   void GcodeSuite::M914() {
130
   void GcodeSuite::M914() {
131
     #define TMC_SET_GET_SGT(P,Q) do { \
131
     #define TMC_SET_GET_SGT(P,Q) do { \
132
-      if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, extended_axis_codes[TMC_##Q], parser.value_int()); \
133
-      else tmc_get_sgt(stepper##Q, extended_axis_codes[TMC_##Q]); } while(0)
132
+      if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, TMC_##Q, parser.value_int()); \
133
+      else tmc_get_sgt(stepper##Q, TMC_##Q); } while(0)
134
 
134
 
135
     #ifdef X_HOMING_SENSITIVITY
135
     #ifdef X_HOMING_SENSITIVITY
136
       #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
136
       #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)

Loading…
Cancel
Save