From 7bad16dc59bf032f6ed9f646749cc8120425e899 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 4 Aug 2022 01:20:33 +0200 Subject: [PATCH] ESP32 DCCWaveform::begin() bugfix for prog --- DCCWaveform.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 6d1406f..ac7ecb1 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -212,17 +212,22 @@ DCCWaveform::DCCWaveform(byte preambleBits, bool isMain) { void DCCWaveform::begin() { for(const auto& md: TrackManager::getMainDrivers()) { if(rmtMainChannel) { - /* rmtMainChannel->addPin(md->getSignalPin); // add pin to existing main channel */ + DIAG(F("added pin %d to MAIN channel"), md->getSignalPin()); + rmtMainChannel->addPin(md->getSignalPin()); // add pin to existing main channel } else { - DIAG(F("new MAIN channel %d"), md->getSignalPin()); + DIAG(F("new MAIN channel with pin %d"), md->getSignalPin()); rmtMainChannel = new RMTChannel(md->getSignalPin(), true); /* create new main channel */ } } - if (rmtProgChannel) { - /* exchange prog channel - not supported yet */ - } else { - DIAG(F("new PROGchannel %d"), TrackManager::getProgDriver()->getSignalPin()); - rmtProgChannel = new RMTChannel(TrackManager::getProgDriver()->getSignalPin(), false); + MotorDriver *md = TrackManager::getProgDriver(); + if (md) { + if (rmtProgChannel) { + DIAG(F("added pin %d to PROG channel"), md->getSignalPin()); + rmtProgChannel->addPin(md->getSignalPin()); // add pin to existing prog channel + } else { + DIAG(F("new PROGchannel with pin %d"), TrackManager::getProgDriver()->getSignalPin()); + rmtProgChannel = new RMTChannel(TrackManager::getProgDriver()->getSignalPin(), false); + } } }