congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
PinInfo.isSupported
Code IndexAdd Tabnine to your IDE (free)

How to use
isSupported
method
in
com.diozero.api.PinInfo

Best Java code snippets using com.diozero.api.PinInfo.isSupported (Showing top 7 results out of 315)

origin: mattjlewis/diozero

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;
}
origin: mattjlewis/diozero

@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;
}
 
origin: mattjlewis/diozero

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;
}
origin: mattjlewis/diozero

default AnalogInputDeviceInterface provisionAnalogInputDevice(int adcNumber) throws RuntimeIOException {
  PinInfo pin_info = getBoardPinInfo().getByAdcNumber(adcNumber);
  if (pin_info == null || ! pin_info.isSupported(DeviceMode.ANALOG_INPUT)) {
    throw new InvalidModeException("Invalid mode (analog input) for adc " + adcNumber);
  }
  
  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;
}
origin: mattjlewis/diozero

default GpioDigitalInputDeviceInterface provisionDigitalInputDevice(int gpio, GpioPullUpDown pud,
    GpioEventTrigger trigger) throws RuntimeIOException {
  PinInfo pin_info = getBoardPinInfo().getByGpioNumber(gpio);
  if (pin_info == null || !pin_info.isSupported(DeviceMode.DIGITAL_INPUT)) {
    throw new InvalidModeException("Invalid mode (digital 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");
  }
  GpioDigitalInputDeviceInterface device = createDigitalInputDevice(key, pin_info, pud, trigger);
  deviceOpened(device);
  return device;
}
 
origin: mattjlewis/diozero

default GpioDigitalOutputDeviceInterface provisionDigitalOutputDevice(int gpio, boolean initialValue)
    throws RuntimeIOException {
  PinInfo pin_info = getBoardPinInfo().getByGpioNumber(gpio);
  if (pin_info == null || ! pin_info.isSupported(DeviceMode.DIGITAL_OUTPUT)) {
    throw new InvalidModeException("Invalid mode (digital output) 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");
  }
  GpioDigitalOutputDeviceInterface device = createDigitalOutputDevice(key, pin_info, initialValue);
  deviceOpened(device);
  return device;
}
 
origin: mattjlewis/diozero

@Override
public AnalogInputDeviceInterface provisionAnalogInputDevice(int gpio) {
  // Special case - The Arduino can switch between digital and analog input hence use of gpio rather than adc
  PinInfo pin_info = getBoardPinInfo().getByGpioNumber(gpio);
  if (pin_info == null || ! pin_info.isSupported(DeviceMode.ANALOG_INPUT)) {
    throw new InvalidModeException("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;
}
 
com.diozero.apiPinInfoisSupported

Popular methods of PinInfo

  • getDeviceNumber
  • <init>
  • getHeader
  • getPinNumber
  • getKeyPrefix
  • getModes
  • getName
  • getSysFsNumber

Popular in Java

  • Making http requests using okhttp
  • getSharedPreferences (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getApplicationContext (Context)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JOptionPane (javax.swing)
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now