Skip to content

Commit 200d4b0

Browse files
committed
share cutout info
1 parent 803aa6a commit 200d4b0

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

DCCRMT.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ static void IRAM_ATTR mcpwmIsrHandler(void* arg) {
167167
if (cutoutCounter == 2) {
168168
__digitalWrite(13 /*BRKA*/, 0);
169169
cutoutCounter++;
170+
DCCWaveform::incCutoutCounter();
170171
} else if (cutoutCounter == 3) {
171172
__digitalWrite(13 /*BRKA*/, 1);
172173
cutoutCounter++;
@@ -192,7 +193,7 @@ static void IRAM_ATTR mcpwmPulseOn() {
192193
//gpio_set_direction((gpio_num_t)13, GPIO_MODE_OUTPUT);
193194
pinMode(13, OUTPUT);
194195
digitalWrite(13, 1);
195-
196+
DCCWaveform::setRailcomPossible(true);
196197
mcpwm_config_t pwm_config = {
197198
.frequency = CUTOUT_BASE_FREQ, // calculation see above
198199
.cmpr_a = CUTOUT_OFFSET_IN_PERCENT, // duty cycle of PWMxA (float in %)

DCCWaveform.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,6 @@ volatile byte DCCWaveform::railcomCutoutCounter=0; // cyclic cutout
132132
volatile byte DCCWaveform::railcomLastAddressHigh=0;
133133
volatile byte DCCWaveform::railcomLastAddressLow=0;
134134

135-
bool DCCWaveform::setRailcom(bool on, bool debug) {
136-
if (on && railcomPossible) {
137-
railcomActive=true;
138-
railcomDebug=debug;
139-
}
140-
else {
141-
railcomActive=false;
142-
railcomDebug=false;
143-
railcomSampleWindow=false;
144-
}
145-
return railcomActive;
146-
}
147135

148136
#pragma GCC push_options
149137
#pragma GCC optimize ("-O3")

DCCWaveform.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,28 @@ class DCCWaveform {
8282
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
8383
bool isReminderWindowOpen();
8484
void promotePendingPacket();
85-
static bool setRailcom(bool on, bool debug);
85+
static bool setRailcom(bool on, bool debug) {
86+
if (on && railcomPossible) {
87+
railcomActive=true;
88+
railcomDebug=debug;
89+
}
90+
else {
91+
railcomActive=false;
92+
railcomDebug=false;
93+
railcomSampleWindow=false;
94+
}
95+
return railcomActive;
96+
}
97+
8698
inline static bool isRailcom() {
8799
return railcomActive;
88100
};
89101
inline static byte getRailcomCutoutCounter() {
90102
return railcomCutoutCounter;
91103
};
104+
inline static void incCutoutCounter() {
105+
railcomCutoutCounter++;
106+
}
92107
inline static bool isRailcomSampleWindow() {
93108
return railcomSampleWindow;
94109
};
@@ -138,6 +153,8 @@ class DCCWaveform {
138153
static volatile byte railcomCutoutCounter; // incremented for each cutout
139154
static volatile byte railcomLastAddressHigh,railcomLastAddressLow;
140155
static bool cutoutNextTime; // railcom
156+
157+
141158
#ifdef ARDUINO_ARCH_ESP32
142159
static RMTChannel *rmtMainChannel;
143160
static RMTChannel *rmtProgChannel;

DCCWaveformRMT.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,4 @@ void IRAM_ATTR DCCWaveform::loop() {
115115
DCCACK::checkAck(progTrack.getResets());
116116
}
117117

118-
bool DCCWaveform::setRailcom(bool on, bool debug) {
119-
// TODO... ESP32 railcom waveform
120-
return false;
121-
}
122-
123118
#endif

0 commit comments

Comments
 (0)