Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add remainderWindowOpen to give immediate packets a better chance #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DCC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ void DCC::loop() {

void DCC::issueReminders() {
// if the main track transmitter still has a pending packet, skip this time around.
if ( DCCWaveform::mainTrack.packetPending) return;
if (!DCCWaveform::mainTrack.reminderWindowOpen) return;

// This loop searches for a loco in the speed table starting at nextLoco and cycling back around
for (int reg=0;reg<MAX_LOCOS;reg++) {
Expand Down
2 changes: 1 addition & 1 deletion DCCEX.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "LCN.h"
#include "freeMemory.h"

#if __has_include ( "myAutomation.h")
#if __has_include ("myAutomation.h") && __has_include ("RMFT.h")
#include "RMFT.h"
#define RMFT_ACTIVE
#endif
Expand Down
6 changes: 6 additions & 0 deletions DCCWaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const byte bitMask[] = {0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
DCCWaveform::DCCWaveform( byte preambleBits, bool isMain) {
isMainTrack = isMain;
packetPending = false;
reminderWindowOpen = false;
memcpy(transmitPacket, idlePacket, sizeof(idlePacket));
state = WAVE_START;
// The +1 below is to allow the preamble generator to create the stop bit
Expand Down Expand Up @@ -222,6 +223,10 @@ void DCCWaveform::interrupt2() {
//end of Byte
bits_sent = 0;
bytes_sent++;
// if this is the byte before last byte, open reminder window
if (bytes_sent == transmitLength && transmitRepeats == 0 && !packetPending) {
reminderWindowOpen = true;
}
// if this is the last byte, prepere for next packet
if (bytes_sent >= transmitLength) {
// end of transmission buffer... repeat or switch to next message
Expand Down Expand Up @@ -270,6 +275,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
pendingLength = byteCount + 1;
pendingRepeats = repeats;
packetPending = true;
reminderWindowOpen = false;
sentResetsSincePacket=0;
}

Expand Down
1 change: 1 addition & 0 deletions DCCWaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class DCCWaveform {
}
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
volatile bool packetPending;
volatile bool reminderWindowOpen;
volatile byte sentResetsSincePacket;
volatile bool autoPowerOff=false;
void setAckBaseline(); //prog track only
Expand Down