public class DigitalIOFeature extends AbstractPinFeature implements DigitalIO
| Constructor and Description |
|---|
DigitalIOFeature(Pin pin,
DigitalInput input,
DigitalOutput output) |
| Modifier and Type | Method and Description |
|---|---|
void |
addInterruptListener(InterruptListener listener)
Adds an interrupt listener to the digital input.
|
void |
applySignal(Signal signal)
Writes a state to the pin.
|
boolean |
areInterruptsEnabled()
This method checks whether interrupts are currently enabled.
|
void |
awaitBlinkingStopped()
Halts the current thread until the blinking on the output
has stopped.
|
void |
blinkTimes(int periodLengthMilliseconds,
int times)
This method is used to let the input blink a number of times.
|
void |
clearInterruptListeners()
Removes all interrupt listeners that are currently registered.
|
void |
disableInterrupts()
This method disables interrupt events on this input.
|
void |
enableInterrupts()
This method enables interrupt events on this input.
|
void |
fireInterruptEvent(InterruptEventArgs args)
Fire interrupt event.
|
Signal |
getAppliedSignal()
Gets the signal that is currently applied to the pin.
|
int |
getInterruptDebounceMs()
Returns the maximum time that is used for debouncing
interrupts.
|
List<InterruptListener> |
getInterruptListeners()
Gets a list of all the registered interrupt listeners.
|
Edge |
getInterruptTrigger()
Gets the interrupt trigger that is currently set.
|
String |
getName() |
void |
high()
Applies a high level signal to the pin.
|
boolean |
isBlinking()
Checks if this output is currently blinking.
|
boolean |
isBlocking() |
boolean |
isHigh()
Queries if the signal on the pin
is currently high.
|
boolean |
isInputActive()
Checks if the pin is currently used as an input.
|
boolean |
isLow()
Queries if the signal on the pin
is currently low.
|
boolean |
isOutputActive()
Checks if the pin is currently used as an output.
|
void |
low()
Applies a low level signal to the pin.
|
Signal |
read()
Reads the current signal on the pin.
|
Signal |
readDebounced(int debounceMilliseconds)
Reads the signal on the pin debounced.
|
void |
removeInterruptListener(InterruptListener listener)
Removes an interrupt listener from the digital input.
|
void |
setInterruptDebounceMs(int milliSeconds)
If the edges of interrupts should be debounced before calling
the interrupt event handlers, then the maximum time that
should be used for debouncing can be specified here.
|
void |
setInterruptTrigger(Edge edge)
Sets the interrupt trigger.
|
protected void |
setupImpl() |
void |
startBlinking(int periodLengthMilliseconds)
This method is used to let the pin blink indefinitely.
|
void |
startBlinking(int periodLengthMilliseconds,
int durationMilliseconds)
This method is used to let the pin blink for a specified
duration.
|
void |
stopBlinking()
Stops any blinking process that is currently in progress on
this output.
|
protected void |
teardownImpl() |
void |
toggle()
Toggles the current signal on the pin.
|
void |
write(Signal signal)
Writes a state to the pin.
|
activate, blockPin, getPin, isActivatedFeature, isSetup, isTorndownOnShutdown, setTeardownOnShutdown, setup, teardown, toString, unblockPinclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitactivate, blockPin, getPin, isActivatedFeature, isSetup, isTorndownOnShutdown, setTeardownOnShutdown, setup, teardown, unblockPinpublic DigitalIOFeature(Pin pin, DigitalInput input, DigitalOutput output)
public Signal read()
DigitalInputread in interface DigitalInputpublic Signal readDebounced(int debounceMilliseconds)
DigitalInputreadDebounced in interface DigitalInputdebounceMilliseconds - this is the time that is used for debouncing
in the worst case. When the input is still bouncing after the
specified period, then the return value will not be reliable.public void disableInterrupts()
DigitalInputInterruptListener's
interruptRequest
method.disableInterrupts in interface DigitalInputpublic void enableInterrupts()
DigitalInputenableInterrupts in interface DigitalInputpublic boolean areInterruptsEnabled()
DigitalInputdisableInterrupts() to disable
interrupts and DigitalInput.enableInterrupts() to enable them.areInterruptsEnabled in interface DigitalInputpublic void setInterruptDebounceMs(int milliSeconds)
DigitalInputsetInterruptDebounceMs in interface DigitalInputmilliSeconds - The maximum time that is used for debouncingpublic int getInterruptDebounceMs()
DigitalInputgetInterruptDebounceMs in interface DigitalInputpublic void setInterruptTrigger(Edge edge)
DigitalInputEdge that is
used for interrupt detection. Interrupts can either trigger on a
rising edge, a falling edge,
or on both edges.
The default value is both edges.setInterruptTrigger in interface DigitalInputedge - the edge that is used for triggering interrupts on this input.public Edge getInterruptTrigger()
DigitalInputgetInterruptTrigger in interface DigitalInputpublic void fireInterruptEvent(InterruptEventArgs args)
DigitalInputfireInterruptEvent in interface DigitalInputargs - the argspublic void addInterruptListener(InterruptListener listener)
DigitalInputaddInterruptListener in interface DigitalInputlistener - the listener that is to be added.public void removeInterruptListener(InterruptListener listener)
DigitalInputremoveInterruptListener in interface DigitalInputlistener - the listener that is to be removed.public void clearInterruptListeners()
DigitalInputclearInterruptListeners in interface DigitalInputpublic List<InterruptListener> getInterruptListeners()
DigitalInputgetInterruptListeners in interface DigitalInputpublic String getName()
getName in interface PinFeaturepublic void write(Signal signal)
DigitalOutputwrite in interface DigitalOutputsignal - the signalpublic void applySignal(Signal signal)
DigitalOutputapplySignal in interface DigitalOutputsignal - the signalpublic Signal getAppliedSignal()
DigitalOutputgetAppliedSignal in interface DigitalOutputpublic void high()
DigitalOutputhigh in interface DigitalOutputpublic void low()
DigitalOutputlow in interface DigitalOutputpublic void toggle()
DigitalOutputtoggle in interface DigitalOutputpublic boolean isHigh()
DigitalOutputisHigh in interface DigitalOutputpublic boolean isLow()
DigitalOutputisLow in interface DigitalOutputpublic void startBlinking(int periodLengthMilliseconds)
DigitalOutputstopBlinking() method.
You can specify the duration of a blinking period.
A blinking period is the full cycle of a state transition
and includes the the high phase as well as the low phase.
Both phases have the same duration.startBlinking in interface DigitalOutputperiodLengthMilliseconds - the duration of one full
blinking period in millisecondspublic void startBlinking(int periodLengthMilliseconds,
int durationMilliseconds)
DigitalOutputstopBlinking()
method. You can specify the duration of a blinking period.
A blinking period is the full cycle of a state transition
and includes the the high phase as well as the low phase.
Both phases have the same duration.
Also, you can specify the duration of the whole blinking process,
e.g. specify to let the output blink for 3000 milliseconds.startBlinking in interface DigitalOutputperiodLengthMilliseconds - the duration of one full
blinking period in millisecondsdurationMilliseconds - the duration of the whole blinking
process in milliseconds. A value of 0
let's it blink indefinitely.public void blinkTimes(int periodLengthMilliseconds,
int times)
DigitalOutputblinkTimes in interface DigitalOutputperiodLengthMilliseconds - the duration of one full
blinking period in millisecondstimes - the amount of times the output should blinkpublic void stopBlinking()
DigitalOutputstopBlinking in interface DigitalOutputpublic boolean isBlinking()
DigitalOutputisBlinking in interface DigitalOutputpublic void awaitBlinkingStopped()
DigitalOutputawaitBlinkingStopped in interface DigitalOutputprotected void setupImpl()
setupImpl in class AbstractPinFeatureprotected void teardownImpl()
teardownImpl in class AbstractPinFeaturepublic boolean isBlocking()
isBlocking in interface PinFeatureisBlocking in class AbstractPinFeaturepublic boolean isInputActive()
DigitalIOisInputActive in interface DigitalIOpublic boolean isOutputActive()
DigitalIOisOutputActive in interface DigitalIOCopyright © 2015 silverspoon.io. All rights reserved.