From d697d8d26fd96c0a0079ed42c074f296a969ea43 Mon Sep 17 00:00:00 2001 From: bdring Date: Tue, 15 Sep 2020 11:42:43 -0500 Subject: [PATCH] User I/O array error --- Grbl_Esp32/src/System.cpp | 6 +++--- Grbl_Esp32/src/UserOutput.cpp | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Grbl_Esp32/src/System.cpp b/Grbl_Esp32/src/System.cpp index eb0853a8..9d292417 100644 --- a/Grbl_Esp32/src/System.cpp +++ b/Grbl_Esp32/src/System.cpp @@ -97,9 +97,9 @@ void system_ini() { // Renamed from system_init() due to conflict with esp32 fi // Setup M62,M63,M64,M65 pins myDigitalOutputs[0] = new UserOutput::DigitalOutput(0, USER_DIGITAL_PIN_0); - myDigitalOutputs[0] = new UserOutput::DigitalOutput(1, USER_DIGITAL_PIN_1); - myDigitalOutputs[0] = new UserOutput::DigitalOutput(2, USER_DIGITAL_PIN_2); - myDigitalOutputs[0] = new UserOutput::DigitalOutput(3, USER_DIGITAL_PIN_3); + myDigitalOutputs[1] = new UserOutput::DigitalOutput(1, USER_DIGITAL_PIN_1); + myDigitalOutputs[2] = new UserOutput::DigitalOutput(2, USER_DIGITAL_PIN_2); + myDigitalOutputs[3] = new UserOutput::DigitalOutput(3, USER_DIGITAL_PIN_3); // Setup M67 Pins myAnalogOutputs[0] = new UserOutput::AnalogOutput(0, USER_ANALOG_PIN_0, USER_ANALOG_PIN_0_FREQ); diff --git a/Grbl_Esp32/src/UserOutput.cpp b/Grbl_Esp32/src/UserOutput.cpp index 39bfaee3..dbc28349 100644 --- a/Grbl_Esp32/src/UserOutput.cpp +++ b/Grbl_Esp32/src/UserOutput.cpp @@ -58,6 +58,9 @@ namespace UserOutput { _pin = pin; _pwm_frequency = pwm_frequency; + if (pin == UNDEFINED_PIN) + return; + // determine the highest bit precision allowed by frequency _resolution_bits = sys_calc_pwm_precision(_pwm_frequency); @@ -87,7 +90,7 @@ namespace UserOutput { float duty; // look for errors, but ignore if turning off to prevent mask turn off from generating errors - if (_number == UNDEFINED_PIN && percent != 0.0) { + if (_number == UNDEFINED_PIN) { return false; }