1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 05:11:24 +01:00

Trackmanager broadcast power state on track mode change

This commit is contained in:
Harald Barth 2023-11-21 11:51:26 +01:00
parent a7096e782c
commit e6f33cfdee
3 changed files with 8 additions and 6 deletions

View File

@ -668,7 +668,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
break; break;
#endif #endif
case '=': // TRACK MANAGER CONTROL <= [params]> case '=': // TRACK MANAGER CONTROL <= [params]>
if (TrackManager::parseJ(stream, params, p)) if (TrackManager::parseEqualSign(stream, params, p))
return; return;
break; break;

View File

@ -350,7 +350,7 @@ void TrackManager::applyDCSpeed(byte t) {
track[t]->setDCSignal(speedByte); 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 if (params==0) { // <=> List track assignments
@ -397,8 +397,8 @@ bool TrackManager::parseJ(Print *stream, int16_t params, int16_t p[])
return false; return false;
} }
// null stream means send to commandDistributor for broadcast
void TrackManager::streamTrackState(Print* stream, byte t) { void TrackManager::streamTrackState(Print* stream, byte t) {
// null stream means send to commandDistributor for broadcast
if (track[t]==NULL) return; if (track[t]==NULL) return;
auto format=F("<= %d XXX>\n"); auto format=F("<= %d XXX>\n");
TRACK_MODE tm = track[t]->getMode(); TRACK_MODE tm = track[t]->getMode();
@ -433,10 +433,12 @@ void TrackManager::streamTrackState(Print* stream, byte t) {
format=F("<= %c DC %d>\n"); 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]); StringFormatter::send(stream,format,'A'+t, trackDCAddr[t]);
else } else {
CommandDistributor::broadcastTrackState(format,'A'+t, trackDCAddr[t]); CommandDistributor::broadcastTrackState(format,'A'+t, trackDCAddr[t]);
CommandDistributor::broadcastPower();
}
} }

View File

@ -73,7 +73,7 @@ class TrackManager {
static const int16_t MAX_TRACKS=8; static const int16_t MAX_TRACKS=8;
static bool setTrackMode(byte track, TRACK_MODE mode, int16_t DCaddr=0); 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 void loop();
static POWERMODE getMainPower(); static POWERMODE getMainPower();
static POWERMODE getProgPower(); static POWERMODE getProgPower();