Преглед изворни кода

Show E0-E4 in monitor_tmc_driver output (#9969)

Fix #9966
Scott Lahteine пре 7 година
родитељ
комит
b08ec22fe1
No account linked to committer's email address
1 измењених фајлова са 19 додато и 22 уклоњено
  1. 19
    22
      Marlin/src/feature/tmc_util.cpp

+ 19
- 22
Marlin/src/feature/tmc_util.cpp Прегледај датотеку

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" };
40
 char extended_axis_codes[11][3] = { "X", "X2", "Y", "Y2", "Z", "Z2", "E0", "E1", "E2", "E3", "E4" };
41
 
41
 
42
-/*
42
+/**
43
  * Check for over temperature or short to ground error flags.
43
  * Check for over temperature or short to ground error flags.
44
  * Report and log warning of overtemperature condition.
44
  * Report and log warning of overtemperature condition.
45
  * Reduce driver current in a persistent otpw condition.
45
  * Reduce driver current in a persistent otpw condition.
96
   #endif
96
   #endif
97
 
97
 
98
   template<typename TMC>
98
   template<typename TMC>
99
-  void monitor_tmc_driver(TMC &st, const char axisID, uint8_t &otpw_cnt) {
99
+  void monitor_tmc_driver(TMC &st, const char * const axisName, uint8_t &otpw_cnt) {
100
     TMC_driver_data data = get_driver_data(st);
100
     TMC_driver_data data = get_driver_data(st);
101
 
101
 
102
     #if ENABLED(STOP_ON_ERROR)
102
     #if ENABLED(STOP_ON_ERROR)
103
       if (data.is_error) {
103
       if (data.is_error) {
104
         SERIAL_EOL();
104
         SERIAL_EOL();
105
-        SERIAL_ECHO(axisID);
105
+        SERIAL_ECHO(axisName);
106
         SERIAL_ECHOPGM(" driver error detected:");
106
         SERIAL_ECHOPGM(" driver error detected:");
107
         if (data.is_ot) SERIAL_ECHOPGM("\novertemperature");
107
         if (data.is_ot) SERIAL_ECHOPGM("\novertemperature");
108
         if (st.s2ga()) SERIAL_ECHOPGM("\nshort to ground (coil A)");
108
         if (st.s2ga()) SERIAL_ECHOPGM("\nshort to ground (coil A)");
124
       SERIAL_EOL();
124
       SERIAL_EOL();
125
       SERIAL_ECHO(timestamp);
125
       SERIAL_ECHO(timestamp);
126
       SERIAL_ECHOPGM(": ");
126
       SERIAL_ECHOPGM(": ");
127
-      SERIAL_ECHO(axisID);
127
+      SERIAL_ECHO(axisName);
128
       SERIAL_ECHOPGM(" driver overtemperature warning! (");
128
       SERIAL_ECHOPGM(" driver overtemperature warning! (");
129
       SERIAL_ECHO(st.getCurrent());
129
       SERIAL_ECHO(st.getCurrent());
130
       SERIAL_ECHOLNPGM("mA)");
130
       SERIAL_ECHOLNPGM("mA)");
134
       if (data.is_otpw && !st.isEnabled() && otpw_cnt > 4) {
134
       if (data.is_otpw && !st.isEnabled() && otpw_cnt > 4) {
135
         st.setCurrent(st.getCurrent() - CURRENT_STEP_DOWN, R_SENSE, HOLD_MULTIPLIER);
135
         st.setCurrent(st.getCurrent() - CURRENT_STEP_DOWN, R_SENSE, HOLD_MULTIPLIER);
136
         #if ENABLED(REPORT_CURRENT_CHANGE)
136
         #if ENABLED(REPORT_CURRENT_CHANGE)
137
-          SERIAL_ECHO(axisID);
137
+          SERIAL_ECHO(axisName);
138
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent());
138
           SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent());
139
         #endif
139
         #endif
140
       }
140
       }
148
 
148
 
149
     if (report_tmc_status) {
149
     if (report_tmc_status) {
150
       const uint32_t pwm_scale = get_pwm_scale(st);
150
       const uint32_t pwm_scale = get_pwm_scale(st);
151
-      SERIAL_ECHO(axisID);
151
+      SERIAL_ECHO(axisName);
152
       SERIAL_ECHOPAIR(":", pwm_scale);
152
       SERIAL_ECHOPAIR(":", pwm_scale);
153
       SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
153
       SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
154
       SERIAL_ECHOPGM("| ");
154
       SERIAL_ECHOPGM("| ");
169
       next_cOT = millis() + 500;
169
       next_cOT = millis() + 500;
170
       #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS)
170
       #if HAS_HW_COMMS(X) || ENABLED(IS_TRAMS)
171
         static uint8_t x_otpw_cnt = 0;
171
         static uint8_t x_otpw_cnt = 0;
172
-        monitor_tmc_driver(stepperX, axis_codes[X_AXIS], x_otpw_cnt);
172
+        monitor_tmc_driver(stepperX, extended_axis_codes[TMC_X], x_otpw_cnt);
173
       #endif
173
       #endif
174
       #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS)
174
       #if HAS_HW_COMMS(Y) || ENABLED(IS_TRAMS)
175
         static uint8_t y_otpw_cnt = 0;
175
         static uint8_t y_otpw_cnt = 0;
176
-        monitor_tmc_driver(stepperY, axis_codes[Y_AXIS], y_otpw_cnt);
176
+        monitor_tmc_driver(stepperY, extended_axis_codes[TMC_Y], y_otpw_cnt);
177
       #endif
177
       #endif
178
       #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS)
178
       #if HAS_HW_COMMS(Z) || ENABLED(IS_TRAMS)
179
         static uint8_t z_otpw_cnt = 0;
179
         static uint8_t z_otpw_cnt = 0;
180
-        monitor_tmc_driver(stepperZ, axis_codes[Z_AXIS], z_otpw_cnt);
180
+        monitor_tmc_driver(stepperZ, extended_axis_codes[TMC_Z], z_otpw_cnt);
181
       #endif
181
       #endif
182
       #if HAS_HW_COMMS(X2)
182
       #if HAS_HW_COMMS(X2)
183
         static uint8_t x2_otpw_cnt = 0;
183
         static uint8_t x2_otpw_cnt = 0;
184
-        monitor_tmc_driver(stepperX2, axis_codes[X_AXIS], x2_otpw_cnt);
184
+        monitor_tmc_driver(stepperX2, extended_axis_codes[TMC_X], x2_otpw_cnt);
185
       #endif
185
       #endif
186
       #if HAS_HW_COMMS(Y2)
186
       #if HAS_HW_COMMS(Y2)
187
         static uint8_t y2_otpw_cnt = 0;
187
         static uint8_t y2_otpw_cnt = 0;
188
-        monitor_tmc_driver(stepperY2, axis_codes[Y_AXIS], y2_otpw_cnt);
188
+        monitor_tmc_driver(stepperY2, extended_axis_codes[TMC_Y], y2_otpw_cnt);
189
       #endif
189
       #endif
190
       #if HAS_HW_COMMS(Z2)
190
       #if HAS_HW_COMMS(Z2)
191
         static uint8_t z2_otpw_cnt = 0;
191
         static uint8_t z2_otpw_cnt = 0;
192
-        monitor_tmc_driver(stepperZ2, axis_codes[Z_AXIS], z2_otpw_cnt);
192
+        monitor_tmc_driver(stepperZ2, extended_axis_codes[TMC_Z], z2_otpw_cnt);
193
       #endif
193
       #endif
194
       #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS)
194
       #if HAS_HW_COMMS(E0) || ENABLED(IS_TRAMS)
195
         static uint8_t e0_otpw_cnt = 0;
195
         static uint8_t e0_otpw_cnt = 0;
196
-        monitor_tmc_driver(stepperE0, axis_codes[E_AXIS], e0_otpw_cnt);
196
+        monitor_tmc_driver(stepperE0, extended_axis_codes[TMC_E0], e0_otpw_cnt);
197
       #endif
197
       #endif
198
       #if HAS_HW_COMMS(E1)
198
       #if HAS_HW_COMMS(E1)
199
         static uint8_t e1_otpw_cnt = 0;
199
         static uint8_t e1_otpw_cnt = 0;
200
-        monitor_tmc_driver(stepperE1, axis_codes[E_AXIS], e1_otpw_cnt);
200
+        monitor_tmc_driver(stepperE1, extended_axis_codes[TMC_E1], e1_otpw_cnt);
201
       #endif
201
       #endif
202
       #if HAS_HW_COMMS(E2)
202
       #if HAS_HW_COMMS(E2)
203
         static uint8_t e2_otpw_cnt = 0;
203
         static uint8_t e2_otpw_cnt = 0;
204
-        monitor_tmc_driver(stepperE2, axis_codes[E_AXIS], e2_otpw_cnt);
204
+        monitor_tmc_driver(stepperE2, extended_axis_codes[TMC_E2], e2_otpw_cnt);
205
       #endif
205
       #endif
206
       #if HAS_HW_COMMS(E3)
206
       #if HAS_HW_COMMS(E3)
207
         static uint8_t e3_otpw_cnt = 0;
207
         static uint8_t e3_otpw_cnt = 0;
208
-        monitor_tmc_driver(stepperE3, axis_codes[E_AXIS], e3_otpw_cnt);
208
+        monitor_tmc_driver(stepperE3, extended_axis_codes[TMC_E3], e3_otpw_cnt);
209
       #endif
209
       #endif
210
       #if HAS_HW_COMMS(E4)
210
       #if HAS_HW_COMMS(E4)
211
         static uint8_t e4_otpw_cnt = 0;
211
         static uint8_t e4_otpw_cnt = 0;
212
-        monitor_tmc_driver(stepperE4, axis_codes[E_AXIS], e4_otpw_cnt);
212
+        monitor_tmc_driver(stepperE4, extended_axis_codes[TMC_E4], e4_otpw_cnt);
213
       #endif
213
       #endif
214
 
214
 
215
       if (report_tmc_status) SERIAL_EOL();
215
       if (report_tmc_status) SERIAL_EOL();
299
       SERIAL_CHAR(':');
299
       SERIAL_CHAR(':');
300
     }
300
     }
301
     SERIAL_PRINT((drv_status >> 4) & 0xF, HEX);
301
     SERIAL_PRINT((drv_status >> 4) & 0xF, HEX);
302
-    SERIAL_PRINT(drv_status & 0xF, HEX);
302
+    SERIAL_PRINT((drv_status) & 0xF, HEX);
303
     SERIAL_EOL();
303
     SERIAL_EOL();
304
   }
304
   }
305
 
305
 
376
         break;
376
         break;
377
       case TMC_TPWMTHRS_MMS: {
377
       case TMC_TPWMTHRS_MMS: {
378
           uint32_t tpwmthrs_val = st.TPWMTHRS();
378
           uint32_t tpwmthrs_val = st.TPWMTHRS();
379
-          if (tpwmthrs_val)
380
-            SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm));
381
-          else
382
-            SERIAL_CHAR('-');
379
+          tpwmthrs_val ? SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm)) : SERIAL_CHAR('-');
383
         }
380
         }
384
         break;
381
         break;
385
       case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;
382
       case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;

Loading…
Откажи
Сачувај