From a7da30b236f761acf8417a1bb86a6a2253ee8ad5 Mon Sep 17 00:00:00 2001 From: SteveT Date: Fri, 14 Aug 2020 20:46:33 -0400 Subject: [PATCH] turnout list improvements --- WiThrottle.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/WiThrottle.cpp b/WiThrottle.cpp index c7a44d4..5d948a2 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -114,15 +114,13 @@ void WiThrottle::parse(Print & stream, byte * cmdx) { heartBeat=millis(); // DIAG(F("\nWiThrottle(%d)<-[%e]\n"),clientid, cmd); - // Send turnout list when requested + // Send turnout list when requested (will replace list on client) if (sendTurnoutList) { - if (Turnout::firstTurnout) { - StringFormatter::send(stream,F("PTL")); - for(Turnout *tt=Turnout::firstTurnout;tt!=NULL;tt=tt->nextTurnout){ - StringFormatter::send(stream,F("]\\[%d}|{T%d}|{%d"), tt->data.id, tt->data.id, (bool)(tt->data.tStatus & STATUS_ACTIVE)); - } - StringFormatter::send(stream,F("\n")); + StringFormatter::send(stream,F("PTL")); + for(Turnout *tt=Turnout::firstTurnout;tt!=NULL;tt=tt->nextTurnout){ + StringFormatter::send(stream,F("]\\[%d}|{%d}|{%c"), tt->data.id, tt->data.id, Turnout::isActive(tt->data.id)?'4':'2'); } + StringFormatter::send(stream,F("\n")); sendTurnoutList = false; } @@ -161,6 +159,7 @@ void WiThrottle::parse(Print & stream, byte * cmdx) { } Turnout::activate(id,newstate); StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id ); + sendTurnoutList = true; } break; case 'N': // Heartbeat (2)