From a7d8ed2b1e0f762daa2e0c004fe277bb77b184ca Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 20 Feb 2021 13:50:39 +0100 Subject: [PATCH] faultpin is common only if it exists ; make code prettier --- DCCWaveform.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 4eed0cb..7f26fe5 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -39,10 +39,15 @@ void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) { progTripValue = progDriver->mA2raw(TRIP_CURRENT_PROG); // need only calculate once hence static mainTrack.setPowerMode(POWERMODE::OFF); progTrack.setPowerMode(POWERMODE::OFF); + // Fault pin config for odd motor boards (example pololu) + MotorDriver::commonFaultPin = ((mainDriver->getFaultPin() == progDriver->getFaultPin()) + && (mainDriver->getFaultPin() != UNUSED_PIN)); + // Only use PWM if both pins are PWM capable. Otherwise JOIN does not work MotorDriver::usePWM= mainDriver->isPWMCapable() && progDriver->isPWMCapable(); - MotorDriver::commonFaultPin = (mainDriver->getFaultPin() == progDriver->getFaultPin()); - if (MotorDriver::usePWM) DIAG(F("\nWaveform using PWM pins for accuracy.")); - else DIAG(F("\nWaveform accuracy limited by signal pin configuration.")); + if (MotorDriver::usePWM) + DIAG(F("\nWaveform using PWM pins for accuracy.")); + else + DIAG(F("\nWaveform accuracy limited by signal pin configuration.")); DCCTimer::begin(DCCWaveform::interruptHandler); }