Package com.pi4j.io.gpio.impl
Class GpioPinImpl
- java.lang.Object
-
- com.pi4j.io.gpio.impl.GpioPinImpl
-
- All Implemented Interfaces:
GpioPin
,GpioPinAnalog
,GpioPinAnalogInput
,GpioPinAnalogOutput
,GpioPinDigital
,GpioPinDigitalInput
,GpioPinDigitalMultipurpose
,GpioPinDigitalOutput
,GpioPinInput
,GpioPinOutput
,GpioPinPwm
,GpioPinPwmOutput
public class GpioPinImpl extends Object implements GpioPin, GpioPinDigitalInput, GpioPinDigitalOutput, GpioPinDigitalMultipurpose, GpioPinAnalogInput, GpioPinAnalogOutput, GpioPinPwmOutput, GpioPinInput, GpioPinOutput
-
-
Field Summary
Fields Modifier and Type Field Description protected int
NO_DEBOUCE
-
Constructor Summary
Constructors Constructor Description GpioPinImpl(GpioController gpio, GpioProvider provider, Pin pin)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(GpioPinListener... listener)
void
addListener(List<? extends GpioPinListener> listeners)
void
addTrigger(GpioTrigger... trigger)
void
addTrigger(List<? extends GpioTrigger> triggers)
Future<?>
blink(long delay)
Future<?>
blink(long delay, long duration)
Future<?>
blink(long delay, long duration, PinState blinkState)
Future<?>
blink(long delay, long duration, PinState blinkState, TimeUnit timeUnit)
Future<?>
blink(long delay, long duration, TimeUnit timeUnit)
Future<?>
blink(long delay, PinState blinkState)
Future<?>
blink(long delay, PinState blinkState, TimeUnit timeUnit)
Future<?>
blink(long delay, TimeUnit timeUnit)
void
clearProperties()
void
export(PinMode mode)
void
export(PinMode mode, PinState defaultState)
int
getDebounce(PinState state)
Gets the configured debounce delay interval (in milliseconds) for the given pin state.Collection<GpioPinListener>
getListeners()
PinMode
getMode()
String
getName()
Pin
getPin()
Map<String,String>
getProperties()
String
getProperty(String key)
String
getProperty(String key, String defaultValue)
GpioProvider
getProvider()
PinPullResistance
getPullResistance()
int
getPwm()
If this is a hardware PWM pin, the value will be between a range of 0 to 1024.GpioPinShutdown
getShutdownOptions()
PinState
getState()
Object
getTag()
Collection<GpioTrigger>
getTriggers()
double
getValue()
boolean
hasDebounce(PinState state)
Determines if a debounce delay interval has been configured for the given pin state.boolean
hasListener(GpioPinListener... listener)
boolean
hasProperty(String key)
void
high()
boolean
isExported()
boolean
isHigh()
boolean
isLow()
boolean
isMode(PinMode mode)
boolean
isPullResistance(PinPullResistance resistance)
boolean
isState(PinState state)
void
low()
Future<?>
pulse(long duration)
Future<?>
pulse(long duration, boolean blocking)
Future<?>
pulse(long duration, boolean blocking, Callable<Void> callback)
Future<?>
pulse(long duration, boolean blocking, Callable<Void> callback, TimeUnit timeUnit)
Future<?>
pulse(long duration, boolean blocking, TimeUnit timeUnit)
Future<?>
pulse(long duration, PinState pulseState)
Future<?>
pulse(long duration, PinState pulseState, boolean blocking)
Future<?>
pulse(long duration, PinState pulseState, boolean blocking, Callable<Void> callback)
Future<?>
pulse(long duration, PinState pulseState, boolean blocking, Callable<Void> callback, TimeUnit timeUnit)
Future<?>
pulse(long duration, PinState pulseState, boolean blocking, TimeUnit timeUnit)
Future<?>
pulse(long duration, PinState pulseState, Callable<Void> callback)
Future<?>
pulse(long duration, PinState pulseState, Callable<Void> callback, TimeUnit timeUnit)
Future<?>
pulse(long duration, PinState pulseState, TimeUnit timeUnit)
Future<?>
pulse(long duration, Callable<Void> callback)
Future<?>
pulse(long duration, Callable<Void> callback, TimeUnit timeUnit)
Future<?>
pulse(long duration, TimeUnit timeUnit)
void
pulseSync(long duration)
void
pulseSync(long duration, PinState pulseState)
void
pulseSync(long duration, PinState pulseState, TimeUnit timeUnit)
void
pulseSync(long duration, TimeUnit timeUnit)
void
removeAllListeners()
void
removeAllTriggers()
void
removeListener(GpioPinListener... listener)
void
removeListener(List<? extends GpioPinListener> listeners)
void
removeProperty(String key)
void
removeTrigger(GpioTrigger... trigger)
void
removeTrigger(List<? extends GpioTrigger> triggers)
void
setDebounce(int debounce)
Sets the debounce delay interval (in milliseconds) for all pin states.void
setDebounce(int debounce, PinState... state)
Sets the debounce delay interval (in milliseconds) for the specified pin state.void
setMode(PinMode mode)
void
setName(String name)
void
setProperty(String key, String value)
void
setPullResistance(PinPullResistance resistance)
void
setPwm(int value)
Set the PWM value/rate to toggle the GPIO pin.void
setPwmRange(int range)
This sets the range register in the PWM generator.void
setShutdownOptions(GpioPinShutdown options)
void
setShutdownOptions(Boolean unexport)
void
setShutdownOptions(Boolean unexport, PinState state)
void
setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance)
void
setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance, PinMode mode)
void
setState(boolean state)
void
setState(PinState state)
void
setTag(Object tag)
void
setValue(double value)
void
setValue(Number value)
void
toggle()
String
toString()
void
unexport()
-
-
-
Field Detail
-
NO_DEBOUCE
protected final int NO_DEBOUCE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GpioPinImpl
public GpioPinImpl(GpioController gpio, GpioProvider provider, Pin pin)
-
-
Method Detail
-
getProvider
public GpioProvider getProvider()
- Specified by:
getProvider
in interfaceGpioPin
-
setProperty
public void setProperty(String key, String value)
- Specified by:
setProperty
in interfaceGpioPin
-
hasProperty
public boolean hasProperty(String key)
- Specified by:
hasProperty
in interfaceGpioPin
-
getProperty
public String getProperty(String key, String defaultValue)
- Specified by:
getProperty
in interfaceGpioPin
-
getProperty
public String getProperty(String key)
- Specified by:
getProperty
in interfaceGpioPin
-
getProperties
public Map<String,String> getProperties()
- Specified by:
getProperties
in interfaceGpioPin
-
removeProperty
public void removeProperty(String key)
- Specified by:
removeProperty
in interfaceGpioPin
-
clearProperties
public void clearProperties()
- Specified by:
clearProperties
in interfaceGpioPin
-
isExported
public boolean isExported()
- Specified by:
isExported
in interfaceGpioPin
-
setPullResistance
public void setPullResistance(PinPullResistance resistance)
- Specified by:
setPullResistance
in interfaceGpioPin
-
getPullResistance
public PinPullResistance getPullResistance()
- Specified by:
getPullResistance
in interfaceGpioPin
-
isPullResistance
public boolean isPullResistance(PinPullResistance resistance)
- Specified by:
isPullResistance
in interfaceGpioPin
-
high
public void high()
- Specified by:
high
in interfaceGpioPinDigitalOutput
-
low
public void low()
- Specified by:
low
in interfaceGpioPinDigitalOutput
-
toggle
public void toggle()
- Specified by:
toggle
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, TimeUnit timeUnit)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, PinState blinkState)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, PinState blinkState, TimeUnit timeUnit)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration, TimeUnit timeUnit)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration, PinState blinkState)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration, PinState blinkState, TimeUnit timeUnit)
- Specified by:
blink
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, Callable<Void> callback)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, Callable<Void> callback)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking, Callable<Void> callback)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking, Callable<Void> callback)
- Specified by:
pulse
in interfaceGpioPinDigitalOutput
-
pulseSync
public void pulseSync(long duration) throws InterruptedException
- Specified by:
pulseSync
in interfaceGpioPinDigitalOutput
- Throws:
InterruptedException
-
pulseSync
public void pulseSync(long duration, TimeUnit timeUnit) throws InterruptedException
- Specified by:
pulseSync
in interfaceGpioPinDigitalOutput
- Throws:
InterruptedException
-
pulseSync
public void pulseSync(long duration, PinState pulseState) throws InterruptedException
- Specified by:
pulseSync
in interfaceGpioPinDigitalOutput
- Throws:
InterruptedException
-
pulseSync
public void pulseSync(long duration, PinState pulseState, TimeUnit timeUnit) throws InterruptedException
- Specified by:
pulseSync
in interfaceGpioPinDigitalOutput
- Throws:
InterruptedException
-
setState
public void setState(PinState state)
- Specified by:
setState
in interfaceGpioPinDigitalOutput
-
setState
public void setState(boolean state)
- Specified by:
setState
in interfaceGpioPinDigitalOutput
-
isHigh
public boolean isHigh()
- Specified by:
isHigh
in interfaceGpioPinDigital
-
isLow
public boolean isLow()
- Specified by:
isLow
in interfaceGpioPinDigital
-
getState
public PinState getState()
- Specified by:
getState
in interfaceGpioPinDigital
-
isState
public boolean isState(PinState state)
- Specified by:
isState
in interfaceGpioPinDigital
-
hasDebounce
public boolean hasDebounce(PinState state)
Description copied from interface:GpioPinDigitalInput
Determines if a debounce delay interval has been configured for the given pin state.- Specified by:
hasDebounce
in interfaceGpioPinDigitalInput
- Parameters:
state
- the pin state to test for debounce delay.- Returns:
- 'true' if the specified ping state has been configured with a debounce delay; else return 'false'.
-
getDebounce
public int getDebounce(PinState state)
Description copied from interface:GpioPinDigitalInput
Gets the configured debounce delay interval (in milliseconds) for the given pin state.- Specified by:
getDebounce
in interfaceGpioPinDigitalInput
- Parameters:
state
- the pin state to get the configured debounce delay interval.- Returns:
- the debounce delay interval (in milliseconds) for the specified pin state.
-
setDebounce
public void setDebounce(int debounce, PinState... state)
Description copied from interface:GpioPinDigitalInput
Sets the debounce delay interval (in milliseconds) for the specified pin state.- Specified by:
setDebounce
in interfaceGpioPinDigitalInput
- Parameters:
debounce
- The debounce delay interval in milliseconds.state
- The pin states to apply the debounce delay interval to.
-
setDebounce
public void setDebounce(int debounce)
Description copied from interface:GpioPinDigitalInput
Sets the debounce delay interval (in milliseconds) for all pin states.- Specified by:
setDebounce
in interfaceGpioPinDigitalInput
- Parameters:
debounce
- The debounce delay interval in milliseconds.
-
setValue
public void setValue(double value)
- Specified by:
setValue
in interfaceGpioPinAnalogOutput
-
setValue
public void setValue(Number value)
- Specified by:
setValue
in interfaceGpioPinAnalogOutput
-
getValue
public double getValue()
- Specified by:
getValue
in interfaceGpioPinAnalog
-
setPwm
public void setPwm(int value)
Description copied from interface:GpioPinPwmOutput
Set the PWM value/rate to toggle the GPIO pin. If this is a hardware PWM pin, the value should be between a range of 0 to 1024. If this is a software emulated PWM pin, the value should be between a range of 0 to 100.- Specified by:
setPwm
in interfaceGpioPinPwmOutput
-
setPwmRange
public void setPwmRange(int range)
Description copied from interface:GpioPinPwmOutput
This sets the range register in the PWM generator. The default is 1024 for hardware PWM. The default is 100 for software emulated PWM.- Specified by:
setPwmRange
in interfaceGpioPinPwmOutput
-
getPwm
public int getPwm()
Description copied from interface:GpioPinPwm
If this is a hardware PWM pin, the value will be between a range of 0 to 1024. If this is a software emulated PWM pin, the value will be between a range of 0 to 100.- Specified by:
getPwm
in interfaceGpioPinPwm
- Returns:
- the value currently set for the PWM output
-
addListener
public void addListener(GpioPinListener... listener)
- Specified by:
addListener
in interfaceGpioPin
- Specified by:
addListener
in interfaceGpioPinAnalogInput
- Parameters:
listener
- gpio pin listener interface
-
addListener
public void addListener(List<? extends GpioPinListener> listeners)
- Specified by:
addListener
in interfaceGpioPin
- Specified by:
addListener
in interfaceGpioPinAnalogInput
-
getListeners
public Collection<GpioPinListener> getListeners()
- Specified by:
getListeners
in interfaceGpioPin
- Specified by:
getListeners
in interfaceGpioPinAnalogInput
-
hasListener
public boolean hasListener(GpioPinListener... listener)
- Specified by:
hasListener
in interfaceGpioPin
- Specified by:
hasListener
in interfaceGpioPinAnalogInput
-
removeListener
public void removeListener(GpioPinListener... listener)
- Specified by:
removeListener
in interfaceGpioPin
- Specified by:
removeListener
in interfaceGpioPinAnalogInput
-
removeListener
public void removeListener(List<? extends GpioPinListener> listeners)
- Specified by:
removeListener
in interfaceGpioPin
- Specified by:
removeListener
in interfaceGpioPinAnalogInput
-
removeAllListeners
public void removeAllListeners()
- Specified by:
removeAllListeners
in interfaceGpioPin
- Specified by:
removeAllListeners
in interfaceGpioPinAnalogInput
-
getTriggers
public Collection<GpioTrigger> getTriggers()
- Specified by:
getTriggers
in interfaceGpioPinAnalogInput
- Specified by:
getTriggers
in interfaceGpioPinInput
-
addTrigger
public void addTrigger(GpioTrigger... trigger)
- Specified by:
addTrigger
in interfaceGpioPinAnalogInput
- Specified by:
addTrigger
in interfaceGpioPinInput
-
addTrigger
public void addTrigger(List<? extends GpioTrigger> triggers)
- Specified by:
addTrigger
in interfaceGpioPinAnalogInput
- Specified by:
addTrigger
in interfaceGpioPinInput
-
removeTrigger
public void removeTrigger(GpioTrigger... trigger)
- Specified by:
removeTrigger
in interfaceGpioPinAnalogInput
- Specified by:
removeTrigger
in interfaceGpioPinInput
- Parameters:
trigger
- GPIO trigger interface
-
removeTrigger
public void removeTrigger(List<? extends GpioTrigger> triggers)
- Specified by:
removeTrigger
in interfaceGpioPinAnalogInput
- Specified by:
removeTrigger
in interfaceGpioPinInput
-
removeAllTriggers
public void removeAllTriggers()
- Specified by:
removeAllTriggers
in interfaceGpioPinAnalogInput
- Specified by:
removeAllTriggers
in interfaceGpioPinInput
-
getShutdownOptions
public GpioPinShutdown getShutdownOptions()
- Specified by:
getShutdownOptions
in interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(GpioPinShutdown options)
- Specified by:
setShutdownOptions
in interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport)
- Specified by:
setShutdownOptions
in interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport, PinState state)
- Specified by:
setShutdownOptions
in interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance)
- Specified by:
setShutdownOptions
in interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance, PinMode mode)
- Specified by:
setShutdownOptions
in interfaceGpioPin
-
-