Package com.pi4j.io.gpio
Class GpioProviderBase
- java.lang.Object
-
- com.pi4j.io.gpio.GpioProviderBase
-
- All Implemented Interfaces:
GpioProvider
- Direct Known Subclasses:
SimulatedGpioProvider
,WiringPiGpioProviderBase
public abstract class GpioProviderBase extends Object implements GpioProvider
Abstract base implementation ofGpioProvider
.- Author:
- Robert Savage (http://www.savagehomeautomation.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected GpioProviderPinCache[]
cache
static int
DEFAULT_CACHE_SIZE
protected boolean
isshutdown
protected Map<Pin,List<PinListener>>
listeners
-
Constructor Summary
Constructors Constructor Description GpioProviderBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addListener(Pin pin, PinListener listener)
protected void
dispatchPinAnalogValueChangeEvent(Pin pin, double value)
protected void
dispatchPinDigitalStateChangeEvent(Pin pin, PinState state)
void
export(Pin pin, PinMode mode)
void
export(Pin pin, PinMode mode, PinState defaultState)
PinMode
getMode(Pin pin)
abstract String
getName()
protected GpioProviderPinCache
getPinCache(Pin pin)
PinPullResistance
getPullResistance(Pin pin)
int
getPwm(Pin pin)
PinState
getState(Pin pin)
double
getValue(Pin pin)
boolean
hasPin(Pin pin)
boolean
isExported(Pin pin)
boolean
isShutdown()
This method returns TRUE if the GPIO provider has been shutdown.void
removeAllListeners()
void
removeListener(Pin pin, PinListener listener)
void
setMode(Pin pin, PinMode mode)
void
setPullResistance(Pin pin, PinPullResistance resistance)
void
setPwm(Pin pin, int value)
void
setPwmRange(Pin pin, int range)
void
setState(Pin pin, PinState state)
void
setValue(Pin pin, double value)
void
shutdown()
void
unexport(Pin pin)
-
-
-
Field Detail
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZE
- See Also:
- Constant Field Values
-
listeners
protected final Map<Pin,List<PinListener>> listeners
-
cache
protected GpioProviderPinCache[] cache
-
isshutdown
protected boolean isshutdown
-
-
Method Detail
-
getName
public abstract String getName()
- Specified by:
getName
in interfaceGpioProvider
-
hasPin
public boolean hasPin(Pin pin)
- Specified by:
hasPin
in interfaceGpioProvider
-
getPinCache
protected GpioProviderPinCache getPinCache(Pin pin)
-
export
public void export(Pin pin, PinMode mode, PinState defaultState)
- Specified by:
export
in interfaceGpioProvider
-
export
public void export(Pin pin, PinMode mode)
- Specified by:
export
in interfaceGpioProvider
-
isExported
public boolean isExported(Pin pin)
- Specified by:
isExported
in interfaceGpioProvider
-
unexport
public void unexport(Pin pin)
- Specified by:
unexport
in interfaceGpioProvider
-
setMode
public void setMode(Pin pin, PinMode mode)
- Specified by:
setMode
in interfaceGpioProvider
-
getMode
public PinMode getMode(Pin pin)
- Specified by:
getMode
in interfaceGpioProvider
-
setPullResistance
public void setPullResistance(Pin pin, PinPullResistance resistance)
- Specified by:
setPullResistance
in interfaceGpioProvider
-
getPullResistance
public PinPullResistance getPullResistance(Pin pin)
- Specified by:
getPullResistance
in interfaceGpioProvider
-
setState
public void setState(Pin pin, PinState state)
- Specified by:
setState
in interfaceGpioProvider
-
getState
public PinState getState(Pin pin)
- Specified by:
getState
in interfaceGpioProvider
-
setValue
public void setValue(Pin pin, double value)
- Specified by:
setValue
in interfaceGpioProvider
-
getValue
public double getValue(Pin pin)
- Specified by:
getValue
in interfaceGpioProvider
-
setPwm
public void setPwm(Pin pin, int value)
- Specified by:
setPwm
in interfaceGpioProvider
-
setPwmRange
public void setPwmRange(Pin pin, int range)
- Specified by:
setPwmRange
in interfaceGpioProvider
-
getPwm
public int getPwm(Pin pin)
- Specified by:
getPwm
in interfaceGpioProvider
-
addListener
public void addListener(Pin pin, PinListener listener)
- Specified by:
addListener
in interfaceGpioProvider
-
removeListener
public void removeListener(Pin pin, PinListener listener)
- Specified by:
removeListener
in interfaceGpioProvider
-
removeAllListeners
public void removeAllListeners()
- Specified by:
removeAllListeners
in interfaceGpioProvider
-
dispatchPinDigitalStateChangeEvent
protected void dispatchPinDigitalStateChangeEvent(Pin pin, PinState state)
-
dispatchPinAnalogValueChangeEvent
protected void dispatchPinAnalogValueChangeEvent(Pin pin, double value)
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceGpioProvider
-
isShutdown
public boolean isShutdown()
This method returns TRUE if the GPIO provider has been shutdown.- Specified by:
isShutdown
in interfaceGpioProvider
- Returns:
- shutdown state
-
-