1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-31 01:59:54 +02:00

Improved the initial selection of spindle.

This commit is contained in:
Mitch Bradley
2021-06-20 08:40:06 -10:00
parent 36e1a960f3
commit f8ad403439
3 changed files with 11 additions and 5 deletions

View File

@@ -111,6 +111,8 @@ void grbl_init() {
for (auto s : config->_spindles) { for (auto s : config->_spindles) {
s->init(); s->init();
} }
Spindles::Spindle::switchSpindle(0, config->_spindles, spindle);
config->_coolant->init(); config->_coolant->init();
limits_init(); limits_init();
config->_probe->init(); config->_probe->init();

View File

@@ -476,11 +476,9 @@ void MachineConfig::afterParse() {
} }
if (_spindles.size() == 0) { if (_spindles.size() == 0) {
log_info("Using null spindle"); log_info("Spindle config missing; using null spindle");
_spindles.push_back(new Spindles::Null()); _spindles.push_back(new Spindles::Null());
} }
spindle = _spindles[0];
uint32_t next_tool = 100; uint32_t next_tool = 100;
for (auto s : _spindles) { for (auto s : _spindles) {
if (s->_tool == -1) { if (s->_tool == -1) {

View File

@@ -39,11 +39,17 @@ namespace Spindles {
} }
if (candidate) { if (candidate) {
if (candidate != spindle) { if (candidate != spindle) {
spindle->stop(); if (spindle != nullptr) {
spindle->stop();
}
spindle = candidate; spindle = candidate;
} }
} else { } else {
if (!spindle) { if (spindle == nullptr) {
if (spindles.size() == 0) {
log_error("No spindles are defined");
return;
}
spindle = spindles[0]; spindle = spindles[0];
} }
} }