@Override public void setMode(Pin pin, PinMode mode) { // no need to export an Odroid AIN pin if (mode == PinMode.ANALOG_INPUT) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } // local pin mode cache pinModeCache[pin.getAddress()] = mode; // cache mode getPinCache(pin).setMode(mode); return; } super.setMode(pin, mode); }
@Override public void setMode(Pin pin, PinMode mode) { // no need to export an Odroid AIN pin if (mode == PinMode.ANALOG_INPUT) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } // local pin mode cache pinModeCache[pin.getAddress()] = mode; // cache mode getPinCache(pin).setMode(mode); return; } super.setMode(pin, mode); }
@Override public void export(Pin pin, PinMode mode, PinState defaultState) { super.export(pin, mode); //System.out.println("-- EXPORTING PIN [" + pin.getAddress() + "] to mode [" + mode.getName() + "]"); // get mode configured direction value int direction = mode.getDirection().getValue(); // if a default state was provided and the direction is OUT, then override the // pin direction to include initial state value if(defaultState != null && mode.getDirection() == PinDirection.OUT){ if(defaultState == PinState.LOW) direction = GpioUtil.DIRECTION_LOW; else if(defaultState == PinState.HIGH) direction = GpioUtil.DIRECTION_HIGH; } // if not already exported, export the pin and set the pin direction if(!GpioUtil.isExported(pin.getAddress())){ GpioUtil.export(pin.getAddress(), direction); } // if the pin is already exported, then check its current configured direction // if the direction does not match, then set the new direction for the pin else if(GpioUtil.getDirection(pin.getAddress()) != mode.getDirection().getValue()){ GpioUtil.setDirection(pin.getAddress(), direction); } // set the pin input/output mode setMode(pin, mode); }
@Override public void export(Pin pin, PinMode mode, PinState defaultState) { super.export(pin, mode); //System.out.println("-- EXPORTING PIN [" + pin.getAddress() + "] to mode [" + mode.getName() + "]"); // get mode configured direction value int direction = mode.getDirection().getValue(); // if a default state was provided and the direction is OUT, then override the // pin direction to include initial state value if(defaultState != null && mode.getDirection() == PinDirection.OUT){ if(defaultState == PinState.LOW) direction = GpioUtil.DIRECTION_LOW; else if(defaultState == PinState.HIGH) direction = GpioUtil.DIRECTION_HIGH; } // if not already exported, export the pin and set the pin direction if(!GpioUtil.isExported(pin.getAddress())){ GpioUtil.export(pin.getAddress(), direction); } // if the pin is already exported, then check its current configured direction // if the direction does not match, then set the new direction for the pin else if(GpioUtil.getDirection(pin.getAddress()) != mode.getDirection().getValue()){ GpioUtil.setDirection(pin.getAddress(), direction); } // set the pin input/output mode setMode(pin, mode); }