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);