diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index eef84a9..ee760b0 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -161,8 +161,8 @@ void CommandDistributor::broadcastTurnout(int16_t id, bool isClosed ) { #endif } -void CommandDistributor::broadcastTurntable(int16_t id, uint8_t position) { - broadcastReply(COMMAND_TYPE, F("\n"), id, position); +void CommandDistributor::broadcastTurntable(int16_t id, uint8_t position, bool moving) { + broadcastReply(COMMAND_TYPE, F("\n"), id, position, moving); } void CommandDistributor::broadcastClockTime(int16_t time, int8_t rate) { diff --git a/CommandDistributor.h b/CommandDistributor.h index b1af10a..a51d58a 100644 --- a/CommandDistributor.h +++ b/CommandDistributor.h @@ -49,7 +49,7 @@ public : static void broadcastLoco(byte slot); static void broadcastSensor(int16_t id, bool value); static void broadcastTurnout(int16_t id, bool isClosed); - static void broadcastTurntable(int16_t id, uint8_t position); + static void broadcastTurntable(int16_t id, uint8_t position, bool moving); static void broadcastClockTime(int16_t time, int8_t rate); static void setClockTime(int16_t time, int8_t rate, byte opt); static int16_t retClockTime(); diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index 24a7914..2b0e06f 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -1226,3 +1226,8 @@ void DCCEXParser::callback_Wloco(int16_t result) StringFormatter::send(getAsyncReplyStream(), F("\n"), result); commitAsyncReplyStream(); } + +void DCCEXParser::callback_Imoving(bool moving) { + if (!moving) StringFormatter::send(getAsyncReplyStream(), F("")); + commitAsyncReplyStream(); +} diff --git a/DCCEXParser.h b/DCCEXParser.h index 8a7367a..7a7ef89 100644 --- a/DCCEXParser.h +++ b/DCCEXParser.h @@ -72,6 +72,7 @@ struct DCCEXParser static void callback_Wloco(int16_t result); static void callback_Vbit(int16_t result); static void callback_Vbyte(int16_t result); + static void callback_Imoving(bool moving); static FILTER_CALLBACK filterCallback; static FILTER_CALLBACK filterRMFTCallback; static AT_COMMAND_CALLBACK atCommandCallback; diff --git a/Turntables.cpp b/Turntables.cpp index a7d42ab..a0419b1 100644 --- a/Turntables.cpp +++ b/Turntables.cpp @@ -95,10 +95,10 @@ uint8_t Turntable::getPositionCount() { /* * Public static functions */ -bool Turntable::setPositionStateOnly(uint16_t id, uint8_t position) { +bool Turntable::setPositionStateOnly(uint16_t id, uint8_t position, bool moving) { Turntable *tto = get(id); if (!tto) return false; - CommandDistributor::broadcastTurntable(id, position); + CommandDistributor::broadcastTurntable(id, position, moving); #if defined(EXRAIL_ACTIVE) // RMFT2::turntableEvent(id, position); #endif @@ -116,7 +116,11 @@ bool Turntable::setPosition(uint16_t id, uint8_t position, uint8_t activity) { if (ok) { // Broadcast a position change only if non zero has been set, or home/calibration sent if (position > 0 || (position == 0 && (activity == 2 || activity == 3))) { - tto->setPositionStateOnly(id, position); + if (tto->getType() == TURNTABLE_EXTT) { + tto->setPositionStateOnly(id, position, 1); + } else { + tto->setPositionStateOnly(id, position, 0); + } tto->_turntableData.position = position; } } diff --git a/Turntables.h b/Turntables.h index 36f5b90..d59bc80 100644 --- a/Turntables.h +++ b/Turntables.h @@ -36,6 +36,9 @@ enum { TURNTABLE_DCC = 1, }; +// Callback needs to return a bool: 1 = moving, 0 = stopped +typedef void (*EXTT_CALLBACK)(bool moving); + /************************************************************************************* * Turntable positions. * @@ -167,7 +170,7 @@ public: */ inline static bool exists(uint16_t id) { return get(id) != 0; } static bool setPosition(uint16_t id, uint8_t position, uint8_t activity=0); - static bool setPositionStateOnly(uint16_t id, uint8_t position); + static bool setPositionStateOnly(uint16_t id, uint8_t position, bool moving); inline static Turntable *first() { return _firstTurntable; } static bool printAll(Print *stream) { bool gotOne = false;