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.Steps 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)
BlinkersetConstant in interface Blinkercolor - the color with which the LED or light should be illuminatedpublic void stopBlinking()
BlinkerstopBlinking in interface Blinkerpublic int getBlinkerPatternMaxLength()
BlinkerBlinker.Steps that can be present in a patterngetBlinkerPatternMaxLength in interface BlinkerBlinker.Steps that can be present in a patternpublic void pushPattern(java.util.Collection<Blinker.Step> steps)
BlinkerpushPattern in interface Blinkersteps - the new pattern to be displayedpublic boolean patternStackNotEmpty()
BlinkerpatternStackNotEmpty in interface Blinkerpublic boolean popPattern()
BlinkerpopPattern in interface Blinkerpublic void setPattern(java.util.Collection<Blinker.Step> steps)
BlinkersetPattern in interface Blinkersteps - 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()
BlinkergetPattern in interface Blinkerprotected void scheduleNext()
protected void stop()