mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 12:51:24 +01:00
make sentResetsSincePacket private to the class and replace all accesses with with methods
This commit is contained in:
parent
863f2f4a85
commit
c7cf8246a7
@ -81,7 +81,7 @@ void DCCACK::Setup(int cv, byte byteValueOrBitnum, ackOp const program[], ACK_C
|
||||
if (ackManagerRejoin ) {
|
||||
// Change from JOIN must zero resets packet.
|
||||
TrackManager::setJoin(false);
|
||||
DCCWaveform::progTrack.sentResetsSincePacket = 0;
|
||||
DCCWaveform::progTrack.clearResets();
|
||||
}
|
||||
|
||||
autoPowerOff=false;
|
||||
@ -93,7 +93,7 @@ void DCCACK::Setup(int cv, byte byteValueOrBitnum, ackOp const program[], ACK_C
|
||||
/* TODO !!! in MotorDriver surely!
|
||||
if (MotorDriver::commonFaultPin)
|
||||
DCCWaveform::mainTrack.setPowerMode(POWERMODE::ON);
|
||||
DCCWaveform::progTrack.sentResetsSincePacket = 0;
|
||||
DCCWaveform::progTrack.clearResets();
|
||||
**/
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ const byte RESET_MIN=8; // tuning of reset counter before sending message
|
||||
|
||||
// checkRessets return true if the caller should yield back to loop and try later.
|
||||
bool DCCACK::checkResets(uint8_t numResets) {
|
||||
return DCCWaveform::progTrack.sentResetsSincePacket < numResets;
|
||||
return DCCWaveform::progTrack.getResets() < numResets;
|
||||
}
|
||||
// Operations applicable to PROG track ONLY.
|
||||
// (yes I know I could have subclassed the main track but...)
|
||||
|
@ -89,7 +89,7 @@ void DCCWaveform::interruptHandler() {
|
||||
// WAVE_PENDING means we dont yet know what the next bit is
|
||||
if (mainTrack.state==WAVE_PENDING) mainTrack.interrupt2();
|
||||
if (progTrack.state==WAVE_PENDING) progTrack.interrupt2();
|
||||
else DCCACK::checkAck(progTrack.sentResetsSincePacket);
|
||||
else DCCACK::checkAck(progTrack.getResets());
|
||||
|
||||
}
|
||||
#pragma GCC pop_options
|
||||
@ -160,14 +160,14 @@ void DCCWaveform::interrupt2() {
|
||||
transmitLength = pendingLength;
|
||||
transmitRepeats = pendingRepeats;
|
||||
packetPending = false;
|
||||
sentResetsSincePacket=0;
|
||||
clearResets();
|
||||
}
|
||||
else {
|
||||
// Fortunately reset and idle packets are the same length
|
||||
memcpy( transmitPacket, isMainTrack ? idlePacket : resetPacket, sizeof(idlePacket));
|
||||
transmitLength = sizeof(idlePacket);
|
||||
transmitRepeats = 0;
|
||||
if (sentResetsSincePacket<250) sentResetsSincePacket++;
|
||||
if (getResets() < 250) sentResetsSincePacket++; // only place to increment (private!)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,7 +189,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
|
||||
pendingLength = byteCount + 1;
|
||||
pendingRepeats = repeats;
|
||||
packetPending = true;
|
||||
sentResetsSincePacket=0;
|
||||
clearResets();
|
||||
}
|
||||
bool DCCWaveform::getPacketPending() {
|
||||
return packetPending;
|
||||
@ -237,7 +237,7 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
|
||||
pendingPacket[byteCount] = checksum;
|
||||
pendingLength = byteCount + 1;
|
||||
pendingRepeats = repeats;
|
||||
sentResetsSincePacket=0;
|
||||
clearResets();
|
||||
{
|
||||
int ret;
|
||||
do {
|
||||
|
@ -69,12 +69,12 @@ class DCCWaveform {
|
||||
};
|
||||
#endif
|
||||
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
|
||||
volatile byte sentResetsSincePacket;
|
||||
bool getPacketPending();
|
||||
|
||||
private:
|
||||
#ifndef ARDUINO_ARCH_ESP32
|
||||
volatile bool packetPending;
|
||||
volatile byte sentResetsSincePacket;
|
||||
#else
|
||||
volatile uint32_t resetPacketBase;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user