From e6f33cfdee7aacc37e8071f3fe4e1659b77d8924 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Tue, 21 Nov 2023 11:51:26 +0100 Subject: [PATCH] Trackmanager broadcast power state on track mode change --- DCCEXParser.cpp | 2 +- TrackManager.cpp | 10 ++++++---- TrackManager.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index aed185b..8a81616 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -668,7 +668,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream) break; #endif case '=': // TRACK MANAGER CONTROL <= [params]> - if (TrackManager::parseJ(stream, params, p)) + if (TrackManager::parseEqualSign(stream, params, p)) return; break; diff --git a/TrackManager.cpp b/TrackManager.cpp index 2f528bd..58a5c30 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -350,7 +350,7 @@ void TrackManager::applyDCSpeed(byte t) { track[t]->setDCSignal(speedByte); } -bool TrackManager::parseJ(Print *stream, int16_t params, int16_t p[]) +bool TrackManager::parseEqualSign(Print *stream, int16_t params, int16_t p[]) { if (params==0) { // <=> List track assignments @@ -397,8 +397,8 @@ bool TrackManager::parseJ(Print *stream, int16_t params, int16_t p[]) return false; } +// null stream means send to commandDistributor for broadcast void TrackManager::streamTrackState(Print* stream, byte t) { - // null stream means send to commandDistributor for broadcast if (track[t]==NULL) return; auto format=F("<= %d XXX>\n"); TRACK_MODE tm = track[t]->getMode(); @@ -433,10 +433,12 @@ void TrackManager::streamTrackState(Print* stream, byte t) { format=F("<= %c DC %d>\n"); } - if (stream) + if (stream) { // null stream means send to commandDistributor for broadcast StringFormatter::send(stream,format,'A'+t, trackDCAddr[t]); - else + } else { CommandDistributor::broadcastTrackState(format,'A'+t, trackDCAddr[t]); + CommandDistributor::broadcastPower(); + } } diff --git a/TrackManager.h b/TrackManager.h index 644c45a..8092f0a 100644 --- a/TrackManager.h +++ b/TrackManager.h @@ -73,7 +73,7 @@ class TrackManager { static const int16_t MAX_TRACKS=8; static bool setTrackMode(byte track, TRACK_MODE mode, int16_t DCaddr=0); - static bool parseJ(Print * stream, int16_t params, int16_t p[]); + static bool parseEqualSign(Print * stream, int16_t params, int16_t p[]); static void loop(); static POWERMODE getMainPower(); static POWERMODE getProgPower();