diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 643d0a4..6237e48 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -473,7 +473,7 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream) return; return; - case 'J': // < > + case '=': // <= Track manager control > if (TrackManager::parseJ(stream, params, p)) return; break; diff --git a/TrackManager.cpp b/TrackManager.cpp index 69fcf78..991ff37 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -35,6 +35,7 @@ const int16_t HASH_KEYWORD_PROG = -29718; const int16_t HASH_KEYWORD_MAIN = 11339; const int16_t HASH_KEYWORD_OFF = 22479; const int16_t HASH_KEYWORD_DC = 2183; +const int16_t HASH_KEYWORD_A = 65; // parser makes single chars the ascii. MotorDriver * TrackManager::track[MAX_TRACKS]; int16_t TrackManager::trackMode[MAX_TRACKS]; @@ -113,10 +114,10 @@ bool TrackManager::setTrackMode(byte trackToSet, int16_t modeOrAddr) { bool TrackManager::parseJ(Print *stream, int16_t params, int16_t p[]) { - if (params==0) { // List track assignments + if (params==0) { // <=> List track assignments FOR_EACH_TRACK(t) if (track[t]!=NULL) { - StringFormatter::send(stream,F("1 && (p[1]<0 || p[1]>=MAX_TRACKS)) + p[0]-=HASH_KEYWORD_A; // convert A... to 0.... + + if (params>1 && (p[0]<0 || p[0]>=MAX_TRACKS)) return false; - if (params==2 && p[1]==HASH_KEYWORD_MAIN) // - return setTrackMode(p[1],TRACK_MODE_MAIN); + if (params==2 && p[1]==HASH_KEYWORD_MAIN) // <= id MAIN> + return setTrackMode(p[0],TRACK_MODE_MAIN); - if (params==2 && p[1]==HASH_KEYWORD_PROG) // - return setTrackMode(p[1],TRACK_MODE_PROG); + if (params==2 && p[1]==HASH_KEYWORD_PROG) // <= id PROG> + return setTrackMode(p[0],TRACK_MODE_PROG); - if (params==2 && p[1]==HASH_KEYWORD_OFF) // - return setTrackMode(p[1],TRACK_MODE_OFF); + if (params==2 && p[1]==HASH_KEYWORD_OFF) // <= id OFF> + return setTrackMode(p[0],TRACK_MODE_OFF); - if (params==3 && p[1]==HASH_KEYWORD_DC) // - return setTrackMode(p[1],p[2]); + if (params==3 && p[1]==HASH_KEYWORD_DC) // <= id DC cab> + return setTrackMode(p[0],p[2]); return false; }