소스 검색

🩹 Fix non-PWM cutter compile (#23169)

Mike La Spina 2 년 전
부모
커밋
ea0d0e8e8b
No account linked to committer's email address
4개의 변경된 파일50개의 추가작업 그리고 24개의 파일을 삭제
  1. 4
    8
      Marlin/src/feature/spindle_laser.h
  2. 23
    1
      Marlin/src/feature/spindle_laser_types.h
  3. 17
    15
      Marlin/src/gcode/control/M3-M5.cpp
  4. 6
    0
      buildroot/tests/mega1280

+ 4
- 8
Marlin/src/feature/spindle_laser.h 파일 보기

@@ -41,18 +41,10 @@
41 41
 #define PCT_TO_PWM(X) ((X) * 255 / 100)
42 42
 #define PCT_TO_SERVO(X) ((X) * 180 / 100)
43 43
 
44
-#ifndef SPEED_POWER_INTERCEPT
45
-  #define SPEED_POWER_INTERCEPT 0
46
-#endif
47
-
48 44
 // #define _MAP(N,S1,S2,D1,D2) ((N)*_MAX((D2)-(D1),0)/_MAX((S2)-(S1),1)+(D1))
49 45
 
50 46
 class SpindleLaser {
51 47
 public:
52
-  static constexpr float
53
-    min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)),
54
-    max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX);
55
-
56 48
   static const inline uint8_t pct_to_ocr(const_float_t pct) { return uint8_t(PCT_TO_PWM(pct)); }
57 49
 
58 50
   // cpower = configured values (e.g., SPEED_POWER_MAX)
@@ -158,6 +150,9 @@ public:
158 150
     }
159 151
 
160 152
     static inline cutter_power_t power_to_range(const cutter_power_t pwr, const uint8_t pwrUnit) {
153
+      static constexpr float
154
+        min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)),
155
+        max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX);
161 156
       if (pwr <= 0) return 0;
162 157
       cutter_power_t upwr;
163 158
       switch (pwrUnit) {
@@ -186,6 +181,7 @@ public:
186 181
       }
187 182
       return upwr;
188 183
     }
184
+
189 185
   #endif // SPINDLE_LASER_USE_PWM
190 186
 
191 187
   /**

+ 23
- 1
Marlin/src/feature/spindle_laser_types.h 파일 보기

@@ -28,12 +28,34 @@
28 28
 
29 29
 #include "../inc/MarlinConfigPre.h"
30 30
 
31
+#define MSG_CUTTER(M) _MSG_CUTTER(M)
32
+
33
+#ifndef SPEED_POWER_INTERCEPT
34
+  #define SPEED_POWER_INTERCEPT 0
35
+#endif
31 36
 #if ENABLED(SPINDLE_FEATURE)
32 37
   #define _MSG_CUTTER(M) MSG_SPINDLE_##M
38
+  #ifndef SPEED_POWER_MIN
39
+    #define SPEED_POWER_MIN      5000
40
+  #endif
41
+  #ifndef SPEED_POWER_MAX
42
+    #define SPEED_POWER_MAX     30000
43
+  #endif
44
+  #ifndef SPEED_POWER_STARTUP
45
+    #define SPEED_POWER_STARTUP 25000
46
+  #endif
33 47
 #else
34 48
   #define _MSG_CUTTER(M) MSG_LASER_##M
49
+  #ifndef SPEED_POWER_MIN
50
+    #define SPEED_POWER_MIN         0
51
+  #endif
52
+  #ifndef SPEED_POWER_MAX
53
+    #define SPEED_POWER_MAX       255
54
+  #endif
55
+  #ifndef SPEED_POWER_STARTUP
56
+    #define SPEED_POWER_STARTUP   255
57
+  #endif
35 58
 #endif
36
-#define MSG_CUTTER(M) _MSG_CUTTER(M)
37 59
 
38 60
 typedef IF<(SPEED_POWER_MAX > 255), uint16_t, uint8_t>::type cutter_cpower_t;
39 61
 

+ 17
- 15
Marlin/src/gcode/control/M3-M5.cpp 파일 보기

@@ -66,21 +66,23 @@
66 66
  *  PWM duty cycle goes from 0 (off) to 255 (always on).
67 67
  */
68 68
 void GcodeSuite::M3_M4(const bool is_M4) {
69
-  auto get_s_power = [] {
70
-    if (parser.seenval('S')) {
71
-      const float spwr = parser.value_float();
72
-      #if ENABLED(SPINDLE_SERVO)
73
-        cutter.unitPower = spwr;
74
-      #else
75
-        cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM,
76
-                              cutter.power_to_range(cutter_power_t(round(spwr))),
77
-                              spwr > 0 ? 255 : 0);
78
-      #endif
79
-    }
80
-    else
81
-      cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
82
-    return cutter.unitPower;
83
-  };
69
+  #if EITHER(SPINDLE_LASER_USE_PWM, SPINDLE_SERVO)
70
+    auto get_s_power = [] {
71
+      if (parser.seenval('S')) {
72
+        const float spwr = parser.value_float();
73
+        #if ENABLED(SPINDLE_SERVO)
74
+          cutter.unitPower = spwr;
75
+        #else
76
+          cutter.unitPower = TERN(SPINDLE_LASER_USE_PWM,
77
+                                cutter.power_to_range(cutter_power_t(round(spwr))),
78
+                                spwr > 0 ? 255 : 0);
79
+        #endif
80
+      }
81
+      else
82
+        cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
83
+      return cutter.unitPower;
84
+    };
85
+  #endif
84 86
 
85 87
   #if ENABLED(LASER_POWER_INLINE)
86 88
     if (parser.seen('I') == DISABLED(LASER_POWER_INLINE_INVERT)) {

+ 6
- 0
buildroot/tests/mega1280 파일 보기

@@ -28,6 +28,12 @@ opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \
28 28
 exec_test $1 $2 "Spindle, MESH_BED_LEVELING, closed loop, Power Monitor, and LCD" "$3"
29 29
 
30 30
 #
31
+# ...and without PWM
32
+#
33
+opt_disable SPINDLE_LASER_USE_PWM
34
+exec_test $1 $2 "(No PWM)" "$3"
35
+
36
+#
31 37
 # Test DUAL_X_CARRIAGE
32 38
 #
33 39
 restore_configs

Loading…
취소
저장