1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 13:21:23 +01:00

fix vpin numbers

This commit is contained in:
travis-farmer 2024-11-25 10:43:17 -05:00
parent 62de9d9796
commit 44486605a5
No known key found for this signature in database
GPG Key ID: 0BC296791D14CB35

View File

@ -247,13 +247,13 @@ public:
int _readAnalogue(VPIN vpin) override { int _readAnalogue(VPIN vpin) override {
// Return acquired data value, e.g. // Return acquired data value, e.g.
int pin = vpin - _firstVpin; int pin = vpin - _firstVpin - numDiscreteInputs;
return inputRegisters[pin]; return inputRegisters[pin];
} }
void _write(VPIN vpin, int value) override { void _write(VPIN vpin, int value) override {
// Update current state for this device, in preparation the bus transmission // Update current state for this device, in preparation the bus transmission
uint16_t pin = vpin - _firstVpin - numDiscreteInputs; uint16_t pin = vpin - _firstVpin - numDiscreteInputs - numInputRegisters;
if (pin < numCoils) { if (pin < numCoils) {
if (value) if (value)
coils[pin] = value; coils[pin] = value;
@ -263,7 +263,7 @@ public:
} }
void writeAnalogue(VPIN vpin, int value) { void writeAnalogue(VPIN vpin, int value) {
uint16_t pin = vpin - _firstVpin - numInputRegisters; uint16_t pin = vpin - _firstVpin - numDiscreteInputs - numInputRegisters - numCoils;
if (pin < numHoldingRegisters) { if (pin < numHoldingRegisters) {
if (value) if (value)
holdingRegisters[pin] = value; holdingRegisters[pin] = value;