mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 15:46:14 +01:00
memory saving
This commit is contained in:
parent
158cb47474
commit
f910e75da0
|
@ -480,7 +480,8 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
|||
break;
|
||||
DCC::writeCVByteMain(p[0], p[1], p[2]);
|
||||
return;
|
||||
|
||||
|
||||
#ifdef HAS_ENOUGH_MEMORY
|
||||
case 'r': // READ CV on MAIN <r CAB CV> Requires Railcom
|
||||
if (params != 2)
|
||||
break;
|
||||
|
@ -488,6 +489,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
|||
if (!stashCallback(stream, p, ringStream)) break;
|
||||
DCC::readCVByteMain(p[0], p[1],callback_r);
|
||||
return;
|
||||
#endif
|
||||
|
||||
case 'b': // WRITE CV BIT ON MAIN <b CAB CV BIT VALUE>
|
||||
if (params != 4)
|
||||
|
@ -1129,7 +1131,7 @@ bool DCCEXParser::parseC(Print *stream, int16_t params, int16_t p[]) {
|
|||
DCC::setGlobalSpeedsteps(128);
|
||||
DIAG(F("128 Speedsteps"));
|
||||
return true;
|
||||
#if defined(HAS_ENOUGH_MEMORY) && !defined(ARDUINO_ARCH_UNO) && !defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(HAS_ENOUGH_MEMORY)
|
||||
case "RAILCOM"_hk:
|
||||
{ // <C RAILCOM ON|OFF|DEBUG >
|
||||
if (params<2) return false;
|
||||
|
@ -1213,11 +1215,11 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[])
|
|||
Diag::CMD = onOff;
|
||||
return true;
|
||||
|
||||
#ifdef HAS_ENOUGH_MEMORY
|
||||
case "RAILCOM"_hk: // <D RAILCOM ON/OFF>
|
||||
Diag::RAILCOM = onOff;
|
||||
return true;
|
||||
|
||||
#ifdef HAS_ENOUGH_MEMORY
|
||||
case "WIFI"_hk: // <D WIFI ON/OFF>
|
||||
Diag::WIFI = onOff;
|
||||
return true;
|
||||
|
|
|
@ -74,12 +74,14 @@ void DCCWaveform::loop() {
|
|||
void DCCWaveform::interruptHandler() {
|
||||
// call the timer edge sensitive actions for progtrack and maintrack
|
||||
// member functions would be cleaner but have more overhead
|
||||
#if defined(HAS_ENOUGH_MEMORY)
|
||||
if (cutoutNextTime) {
|
||||
cutoutNextTime=false;
|
||||
railcomSampleWindow=false; // about to cutout, stop reading railcom data.
|
||||
railcomCutoutCounter++;
|
||||
DCCTimer::startRailcomTimer(9);
|
||||
}
|
||||
#endif
|
||||
byte sigMain=signalTransform[mainTrack.state];
|
||||
byte sigProg=TrackManager::progTrackSyncMain? sigMain : signalTransform[progTrack.state];
|
||||
|
||||
|
@ -160,6 +162,8 @@ void DCCWaveform::interrupt2() {
|
|||
reminderWindowOpen=transmitRepeats==0 && remainingPreambles<10 && remainingPreambles>1;
|
||||
if (remainingPreambles==1)
|
||||
promotePendingPacket();
|
||||
|
||||
#if defined(HAS_ENOUGH_MEMORY)
|
||||
else if (isMainTrack && railcomActive) {
|
||||
if (remainingPreambles==(requiredPreambles-1)) {
|
||||
// First look if we need to start a railcom cutout on next interrupt
|
||||
|
@ -179,6 +183,7 @@ void DCCWaveform::interrupt2() {
|
|||
DCCTimer::ackRailcomTimer();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Update free memory diagnostic as we don't have anything else to do this time.
|
||||
// Allow for checkAck and its called functions using 22 bytes more.
|
||||
else DCCTimer::updateMinimumFreeMemoryISR(22);
|
||||
|
|
|
@ -14,11 +14,15 @@ Some CPUs require very specific choice of brake pins etc to match their internal
|
|||
- Nucleo ... TBA
|
||||
|
||||
Enabling the Railcom Cutout requires a `<C RAILCOM ON>` command. This can be added to myAutomation using `PARSE("<C RAILCOM ON>")`
|
||||
Code to calculate the cutout position and provide synchronization for the sampling is in `DCCWaveform.cpp` (not ESP32)
|
||||
and in general a global search for "railcom" will show all code changes that have been made to support this.
|
||||
|
||||
Code to actually implement the timing of the cutout is hihjly cpu dependent and can be found in gthe various implementations of `DCCTimer.h`. At this time only `DCCTimerAVR.cpp`has implemented this.
|
||||
|
||||
|
||||
Reading Railcom data:
|
||||
A new HAL handler has been added to process input from a 2-block railcom reader (Refer Henk) which operates as a 2 channel UART accessible over I2C. The reader(s) sit between the CS and the track and collect railcom data from locos during the cutout.
|
||||
After the cutout the HAL driver reads the UARTs over I2C and passes the raw data to the CS logic for analysis.
|
||||
A new HAL handler (`IO_I2CRailcom.h`)has been added to process input from a 2-block railcom reader (Refer Henk) which operates as a 2 channel UART accessible over I2C. The reader(s) sit between the CS and the track and collect railcom data from locos during the cutout.
|
||||
After the cutout the HAL driver reads the UARTs over I2C and passes the raw data to the CS logic (`Railcom.cpp`)for analysis.
|
||||
|
||||
Each 2-block reader is described in myAutomation like `HAL(I2CRailcom,10000,2,0x48)` which will assign 2 channels on i2c address 0x48 with vpin numbers 10000 and 10001. If you only use the first channel in the reader, just asign one pin instead of two.
|
||||
(Implementation notes.. potentially other readers are possible with suitable HAL drivers. There are however several touch-points with the code DCC Waveform code which helps the HAL driver to understand when the data is safe to sample, and how to interpret responses when the sender is unknown. )
|
||||
|
|
Loading…
Reference in New Issue
Block a user