@Override public boolean isExported(Pin pin) { // Odroid AIN pins are not exported if (getMode(pin) == PinMode.ANALOG_INPUT) { return false; } return super.isExported(pin); }
@Override public boolean isExported(Pin pin) { // Odroid AIN pins are not exported if (getMode(pin) == PinMode.ANALOG_INPUT) { return false; } return super.isExported(pin); }
@Override public double getValue(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); // handle analog input reading for Odroid boards if (mode == PinMode.ANALOG_INPUT) { // read latest analog input value from WiringPi // we need to re-address the pin for Odroid boards (analog_address = assigned_pin_address - AIN_ADDRESS_OFFSET) double value = com.pi4j.wiringpi.Gpio.analogRead(pin.getAddress() - AIN_ADDRESS_OFFSET); // cache latest analog input value getPinCache(pin).setAnalogValue(value); // return latest analog input value return value; } return super.getValue(pin); }
@Override public double getValue(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); // handle analog input reading for Odroid boards if (mode == PinMode.ANALOG_INPUT) { // read latest analog input value from WiringPi // we need to re-address the pin for Odroid boards (analog_address = assigned_pin_address - AIN_ADDRESS_OFFSET) double value = com.pi4j.wiringpi.Gpio.analogRead(pin.getAddress() - AIN_ADDRESS_OFFSET); // cache latest analog input value getPinCache(pin).setAnalogValue(value); // return latest analog input value return value; } return super.getValue(pin); }