mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-29 17:19:50 +02:00
Created Spindle::linearSpeeds factor to reduce repetition
This commit is contained in:
@@ -52,8 +52,7 @@ namespace Spindles {
|
|||||||
|
|
||||||
if (_speeds.size() == 0) {
|
if (_speeds.size() == 0) {
|
||||||
// The default speed map for a Laser is linear from 0=0% to 255=100%
|
// The default speed map for a Laser is linear from 0=0% to 255=100%
|
||||||
_speeds.push_back({ 0, 0 });
|
linearSpeeds(255, 100.0f);
|
||||||
_speeds.push_back({ 255, 100 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSpeeds(_pwm_period);
|
setupSpeeds(_pwm_period);
|
||||||
|
@@ -20,8 +20,7 @@ namespace Spindles {
|
|||||||
// The default speed map for an On/Off spindle is off - 0% -
|
// The default speed map for an On/Off spindle is off - 0% -
|
||||||
// for speed 0 and on - 100% - for any nonzero speedl
|
// for speed 0 and on - 100% - for any nonzero speedl
|
||||||
// In other words there is a step transition right at 0.
|
// In other words there is a step transition right at 0.
|
||||||
_speeds.push_back({ 0, 0 });
|
linearSpeeds(0, 100.0f);
|
||||||
_speeds.push_back({ 0, 100 });
|
|
||||||
}
|
}
|
||||||
setupSpeeds(1);
|
setupSpeeds(1);
|
||||||
config_message();
|
config_message();
|
||||||
|
@@ -66,8 +66,7 @@ namespace Spindles {
|
|||||||
|
|
||||||
if (_speeds.size() == 0) {
|
if (_speeds.size() == 0) {
|
||||||
// The default speed map for a PWM spindle is linear from 0=0% to 10000=100%
|
// The default speed map for a PWM spindle is linear from 0=0% to 10000=100%
|
||||||
_speeds.push_back({ 0, 0 });
|
linearSpeeds(10000, 100.0f);
|
||||||
_speeds.push_back({ 10000, 100 });
|
|
||||||
}
|
}
|
||||||
setupSpeeds(_pwm_period);
|
setupSpeeds(_pwm_period);
|
||||||
config_message();
|
config_message();
|
||||||
|
@@ -98,6 +98,12 @@ namespace Spindles {
|
|||||||
|
|
||||||
void Spindle::afterParse() {}
|
void Spindle::afterParse() {}
|
||||||
|
|
||||||
|
void Spindle::linearSpeeds(SpindleSpeed maxSpeed, float maxPercent) {
|
||||||
|
_speeds.clear();
|
||||||
|
_speeds.push_back({ 0, 0.0f });
|
||||||
|
_speeds.push_back({ maxSpeed, maxPercent });
|
||||||
|
}
|
||||||
|
|
||||||
void Spindle::shelfSpeeds(SpindleSpeed min, SpindleSpeed max) {
|
void Spindle::shelfSpeeds(SpindleSpeed min, SpindleSpeed max) {
|
||||||
float minPercent = 100.0f * min / max;
|
float minPercent = 100.0f * min / max;
|
||||||
_speeds.clear();
|
_speeds.clear();
|
||||||
|
@@ -56,6 +56,7 @@ namespace Spindles {
|
|||||||
uint32_t mapSpeed(SpindleSpeed speed);
|
uint32_t mapSpeed(SpindleSpeed speed);
|
||||||
void setupSpeeds(uint32_t max_dev_speed);
|
void setupSpeeds(uint32_t max_dev_speed);
|
||||||
void shelfSpeeds(SpindleSpeed min, SpindleSpeed max);
|
void shelfSpeeds(SpindleSpeed min, SpindleSpeed max);
|
||||||
|
void linearSpeeds(SpindleSpeed maxSpeed, float maxPercent);
|
||||||
|
|
||||||
static void switchSpindle(uint8_t new_tool, SpindleList spindles, Spindle*& spindle);
|
static void switchSpindle(uint8_t new_tool, SpindleList spindles, Spindle*& spindle);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user