From 72d131035e777cb6b73d68c6f0028b6fdf3bd440 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 23 Apr 2023 20:24:29 +0200 Subject: [PATCH] disable more PROG stuff (all hash keywords PROG etc) --- DCCACK.cpp | 4 ++-- DCCEXParser.cpp | 14 +++++++++++--- GITHUB_SHA.h | 2 +- TrackManager.cpp | 21 ++++++++++++++++++--- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/DCCACK.cpp b/DCCACK.cpp index 8c5e8c7..1b339ee 100644 --- a/DCCACK.cpp +++ b/DCCACK.cpp @@ -152,7 +152,7 @@ byte DCCACK::getAck() { return(0); // pending set off but not detected means no ACK. } - +#ifndef DISABLE_PROG void DCCACK::loop() { while (ackManagerProg) { byte opcode=GETFLASH(ackManagerProg); @@ -414,7 +414,7 @@ void DCCACK::callback(int value) { (ackManagerCallback)( value); } } - +#endif void DCCACK::checkAck(byte sentResetsSincePacket) { if (!ackPending) return; diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index b07fe66..0a496d5 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -54,7 +54,6 @@ // These keywords are used in the <1> command. The number is what you get if you use the keyword as a parameter. // To discover new keyword numbers , use the <$ YOURKEYWORD> command -const int16_t HASH_KEYWORD_PROG = -29718; const int16_t HASH_KEYWORD_MAIN = 11339; const int16_t HASH_KEYWORD_JOIN = -30750; const int16_t HASH_KEYWORD_CABS = -11981; @@ -64,7 +63,10 @@ const int16_t HASH_KEYWORD_ACK = 3113; const int16_t HASH_KEYWORD_ON = 2657; const int16_t HASH_KEYWORD_DCC = 6436; const int16_t HASH_KEYWORD_SLOW = -17209; +#ifndef DISABLE_PROG +const int16_t HASH_KEYWORD_PROG = -29718; const int16_t HASH_KEYWORD_PROGBOOST = -6353; +#endif #ifndef DISABLE_EEPROM const int16_t HASH_KEYWORD_EEPROM = -7168; #endif @@ -380,7 +382,9 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) #endif case 'M': // WRITE TRANSPARENT DCC PACKET MAIN +#ifndef DISABLE_PROG case 'P': // WRITE TRANSPARENT DCC PACKET PROG

+#endif // NOTE: this command was parsed in HEX instead of decimal params--; // drop REG if (params<1) break; @@ -474,9 +478,11 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) else if (p[0]==HASH_KEYWORD_MAIN) { // <1 MAIN> main=true; } +#ifndef DISABLE_PROG else if (p[0]==HASH_KEYWORD_PROG) { // <1 PROG> prog=true; } +#endif else break; // will reply } if (main) TrackManager::setMainPower(POWERMODE::ON); @@ -500,9 +506,11 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) if (p[0]==HASH_KEYWORD_MAIN) { // <0 MAIN> main=true; } +#ifndef DISABLE_PROG else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG> prog=true; } +#endif else break; // will reply } @@ -941,11 +949,11 @@ bool DCCEXParser::parseD(Print *stream, int16_t params, int16_t p[]) Diag::LCN = onOff; return true; #endif - +#ifndef DISABLE_PROG case HASH_KEYWORD_PROGBOOST: TrackManager::progTrackBoosted=true; return true; - +#endif case HASH_KEYWORD_RESET: DCCTimer::reset(); break; // and if we didnt restart diff --git a/GITHUB_SHA.h b/GITHUB_SHA.h index f3e8efd..b530ccd 100644 --- a/GITHUB_SHA.h +++ b/GITHUB_SHA.h @@ -1 +1 @@ -#define GITHUB_SHA "devel-202304172140Z" +#define GITHUB_SHA "devel-202304231822Z" diff --git a/TrackManager.cpp b/TrackManager.cpp index fcd0c10..9c0f0b0 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -33,8 +33,9 @@ FOR_EACH_TRACK(t) \ if (trackMode[t]==findmode) \ track[t]->function; - +#ifndef DISABLE_PROG const int16_t HASH_KEYWORD_PROG = -29718; +#endif const int16_t HASH_KEYWORD_MAIN = 11339; const int16_t HASH_KEYWORD_OFF = 22479; const int16_t HASH_KEYWORD_DC = 2183; @@ -116,7 +117,11 @@ void TrackManager::Setup(const FSH * shieldname, // Default the first 2 tracks (which may be null) and perform HA waveform check. setTrackMode(0,TRACK_MODE_MAIN); +#ifndef DISABLE_PROG setTrackMode(1,TRACK_MODE_PROG); +#else + setTrackMode(1,TRACK_MODE_MAIN); +#endif // TODO Fault pin config for odd motor boards (example pololu) // MotorDriver::commonFaultPin = ((mainDriver->getFaultPin() == progDriver->getFaultPin()) @@ -198,7 +203,11 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr pinMode(p.invpin, OUTPUT); // gpio_reset_pin may reset to input } #endif +#ifndef DISABLE_PROG if (mode==TRACK_MODE_PROG) { +#else + if (false) { +#endif // only allow 1 track to be prog FOR_EACH_TRACK(t) if (trackMode[t]==TRACK_MODE_PROG && t != trackToSet) { @@ -306,8 +315,10 @@ bool TrackManager::parseJ(Print *stream, int16_t params, int16_t p[]) if (params==2 && p[1]==HASH_KEYWORD_MAIN) // <= id MAIN> return setTrackMode(p[0],TRACK_MODE_MAIN); +#ifndef DISABLE_PROG if (params==2 && p[1]==HASH_KEYWORD_PROG) // <= id PROG> return setTrackMode(p[0],TRACK_MODE_PROG); +#endif if (params==2 && p[1]==HASH_KEYWORD_OFF) // <= id OFF> return setTrackMode(p[0],TRACK_MODE_OFF); @@ -332,9 +343,11 @@ void TrackManager::streamTrackState(Print* stream, byte t) { case TRACK_MODE_MAIN: format=F("<= %c MAIN>\n"); break; +#ifndef DISABLE_PROG case TRACK_MODE_PROG: format=F("<= %c PROG>\n"); break; +#endif case TRACK_MODE_OFF: format=F("<= %c OFF>\n"); break; @@ -357,8 +370,10 @@ void TrackManager::streamTrackState(Print* stream, byte t) { byte TrackManager::nextCycleTrack=MAX_TRACKS; void TrackManager::loop() { - DCCWaveform::loop(); - DCCACK::loop(); + DCCWaveform::loop(); +#ifndef DISABLE_PROG + DCCACK::loop(); +#endif bool dontLimitProg=DCCACK::isActive() || progTrackSyncMain || progTrackBoosted; nextCycleTrack++; if (nextCycleTrack>lastTrack) nextCycleTrack=0;