From a6dfd9257c33e73f1320e405ace288f56e9bfb22 Mon Sep 17 00:00:00 2001 From: Mitch Bradley Date: Wed, 23 Jun 2021 19:42:39 -1000 Subject: [PATCH] Create default speed map for Laser and Null spindles --- Grbl_Esp32/src/Spindles/Laser.cpp | 7 ++++++- Grbl_Esp32/src/Spindles/NullSpindle.cpp | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Grbl_Esp32/src/Spindles/Laser.cpp b/Grbl_Esp32/src/Spindles/Laser.cpp index b56a36af..ea7ea629 100644 --- a/Grbl_Esp32/src/Spindles/Laser.cpp +++ b/Grbl_Esp32/src/Spindles/Laser.cpp @@ -50,7 +50,12 @@ namespace Spindles { _pwm_precision = calc_pwm_precision(_pwm_freq); // determine the best precision _pwm_period = (1 << _pwm_precision); - // pre-calculate some PWM count values + if (_speeds.size() == 0) { + // The default speed map for a Laser is linear from 0=0% to 255=100% + _speeds.push_back({ 0, 0 }); + _speeds.push_back({ 255, 100 }); + } + setupSpeeds(_laser_full_power); _pwm_chan_num = 0; // Channel 0 is reserved for spindle use } diff --git a/Grbl_Esp32/src/Spindles/NullSpindle.cpp b/Grbl_Esp32/src/Spindles/NullSpindle.cpp index d2a8512d..73f6d208 100644 --- a/Grbl_Esp32/src/Spindles/NullSpindle.cpp +++ b/Grbl_Esp32/src/Spindles/NullSpindle.cpp @@ -33,6 +33,9 @@ namespace Spindles { void Null::init() { is_reversable = false; config_message(); + if (_speeds.size() == 0) { + _speeds.push_back({ 0, 0 }); + } } void IRAM_ATTR Null::setSpeedfromISR(uint32_t dev_speed) {}; void Null::setState(SpindleState state, SpindleSpeed speed) {