1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-04-15 18:00:11 +02:00

Merge branch 'EX-RAIL-sensormod'

This commit is contained in:
Harald Barth 2021-11-07 16:17:22 +01:00
commit 177c8c0367
2 changed files with 23 additions and 6 deletions

View File

@ -160,7 +160,7 @@ void IODevice::write(VPIN vpin, int value) {
return; return;
} }
#ifdef DIAG_IO #ifdef DIAG_IO
//DIAG(F("IODevice::write(): Vpin ID %d not found!"), (int)vpin); DIAG(F("IODevice::write(): Vpin ID %d not found!"), (int)vpin);
#endif #endif
} }
@ -179,7 +179,7 @@ void IODevice::writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t para
return; return;
} }
#ifdef DIAG_IO #ifdef DIAG_IO
//DIAG(F("IODevice::writeAnalogue(): Vpin ID %d not found!"), (int)vpin); DIAG(F("IODevice::writeAnalogue(): Vpin ID %d not found!"), (int)vpin);
#endif #endif
} }
@ -265,7 +265,7 @@ int IODevice::read(VPIN vpin) {
return dev->_read(vpin); return dev->_read(vpin);
} }
#ifdef DIAG_IO #ifdef DIAG_IO
//DIAG(F("IODevice::read(): Vpin %d not found!"), (int)vpin); DIAG(F("IODevice::read(): Vpin %d not found!"), (int)vpin);
#endif #endif
return false; return false;
} }
@ -288,7 +288,17 @@ int IODevice::readAnalogue(VPIN vpin) {
// Minimal implementations of public HAL interface, to support Arduino pin I/O and nothing more. // Minimal implementations of public HAL interface, to support Arduino pin I/O and nothing more.
void IODevice::begin() { DIAG(F("NO HAL CONFIGURED!")); } void IODevice::begin() { DIAG(F("NO HAL CONFIGURED!")); }
bool IODevice::configure(VPIN, ConfigTypeEnum, int, int []) { return true; } bool IODevice::configure(VPIN pin, ConfigTypeEnum, int, int p[]) {
#ifdef DIAG_IO
DIAG(F("Arduino _configurePullup Pin:%d Val:%d"), pin, p[0]);
#endif
if (p[0]) {
pinMode(pin, INPUT_PULLUP);
} else {
pinMode(pin, INPUT);
}
return true;
}
void IODevice::write(VPIN vpin, int value) { void IODevice::write(VPIN vpin, int value) {
digitalWrite(vpin, value); digitalWrite(vpin, value);
pinMode(vpin, OUTPUT); pinMode(vpin, OUTPUT);
@ -297,7 +307,6 @@ void IODevice::writeAnalogue(VPIN, int, uint8_t, uint16_t) {}
bool IODevice::isBusy(VPIN) { return false; } bool IODevice::isBusy(VPIN) { return false; }
bool IODevice::hasCallback(VPIN) { return false; } bool IODevice::hasCallback(VPIN) { return false; }
int IODevice::read(VPIN vpin) { int IODevice::read(VPIN vpin) {
pinMode(vpin, INPUT_PULLUP);
return !digitalRead(vpin); // Return inverted state (5v=0, 0v=1) return !digitalRead(vpin); // Return inverted state (5v=0, 0v=1)
} }
int IODevice::readAnalogue(VPIN vpin) { int IODevice::readAnalogue(VPIN vpin) {
@ -434,7 +443,7 @@ int ArduinoPins::_readAnalogue(VPIN vpin) {
interrupts(); interrupts();
#ifdef DIAG_IO #ifdef DIAG_IO
//DIAG(F("Arduino Read Pin:%d Value:%d"), pin, value); DIAG(F("Arduino Read Pin:%d Value:%d"), pin, value);
#endif #endif
return value; return value;
} }

View File

@ -66,6 +66,14 @@ byte RMFT2::flags[MAX_FLAGS];
byte opcode=GET_OPCODE; byte opcode=GET_OPCODE;
if (opcode==OPCODE_ENDEXRAIL) break; if (opcode==OPCODE_ENDEXRAIL) break;
switch (opcode) {
case OPCODE_AT:
case OPCODE_AFTER:
case OPCODE_IF:
case OPCODE_IFNOT:
IODevice::configureInput((VPIN)GET_OPERAND(0),true);
}
if (opcode==OPCODE_SIGNAL) { if (opcode==OPCODE_SIGNAL) {
VPIN red=GET_OPERAND(0); VPIN red=GET_OPERAND(0);
VPIN amber=GET_OPERAND(1); VPIN amber=GET_OPERAND(1);