From 06e7ad5c5333cc084e0ee08e71086484d0d06c30 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Wed, 25 May 2022 09:28:28 +0200 Subject: [PATCH] prevent usage of pins for DC than can not do PWM --- GITHUB_SHA.h | 2 +- MotorDriver.h | 4 ++-- TrackManager.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index fd9c8a0..4e73c0f 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "TM-PORTX-20220524" +#define GITHUB_SHA "TM-PORTX-20220525" diff --git a/MotorDriver.h b/MotorDriver.h index a7fe96c..4c7d6ff 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -111,8 +111,8 @@ class MotorDriver { virtual int getCurrentRawInInterrupt(); virtual unsigned int raw2mA( int raw); virtual int mA2raw( unsigned int mA); - inline bool canBrake() { - return brakePin!=UNUSED_PIN; + inline bool brakeCanPWM() { + return ((brakePin!=UNUSED_PIN) && (digitalPinToTimer(brakePin))); } inline int getRawCurrentTripValue() { return rawCurrentTripValue; diff --git a/TrackManager.cpp b/TrackManager.cpp index b1e76f8..472b263 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -139,8 +139,8 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr //DIAG(F("Track=%c"),trackToSet+'A'); // DC tracks require a motorDriver that can set brake! if ((mode==TRACK_MODE_DC || mode==TRACK_MODE_DCX) - && !track[trackToSet]->canBrake()) { - DIAG(F("No brake:no DC")); + && !track[trackToSet]->brakeCanPWM()) { + DIAG(F("Brake pin can't PWM: No DC")); return false; }