1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-07-28 09:53:45 +02:00

Broadcast stop/estop

Avoids directuion change in reminders
This commit is contained in:
Asbelos
2020-09-03 11:28:52 +01:00
parent 266ef01dbe
commit fd466a5e62
2 changed files with 12 additions and 6 deletions

View File

@@ -48,7 +48,7 @@ void DCC::begin(MotorDriver * mainDriver, MotorDriver* progDriver, byte timerNum
}
void DCC::setThrottle( uint16_t cab, uint8_t tSpeed, bool tDirection) {
byte speedCode = (tSpeed & 0x7F) + tDirection * 128; //speed codes range from 2-127 (0=stop, 1=emergency stop)
byte speedCode = (tSpeed & 0x7F) + tDirection * 128;
setThrottle2(cab, speedCode);
// retain speed for loco reminders
updateLocoReminder(cab, speedCode );
@@ -456,8 +456,10 @@ int DCC::lookupSpeedTable(int locoId) {
void DCC::updateLocoReminder(int loco, byte speedCode) {
if (loco==0) {
// broadcast message
for (int reg = 0; reg < MAX_LOCOS; reg++) speedTable[reg].speedCode = speedCode;
// broadcast stop/estop but dont change direction
for (int reg = 0; reg < MAX_LOCOS; reg++) {
speedTable[reg].speedCode = (speedTable[reg].speedCode & 0x80) | (speedCode & 0x7f);
}
return;
}