mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 13:21:01 +01:00
Negative sensor ids
This commit is contained in:
parent
99222bd37f
commit
9ba13a62c9
13
RMFT2.cpp
13
RMFT2.cpp
@ -330,11 +330,16 @@ void RMFT2::driveLoco(byte speed) {
|
|||||||
speedo=speed;
|
speedo=speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RMFT2::readSensor(int16_t sensorId) {
|
bool RMFT2::readSensor(uint16_t sensorId) {
|
||||||
VPIN vpin=abs(sensorId);
|
// Exrail operands are unsigned but we need the signed version as inserted by the macros.
|
||||||
|
int16_t sId=(int16_t) sensorId;
|
||||||
|
|
||||||
|
VPIN vpin=abs(sId);
|
||||||
if (getFlag(vpin,LATCH_FLAG)) return true; // latched on
|
if (getFlag(vpin,LATCH_FLAG)) return true; // latched on
|
||||||
bool s= IODevice::read(vpin) ^ (sensorId<0);
|
|
||||||
if (s && diag) DIAG(F("EXRAIL Sensor %d hit"),sensorId);
|
// negative sensorIds invert the logic (e.g. for a break-beam sensor which goes OFF when detecting)
|
||||||
|
bool s= IODevice::read(vpin) ^ (sId<0);
|
||||||
|
if (s && diag) DIAG(F("EXRAIL Sensor %d hit"),sId);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
RMFT2.h
6
RMFT2.h
@ -85,7 +85,7 @@ private:
|
|||||||
static RMFT2 * pausingTask;
|
static RMFT2 * pausingTask;
|
||||||
void delayMe(long millisecs);
|
void delayMe(long millisecs);
|
||||||
void driveLoco(byte speedo);
|
void driveLoco(byte speedo);
|
||||||
bool readSensor(int16_t sensorId);
|
bool readSensor(uint16_t sensorId);
|
||||||
bool skipIfBlock();
|
bool skipIfBlock();
|
||||||
bool readLoco();
|
bool readLoco();
|
||||||
void loop2();
|
void loop2();
|
||||||
@ -106,10 +106,10 @@ private:
|
|||||||
unsigned long delayTime;
|
unsigned long delayTime;
|
||||||
byte taskId;
|
byte taskId;
|
||||||
|
|
||||||
int16_t loco;
|
uint16_t loco;
|
||||||
bool forward;
|
bool forward;
|
||||||
bool invert;
|
bool invert;
|
||||||
int speedo;
|
byte speedo;
|
||||||
int16_t onTurnoutId;
|
int16_t onTurnoutId;
|
||||||
byte stackDepth;
|
byte stackDepth;
|
||||||
int callStack[MAX_STACK_DEPTH];
|
int callStack[MAX_STACK_DEPTH];
|
||||||
|
Loading…
Reference in New Issue
Block a user