1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

make DC mode portable to ESP32

This commit is contained in:
Harald Barth 2022-08-10 00:14:28 +02:00
parent e1fd6e9414
commit c1993fba87
3 changed files with 15 additions and 4 deletions

View File

@ -136,16 +136,27 @@ class MotorDriver {
};
inline byte getSignalPin() { return signalPin; };
virtual void setDCSignal(byte speedByte);
inline void detachDCSignal() {
#ifndef ARDUINO_ARCH_ESP32
setDCSignal(128);
#else
ledcDetachPin(brakePin);
#endif
};
virtual int getCurrentRaw();
virtual int getCurrentRawInInterrupt();
virtual unsigned int raw2mA( int raw);
virtual unsigned int mA2raw( unsigned int mA);
inline bool brakeCanPWM() {
#ifdef ARDUINO_ARCH_ESP32
return true;
#else
#ifdef digitalPinToTimer
return ((brakePin!=UNUSED_PIN) && (digitalPinToTimer(brakePin)));
#else
return (brakePin<14 && brakePin >1);
#endif
#endif //digitalPinToTimer
#endif //ESP32
}
inline int getRawCurrentTripValue() {
return rawCurrentTripValue;

View File

@ -56,8 +56,8 @@
new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 1.95, 2000, UNUSED_PIN)
#elif defined(ARDUINO_ARCH_ESP32)
#define STANDARD_MOTOR_SHIELD F("STANDARD_MOTOR_SHIELD"), \
new MotorDriver(25/* 3*/, 19/*12*/, UNUSED_PIN, UNUSED_PIN, 36/*A4*/, 0.57, 2000, UNUSED_PIN), \
new MotorDriver(23/*11*/, 18/*13*/, UNUSED_PIN, UNUSED_PIN, 39/*A5*/, 0.57, 2000, UNUSED_PIN)
new MotorDriver(25/* 3*/, 19/*12*/, UNUSED_PIN, 13/*9*/, 36/*A4*/, 0.57, 2000, UNUSED_PIN), \
new MotorDriver(23/*11*/, 18/*13*/, UNUSED_PIN, 12/*8*/, 39/*A5*/, 0.57, 2000, UNUSED_PIN)
#else
#define STANDARD_MOTOR_SHIELD F("STANDARD_MOTOR_SHIELD"), \
new MotorDriver(3, 12, UNUSED_PIN, 9, A0, 2.99, 2000, UNUSED_PIN), \

View File

@ -170,7 +170,7 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
else {
// DCC tracks need to have set the PWM to zero or they will not work.
// 128 is speed=0 and dir=0 and then loosen brake.
track[trackToSet]->setDCSignal(128);
track[trackToSet]->detachDCSignal();
track[trackToSet]->setBrake(false);
}