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, listenersDEFAULT_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, unexportclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetMaxSupportedValue, getMinSupportedValueaddListener, export, export, getMode, getName, getPullResistance, getPwm, getState, hasPin, isExported, isShutdown, removeAllListeners, removeListener, setMode, setPullResistance, setPwm, setPwmRange, setState, setValue, unexportprotected 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 GpioProvidergetValue in class GpioProviderBasepin - to get conversion values forpublic float getPercentValue(Pin pin)
getPercentValue in interface AdcGpioProviderpublic float getPercentValue(GpioPinAnalogInput pin)
getPercentValue in interface AdcGpioProviderpublic double getImmediateValue(GpioPinAnalogInput pin) throws IOException
getImmediateValue in interface AdcGpioProviderpin - requested input pin to acquire conversion valueIOExceptionpublic void shutdown()
shutdown in interface GpioProvidershutdown in class GpioProviderBasepublic double getEventThreshold(Pin pin)
getEventThreshold in interface AdcGpioProviderpin - analog input pinpublic double getEventThreshold(GpioPinAnalogInput pin)
getEventThreshold in interface AdcGpioProviderpin - analog input pinpublic void setEventThreshold(double threshold,
Pin... pin)
setEventThreshold in interface AdcGpioProviderthreshold - 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 AdcGpioProviderthreshold - 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 AdcGpioProviderpublic void setMonitorInterval(int monitorInterval)
setMonitorInterval in interface AdcGpioProvidermonitorInterval - public boolean getMonitorEnabled()
getMonitorEnabled in interface AdcGpioProviderpublic void setMonitorEnabled(boolean enabled)
setMonitorEnabled in interface AdcGpioProviderenabled - monitoring enabled or disabled statepublic abstract double getImmediateValue(Pin pin) throws IOException
getImmediateValue in interface AdcGpioProviderpin - requested input pin to acquire conversion valueIOExceptionCopyright © 2012–2018 Pi4J. All rights reserved.