@Override public PinMode getMode(Pin pin) { super.getMode(pin); // return first mode found; this device has singular fixed pin modes for(PinMode mode : pin.getSupportedPinModes()) return mode; return null; }
@Override public void unexport(Pin pin) { // no need to unexport an Odroid AIN pin if (pin.getSupportedPinModes().contains(PinMode.ANALOG_INPUT)) { return; } super.unexport(pin); }
@Override public void unexport(Pin pin) { // no need to unexport an Odroid AIN pin if (pin.getSupportedPinModes().contains(PinMode.ANALOG_INPUT)) { return; } super.unexport(pin); }
/** * Get all pin instances from this provider that support one of the provided pin modes. * @param mode one or more pin modes that you wish to include in the result set * @return pin instances that support the provided pin modes */ public static Pin[] allPins(PinMode ... mode) { List<Pin> results = new ArrayList<>(); for(Pin p : pins.values()){ EnumSet<PinMode> supported_modes = p.getSupportedPinModes(); for(PinMode m : mode){ if(supported_modes.contains(m)){ results.add(p); continue; } } } return results.toArray(new Pin[0]); } }
/** * Get all pin instances from this provider that support one of the provided pin modes. * @param mode one or more pin modes that you wish to include in the result set * @return pin instances that support the provided pin modes */ public static Pin[] allPins(PinMode ... mode) { List<Pin> results = new ArrayList<>(); for(Pin p : pins.values()){ EnumSet<PinMode> supported_modes = p.getSupportedPinModes(); for(PinMode m : mode){ if(supported_modes.contains(m)){ results.add(p); continue; } } } return results.toArray(new Pin[0]); } }
@Override public void setMode(Pin pin, PinMode mode) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); }
@Override public void setMode(Pin pin, PinMode mode) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); }
@Override public void setMode(Pin pin, PinMode mode) { super.setMode(pin, mode); // local pin mode cache pinModeCache[pin.getAddress()] = mode; if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); // set pin mode on hardware com.pi4j.wiringpi.Gpio.pinMode(pin.getAddress(), mode.getValue()); }
@Override public void setMode(Pin pin, PinMode mode) { super.setMode(pin, mode); // local pin mode cache pinModeCache[pin.getAddress()] = mode; if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); // set pin mode on hardware com.pi4j.wiringpi.Gpio.pinMode(pin.getAddress(), mode.getValue()); }
@Override public void export(Pin pin, PinMode mode) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache exported state getPinCache(pin).setExported(true); // cache mode getPinCache(pin).setMode(mode); }
@Override public void export(Pin pin, PinMode mode) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache exported state getPinCache(pin).setExported(true); // cache mode getPinCache(pin).setMode(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 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); }