|
@@ -39,24 +39,27 @@
|
39
|
39
|
#ifndef SPEED_POWER_INTERCEPT
|
40
|
40
|
#define SPEED_POWER_INTERCEPT 0
|
41
|
41
|
#endif
|
42
|
|
-#define SPEED_POWER_FLOOR TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0)
|
43
|
42
|
|
44
|
43
|
// #define _MAP(N,S1,S2,D1,D2) ((N)*_MAX((D2)-(D1),0)/_MAX((S2)-(S1),1)+(D1))
|
45
|
44
|
|
46
|
45
|
class SpindleLaser {
|
47
|
46
|
public:
|
48
|
47
|
static constexpr float
|
49
|
|
- min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN))),
|
|
48
|
+ min_pct = TERN(CUTTER_POWER_RELATIVE, 0, TERN(SPINDLE_FEATURE, round(100.0f * (SPEED_POWER_MIN) / (SPEED_POWER_MAX)), SPEED_POWER_MIN)),
|
50
|
49
|
max_pct = TERN(SPINDLE_FEATURE, 100, SPEED_POWER_MAX);
|
51
|
50
|
|
52
|
51
|
static const inline uint8_t pct_to_ocr(const float pct) { return uint8_t(PCT_TO_PWM(pct)); }
|
53
|
52
|
|
54
|
|
- // cpower = configured values (ie SPEED_POWER_MAX)
|
55
|
|
- static const inline uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) { // configured value to pct
|
56
|
|
- return unitPower ? round(100.0f * (cpwr - (SPEED_POWER_FLOOR)) / (SPEED_POWER_MAX - (SPEED_POWER_FLOOR))) : 0;
|
|
53
|
+ // cpower = configured values (e.g., SPEED_POWER_MAX)
|
|
54
|
+
|
|
55
|
+ // Convert configured power range to a percentage
|
|
56
|
+ static const inline uint8_t cpwr_to_pct(const cutter_cpower_t cpwr) {
|
|
57
|
+ constexpr cutter_cpower_t power_floor = TERN(CUTTER_POWER_RELATIVE, SPEED_POWER_MIN, 0),
|
|
58
|
+ power_range = SPEED_POWER_MAX - power_floor;
|
|
59
|
+ return unitPower ? round(100.0f * (cpwr - power_floor) / power_range) : 0;
|
57
|
60
|
}
|
58
|
61
|
|
59
|
|
- // Convert a configured value (cpower)(ie SPEED_POWER_STARTUP) to unit power (upwr, upower),
|
|
62
|
+ // Convert a cpower (e.g., SPEED_POWER_STARTUP) to unit power (upwr, upower),
|
60
|
63
|
// which can be PWM, Percent, or RPM (rel/abs).
|
61
|
64
|
static const inline cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power
|
62
|
65
|
const cutter_power_t upwr = (
|