Kaynağa Gözat

Simplify TMC monitor code

Scott Lahteine 5 yıl önce
ebeveyn
işleme
f6a6839a82
1 değiştirilmiş dosya ile 47 ekleme ve 38 silme
  1. 47
    38
      Marlin/src/feature/tmc_util.cpp

+ 47
- 38
Marlin/src/feature/tmc_util.cpp Dosyayı Görüntüle

@@ -346,64 +346,73 @@
346 346
     #endif
347 347
 
348 348
     if (need_update_error_counters || need_debug_reporting) {
349
-      #if AXIS_IS_TMC(X)
350
-        if (monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting)) {
351
-          #if AXIS_IS_TMC(X2)
352
-            step_current_down(stepperX2);
353
-          #endif
354
-        }
355
-      #endif
356
-      #if AXIS_IS_TMC(X2)
357
-        if (monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting)) {
349
+
350
+      #if AXIS_IS_TMC(X) || AXIS_IS_TMC(X2)
351
+      {
352
+        bool result = false;
353
+        #if AXIS_IS_TMC(X)
354
+          if (monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting)) result = true;
355
+        #endif
356
+        #if AXIS_IS_TMC(X2)
357
+          if (monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting)) result = true;
358
+        #endif
359
+        if (result) {
358 360
           #if AXIS_IS_TMC(X)
359 361
             step_current_down(stepperX);
360 362
           #endif
361
-        }
362
-      #endif
363
-      #if AXIS_IS_TMC(Y)
364
-        if (monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting)) {
365
-          #if AXIS_IS_TMC(Y2)
366
-            step_current_down(stepperY2);
363
+          #if AXIS_IS_TMC(X2)
364
+            step_current_down(stepperX2);
367 365
           #endif
368 366
         }
367
+      }
369 368
       #endif
370
-      #if AXIS_IS_TMC(Y2)
371
-        if (monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting)) {
369
+
370
+      #if AXIS_IS_TMC(Y) || AXIS_IS_TMC(Y2)
371
+      {
372
+        bool result = false;
373
+        #if AXIS_IS_TMC(Y)
374
+          if (monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting)) result = true;
375
+        #endif
376
+        #if AXIS_IS_TMC(Y2)
377
+          if (monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting)) result = true;
378
+        #endif
379
+        if (result) {
372 380
           #if AXIS_IS_TMC(Y)
373 381
             step_current_down(stepperY);
374 382
           #endif
375
-        }
376
-      #endif
377
-      #if AXIS_IS_TMC(Z)
378
-        if (monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting)) {
379
-          #if AXIS_IS_TMC(Z2)
380
-            step_current_down(stepperZ2);
381
-          #endif
382
-          #if AXIS_IS_TMC(Z3)
383
-            step_current_down(stepperZ3);
384
-          #endif
385
-        }
386
-      #endif
387
-      #if AXIS_IS_TMC(Z2)
388
-        if (monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting)) {
389
-          #if AXIS_IS_TMC(Z)
390
-            step_current_down(stepperZ);
391
-          #endif
392
-          #if AXIS_IS_TMC(Z3)
393
-            step_current_down(stepperZ3);
383
+          #if AXIS_IS_TMC(Y2)
384
+            step_current_down(stepperY2);
394 385
           #endif
395 386
         }
387
+      }
396 388
       #endif
397
-      #if AXIS_IS_TMC(Z3)
398
-        if (monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting)) {
389
+
390
+      #if AXIS_IS_TMC(Z) || AXIS_IS_TMC(Z2) || AXIS_IS_TMC(Z3)
391
+      {
392
+        bool result = false;
393
+        #if AXIS_IS_TMC(Z)
394
+          if (monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting)) result = true;
395
+        #endif
396
+        #if AXIS_IS_TMC(Z2)
397
+          if (monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting)) result = true;
398
+        #endif
399
+        #if AXIS_IS_TMC(Z3)
400
+          if (monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting)) result = true;
401
+        #endif
402
+        if (result) {
399 403
           #if AXIS_IS_TMC(Z)
400 404
             step_current_down(stepperZ);
401 405
           #endif
402 406
           #if AXIS_IS_TMC(Z2)
403 407
             step_current_down(stepperZ2);
404 408
           #endif
409
+          #if AXIS_IS_TMC(Z3)
410
+            step_current_down(stepperZ3);
411
+          #endif
405 412
         }
413
+      }
406 414
       #endif
415
+
407 416
       #if AXIS_IS_TMC(E0)
408 417
         (void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting);
409 418
       #endif

Loading…
İptal
Kaydet