1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-27 01:56:14 +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

@ -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';