From d8366f33c89521d451d39d77d0ca12e13314d20d Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Sat, 21 Aug 2021 00:25:00 +0100 Subject: [PATCH] Make output turnout state rather than full turnout definition. command currently prints the current states for outputs and for sensors, but prints the full configuration of turnouts. This change makes the turnout output consistent, i.e. just is output for each turnout. The command still outputs the full turnout definition. --- Turnouts.cpp | 4 +--- Turnouts.h | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Turnouts.cpp b/Turnouts.cpp index 86607f4..2647e1a 100644 --- a/Turnouts.cpp +++ b/Turnouts.cpp @@ -194,9 +194,7 @@ // Display, on the specified stream, the current state of the turnout (1 or 0). void Turnout::printState(uint16_t id, Print *stream) { Turnout *tt = get(id); - if (!tt) - StringFormatter::send(stream, F("\n"), - id, tt->_turnoutData.closed ^ useLegacyTurnoutBehaviour); + if (!tt) tt->printState(stream); } #endif \ No newline at end of file diff --git a/Turnouts.h b/Turnouts.h index 0a05dca..5ab7b07 100644 --- a/Turnouts.h +++ b/Turnouts.h @@ -119,6 +119,10 @@ public: inline bool isType(uint8_t type) { return _turnoutData.turnoutType == type; } inline uint16_t getId() { return _turnoutData.id; } inline Turnout *next() { return _nextTurnout; } + inline void printState(Print *stream) { + StringFormatter::send(stream, F("\n"), + _turnoutData.id, _turnoutData.closed ^ useLegacyTurnoutBehaviour); + } /* * Virtual functions */ @@ -170,7 +174,7 @@ public: static void printAll(Print *stream) { for (Turnout *tt = _firstTurnout; tt != 0; tt = tt->_nextTurnout) - tt->print(stream); + tt->printState(stream); } static void printState(uint16_t id, Print *stream);