From 6687c6f46d59eb5989c237ba7cae5706df342c9e Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Mon, 4 Jul 2022 23:15:02 +0200 Subject: [PATCH] when brake pin has inverted sense, honor that when running in DC mode as well --- MotorDriver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MotorDriver.cpp b/MotorDriver.cpp index 9aadbe6..0c6cef1 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -179,6 +179,8 @@ void MotorDriver::setDCSignal(byte speedcode) { if (tSpeed <= 1) brake = 255; else if (tSpeed >= 127) brake = 0; else brake = 2 * (128-tSpeed); + if (invertBrake) + brake=255-brake; analogWrite(brakePin,brake); // as the port registers can be shadowed to get syncronized DCC signals // we need to take care of that and we have to turn off interrupts during