edu.berkeley.guir.ptk.output
Class OrbOutput

java.lang.Object
  extended byedu.berkeley.guir.ptk.PTK
      extended byedu.berkeley.guir.ptk.output.Output
          extended byedu.berkeley.guir.ptk.output.OrbOutput
All Implemented Interfaces:
Animatable, java.lang.Runnable
Direct Known Subclasses:
ActivityOrbOutput, AudioOrbOutput, PressureAudioOrbOutput

public class OrbOutput
extends Output
implements Animatable

Provides an interface for displaying events on an Ambient Orb. Uses the Ambient Orb's API to provide animation methods without implementing Animatable. For an example of an application that uses this, see the AudioOrbAppNon.

Author:
tmatthew

Field Summary
static int[] ALL_COLORS
          An array of integers representing all the pre-defined colors displayed by the ambient orb.
static int[] BASIC_COLORS
          An array of normal color constants.
static int[] BLUE_COLORS
          An array of blue color constants.
static int BRIGHT
          Brightness constant: use to set OrbOutput.brightness.
 int brightness
          The brightness of the Orb: set to DIM, MEDIUM_BRIGHT, or, BRIGHT.
 int changeblind_anim
          These define the speed and style of animations on the orb for each notification level.
 long COLOR_TIME
          The amount of time the Orb stays on one color - used in the methods provided in this class for looping through colors.
static int[] DARK_COLORS
          An array of dark color constants.
static int DIM
          Brightness constant: use to set OrbOutput.brightness.
static int[] GREEN_COLORS
          An array of green color constants.
 int interrupt_anim
          Default for interrupt is AML.ANIM_NONE, which is an abrupt change.
static int[] LIGHT_COLORS
          An array of light color constants.
static int[] MAGENTA_COLORS
          An array of magenta color constants.
 int makeaware_anim
          Default for make aware is AML.ANIM_FAST, which is a smooth, medium-paced change.
static int MEDIUM_BRIGHT
          Brightness constant: use to set OrbOutput.brightness.
static java.lang.String my_port
          The COM port to which the Ambient Orb is connected
static int[] NORMAL_COLORS
          An array of normal color constants.
protected  ambient.orb.AML orb
          An ambient orb API object.
static int[] PURPLE_COLORS
          An array of purple color constants.
static int[] RED_YELLOW_COLORS
          An array of red, orange, and yellow color constants.
 
Fields inherited from class edu.berkeley.guir.ptk.output.Output
animatable, d_queue, data_ids_I_want, history, ITEMS_LENGTH, metadata_I_want, num_ids, num_metadata, output_cycle_time, transition
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
OrbOutput()
          Constructor that initializes serial port communication with the Ambient Orb, sets the Orb's brightness and resets it.
 
