mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
delay long only at write, poweroff short always at rejoi
This commit is contained in:
parent
3038f29dac
commit
1feaa98ee5
31
DCC.cpp
31
DCC.cpp
|
@ -772,7 +772,7 @@ void DCC::ackManagerLoop() {
|
||||||
if (DCCWaveform::progTrack.getPowerMode()==POWERMODE::OVERLOAD) return;
|
if (DCCWaveform::progTrack.getPowerMode()==POWERMODE::OVERLOAD) return;
|
||||||
if (checkResets(DCCWaveform::progTrack.autoPowerOff || ackManagerRejoin ? 20 : 3)) return;
|
if (checkResets(DCCWaveform::progTrack.autoPowerOff || ackManagerRejoin ? 20 : 3)) return;
|
||||||
DCCWaveform::progTrack.setAckBaseline();
|
DCCWaveform::progTrack.setAckBaseline();
|
||||||
callbackState=READY;
|
callbackState=AFTER_READ;
|
||||||
break;
|
break;
|
||||||
case W0: // write 0 bit
|
case W0: // write 0 bit
|
||||||
case W1: // write 1 bit
|
case W1: // write 1 bit
|
||||||
|
@ -958,6 +958,7 @@ void DCC::callback(int value) {
|
||||||
|
|
||||||
switch (callbackState) {
|
switch (callbackState) {
|
||||||
case AFTER_WRITE: // first attempt to callback after a write operation
|
case AFTER_WRITE: // first attempt to callback after a write operation
|
||||||
|
// If no poweroff and no rejoin planned, continue without delay.
|
||||||
if (!ackManagerRejoin && !DCCWaveform::progTrack.autoPowerOff) {
|
if (!ackManagerRejoin && !DCCWaveform::progTrack.autoPowerOff) {
|
||||||
callbackState=READY;
|
callbackState=READY;
|
||||||
break;
|
break;
|
||||||
|
@ -966,20 +967,24 @@ void DCC::callback(int value) {
|
||||||
callbackState=WAITING_100;
|
callbackState=WAITING_100;
|
||||||
if (Diag::ACK) DIAG(F("Stable 100mS"));
|
if (Diag::ACK) DIAG(F("Stable 100mS"));
|
||||||
break;
|
break;
|
||||||
|
case AFTER_READ:
|
||||||
case WAITING_100: // waiting for 100mS
|
// If we are going to power off anyway, it doesnt matter
|
||||||
|
// but if we will keep the power on, we must off it for 30mS
|
||||||
|
// If we do not plan do rejoin, we don't need to power off either
|
||||||
|
if (DCCWaveform::progTrack.autoPowerOff || !ackManagerRejoin) {
|
||||||
|
callbackState=READY;
|
||||||
|
} else {
|
||||||
|
DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF);
|
||||||
|
callbackStart=millis();
|
||||||
|
callbackState=WAITING_30;
|
||||||
|
if (Diag::ACK) DIAG(F("OFF 30mS"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WAITING_100: // waiting for 100mS for decoder write to settle
|
||||||
if (millis()-callbackStart < 100) break;
|
if (millis()-callbackStart < 100) break;
|
||||||
// stable after power maintained for 100mS
|
// stable after power maintained for 100mS
|
||||||
|
// still may need to do the 30mS delay
|
||||||
// If we are going to power off anyway, it doesnt matter
|
callbackState=AFTER_READ;
|
||||||
// but if we will keep the power on, we must off it for 30mS
|
|
||||||
if (DCCWaveform::progTrack.autoPowerOff) callbackState=READY;
|
|
||||||
else { // Need to cycle power off and on
|
|
||||||
DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF);
|
|
||||||
callbackStart=millis();
|
|
||||||
callbackState=WAITING_30;
|
|
||||||
if (Diag::ACK) DIAG(F("OFF 30mS"));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WAITING_30: // waiting for 30mS with power off
|
case WAITING_30: // waiting for 30mS with power off
|
||||||
|
|
1
DCC.h
1
DCC.h
|
@ -73,6 +73,7 @@ enum ackOp : byte
|
||||||
|
|
||||||
enum CALLBACK_STATE : byte {
|
enum CALLBACK_STATE : byte {
|
||||||
AFTER_WRITE, // Start callback sequence after something was written to the decoder
|
AFTER_WRITE, // Start callback sequence after something was written to the decoder
|
||||||
|
AFTER_READ, // Start callback sequence after something was read from the decoder
|
||||||
WAITING_100, // Waiting for 100mS of stable power
|
WAITING_100, // Waiting for 100mS of stable power
|
||||||
WAITING_30, // waiting to 30ms of power off gap.
|
WAITING_30, // waiting to 30ms of power off gap.
|
||||||
READY, // Ready to complete callback
|
READY, // Ready to complete callback
|
||||||
|
|
Loading…
Reference in New Issue
Block a user