mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +01:00
fix vpin numbers
This commit is contained in:
parent
62de9d9796
commit
44486605a5
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user