mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
idle waveform through RMT
This commit is contained in:
parent
7a123e7e17
commit
e5ce76e703
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* © 2021, Harald Barth.
|
||||
* © 2021-2022, Harald Barth.
|
||||
*
|
||||
* This file is part of DCC-EX
|
||||
*
|
||||
|
|
5
DCCRMT.h
5
DCCRMT.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* © 2021, Harald Barth.
|
||||
* © 2021-2022, Harald Barth.
|
||||
*
|
||||
* This file is part of DCC-EX
|
||||
*
|
||||
|
@ -37,9 +37,6 @@ class RMTChannel {
|
|||
//int RMTfillData(dccPacket packet);
|
||||
int RMTfillData(const byte buffer[], byte byteCount, byte repeatCount);
|
||||
|
||||
static RMTChannel mainRMTChannel;
|
||||
static RMTChannel progRMTChannel;
|
||||
|
||||
private:
|
||||
|
||||
rmt_channel_t channel;
|
||||
|
|
|
@ -198,12 +198,31 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
|
|||
|
||||
DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true);
|
||||
DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false);
|
||||
RMTChannel *DCCWaveform::rmtMainChannel = NULL;
|
||||
RMTChannel *DCCWaveform::rmtProgChannel = NULL;
|
||||
|
||||
DCCWaveform::DCCWaveform(byte preambleBits, bool isMain) {
|
||||
isMainTrack = isMain;
|
||||
packetPending = false;
|
||||
requiredPreambles = preambleBits;
|
||||
}
|
||||
void DCCWaveform::begin() {
|
||||
for(const auto& md: TrackManager::getMainDrivers()) {
|
||||
if(rmtMainChannel) {
|
||||
/* rmtMainChannel->addPin(md->getSignalPin); // add pin to existing main channel */
|
||||
} else {
|
||||
DIAG(F("new MAIN channel %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);
|
||||
}
|
||||
}
|
||||
|
||||
void DCCWaveform::begin() {
|
||||
}
|
||||
void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repeats) {
|
||||
}
|
||||
void DCCWaveform::loop() {
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
#define DCCWaveform_h
|
||||
|
||||
#include "MotorDriver.h"
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include "DCCRMT.h"
|
||||
#include "TrackManager.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -71,6 +75,9 @@ class DCCWaveform {
|
|||
byte pendingPacket[MAX_PACKET_SIZE+1]; // +1 for checksum
|
||||
byte pendingLength;
|
||||
byte pendingRepeats;
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
static RMTChannel *rmtMainChannel;
|
||||
static RMTChannel *rmtProgChannel;
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -112,6 +112,7 @@ class MotorDriver {
|
|||
else
|
||||
pinMode(signalPin, INPUT);
|
||||
};
|
||||
inline byte getSignalPin() { return signalPin; };
|
||||
virtual void setBrake( bool on);
|
||||
virtual void setDCSignal(byte speedByte);
|
||||
virtual int getCurrentRaw();
|
||||
|
|
|
@ -303,6 +303,15 @@ MotorDriver * TrackManager::getProgDriver() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
std::vector<MotorDriver *>TrackManager::getMainDrivers() {
|
||||
std::vector<MotorDriver *> v;
|
||||
FOR_EACH_TRACK(t)
|
||||
if (trackMode[t]==TRACK_MODE_MAIN) v.push_back(track[t]);
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
|
||||
void TrackManager::setPower2(bool setProg,POWERMODE mode) {
|
||||
if (!setProg) mainPowerGuess=mode;
|
||||
FOR_EACH_TRACK(t) {
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include <vector>
|
||||
#endif
|
||||
#ifndef TrackManager_h
|
||||
#define TrackManager_h
|
||||
#include "FSH.h"
|
||||
|
@ -55,6 +58,9 @@ class TrackManager {
|
|||
static void setPROGSignal( bool on);
|
||||
static void setDCSignal(int16_t cab, byte speedbyte);
|
||||
static MotorDriver * getProgDriver();
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
static std::vector<MotorDriver *>getMainDrivers();
|
||||
#endif
|
||||
static void setPower2(bool progTrack,POWERMODE mode);
|
||||
static void setPower(POWERMODE mode) {setMainPower(mode); setProgPower(mode);}
|
||||
static void setMainPower(POWERMODE mode) {setPower2(false,mode);}
|
||||
|
|
Loading…
Reference in New Issue
Block a user