diff --git a/DCCTimer.h b/DCCTimer.h index 984d6eb..4ce8590 100644 --- a/DCCTimer.h +++ b/DCCTimer.h @@ -68,7 +68,7 @@ class DCCTimer { static void DCCEXanalogWrite(uint8_t pin, int value); static void DCCEXledcDetachPin(uint8_t pin); static void DCCEXanalogCopyChannel(uint8_t frompin, uint8_t topin); - static void DCCEXInrushControlOn(uint8_t pin); + static void DCCEXInrushControlOn(uint8_t pin, int duty); // Update low ram level. Allow for extra bytes to be specified // by estimation or inspection, that may be used by other // called subroutines. Must be called with interrupts disabled. diff --git a/DCCTimerESP.cpp b/DCCTimerESP.cpp index 3e8d49e..b651a49 100644 --- a/DCCTimerESP.cpp +++ b/DCCTimerESP.cpp @@ -245,10 +245,10 @@ void DCCTimer::DCCEXanalogWrite(uint8_t pin, int value) { ledcWrite(pin_to_channel[pin], value); } } -void DCCTimer::DCCEXInrushControlOn(uint8_t pin) { +void DCCTimer::DCCEXInrushControlOn(uint8_t pin, int duty) { ledcSetup(0, 62500, 8); ledcAttachPin(pin, 0); - ledcWrite(0, 207); + ledcWrite(0, duty); } int ADCee::init(uint8_t pin) { diff --git a/MotorDriver.cpp b/MotorDriver.cpp index afd8e6e..235f557 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -411,7 +411,7 @@ void MotorDriver::throttleInrush(bool on) { duty = 255-duty; #if defined(ARDUINO_ARCH_ESP32) if(on) { - DCCTimer::DCCEXInrushControlOn(brakePin); + DCCTimer::DCCEXInrushControlOn(brakePin, duty); } else { ledcDetachPin(brakePin); // not DCCTimer::DCCEXledcDetachPin() as we have not // registered the pin in the pin to channel array