1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +01:00

prettier MAX_TRACKS

This commit is contained in:
Harald Barth 2023-11-14 11:12:14 +01:00
parent fd6e8705c8
commit 763ef8be34
2 changed files with 4 additions and 2 deletions

View File

@ -249,7 +249,7 @@ void CommandDistributor::broadcastLoco(byte slot) {
void CommandDistributor::broadcastPower() { void CommandDistributor::broadcastPower() {
char pstr[] = "? x"; char pstr[] = "? x";
for(byte t=0; t<8; t++) for(byte t=0; t<TrackManager::MAX_TRACKS; t++)
if (TrackManager::getPower(t, pstr)) if (TrackManager::getPower(t, pstr))
broadcastReply(COMMAND_TYPE, F("<p%s>\n"),pstr); broadcastReply(COMMAND_TYPE, F("<p%s>\n"),pstr);

View File

@ -526,7 +526,7 @@ POWERMODE TrackManager::getProgPower() {
FOR_EACH_TRACK(t) FOR_EACH_TRACK(t)
if (track[t]->getMode() & TRACK_MODE_PROG) if (track[t]->getMode() & TRACK_MODE_PROG)
return track[t]->getPower(); // optimize: there is max one prog track return track[t]->getPower(); // optimize: there is max one prog track
return POWERMODE::OFF; return POWERMODE::OFF;
} }
// returns on if all are on. returns off otherwise // returns on if all are on. returns off otherwise
@ -545,6 +545,8 @@ POWERMODE TrackManager::getMainPower() {
} }
bool TrackManager::getPower(byte t, char s[]) { bool TrackManager::getPower(byte t, char s[]) {
if (t > lastTrack)
return false;
if (track[t]) { if (track[t]) {
s[0] = track[t]->getPower() == POWERMODE::ON ? '1' : '0'; s[0] = track[t]->getPower() == POWERMODE::ON ? '1' : '0';
s[2] = t + 'A'; s[2] = t + 'A';