From f755c291d52f0703efda4cc4b90e665214bd90bf Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 16 Dec 2021 12:32:14 +0000 Subject: [PATCH] Turnout typos and power broadcast --- Turnouts.h | 2 +- WiThrottle.cpp | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Turnouts.h b/Turnouts.h index cce0190..8666250 100644 --- a/Turnouts.h +++ b/Turnouts.h @@ -165,7 +165,7 @@ public: #endif static void printAll(Print *stream) { for (Turnout *tt = _firstTurnout; tt != 0; tt = tt->_nextTurnout) - StringFormatter::send(stream, F("\n"),tt->getId(), tt->isThrown()); + StringFormatter::send(stream, F("\n"),tt->getId(), tt->isThrown()); } diff --git a/WiThrottle.cpp b/WiThrottle.cpp index b3cc0a8..b9fef3f 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -50,6 +50,7 @@ #include "GITHUB_SHA.h" #include "version.h" #include "RMFT2.h" +#include "CommandDistributor.h" #define STR_HELPER(x) #x #define STR(x) STR_HELPER(x) @@ -113,12 +114,6 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) { if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d)<-[%e]"),millis(),clientid,cmd); if (initSent) { - // Send power state if different than last sent - bool currentPowerState = (DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON); - if (lastPowerState != currentPowerState) { - StringFormatter::send(stream,F("PPA%x\n"),currentPowerState); - lastPowerState = currentPowerState; - } // Send turnout list if changed since last sent (will replace list on client) if (turnoutListHash != Turnout::turnoutlistHash) { StringFormatter::send(stream,F("PTL")); @@ -148,10 +143,9 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) { case 'P': if (cmd[1]=='P' && cmd[2]=='A' ) { //PPA power mode DCCWaveform::mainTrack.setPowerMode(cmd[3]=='1'?POWERMODE::ON:POWERMODE::OFF); - if (MotorDriver::commonFaultPin) // commonFaultPin prevents individual track handling - DCCWaveform::progTrack.setPowerMode(cmd[3]=='1'?POWERMODE::ON:POWERMODE::OFF); - StringFormatter::send(stream,F("PPA%x\n"),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON); - lastPowerState = (DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON); //remember power state sent for comparison later + if (MotorDriver::commonFaultPin) // commonFaultPin prevents individual track handling + DCCWaveform::progTrack.setPowerMode(cmd[3]=='1'?POWERMODE::ON:POWERMODE::OFF); + CommandDistributor::broadcastPower(); } #if defined(RMFT_ACTIVE) else if (cmd[1]=='R' && cmd[2]=='A' && cmd[3]=='2' ) { // Route activate @@ -202,7 +196,6 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) { StringFormatter::send(stream,F("HtDCC-EX v%S, %S, %S, %S\n"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA)); StringFormatter::send(stream,F("PTT]\\[Turnouts}|{Turnout]\\[THROW}|{2]\\[CLOSE}|{4\n")); StringFormatter::send(stream,F("PPA%x\n"),DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON); - lastPowerState = (DCCWaveform::mainTrack.getPowerMode()==POWERMODE::ON); //remember power state sent for comparison later StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS); initSent = true; }