浏览代码

Additional ExtUI features (#13449)

Marcio Teixeira 5 年前
父节点
当前提交
a0ca98f699
共有 3 个文件被更改,包括 134 次插入6 次删除
  1. 1
    1
      Marlin/Makefile
  2. 118
    5
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  3. 15
    0
      Marlin/src/lcd/extensible_ui/ui_api.h

+ 1
- 1
Marlin/Makefile 查看文件

@@ -674,7 +674,7 @@ ASFLAGS :=          $(CDEFS)
674 674
 ifeq ($(HARDWARE_VARIANT), archim)
675 675
   LD_PREFIX = -Wl,--gc-sections,-Map,Marlin.ino.map,--cref,--check-sections,--entry=Reset_Handler,--unresolved-symbols=report-all,--warn-common,--warn-section-align
676 676
   LD_SUFFIX = $(LDLIBS)
677
-  LDFLAGS   = -lm -gcc -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
677
+  LDFLAGS   = -lm -T$(LDSCRIPT) -u _sbrk -u link -u _close -u _fstat -u _isatty -u _lseek -u _read -u _write -u _exit -u kill -u _getpid
678 678
 else
679 679
   LD_PREFIX = -Wl,--gc-sections,--relax
680 680
   LDFLAGS   = -lm

+ 118
- 5
Marlin/src/lcd/extensible_ui/ui_api.cpp 查看文件

@@ -74,8 +74,9 @@
74 74
   #define IFSD(A,B) (B)
75 75
 #endif
76 76
 
77
-#if HAS_TRINAMIC && HAS_LCD_MENU
77
+#if HAS_TRINAMIC
78 78
   #include "../../feature/tmc_util.h"
79
+  #include "../../module/stepper_indirection.h"
79 80
 #endif
80 81
 
81 82
 #include "ui_api.h"
@@ -339,6 +340,122 @@ namespace ExtUI {
339 340
     return !thermalManager.tooColdToExtrude(extruder - E0);
340 341
   }
341 342
 
343
+  #if HAS_SOFTWARE_ENDSTOPS
344
+    bool getSoftEndstopState() {
345
+      return soft_endstops_enabled;
346
+    }
347
+
348
+    void setSoftEndstopState(const bool value) {
349
+      soft_endstops_enabled = value;
350
+    }
351
+  #endif
352
+
353
+  #if HAS_TRINAMIC
354
+    float getAxisCurrent_mA(const axis_t axis) {
355
+      switch (axis) {
356
+        #if AXIS_IS_TMC(X)
357
+          case X: return stepperX.getMilliamps();
358
+        #endif
359
+        #if AXIS_IS_TMC(Y)
360
+          case Y: return stepperY.getMilliamps();
361
+        #endif
362
+        #if AXIS_IS_TMC(Z)
363
+          case Z: return stepperZ.getMilliamps();
364
+        #endif
365
+        default: return NAN;
366
+      };
367
+    }
368
+
369
+    float getAxisCurrent_mA(const extruder_t extruder) {
370
+      switch (extruder) {
371
+        #if AXIS_IS_TMC(E0)
372
+          case E0: return stepperE0.getMilliamps();
373
+        #endif
374
+        #if AXIS_IS_TMC(E1)
375
+          case E1: return stepperE1.getMilliamps();
376
+        #endif
377
+        #if AXIS_IS_TMC(E2)
378
+          case E2: return stepperE2.getMilliamps();
379
+        #endif
380
+        #if AXIS_IS_TMC(E3)
381
+          case E3: return stepperE3.getMilliamps();
382
+        #endif
383
+        #if AXIS_IS_TMC(E4)
384
+          case E4: return stepperE4.getMilliamps();
385
+        #endif
386
+        #if AXIS_IS_TMC(E5)
387
+          case E5: return stepperE5.getMilliamps();
388
+        #endif
389
+        default: return NAN;
390
+      };
391
+    }
392
+
393
+    void  setAxisCurrent_mA(const float mA, const axis_t axis) {
394
+      switch (axis) {
395
+        #if AXIS_IS_TMC(X)
396
+          case X: stepperX.rms_current(clamp(mA, 500, 1500)); break;
397
+        #endif
398
+        #if AXIS_IS_TMC(Y)
399
+          case Y: stepperY.rms_current(clamp(mA, 500, 1500)); break;
400
+        #endif
401
+        #if AXIS_IS_TMC(Z)
402
+          case Z: stepperZ.rms_current(clamp(mA, 500, 1500)); break;
403
+        #endif
404
+      };
405
+    }
406
+
407
+    void  setAxisCurrent_mA(const float mA, const extruder_t extruder) {
408
+      switch (extruder) {
409
+        #if AXIS_IS_TMC(E0)
410
+          case E0: stepperE0.rms_current(clamp(mA, 500, 1500)); break;
411
+        #endif
412
+        #if AXIS_IS_TMC(E1)
413
+          case E1: stepperE1.rms_current(clamp(mA, 500, 1500)); break;
414
+        #endif
415
+        #if AXIS_IS_TMC(E2)
416
+          case E2: stepperE2.rms_current(clamp(mA, 500, 1500)); break;
417
+        #endif
418
+        #if AXIS_IS_TMC(E3)
419
+          case E3: stepperE3.rms_current(clamp(mA, 500, 1500)); break;
420
+        #endif
421
+        #if AXIS_IS_TMC(E4)
422
+          case E4: stepperE4.rms_current(clamp(mA, 500, 1500)); break;
423
+        #endif
424
+        #if AXIS_IS_TMC(E5)
425
+          case E5: stepperE5.rms_current(clamp(mA, 500, 1500)); break;
426
+        #endif
427
+      };
428
+    }
429
+
430
+    int getTMCBumpSensitivity(const axis_t axis) {
431
+      switch (axis) {
432
+        #if X_SENSORLESS && AXIS_HAS_STALLGUARD(X)
433
+          case X: return stepperX.sgt();
434
+        #endif
435
+        #if Y_SENSORLESS && AXIS_HAS_STALLGUARD(Y)
436
+          case Y: return stepperY.sgt();
437
+        #endif
438
+        #if Z_SENSORLESS && AXIS_HAS_STALLGUARD(Z)
439
+          case Z: return stepperZ.sgt();
440
+        #endif
441
+      }
442
+    }
443
+
444
+    void setTMCBumpSensitivity(const float value, const axis_t axis) {
445
+      switch (axis) {
446
+        #if X_SENSORLESS && AXIS_HAS_STALLGUARD(X)
447
+          case X: stepperX.sgt(clamp(value, -64, 63)); break;
448
+        #endif
449
+        #if Y_SENSORLESS && AXIS_HAS_STALLGUARD(Y)
450
+          case Y: stepperY.sgt(clamp(value, -64, 63)); break;
451
+        #endif
452
+        #if Z_SENSORLESS && AXIS_HAS_STALLGUARD(Z)
453
+          case Z: stepperZ.sgt(clamp(value, -64, 63)); break;
454
+        #endif
455
+      }
456
+    }
457
+  #endif
458
+
342 459
   float getAxisSteps_per_mm(const axis_t axis) {
343 460
     return planner.settings.axis_steps_per_mm[axis];
344 461
   }
@@ -787,10 +904,6 @@ void MarlinUI::init() {
787 904
     SET_INPUT_PULLUP(SD_DETECT_PIN);
788 905
   #endif
789 906
 
790
-  #if HAS_TRINAMIC && HAS_LCD_MENU
791
-    init_tmc_section();
792
-  #endif
793
-
794 907
   ExtUI::onStartup();
795 908
 }
796 909
 

+ 15
- 0
Marlin/src/lcd/extensible_ui/ui_api.h 查看文件

@@ -68,6 +68,21 @@ namespace ExtUI {
68 68
    */
69 69
   PGM_P getFirmwareName_str();
70 70
 
71
+  #if HAS_SOFTWARE_ENDSTOPS
72
+    bool getSoftEndstopState();
73
+    void setSoftEndstopState(const bool);
74
+  #endif
75
+
76
+  #if HAS_TRINAMIC
77
+    float getAxisCurrent_mA(const axis_t);
78
+    float getAxisCurrent_mA(const extruder_t);
79
+    void  setAxisCurrent_mA(const float, const axis_t);
80
+    void  setAxisCurrent_mA(const float, const extruder_t);
81
+
82
+    int getTMCBumpSensitivity(const axis_t);
83
+    void setTMCBumpSensitivity(const float, const axis_t);
84
+  #endif
85
+
71 86
   float getActualTemp_celsius(const heater_t);
72 87
   float getActualTemp_celsius(const extruder_t);
73 88
   float getTargetTemp_celsius(const heater_t);

正在加载...
取消
保存