Skip to content

Commit

Permalink
Broadcast loco forgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Asbelos committed Jul 19, 2024
1 parent dc2eae4 commit 27dc805
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CommandDistributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ void CommandDistributor::broadcastLoco(byte slot) {
#endif
}

void CommandDistributor::broadcastForgetLoco(int16_t loco) {
broadcastReply(COMMAND_TYPE, F("<l %d 0 1 0>\n<- %d>\n"), loco,loco);
}

void CommandDistributor::broadcastPower() {
char pstr[] = "? x";
for(byte t=0; t<TrackManager::MAX_TRACKS; t++)
Expand Down
1 change: 1 addition & 0 deletions CommandDistributor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CommandDistributor {
public :
static void parse(byte clientId,byte* buffer, RingStream * ring);
static void broadcastLoco(byte slot);
static void broadcastForgetLoco(int16_t loco);
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, bool moving);
Expand Down
6 changes: 5 additions & 1 deletion DCC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,15 @@ void DCC::forgetLoco(int cab) { // removes any speed reminders for this loco
if (reg>=0) {
speedTable[reg].loco=0;
setThrottle2(cab,1); // ESTOP if this loco still on track
CommandDistributor::broadcastForgetLoco(cab);
}
}
void DCC::forgetAllLocos() { // removes all speed reminders
setThrottle2(0,1); // ESTOP all locos still on track
for (int i=0;i<MAX_LOCOS;i++) speedTable[i].loco=0;
for (int i=0;i<MAX_LOCOS;i++) {
if (speedTable[i].loco) CommandDistributor::broadcastForgetLoco(speedTable[i].loco);
speedTable[i].loco=0;
}
}

byte DCC::loopStatus=0;
Expand Down
3 changes: 2 additions & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

#include "StringFormatter.h"

#define VERSION "5.2.70"
#define VERSION "5.2.71"
// 5.2.71 - Broadcasts of loco forgets.
// 5.2.70 - IO_RocoDriver renamed to IO_EncoderThrottle.
// - and included in IODEvice.h (circular dependency removed)
// 5.2.69 - IO_RocoDriver. Direct drive train with rotary encoder hw.
Expand Down

0 comments on commit 27dc805

Please sign in to comment.