mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
Start on callback
This commit is contained in:
parent
dbf053858b
commit
a0c1ad182c
|
@ -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("<i %d %d>\n"), id, position);
|
||||
void CommandDistributor::broadcastTurntable(int16_t id, uint8_t position, bool moving) {
|
||||
broadcastReply(COMMAND_TYPE, F("<i %d %d %d>\n"), id, position, moving);
|
||||
}
|
||||
|
||||
void CommandDistributor::broadcastClockTime(int16_t time, int8_t rate) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1226,3 +1226,8 @@ void DCCEXParser::callback_Wloco(int16_t result)
|
|||
StringFormatter::send(getAsyncReplyStream(), F("<w %d>\n"), result);
|
||||
commitAsyncReplyStream();
|
||||
}
|
||||
|
||||
void DCCEXParser::callback_Imoving(bool moving) {
|
||||
if (!moving) StringFormatter::send(getAsyncReplyStream(), F("<i>"));
|
||||
commitAsyncReplyStream();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user