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 intNO_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 voidaddListener(GpioPinListener... listener)voidaddListener(List<? extends GpioPinListener> listeners)voidaddTrigger(GpioTrigger... trigger)voidaddTrigger(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)voidclearProperties()voidexport(PinMode mode)voidexport(PinMode mode, PinState defaultState)intgetDebounce(PinState state)Gets the configured debounce delay interval (in milliseconds) for the given pin state.Collection<GpioPinListener>getListeners()PinModegetMode()StringgetName()PingetPin()Map<String,String>getProperties()StringgetProperty(String key)StringgetProperty(String key, String defaultValue)GpioProvidergetProvider()PinPullResistancegetPullResistance()intgetPwm()If this is a hardware PWM pin, the value will be between a range of 0 to 1024.GpioPinShutdowngetShutdownOptions()PinStategetState()ObjectgetTag()Collection<GpioTrigger>getTriggers()doublegetValue()booleanhasDebounce(PinState state)Determines if a debounce delay interval has been configured for the given pin state.booleanhasListener(GpioPinListener... listener)booleanhasProperty(String key)voidhigh()booleanisExported()booleanisHigh()booleanisLow()booleanisMode(PinMode mode)booleanisPullResistance(PinPullResistance resistance)booleanisState(PinState state)voidlow()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)voidpulseSync(long duration)voidpulseSync(long duration, PinState pulseState)voidpulseSync(long duration, PinState pulseState, TimeUnit timeUnit)voidpulseSync(long duration, TimeUnit timeUnit)voidremoveAllListeners()voidremoveAllTriggers()voidremoveListener(GpioPinListener... listener)voidremoveListener(List<? extends GpioPinListener> listeners)voidremoveProperty(String key)voidremoveTrigger(GpioTrigger... trigger)voidremoveTrigger(List<? extends GpioTrigger> triggers)voidsetDebounce(int debounce)Sets the debounce delay interval (in milliseconds) for all pin states.voidsetDebounce(int debounce, PinState... state)Sets the debounce delay interval (in milliseconds) for the specified pin state.voidsetMode(PinMode mode)voidsetName(String name)voidsetProperty(String key, String value)voidsetPullResistance(PinPullResistance resistance)voidsetPwm(int value)Set the PWM value/rate to toggle the GPIO pin.voidsetPwmRange(int range)This sets the range register in the PWM generator.voidsetShutdownOptions(GpioPinShutdown options)voidsetShutdownOptions(Boolean unexport)voidsetShutdownOptions(Boolean unexport, PinState state)voidsetShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance)voidsetShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance, PinMode mode)voidsetState(boolean state)voidsetState(PinState state)voidsetTag(Object tag)voidsetValue(double value)voidsetValue(Number value)voidtoggle()StringtoString()voidunexport()
-
-
-
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:
getProviderin interfaceGpioPin
-
setProperty
public void setProperty(String key, String value)
- Specified by:
setPropertyin interfaceGpioPin
-
hasProperty
public boolean hasProperty(String key)
- Specified by:
hasPropertyin interfaceGpioPin
-
getProperty
public String getProperty(String key, String defaultValue)
- Specified by:
getPropertyin interfaceGpioPin
-
getProperty
public String getProperty(String key)
- Specified by:
getPropertyin interfaceGpioPin
-
getProperties
public Map<String,String> getProperties()
- Specified by:
getPropertiesin interfaceGpioPin
-
removeProperty
public void removeProperty(String key)
- Specified by:
removePropertyin interfaceGpioPin
-
clearProperties
public void clearProperties()
- Specified by:
clearPropertiesin interfaceGpioPin
-
isExported
public boolean isExported()
- Specified by:
isExportedin interfaceGpioPin
-
setPullResistance
public void setPullResistance(PinPullResistance resistance)
- Specified by:
setPullResistancein interfaceGpioPin
-
getPullResistance
public PinPullResistance getPullResistance()
- Specified by:
getPullResistancein interfaceGpioPin
-
isPullResistance
public boolean isPullResistance(PinPullResistance resistance)
- Specified by:
isPullResistancein interfaceGpioPin
-
high
public void high()
- Specified by:
highin interfaceGpioPinDigitalOutput
-
low
public void low()
- Specified by:
lowin interfaceGpioPinDigitalOutput
-
toggle
public void toggle()
- Specified by:
togglein interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, TimeUnit timeUnit)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, PinState blinkState)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, PinState blinkState, TimeUnit timeUnit)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration, TimeUnit timeUnit)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration, PinState blinkState)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
blink
public Future<?> blink(long delay, long duration, PinState blinkState, TimeUnit timeUnit)
- Specified by:
blinkin interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, Callable<Void> callback)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, Callable<Void> callback)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking, Callable<Void> callback)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, boolean blocking, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking, Callable<Void> callback, TimeUnit timeUnit)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulse
public Future<?> pulse(long duration, PinState pulseState, boolean blocking, Callable<Void> callback)
- Specified by:
pulsein interfaceGpioPinDigitalOutput
-
pulseSync
public void pulseSync(long duration) throws InterruptedException- Specified by:
pulseSyncin interfaceGpioPinDigitalOutput- Throws:
InterruptedException
-
pulseSync
public void pulseSync(long duration, TimeUnit timeUnit) throws InterruptedException- Specified by:
pulseSyncin interfaceGpioPinDigitalOutput- Throws:
InterruptedException
-
pulseSync
public void pulseSync(long duration, PinState pulseState) throws InterruptedException- Specified by:
pulseSyncin interfaceGpioPinDigitalOutput- Throws:
InterruptedException
-
pulseSync
public void pulseSync(long duration, PinState pulseState, TimeUnit timeUnit) throws InterruptedException- Specified by:
pulseSyncin interfaceGpioPinDigitalOutput- Throws:
InterruptedException
-
setState
public void setState(PinState state)
- Specified by:
setStatein interfaceGpioPinDigitalOutput
-
setState
public void setState(boolean state)
- Specified by:
setStatein interfaceGpioPinDigitalOutput
-
isHigh
public boolean isHigh()
- Specified by:
isHighin interfaceGpioPinDigital
-
isLow
public boolean isLow()
- Specified by:
isLowin interfaceGpioPinDigital
-
getState
public PinState getState()
- Specified by:
getStatein interfaceGpioPinDigital
-
isState
public boolean isState(PinState state)
- Specified by:
isStatein interfaceGpioPinDigital
-
hasDebounce
public boolean hasDebounce(PinState state)
Description copied from interface:GpioPinDigitalInputDetermines if a debounce delay interval has been configured for the given pin state.- Specified by:
hasDebouncein 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:GpioPinDigitalInputGets the configured debounce delay interval (in milliseconds) for the given pin state.- Specified by:
getDebouncein 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:GpioPinDigitalInputSets the debounce delay interval (in milliseconds) for the specified pin state.- Specified by:
setDebouncein 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:GpioPinDigitalInputSets the debounce delay interval (in milliseconds) for all pin states.- Specified by:
setDebouncein interfaceGpioPinDigitalInput- Parameters:
debounce- The debounce delay interval in milliseconds.
-
setValue
public void setValue(double value)
- Specified by:
setValuein interfaceGpioPinAnalogOutput
-
setValue
public void setValue(Number value)
- Specified by:
setValuein interfaceGpioPinAnalogOutput
-
getValue
public double getValue()
- Specified by:
getValuein interfaceGpioPinAnalog
-
setPwm
public void setPwm(int value)
Description copied from interface:GpioPinPwmOutputSet 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:
setPwmin interfaceGpioPinPwmOutput
-
setPwmRange
public void setPwmRange(int range)
Description copied from interface:GpioPinPwmOutputThis 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:
setPwmRangein interfaceGpioPinPwmOutput
-
getPwm
public int getPwm()
Description copied from interface:GpioPinPwmIf 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:
getPwmin interfaceGpioPinPwm- Returns:
- the value currently set for the PWM output
-
addListener
public void addListener(GpioPinListener... listener)
- Specified by:
addListenerin interfaceGpioPin- Specified by:
addListenerin interfaceGpioPinAnalogInput- Parameters:
listener- gpio pin listener interface
-
addListener
public void addListener(List<? extends GpioPinListener> listeners)
- Specified by:
addListenerin interfaceGpioPin- Specified by:
addListenerin interfaceGpioPinAnalogInput
-
getListeners
public Collection<GpioPinListener> getListeners()
- Specified by:
getListenersin interfaceGpioPin- Specified by:
getListenersin interfaceGpioPinAnalogInput
-
hasListener
public boolean hasListener(GpioPinListener... listener)
- Specified by:
hasListenerin interfaceGpioPin- Specified by:
hasListenerin interfaceGpioPinAnalogInput
-
removeListener
public void removeListener(GpioPinListener... listener)
- Specified by:
removeListenerin interfaceGpioPin- Specified by:
removeListenerin interfaceGpioPinAnalogInput
-
removeListener
public void removeListener(List<? extends GpioPinListener> listeners)
- Specified by:
removeListenerin interfaceGpioPin- Specified by:
removeListenerin interfaceGpioPinAnalogInput
-
removeAllListeners
public void removeAllListeners()
- Specified by:
removeAllListenersin interfaceGpioPin- Specified by:
removeAllListenersin interfaceGpioPinAnalogInput
-
getTriggers
public Collection<GpioTrigger> getTriggers()
- Specified by:
getTriggersin interfaceGpioPinAnalogInput- Specified by:
getTriggersin interfaceGpioPinInput
-
addTrigger
public void addTrigger(GpioTrigger... trigger)
- Specified by:
addTriggerin interfaceGpioPinAnalogInput- Specified by:
addTriggerin interfaceGpioPinInput
-
addTrigger
public void addTrigger(List<? extends GpioTrigger> triggers)
- Specified by:
addTriggerin interfaceGpioPinAnalogInput- Specified by:
addTriggerin interfaceGpioPinInput
-
removeTrigger
public void removeTrigger(GpioTrigger... trigger)
- Specified by:
removeTriggerin interfaceGpioPinAnalogInput- Specified by:
removeTriggerin interfaceGpioPinInput- Parameters:
trigger- GPIO trigger interface
-
removeTrigger
public void removeTrigger(List<? extends GpioTrigger> triggers)
- Specified by:
removeTriggerin interfaceGpioPinAnalogInput- Specified by:
removeTriggerin interfaceGpioPinInput
-
removeAllTriggers
public void removeAllTriggers()
- Specified by:
removeAllTriggersin interfaceGpioPinAnalogInput- Specified by:
removeAllTriggersin interfaceGpioPinInput
-
getShutdownOptions
public GpioPinShutdown getShutdownOptions()
- Specified by:
getShutdownOptionsin interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(GpioPinShutdown options)
- Specified by:
setShutdownOptionsin interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport)
- Specified by:
setShutdownOptionsin interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport, PinState state)
- Specified by:
setShutdownOptionsin interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance)
- Specified by:
setShutdownOptionsin interfaceGpioPin
-
setShutdownOptions
public void setShutdownOptions(Boolean unexport, PinState state, PinPullResistance resistance, PinMode mode)
- Specified by:
setShutdownOptionsin interfaceGpioPin
-
-