public int getChannel() { return pinInfo.getPinNumber(); }
public int getChannel() { return pinInfo.getPinNumber(); } }
protected void addAdcPinInfo(PinInfo pinInfo) { adcs.put(Integer.valueOf(pinInfo.getDeviceNumber()), pinInfo); pinsByName.put(pinInfo.getName(), pinInfo); if (pinInfo.getPinNumber() != PinInfo.NOT_DEFINED) { getPinsForHeader(pinInfo.getHeader()).put(Integer.valueOf(pinInfo.getPinNumber()), pinInfo); } }
protected void addGpioPinInfo(PinInfo pinInfo) { gpios.put(Integer.valueOf(pinInfo.getDeviceNumber()), pinInfo); pinsByName.put(pinInfo.getName(), pinInfo); if (pinInfo.getPinNumber() != PinInfo.NOT_DEFINED) { getPinsForHeader(pinInfo.getHeader()).put(Integer.valueOf(pinInfo.getPinNumber()), pinInfo); } }
protected void addDacPinInfo(PinInfo pinInfo) { dacs.put(Integer.valueOf(pinInfo.getDeviceNumber()), pinInfo); pinsByName.put(pinInfo.getName(), pinInfo); if (pinInfo.getPinNumber() != PinInfo.NOT_DEFINED) { getPinsForHeader(pinInfo.getHeader()).put(Integer.valueOf(pinInfo.getPinNumber()), pinInfo); } }
@Override public PwmOutputDeviceInterface createPwmOutputDevice(String key, PinInfo pinInfo, int pwmFrequency, float initialValue) throws RuntimeIOException { setOutputConfig(pinInfo.getPinNumber(), OutputConfig.PWM); return new PiconZeroPwmOutputDevice(this, key, pinInfo.getDeviceNumber(), pinInfo.getPinNumber(), initialValue); }
@Override public GpioDigitalOutputDeviceInterface createDigitalOutputDevice(String key, PinInfo pinInfo, boolean initialValue) throws RuntimeIOException { setOutputConfig(pinInfo.getPinNumber(), OutputConfig.DIGITAL); return new PiconZeroDigitalOutputDevice(this, key, pinInfo.getDeviceNumber(), pinInfo.getPinNumber(), initialValue); }
protected void addGeneralPinInfo(PinInfo pinInfo) { getPinsForHeader(pinInfo.getHeader()).put(Integer.valueOf(pinInfo.getPinNumber()), pinInfo); }
@Override public GpioDigitalInputDeviceInterface createDigitalInputDevice(String key, PinInfo pinInfo, GpioPullUpDown pud, GpioEventTrigger trigger) throws RuntimeIOException { setInputConfig(pinInfo.getPinNumber(), pud == GpioPullUpDown.PULL_UP ? InputConfig.DIGITAL_PULL_UP : InputConfig.DIGITAL); return new PiconZeroDigitalInputDevice(this, key, pinInfo, pud, trigger); }
@Override public AnalogInputDeviceInterface createAnalogInputDevice(String key, PinInfo pinInfo) { setInputConfig(pinInfo.getPinNumber(), InputConfig.ANALOG); return new PiconZeroAnalogInputDevice(this, key, pinInfo); }
@Override public void setValue(boolean value) throws RuntimeIOException { BbbIoLibNative.setValue(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber(), value); }
@Override public void setValue(boolean value) throws RuntimeIOException { BbbIoLibNative.setValue(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber(), value); }
@Override public AnalogOutputDeviceInterface createAnalogOutputDevice(String key, PinInfo pinInfo) throws RuntimeIOException { return new PiconZeroAnalogOutputDevice(this, key, pinInfo.getDeviceNumber(), pinInfo.getPinNumber()); }
@Override protected void closeDevice() throws RuntimeIOException { Logger.debug("closeDevice()"); // Revert to input mode? BbbIoLibNative.setDir(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber(), BbbIoLibNative.BBBIO_DIR_IN); } }
public BbbIoLibDigitalOutputDevice(BbbIoLibDeviceFactory deviceFactory, String key, PinInfo pinInfo, boolean initialValue) { super(key, deviceFactory); this.pinInfo = pinInfo; BbbIoLibNative.setDir(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber(), BbbIoLibNative.BBBIO_DIR_OUT); setValue(initialValue); }
@Override public void setMode(DeviceMode mode) { int rc = BbbIoLibNative.setDir(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber(), mode == DeviceMode.DIGITAL_INPUT ? BbbIoLibNative.BBBIO_DIR_IN : BbbIoLibNative.BBBIO_DIR_OUT); if (rc < 0) { throw new RuntimeIOException("Error setting direction for gpio " + getGpio()); } this.mode = mode; }
@Override public boolean getValue() throws RuntimeIOException { int rc = BbbIoLibNative.getValue(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber()); if (rc < 0) { throw new RuntimeIOException("Error in BBBioLib.getValue(" + getGpio() + ")"); } return rc != 0; }
@Override public boolean getValue() throws RuntimeIOException { int rc = BbbIoLibNative.getValue(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber()); if (rc < 0) { throw new RuntimeIOException("Error in BBBioLib.getValue(" + getGpio() + ")"); } return rc == 1; }
@Override public boolean getValue() throws RuntimeIOException { int rc = BbbIoLibNative.getValue(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber()); if (rc < 0) { throw new RuntimeIOException("Error in BBBioLib.getValue(" + getGpio() + ")"); } return rc == 1; }
public BbbIoLibDigitalInputDevice(BbbIoLibDeviceFactory deviceFactory, String key, PinInfo pinInfo, GpioPullUpDown pud, GpioEventTrigger trigger) { super(key, deviceFactory); this.pinInfo = pinInfo; // pud? int rc = BbbIoLibNative.setDir(BbbIoLibDeviceFactory.getPort(pinInfo), (byte) pinInfo.getPinNumber(), BbbIoLibNative.BBBIO_DIR_IN); if (rc < 0) { throw new RuntimeIOException("Error in BBBioLib.setDir(" + getGpio() + ", " + BbbIoLibNative.BBBIO_DIR_IN + ")"); } sysFsDigitialInput = deviceFactory.getSysFsDeviceFactory().provisionDigitalInputDevice( getGpio(), pud, trigger); }