1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-31 18:11:48 +02:00

Only start the limits task if there are limit switches

Also added an "Initializing endstops..." message.
This commit is contained in:
Mitch Bradley
2021-06-23 14:00:36 -10:00
parent 93fefa43b0
commit 7fd1391712

View File

@@ -296,11 +296,16 @@ uint8_t limit_mask = 0;
void limits_init() { void limits_init() {
limit_mask = 0; limit_mask = 0;
auto n_axis = config->_axes->_numberAxis; bool hasLimits = false;
auto n_axis = config->_axes->_numberAxis;
for (int axis = 0; axis < n_axis; axis++) { for (int axis = 0; axis < n_axis; axis++) {
for (int gang_index = 0; gang_index < 2; gang_index++) { for (int gang_index = 0; gang_index < 2; gang_index++) {
auto gangConfig = config->_axes->_axis[axis]->_gangs[gang_index]; auto gangConfig = config->_axes->_axis[axis]->_gangs[gang_index];
if (gangConfig->_endstops != nullptr && gangConfig->_endstops->_dual.defined()) { if (gangConfig->_endstops != nullptr && gangConfig->_endstops->_dual.defined()) {
if (!hasLimits) {
info_serial("Initializing endstops...");
hasLimits = true;
}
Pin& pin = gangConfig->_endstops->_dual; Pin& pin = gangConfig->_endstops->_dual;
pin.setAttr(Pin::Attr::Input | Pin::Attr::ISR); pin.setAttr(Pin::Attr::Input | Pin::Attr::ISR);
@@ -316,16 +321,18 @@ void limits_init() {
} }
} }
if (limit_sw_queue == NULL && config->_softwareDebounceMs != 0) { if (hasLimits) {
// setup task used for debouncing if (limit_sw_queue == NULL && config->_softwareDebounceMs != 0) {
if (limit_sw_queue == NULL) { // setup task used for debouncing
limit_sw_queue = xQueueCreate(10, sizeof(int)); if (limit_sw_queue == NULL) {
xTaskCreate(limitCheckTask, limit_sw_queue = xQueueCreate(10, sizeof(int));
"limitCheckTask", xTaskCreate(limitCheckTask,
2048, "limitCheckTask",
NULL, 2048,
5, // priority NULL,
NULL); 5, // priority
NULL);
}
} }
} }
} }