1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-30 03:26:13 +01:00

Logic and diag message done

This commit is contained in:
peteGSX 2023-01-12 08:10:41 +10:00
parent a8646a2f32
commit 9b36bdcf46

View File

@ -105,7 +105,7 @@ private:
if (configType != CONFIGURE_INPUT) return false; if (configType != CONFIGURE_INPUT) return false;
if (paramCount != 1) return false; if (paramCount != 1) return false;
if (vpin >= _firstVpin + _numDigitalPins) { if (vpin >= _firstVpin + _numDigitalPins) {
DIAG(F("Vpin %d is an analogue pin, cannot use as a digital pin"), vpin); DIAG(F("EX-IOExpander ERROR: Vpin %d is an analogue pin, cannot use as a digital pin"), vpin);
return false; return false;
} }
bool pullup = params[0]; bool pullup = params[0];
@ -117,11 +117,16 @@ private:
return true; return true;
} }
int _readAnalogue(VPIN vpin) override { // We only use this to detect incorrect use of analogue pins
int _configureAnalogIn(VPIN vpin) override {
if (vpin < _firstVpin + _numDigitalPins) { if (vpin < _firstVpin + _numDigitalPins) {
DIAG(F("Vpin %d is a digital pin, cannot use as an analogue pin"), vpin); DIAG(F("EX-IOExpander ERROR: Vpin %d is a digital pin, cannot use as an analogue pin"), vpin);
return false;
} }
return false;
}
int _readAnalogue(VPIN vpin) override {
if (vpin < _firstVpin + _numDigitalPins) return false;
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin;
_analogueOutBuffer[0] = EXIORDAN; _analogueOutBuffer[0] = EXIORDAN;
_analogueOutBuffer[1] = pin; _analogueOutBuffer[1] = pin;
@ -130,10 +135,7 @@ private:
} }
int _read(VPIN vpin) override { int _read(VPIN vpin) override {
if (vpin >= _firstVpin + _numDigitalPins) { if (vpin >= _firstVpin + _numDigitalPins) return false;
DIAG(F("Vpin %d is an analogue pin, cannot use as a digital pin"), vpin);
return false;
}
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin;
_digitalOutBuffer[0] = EXIORDD; _digitalOutBuffer[0] = EXIORDD;
_digitalOutBuffer[1] = pin; _digitalOutBuffer[1] = pin;
@ -143,10 +145,7 @@ private:
} }
void _write(VPIN vpin, int value) override { void _write(VPIN vpin, int value) override {
if (vpin >= _firstVpin + _numDigitalPins) { if (vpin >= _firstVpin + _numDigitalPins) return;
DIAG(F("Vpin %d is an analogue pin, cannot use as a digital pin"), vpin);
return;
}
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin;
_digitalOutBuffer[0] = EXIOWRD; _digitalOutBuffer[0] = EXIOWRD;
_digitalOutBuffer[1] = pin; _digitalOutBuffer[1] = pin;