mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 13:21:23 +01:00
Introduce POWERON and POWEROFF opcodes
This commit is contained in:
parent
665a540a73
commit
5c775531f6
15
DCC.cpp
15
DCC.cpp
@ -643,6 +643,21 @@ void DCC::ackManagerLoop(bool blocking) {
|
||||
opcode=pgm_read_byte_near(ackManagerProg);
|
||||
}
|
||||
break;
|
||||
case POWERON:
|
||||
if (DCCWaveform::progTrack.getPowerMode() == POWERMODE::OFF) {
|
||||
DCCWaveform::progTrack.setPowerMode(POWERMODE::ON);
|
||||
DCCWaveform::progTrack.sentResetsSincePacket = 0;
|
||||
DCCWaveform::progTrack.autoPowerOff=true;
|
||||
return;
|
||||
}
|
||||
if (checkResets(blocking, 20)) return;
|
||||
break;
|
||||
case POWEROFF:
|
||||
if (DCCWaveform::progTrack.autoPowerOff) {
|
||||
DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF);
|
||||
DCCWaveform::progTrack.autoPowerOff=false;
|
||||
}
|
||||
break;
|
||||
case SKIPTARGET:
|
||||
break;
|
||||
default:
|
||||
|
4
DCC.h
4
DCC.h
@ -44,6 +44,8 @@ SETCV, // sets cv number to next prog byte
|
||||
STASHLOCOID, // keeps current byte value for later
|
||||
COMBINELOCOID, // combines current value with stashed value and returns it
|
||||
ITSKIP, // skip to SKIPTARGET if ack true
|
||||
POWERON, // check if power on prog track is on and remember state
|
||||
POWEROFF, // turn power off again if it was off before POWERON
|
||||
SKIPTARGET=0xFF // jump to target
|
||||
};
|
||||
|
||||
@ -120,7 +122,7 @@ private:
|
||||
static ACK_CALLBACK ackManagerCallback;
|
||||
static void ackManagerSetup(int cv, byte bitNumOrbyteValue, ackOp const program[], ACK_CALLBACK callback, bool blocking);
|
||||
static void ackManagerLoop(bool blocking);
|
||||
static bool checkResets(bool blocking);
|
||||
static bool checkResets(bool blocking, uint8_t numResets);
|
||||
static const int PROG_REPEATS=8; // repeats of programming commands (some decoders need at least 8 to be reliable)
|
||||
|
||||
|
||||
|
@ -60,6 +60,7 @@ class DCCWaveform {
|
||||
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
|
||||
volatile bool packetPending;
|
||||
volatile byte sentResetsSincePacket;
|
||||
volatile bool autoPowerOff=false;
|
||||
void setAckBaseline(bool debug); //prog track only
|
||||
void setAckPending(bool debug); //prog track only
|
||||
byte getAck(bool debug); //prog track only 0=NACK, 1=ACK 2=keep waiting
|
||||
|
Loading…
Reference in New Issue
Block a user