public class LightBlinker extends java.lang.Object implements Blinker
LightBlinker
is a handy utility that will flash a SwitchableLight
in a pattern of timed durations, and, optionally, colors, if the light supports same (NYI)Blinker.Step
Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<Blinker.Step> |
currentSteps |
protected java.util.concurrent.ScheduledFuture<?> |
future |
protected SwitchableLight |
light |
protected int |
nextStep |
protected java.util.Deque<java.util.ArrayList<Blinker.Step>> |
previousSteps |
static java.lang.String |
TAG |
Constructor and Description |
---|
LightBlinker(SwitchableLight light) |
Modifier and Type | Method and Description |
---|---|
int |
getBlinkerPatternMaxLength()
Returns the maximum number of
Blinker.Step s that can be present in a pattern |
java.util.Collection<Blinker.Step> |
getPattern()
Returns the current blinking pattern
|
protected boolean |
isCurrentPattern(java.util.Collection<Blinker.Step> steps) |
boolean |
patternStackNotEmpty()
Returns whether the pattern stack is currently nonempty.
|
boolean |
popPattern()
Pops the next pattern off of the stack of saved patterns, if any.
|
void |
pushPattern(java.util.Collection<Blinker.Step> steps)
Saves the existing pattern such that it can be later restored, then calls setPattern().
|
protected void |
scheduleNext() |
void |
setConstant(int color)
Sets the blinker pattern to be a single, unchanging color
|
void |
setPattern(java.util.Collection<Blinker.Step> steps)
Sets the pattern with which this LED or light should illuminate.
|
protected void |
stop() |
void |
stopBlinking()
Sets the blinker to constant black and frees any internal resources
|
public static final java.lang.String TAG
protected final SwitchableLight light
protected java.util.ArrayList<Blinker.Step> currentSteps
protected java.util.Deque<java.util.ArrayList<Blinker.Step>> previousSteps
protected java.util.concurrent.ScheduledFuture<?> future
protected int nextStep
public LightBlinker(SwitchableLight light)
public void setConstant(int color)
Blinker
setConstant
in interface Blinker
color
- the color with which the LED or light should be illuminatedpublic void stopBlinking()
Blinker
stopBlinking
in interface Blinker
public int getBlinkerPatternMaxLength()
Blinker
Blinker.Step
s that can be present in a patterngetBlinkerPatternMaxLength
in interface Blinker
Blinker.Step
s that can be present in a patternpublic void pushPattern(java.util.Collection<Blinker.Step> steps)
Blinker
pushPattern
in interface Blinker
steps
- the new pattern to be displayedpublic boolean patternStackNotEmpty()
Blinker
patternStackNotEmpty
in interface Blinker
public boolean popPattern()
Blinker
popPattern
in interface Blinker
public void setPattern(java.util.Collection<Blinker.Step> steps)
Blinker
setPattern
in interface Blinker
steps
- the pattern of colors and durations that the LED or light should illuminate itself withprotected boolean isCurrentPattern(java.util.Collection<Blinker.Step> steps)
public java.util.Collection<Blinker.Step> getPattern()
Blinker
getPattern
in interface Blinker
protected void scheduleNext()
protected void stop()