public VoodooSparkAnalogInputDevice(VoodooSparkDeviceFactory deviceFactory, String key, PinInfo pinInfo) { super(key, deviceFactory); this.deviceFactory = deviceFactory; this.gpio = pinInfo.getDeviceNumber(); }
protected PinInfo addDacPinInfo(String header, int dacNumber, String name, int pin) { PinInfo pin_info = new PinInfo(DAC_KEY_PREFIX, header, dacNumber, pin, name, PinInfo.ANALOG_OUTPUT); addDacPinInfo(pin_info); return pin_info; }
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); } }
@Override public final String createPinKey(PinInfo pinInfo) { return deviceFactoryPrefix + "-" + pinInfo.getKeyPrefix() + "-" + pinInfo.getDeviceNumber(); }
@Override public AnalogOutputDeviceInterface createAnalogOutputDevice(String key, PinInfo pinInfo) throws RuntimeIOException { return new PiconZeroAnalogOutputDevice(this, key, pinInfo.getDeviceNumber(), pinInfo.getPinNumber()); }
public int getChannel() { return pinInfo.getPinNumber(); } }
default PwmOutputDeviceInterface provisionPwmOutputDevice(int pwmOrGpioNum, int pwmFrequency, float initialValue) throws RuntimeIOException { // Lookup by PWM number first, if not found or doesn't support // PWM_OUTPUT, lookup by GPIO number PinInfo pin_info = getBoardPinInfo().getByPwmNumber(pwmOrGpioNum); if (pin_info == null || !pin_info.isSupported(DeviceMode.PWM_OUTPUT)) { pin_info = getBoardPinInfo().getByGpioNumber(pwmOrGpioNum); } if (pin_info != null && (pin_info.isSupported(DeviceMode.PWM_OUTPUT) || pin_info.isSupported(DeviceMode.DIGITAL_OUTPUT))) { // Ok } else { throw new InvalidModeException("Invalid mode (PWM output) for GPIO " + pwmOrGpioNum); } String key = createPinKey(pin_info); // Check if this pin is already provisioned if (isDeviceOpened(key)) { throw new DeviceAlreadyOpenedException("Device " + key + " is already in use"); } PwmOutputDeviceInterface device = createPwmOutputDevice(key, pin_info, pwmFrequency, initialValue); deviceOpened(device); return device; }
protected void addGeneralPinInfo(PinInfo pinInfo) { getPinsForHeader(pinInfo.getHeader()).put(Integer.valueOf(pinInfo.getPinNumber()), pinInfo); }
static byte getPort(PinInfo pinInfo) { return (byte) (pinInfo.getHeader() == BeagleBoneBlackBoardInfo.P8_HEADER ? 8 : 9); } }
@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); }
public int getChannel() { return pinInfo.getPinNumber(); }
@Override public AnalogInputDeviceInterface provisionAnalogInputDevice(int gpio) throws RuntimeIOException { // Special case - PiconZero can switch between digital and analog input hence use of gpio rather than adc PinInfo pin_info = boardPinInfo.getByGpioNumber(gpio); if (pin_info == null || ! pin_info.isSupported(DeviceMode.ANALOG_INPUT)) { throw new IllegalArgumentException("Invalid mode (analog input) for GPIO " + gpio); } String key = createPinKey(pin_info); // Check if this pin is already provisioned if (isDeviceOpened(key)) { throw new DeviceAlreadyOpenedException("Device " + key + " is already in use"); } AnalogInputDeviceInterface device = createAnalogInputDevice(key, pin_info); deviceOpened(device); return device; }
public VoodooSparkAnalogOutputDevice(VoodooSparkDeviceFactory deviceFactory, String key, PinInfo pinInfo) { super(key, deviceFactory); this.deviceFactory = deviceFactory; this.gpio = pinInfo.getDeviceNumber(); }
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); } }
@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); }
@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); }
default AnalogOutputDeviceInterface provisionAnalogOutputDevice(int dacNumber) throws RuntimeIOException { PinInfo pin_info = getBoardPinInfo().getByDacNumber(dacNumber); if (pin_info == null || ! pin_info.isSupported(DeviceMode.ANALOG_OUTPUT)) { throw new InvalidModeException("Invalid mode (analog output) for DAC " + dacNumber); } String key = createPinKey(pin_info); // Check if this pin is already provisioned if (isDeviceOpened(key)) { throw new DeviceAlreadyOpenedException("Device " + key + " is already in use"); } AnalogOutputDeviceInterface device = createAnalogOutputDevice(key, pin_info); deviceOpened(device); return device; }
protected PinInfo addAdcPinInfo(String header, int adcNumber, String name, int pin) { PinInfo pin_info = new PinInfo(ADC_KEY_PREFIX, header, adcNumber, pin, name, PinInfo.ANALOG_INPUT); addAdcPinInfo(pin_info); return pin_info; }
@Override public int getGpio() { return pinInfo.getDeviceNumber(); }
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); } }