From e3ac3a8ddf5f434838b39545b4c2314e227093d4 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Wed, 2 Aug 2023 01:02:46 +0200 Subject: [PATCH] Protect Uno user from choosing DC(X) --- TrackManager.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/TrackManager.cpp b/TrackManager.cpp index 8588383..b786181 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -192,11 +192,16 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr //DIAG(F("Track=%c Mode=%d"),trackToSet+'A', mode); // DC tracks require a motorDriver that can set brake! - if ((mode==TRACK_MODE_DC || mode==TRACK_MODE_DCX) - && !track[trackToSet]->brakeCanPWM()) { - DIAG(F("Brake pin can't PWM: No DC")); - return false; - } + if (mode==TRACK_MODE_DC || mode==TRACK_MODE_DCX) { +#if defined(ARDUINO_AVR_UNO) + DIAG(F("Uno has no PWM timers available for DC")); + return false; +#endif + if (!track[trackToSet]->brakeCanPWM()) { + DIAG(F("Brake pin can't PWM: No DC")); + return false; + } + } #ifdef ARDUINO_ARCH_ESP32 // remove pin from MUX matrix and turn it off