1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-06-16 12:35:24 +02:00

Compare commits

..

No commits in common. "6e5668c2581187db9d28bbd01e932d74dc8b67ff" and "b243ba1784827b15cb9309619ab4157ea2a9116d" have entirely different histories.

3 changed files with 30 additions and 59 deletions

78
DCC.cpp
View File

@ -862,34 +862,15 @@ void DCC::loop() {
} }
void DCC::issueReminders() { void DCC::issueReminders() {
while(true) {
// Move to next loco slot. If occupied, send a reminder. // Move to next loco slot. If occupied, send a reminder.
// slot.loco is -1 for deleted locos, 0 for end of list. auto slot = nextLocoReminder;
for (auto slot=nextLocoReminder;slot->loco;slot++) { if (slot >= &speedTable[MAX_LOCOS]) slot=&speedTable[0]; // Go to start of table
if (slot->loco<0) continue; // deleted loco, skip it if (slot->loco > 0)
if (issueReminder(slot)) { if (!issueReminder(slot))
nextLocoReminder=slot+1; // remember next one to check return;
return; // reminder sent, exit // a loco=0 is at the end of the list, a loco <0 is deleted
} if (slot->loco==0) nextLocoReminder = &speedTable[0];
} else nextLocoReminder=slot+1;
// we have reached the end of the table, so we can move on to
// the next loop state and start from the top.
// There are 0-9 loop states.. speed,f1,speed,f2,speed,f3,speed,f4,speed,f5
loopStatus++;
if (loopStatus>9) loopStatus=0; // reset to 0
// try looking from the start of the table down to where we started last time
for (auto slot=&speedTable[0];slot<nextLocoReminder;slot++) {
if (slot->loco<0) continue; // deleted loco, skip it
if (issueReminder(slot)) {
nextLocoReminder=slot+1; // remember next one to check
return; // reminder sent, exit
}
}
// if we get here then we can update the loop status and start again
if (loopStatus==0) return; // nothing found at all
}
} }
int16_t normalize(byte speed) { int16_t normalize(byte speed) {
@ -910,11 +891,7 @@ bool DCC::issueReminder(LOCO * slot) {
byte flags=slot->groupFlags; byte flags=slot->groupFlags;
switch (loopStatus) { switch (loopStatus) {
case 0: case 0: {
case 2:
case 4:
case 6:
case 8: {
// calculate any momentum change going on // calculate any momentum change going on
auto sc=slot->speedCode; auto sc=slot->speedCode;
if (slot->targetSpeed!=sc) { if (slot->targetSpeed!=sc) {
@ -946,39 +923,34 @@ bool DCC::issueReminder(LOCO * slot) {
// DIAG(F("Reminder %d speed %d"),loco,slot->speedCode); // DIAG(F("Reminder %d speed %d"),loco,slot->speedCode);
setThrottle2(loco, sc); setThrottle2(loco, sc);
} }
return true; // reminder sent break;
case 1: // remind function group 1 (F0-F4) case 1: // remind function group 1 (F0-F4)
if (flags & FN_GROUP_1) { if (flags & FN_GROUP_1)
setFunctionInternal(loco,0, 128 | ((functions>>1)& 0x0F) | ((functions & 0x01)<<4)); // 100D DDDD setFunctionInternal(loco,0, 128 | ((functions>>1)& 0x0F) | ((functions & 0x01)<<4)); // 100D DDDD
return true; // reminder sent
}
break; break;
case 3: // remind function group 2 F5-F8 case 2: // remind function group 2 F5-F8
if (flags & FN_GROUP_2) { if (flags & FN_GROUP_2)
setFunctionInternal(loco,0, 176 | ((functions>>5)& 0x0F)); // 1011 DDDD setFunctionInternal(loco,0, 176 | ((functions>>5)& 0x0F)); // 1011 DDDD
return true; // reminder sent
}
break; break;
case 5: // remind function group 3 F9-F12 case 3: // remind function group 3 F9-F12
if (flags & FN_GROUP_3) { if (flags & FN_GROUP_3)
setFunctionInternal(loco,0, 160 | ((functions>>9)& 0x0F)); // 1010 DDDD setFunctionInternal(loco,0, 160 | ((functions>>9)& 0x0F)); // 1010 DDDD
return true; // reminder sent
}
break; break;
case 7: // remind function group 4 F13-F20 case 4: // remind function group 4 F13-F20
if (flags & FN_GROUP_4) { if (flags & FN_GROUP_4)
setFunctionInternal(loco,222, ((functions>>13)& 0xFF)); setFunctionInternal(loco,222, ((functions>>13)& 0xFF));
return true;
}
break; break;
case 9: // remind function group 5 F21-F28 case 5: // remind function group 5 F21-F28
if (flags & FN_GROUP_5) { if (flags & FN_GROUP_5)
setFunctionInternal(loco,223, ((functions>>21)& 0xFF)); setFunctionInternal(loco,223, ((functions>>21)& 0xFF));
return true; // reminder sent
}
break; break;
} }
return false; // no reminder sent loopStatus++;
// if we reach status 6 then this loco is done so
// reset status to 0 for next loco and return true so caller
// moves on to next loco.
if (loopStatus>5) loopStatus=0;
return loopStatus==0;
} }

View File

@ -159,7 +159,7 @@ void DCCWaveform::interrupt2() {
// As we get to the end of the preambles, open the reminder window. // As we get to the end of the preambles, open the reminder window.
// This delays any reminder insertion until the last moment so // This delays any reminder insertion until the last moment so
// that the reminder doesn't block a more urgent packet. // that the reminder doesn't block a more urgent packet.
reminderWindowOpen=transmitRepeats==0 && remainingPreambles<12 && remainingPreambles>1; reminderWindowOpen=transmitRepeats==0 && remainingPreambles<10 && remainingPreambles>1;
if (remainingPreambles==1) if (remainingPreambles==1)
promotePendingPacket(); promotePendingPacket();

View File

@ -3,8 +3,7 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.5.23" #define VERSION "5.5.22"
// 5.5.23 - Reminder loop Idle packet optimization
// 5.5.22 - (5.4.9) Handle non-compliant decoders returning 255 for cv 20 and confusing <R> with bad consist addresses. // 5.5.22 - (5.4.9) Handle non-compliant decoders returning 255 for cv 20 and confusing <R> with bad consist addresses.
// - DCC 5mS gap to same loco DCC packet restriction // - DCC 5mS gap to same loco DCC packet restriction
// - Catch up MASTER for ESP32 IDF version check // - Catch up MASTER for ESP32 IDF version check