public abstract class AdcGpioProviderBase extends GpioProviderBase implements AdcGpioProvider
This base GPIO provider defined the required interfaces and implements the base functionality for ADC (analog to digital) expansion chips as native Pi4J GPIO pins.
Modifier and Type | Field and Description |
---|---|
protected Pin[] |
allPins |
protected int |
conversionDelay |
protected com.pi4j.gpio.extension.base.AdcGpioProviderBase.ADCMonitor |
monitor |
protected int |
monitorInterval |
protected double[] |
threshold |
cache, DEFAULT_CACHE_SIZE, isshutdown, listeners
DEFAULT_MONITOR_INTERVAL, DEFAULT_THRESHOLD, INVALID_VALUE, MIN_MONITOR_INTERVAL
Constructor and Description |
---|
AdcGpioProviderBase(Pin[] pins)
Default Constructor
|
Modifier and Type | Method and Description |
---|---|
double |
getEventThreshold(GpioPinAnalogInput pin)
Get the event threshold value for a given analog input pin.
|
double |
getEventThreshold(Pin pin)
Get the event threshold value for a given analog input pin.
|
double |
getImmediateValue(GpioPinAnalogInput pin)
This method will perform an immediate data acquisition directly to the ADC chip to get the
requested pin's input conversion value.
|
abstract double |
getImmediateValue(Pin pin)
This method will perform an immediate data acquisition directly to the ADC chip to get the
requested pin's input conversion value.
|
boolean |
getMonitorEnabled()
Get the background monitoring thread's enabled state.
|
int |
getMonitorInterval()
Get the background monitoring thread's rate of data acquisition.
|
float |
getPercentValue(GpioPinAnalogInput pin)
Get the current value in a percentage of the available range instead of a raw value.
|
float |
getPercentValue(Pin pin)
Get the current value in a percentage of the available range instead of a raw value.
|
double |
getValue(Pin pin)
Get the requested analog input pin's conversion value.
|
void |
setEventThreshold(double threshold,
GpioPinAnalogInput... pin)
Set the event threshold value for a given analog input pin.
|
void |
setEventThreshold(double threshold,
Pin... pin)
Set the event threshold value for a given analog input pin.
|
void |
setMonitorEnabled(boolean enabled)
Set the background monitoring thread's enabled state.
|
void |
setMonitorInterval(int monitorInterval)
Change the background monitoring thread's rate of data acquisition.
|
void |
shutdown()
This method is used by the framework to shutdown the
background monitoring thread if needed when the program exits.
|
addListener, dispatchPinAnalogValueChangeEvent, dispatchPinDigitalStateChangeEvent, export, export, getMode, getName, getPinCache, getPullResistance, getPwm, getState, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, unexport
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMaxSupportedValue, getMinSupportedValue
addListener, export, export, getMode, getName, getPullResistance, getPwm, getState, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, unexport
protected com.pi4j.gpio.extension.base.AdcGpioProviderBase.ADCMonitor monitor
protected int conversionDelay
protected int monitorInterval
protected Pin[] allPins
protected double[] threshold
public AdcGpioProviderBase(Pin[] pins)
pins
- the collection of all GPIO pins used with this ADC provider implementationpublic double getValue(Pin pin)
getValue
in interface GpioProvider
getValue
in class GpioProviderBase
pin
- to get conversion values forpublic float getPercentValue(Pin pin)
getPercentValue
in interface AdcGpioProvider
public float getPercentValue(GpioPinAnalogInput pin)
getPercentValue
in interface AdcGpioProvider
public double getImmediateValue(GpioPinAnalogInput pin) throws IOException
getImmediateValue
in interface AdcGpioProvider
pin
- requested input pin to acquire conversion valueIOException
public void shutdown()
shutdown
in interface GpioProvider
shutdown
in class GpioProviderBase
public double getEventThreshold(Pin pin)
getEventThreshold
in interface AdcGpioProvider
pin
- analog input pinpublic double getEventThreshold(GpioPinAnalogInput pin)
getEventThreshold
in interface AdcGpioProvider
pin
- analog input pinpublic void setEventThreshold(double threshold, Pin... pin)
setEventThreshold
in interface AdcGpioProvider
threshold
- threshold value for requested analog input pinpin
- analog input pin (vararg, one or more inputs can be defined.)public void setEventThreshold(double threshold, GpioPinAnalogInput... pin)
setEventThreshold
in interface AdcGpioProvider
threshold
- threshold value for requested analog input pin.pin
- analog input pin (vararg, one or more inputs can be defined.)public int getMonitorInterval()
getMonitorInterval
in interface AdcGpioProvider
public void setMonitorInterval(int monitorInterval)
setMonitorInterval
in interface AdcGpioProvider
monitorInterval
- public boolean getMonitorEnabled()
getMonitorEnabled
in interface AdcGpioProvider
public void setMonitorEnabled(boolean enabled)
setMonitorEnabled
in interface AdcGpioProvider
enabled
- monitoring enabled or disabled statepublic abstract double getImmediateValue(Pin pin) throws IOException
getImmediateValue
in interface AdcGpioProvider
pin
- requested input pin to acquire conversion valueIOException
Copyright © 2012–2016 Pi4J. All rights reserved.