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

@ -69,9 +69,13 @@ void GcodeSuite::M3_M4(const bool is_M4) {
auto get_s_power = [] {
if (parser.seenval('S')) {
const float spwr = parser.value_float();
cutter.unitPower = TERN(SPINDLE_LASER_PWM,
#if ENABLED(SPINDLE_SERVO)
cutter.unitPower = spwr;
#else
cutter.unitPower = TERN(SPINDLE_LASER_PWM,
cutter.power_to_range(cutter_power_t(round(spwr))),
spwr > 0 ? 255 : 0);
#endif
}
else
cutter.unitPower = cutter.cpwr_to_upwr(SPEED_POWER_STARTUP);
@ -108,6 +112,8 @@ void GcodeSuite::M3_M4(const bool is_M4) {
}
else
cutter.set_power(cutter.upower_to_ocr(get_s_power()));
#elif ENABLED(SPINDLE_SERVO)
cutter.set_power(get_s_power());
#else
cutter.set_enabled(true);
#endif