Method Summary
 Event alternateStep(Event prev_event, Event new_event, int display_step)
          Returns an event that represents the "alternate" or "opposite" of what is displayed by the other transition methods in order to create a "flashing" effect.
 Event changeblindTransStep(Event prev_event, Event new_event, int display_step)
          Returns an event that is somewhere between the start and end points of a change blind transition, depending on the display_step and the number of steps involved in the transition.
 void displayEvent(Event e)
          This code needs to actually display the event (e.g.
 Event endTransition(Event prev_event, Event new_event, int display_step)
          Returns an event representative of the end state of a transition.
 int[] getChangeblindColors()
           
 int[] getInterruptColors()
           
 int[] getMakeAwareColors()
           
 Event interruptTransStep(Event prev_event, Event new_event, int display_step)
          Returns an event that is somewhere between the start and end points of a interrupt transition, depending on the display_step and the number of steps involved in the transition.
 void loopAllColors(long time)
          Calls loopColors to display all the colors.
 void loopBlues(long time)
          Calls loopColors to display all the blue colors.
 void loopColors(int[] colors, long time)
          Loops through the given colors, displaying each on the Orb for the given time.
 void loopDarkColors(long time)
          Calls loopColors to display all the dark colors.
 void loopGreens(long time)
          Calls loopColors to display all the green colors.
 void loopLightColors(long time)
          Calls loopColors to display all the light colors.
 void loopMagenta(long time)
          Calls loopColors to display all the magenta colors.
 void loopNormalColors(long time)
          Calls loopColors to display all the normal colors.
 void loopPurples(long time)
          Calls loopColors to display all the purple colors.
 void loopRedYellow(long time)
          Calls loopColors to display all the red-orange-yellow colors.
 Event makeawareTransStep(Event prev_event, Event new_event, int display_step)
          Returns an event that is somewhere between the start and end points of a make aware transition, depending on the display_step and the number of steps involved in the transition.
 void reset()
          Sets to white (tends to still pulse some).
 void sendColor(int c, int animation)
           
 void sendColorAbrupt(int c)
          Transitions from the previous color to given color with an abrupt transition between them.
 void sendColorPulse(int c)
          Transitions from the previous color to given color with a pulsing transition between them.
 void sendColorsAbrupt(int[] colors, long time)
          Loop through the given colors with an abrupt transition between them.
 void sendColorSmoothFast(int c)
          Transitions from the previous color to given color with a smooth, fast transition between them.
 void sendColorSmoothMed(int c)
          Transitions from the previous color to given color with a smooth, medium transition between them.
 void sendColorSmoothMedFast(int c)
          Transitions from the previous color to given color with a smooth, medium fast transition between them.
 void sendColorSmoothMedSlow(int c)
          Transitions from the previous color to given color with a smooth, medium slow transition between them.
 void sendColorSmoothSlow(int c)
          Transitions from the previous color to given color with a smooth, slow transition between them.
 void sendColorSmoothVeryFast(int c)
          Transitions from the previous color to given color with a smooth, very fast transition between them.
 void sendColorSmoothVerySlow(int c)
          Transitions from the previous color to given color with a smooth, very slow transition between them.
 void sendColorsPulse(int[] colors, long time)
          Loop through the given colors with a pulsing transition between them.
 void sendColorsSmoothFast(int[] colors, long time)
          Loop through the given colors with a smooth, fast transition between them.
 void sendColorsSmoothMed(int[] colors, long time)
          Loop through the given colors with a smooth, medium transition between them.
 void sendColorsSmoothMedFast(int[] colors, long time)
          Loop through the given colors with a smooth, medium fast transition between them.
 void sendColorsSmoothMedSlow(int[] colors, long time)
          Loop through the given colors with a smooth, medium slow transition between them.
 void sendColorsSmoothSlow(int[] colors, long time)
          Loop through the given colors with a smooth, slow transition between them.
 void sendColorsSmoothVeryFast(int[] colors, long time)
          Loop through the given colors with a smooth, very fast transition between them.
 void sendColorsSmoothVerySlow(int[] colors, long time)
          Loop through the given colors with a smooth, very slow transition between them.
 void setChangeblindColors(int[] colors)
           
 void setChangeblindParams(Event e, int step)
           
 void setInterruptColors(int[] colors)
           
 void setInterruptParams(Event e, int step)
           
 void setMakeawareColors(int[] colors)
           
 void setMakeawareParams(Event e, int step)
           
 Event startTransition(Event prev_event, Event new_event, int display_step)
          Returns an event representative of the beginning of a transition.
 
Methods inherited from class edu.berkeley.guir.ptk.output.Output
addDataID, addMetadataIWant, checkAction, doIWant, getAllMetadata, getDataIDs, getFirstMetadata, getHistory, handleEvent, interDisplayEvent, isAnimatable, printMetadataIWant, run, setChangeblindTransitionSteps, setDataIDsIWant, setInterruptTransitionSteps, setMakeawareTransitionSteps, setTimeBetweenDisplayEvents, setTransition, setUnsetNotification
 
Methods inherited from class edu.berkeley.guir.ptk.PTK
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIM

public static final int DIM
Brightness constant: use to set OrbOutput.brightness.

See Also:
Constant Field Values

MEDIUM_BRIGHT

public static final int MEDIUM_BRIGHT
Brightness constant: use to set OrbOutput.brightness.

See Also:
Constant Field Values

BRIGHT

public static final int BRIGHT
Brightness constant: use to set OrbOutput.brightness.

See Also:
Constant Field Values

ALL_COLORS

public static final int[] ALL_COLORS
An array of integers representing all the pre-defined colors displayed by the ambient orb. The Ambient Orb API does not list color integer constants in order, so this enables you to loop through all the colors easily.


DARK_COLORS

public static final int[] DARK_COLORS
An array of dark color constants.


NORMAL_COLORS

public static final int[] NORMAL_COLORS
An array of normal color constants.


BASIC_COLORS

public static final int[] BASIC_COLORS
An array of normal color constants.


LIGHT_COLORS

public static final int[] LIGHT_COLORS
An array of light color constants.


MAGENTA_COLORS

public static final int[] MAGENTA_COLORS
An array of magenta color constants.


PURPLE_COLORS

public static final int[] PURPLE_COLORS
An array of purple color constants.


BLUE_COLORS

public static final int[] BLUE_COLORS
An array of blue color constants.


GREEN_COLORS

public static final int[] GREEN_COLORS
An array of green color constants.


RED_YELLOW_COLORS

public static final int[] RED_YELLOW_COLORS
An array of red, orange, and yellow color constants.


orb

protected ambient.orb.AML orb
An ambient orb API object.


my_port

public static java.lang.String my_port
The COM port to which the Ambient Orb is connected


brightness

public int brightness
The brightness of the Orb: set to DIM, MEDIUM_BRIGHT, or, BRIGHT.


COLOR_TIME

public final long COLOR_TIME
The amount of time the Orb stays on one color - used in the methods provided in this class for looping through colors. The default is 2 ms. To change, call setTimeBetweenEvents(long)

See Also:
Constant Field Values

changeblind_anim

public int changeblind_anim
These define the speed and style of animations on the orb for each notification level. Default for changeblind is AML.ANIM_MED, which is smooth and fairly slow.


makeaware_anim

public int makeaware_anim
Default for make aware is AML.ANIM_FAST, which is a smooth, medium-paced change.


interrupt_anim

public int interrupt_anim
Default for interrupt is AML.ANIM_NONE, which is an abrupt change.

Constructor Detail

OrbOutput

public OrbOutput()
Constructor that initializes serial port communication with the Ambient Orb, sets the Orb's brightness and resets it.

Method Detail

getChangeblindColors

public int[] getChangeblindColors()

getMakeAwareColors

public int[] getMakeAwareColors()

getInterruptColors

public int[] getInterruptColors()

setChangeblindColors

public void setChangeblindColors(int[] colors)

setMakeawareColors

public void setMakeawareColors(int[] colors)

setInterruptColors

public void setInterruptColors(int[] colors)

displayEvent

public void displayEvent(Event e)
Description copied from class: Output
This code needs to actually display the event (e.g. print the text, show the image, etc). This function should return as fast as possible.

Specified by:
displayEvent in class Output
Parameters:
e - This event to be displayed

setChangeblindParams

public void setChangeblindParams(Event e,
                                 int step)

setMakeawareParams

public void setMakeawareParams(Event e,
                               int step)

setInterruptParams

public void setInterruptParams(Event e,
                               int step)

startTransition

public Event startTransition(Event prev_event,
                             Event new_event,
                             int display_step)
Description copied from interface: Animatable
Returns an event representative of the beginning of a transition.

Specified by:
startTransition in interface Animatable
Parameters:
prev_event - the previous event sent to this Output (null if the new event is the first).
new_event - the new event to be displayed on the Output.
display_step - a number indicating the display order of the event returned if the Transition is creating a set of events.
Returns:
Event

endTransition

public Event endTransition(Event prev_event,
                           Event new_event,
                           int display_step)
Description copied from interface: Animatable
Returns an event representative of the end state of a transition. This typically involves the new event data.

Specified by:
endTransition in interface Animatable
Parameters:
prev_event - the previous event sent to this Output (null if the new event is the first).
new_event - the new event to be displayed on the Output.
display_step - a number indicating the display order of the event returned if the Transition is creating a set of events.
Returns:
Event

changeblindTransStep

public Event changeblindTransStep(Event prev_event,
                                  Event new_event,
                                  int display_step)
Description copied from interface: Animatable
Returns an event that is somewhere between the start and end points of a change blind transition, depending on the display_step and the number of steps involved in the transition. Only need to implement if the application uses change blind transitions.

Specified by:
changeblindTransStep in interface Animatable
Parameters:
prev_event - the previous event sent to this Output (null if the new event is the first).
new_event - the new event to be displayed on the Output.
display_step - a number indicating the display order of the event returned if the Transition is creating a set of events.
Returns:
Event

makeawareTransStep

public Event makeawareTransStep(Event prev_event,
                                Event new_event,
                                int display_step)
Description copied from interface: Animatable
Returns an event that is somewhere between the start and end points of a make aware transition, depending on the display_step and the number of steps involved in the transition. Only need to implement if the application uses make aware transitions.

Specified by:
makeawareTransStep in interface Animatable
Parameters:
prev_event - the previous event sent to this Output (null if the new event is the first).
new_event - the new event to be displayed on the Output.
display_step - a number indicating the display order of the event returned if the Transition is creating a set of events.
Returns:
Event

interruptTransStep

public Event interruptTransStep(Event prev_event,
                                Event new_event,
                                int display_step)
Description copied from interface: Animatable
Returns an event that is somewhere between the start and end points of a interrupt transition, depending on the display_step and the number of steps involved in the transition. Only need to implement if the application uses interrupt transitions.

Specified by:
interruptTransStep in interface Animatable
Parameters:
prev_event - the previous event sent to this Output (null if the new event is the first).
new_event - the new event to be displayed on the Output.
display_step - a number indicating the display order of the event returned if the Transition is creating a set of events.
Returns:
Event

alternateStep

public Event alternateStep(Event prev_event,
                           Event new_event,
                           int display_step)
Description copied from interface: Animatable
Returns an event that represents the "alternate" or "opposite" of what is displayed by the other transition methods in order to create a "flashing" effect. For example, if a text is displayed on a ticker, the alternateStep might be to delete all the text. For an interrupt transition, the effect would be text flashing between the the new event text (returned by endTransition) and no text (returned by alternateStep).

Specified by:
alternateStep in interface Animatable
Parameters:
prev_event - the previous event sent to this Output (null if the new event is the first).
new_event - the new event to be displayed on the Output.
display_step - a number indicating the display order of the event returned if the Transition is creating a set of events.
Returns:
Event

reset

public void reset()
Sets to white (tends to still pulse some).


sendColor

public void sendColor(int c,
                      int animation)

loopColors

public void loopColors(int[] colors,
                       long time)
Loops through the given colors, displaying each on the Orb for the given time.

Parameters:
colors -
time -

loopRedYellow

public void loopRedYellow(long time)
Calls loopColors to display all the red-orange-yellow colors.


loopGreens

public void loopGreens(long time)
Calls loopColors to display all the green colors.


loopPurples

public void loopPurples(long time)
Calls loopColors to display all the purple colors.


loopMagenta

public void loopMagenta(long time)
Calls loopColors to display all the magenta colors.


loopBlues

public void loopBlues(long time)
Calls loopColors to display all the blue colors.


loopDarkColors

public void loopDarkColors(long time)
Calls loopColors to display all the dark colors.


loopLightColors

public void loopLightColors(long time)
Calls loopColors to display all the light colors.


loopNormalColors

public void loopNormalColors(long time)
Calls loopColors to display all the normal colors.


loopAllColors

public void loopAllColors(long time)
Calls loopColors to display all the colors.


sendColorsAbrupt

public void sendColorsAbrupt(int[] colors,
                             long time)
Loop through the given colors with an abrupt transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsPulse

public void sendColorsPulse(int[] colors,
                            long time)
Loop through the given colors with a pulsing transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothVeryFast

public void sendColorsSmoothVeryFast(int[] colors,
                                     long time)
Loop through the given colors with a smooth, very fast transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothFast

public void sendColorsSmoothFast(int[] colors,
                                 long time)
Loop through the given colors with a smooth, fast transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothMedFast

public void sendColorsSmoothMedFast(int[] colors,
                                    long time)
Loop through the given colors with a smooth, medium fast transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothMed

public void sendColorsSmoothMed(int[] colors,
                                long time)
Loop through the given colors with a smooth, medium transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothMedSlow

public void sendColorsSmoothMedSlow(int[] colors,
                                    long time)
Loop through the given colors with a smooth, medium slow transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothSlow

public void sendColorsSmoothSlow(int[] colors,
                                 long time)
Loop through the given colors with a smooth, slow transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorsSmoothVerySlow

public void sendColorsSmoothVerySlow(int[] colors,
                                     long time)
Loop through the given colors with a smooth, very slow transition between them.

Parameters:
colors - an integer array of Orb color constants.
time - indicates how long to display each color.

sendColorAbrupt

public void sendColorAbrupt(int c)
Transitions from the previous color to given color with an abrupt transition between them.

Parameters:
c - an Orb color constant.

sendColorPulse

public void sendColorPulse(int c)
Transitions from the previous color to given color with a pulsing transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothVeryFast

public void sendColorSmoothVeryFast(int c)
Transitions from the previous color to given color with a smooth, very fast transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothFast

public void sendColorSmoothFast(int c)
Transitions from the previous color to given color with a smooth, fast transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothMedFast

public void sendColorSmoothMedFast(int c)
Transitions from the previous color to given color with a smooth, medium fast transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothMed

public void sendColorSmoothMed(int c)
Transitions from the previous color to given color with a smooth, medium transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothMedSlow

public void sendColorSmoothMedSlow(int c)
Transitions from the previous color to given color with a smooth, medium slow transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothSlow

public void sendColorSmoothSlow(int c)
Transitions from the previous color to given color with a smooth, slow transition between them.

Parameters:
c - an Orb color constant.

sendColorSmoothVerySlow

public void sendColorSmoothVerySlow(int c)
Transitions from the previous color to given color with a smooth, very slow transition between them.

Parameters:
c - an Orb color constant.