Add SPINDLE_SERVO option (#19971)

This commit is contained in:
Alexander Semion
2020-11-01 01:42:05 +03:00
committed by GitHub
parent 76f4dd34e0
commit cd89fa141b
6 changed files with 38 additions and 8 deletions

View File

@@ -35,6 +35,7 @@
#endif
#define PCT_TO_PWM(X) ((X) * 255 / 100)
#define PCT_TO_SERVO(X) ((X) * 180 / 100)
#ifndef SPEED_POWER_INTERCEPT
#define SPEED_POWER_INTERCEPT 0
@@ -60,7 +61,7 @@ public:
}
// Convert a cpower (e.g., SPEED_POWER_STARTUP) to unit power (upwr, upower),
// which can be PWM, Percent, or RPM (rel/abs).
// which can be PWM, Percent, Servo angle, or RPM (rel/abs).
static const inline cutter_power_t cpwr_to_upwr(const cutter_cpower_t cpwr) { // STARTUP power to Unit power
const cutter_power_t upwr = (
#if ENABLED(SPINDLE_FEATURE)
@@ -69,6 +70,8 @@ public:
cpwr // to RPM
#elif CUTTER_UNIT_IS(PERCENT) // to PCT
cpwr_to_pct(cpwr)
#elif CUTTER_UNIT_IS(SERVO) // to SERVO angle
PCT_TO_SERVO(cpwr_to_pct(cpwr))
#else // to PWM
PCT_TO_PWM(cpwr_to_pct(cpwr))
#endif