1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

DCC getFn

This commit is contained in:
Asbelos 2020-10-12 22:18:55 +01:00
parent 576288ba9e
commit 3fe04c1a0e
2 changed files with 10 additions and 0 deletions

View File

@ -155,6 +155,15 @@ int DCC::changeFn( int cab, byte functionNumber, bool pressed) {
return funcstate;
}
int DCC::getFn( int cab, byte functionNumber) {
if (cab<=0 || functionNumber>28) return -1; // unknown
int reg = lookupSpeedTable(cab);
if (reg<0) return -1;
unsigned long funcmask = (1UL<<functionNumber);
return (speedTable[reg].functions & funcmask)? 1 : 0;
}
// Set the group flag to say we have touched the particular group.
// A group will be reminded only if it has been touched.
void DCC::updateGroupflags(byte & flags, int functionNumber) {

1
DCC.h
View File

@ -72,6 +72,7 @@ public:
static void setFunction(int cab, byte fByte, byte eByte);
static void setFn(int cab, byte functionNumber, bool on);
static int changeFn(int cab, byte functionNumber, bool pressed);
static int getFn(int cab, byte functionNumber);
static void updateGroupflags(byte &flags, int functionNumber);
static void setAccessory(int aAdd, byte aNum, bool activate);
static bool writeTextPacket(byte *b, int nBytes);