dLife Home Page

dlife.robot.hemisson
Class HemissonLCD

java.lang.Object
  extended by java.util.Observable
      extended by dlife.robot.Device
          extended by dlife.robot.ArraySensor<Boolean>
              extended by dlife.robot.hemisson.HemissonLCD

public class HemissonLCD
extends ArraySensor<Boolean>

A class for interacting with the HemissonLCD display.


Photo adapted from www.k-team.com.

The LCD can display 2 lines of text with up to 12 characters per line. The LCD also has 3 buttons that can be pressed. When setting text the top line refers to the rearmost line, the bottom line is the frontmost line and the buttons are labeled 0 through 2 going left to right.

Version:
July 22, 2010, July 28, 2010
Author:
Russell Toris, Dickinson College, Grant Braught

Field Summary
static int CENTER_ALIGNMENT
          The integer representation of aligning the LCD text to the center.
static int CENTER_BUTTON
          The integer representation of the center button.
static int LEFT_ALIGNMENT
          The integer representation of aligning the LCD text to the left.
static int LEFT_BUTTON
          The integer representation of the left button.
static int RIGHT_ALIGNMENT
          The integer representation of aligning the LCD text to the right.
static int RIGHT_BUTTON
          The integer representation of the right button.
 
Fields inherited from class dlife.robot.ArraySensor
length, values
 
Fields inherited from class dlife.robot.Device
DEFAULT_GUI_UPDATE_DELAY, DEFAULT_READ_DELAY, myRobot, readCount
 
Constructor Summary
HemissonLCD()
          Create a new HemissonLCD effector.
 
Method Summary
 void clearAll()
          Clear all text on the LCD screen.
 void clearBottomLine()
          Clear all text on the bottom line of the LCD screen.
 void clearTopLine()
          Clear all text on the top line of the LCD screen.
protected  DeviceDisplay[] createGUIObjects()
          Get the object that is the GUI for this HemissonLCD display.
 void freeze()
          Nothing needs to be done on freeze.
 int getBottomLineAlignment()
          Get the current alignment of the bottom line.
 String getBottomLineText()
          Get the current text of the bottom line.
 int getBrightness()
          Get the current brightness value of the LCD.
 boolean getButtonValue(int button)
          Get the value of the given button number.
 int getContrast()
          Get the current contrast value of the LCD.
 int getTopLineAlignment()
          Get the current alignment of the top line.
 String getTopLineText()
          Get the current text of the top line.
static void main(String[] args)
          A test method that creates a Hemission and a HemissonLCD and displays the GUI so that the LCD can be tested.
 void readStateFromRobot()
          Read the data from the buttons on the LCD display and update the values.
 void setBottomLineText(String text, int alignment)
          Set the bottom line of the LCD to the given line of text.
 void setBrightness(int brightness)
          Set the brightness of the display to the given number.
 void setContrast(int contrast)
          Set the contrast of the display to the given number.
 void setText(String text, int alignment)
          Set the text of the LCD screen to the given String.
 void setTopLineText(String text, int alignment)
          Set the top line of the LCD to the given line of text.
 void shutDown()
          Clears the LCD screen, sets the brightness back to 0, and sets the contrast back to 210.
 void startUp()
          Sets the initial brightness to 0, and sets the contrast to 210.
 
Methods inherited from class dlife.robot.ArraySensor
getAverage, getAverage, getMaximum, getMaximum, getMaximumIndex, getMaximumIndex, getMinimum, getMinimum, getMinimumIndex, getMinimumIndex, getNumValues, getSubset, getValue, getValues
 
Methods inherited from class dlife.robot.Device
getAutoRead, getGUI, getGUIUpdateDelay, getReadDelay, getRobot, getSensorReadCount, getSensorReadRate, setAutoRead, setGUIUpdateDelay, setReadDelay, setRobot, startAutoReadTimer, stopAutoReadTimer
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_ALIGNMENT

public static final int LEFT_ALIGNMENT
The integer representation of aligning the LCD text to the left.

See Also:
Constant Field Values

CENTER_ALIGNMENT

public static final int CENTER_ALIGNMENT
The integer representation of aligning the LCD text to the center.

See Also:
Constant Field Values

RIGHT_ALIGNMENT

public static final int RIGHT_ALIGNMENT
The integer representation of aligning the LCD text to the right.

See Also:
Constant Field Values

LEFT_BUTTON

public static final int LEFT_BUTTON
The integer representation of the left button. Buttons are numbered from left to right facing the robot's front.

See Also:
Constant Field Values

CENTER_BUTTON

public static final int CENTER_BUTTON
The integer representation of the center button. Buttons are numbered from left to right facing the robot's front.

See Also:
Constant Field Values

RIGHT_BUTTON

public static final int RIGHT_BUTTON
The integer representation of the right button. Buttons are numbered from left to right facing the robot's front.

See Also:
Constant Field Values
Constructor Detail

HemissonLCD

public HemissonLCD()
Create a new HemissonLCD effector.

Method Detail

startUp

public void startUp()
Sets the initial brightness to 0, and sets the contrast to 210.

Overrides:
startUp in class Device

shutDown

public void shutDown()
Clears the LCD screen, sets the brightness back to 0, and sets the contrast back to 210.

Overrides:
shutDown in class Device

setContrast

public void setContrast(int contrast)
Set the contrast of the display to the given number. This number should be within the range [0,255].

Parameters:
contrast - a value within the range [0,255] specifying the contrast of the LCD
Throws:
IllegalArgumentException - thrown if the contrast value is out of range

getContrast

public int getContrast()
Get the current contrast value of the LCD.

Returns:
the current contrast value of the LCD

setBrightness

public void setBrightness(int brightness)
Set the brightness of the display to the given number. This number should be within the range [0,255].

Parameters:
brightness - a value within the range [0,255] specifying the brightness of the LCD
Throws:
IllegalArgumentException - thrown if the brightness value is out of range

getBrightness

public int getBrightness()
Get the current brightness value of the LCD.

Returns:
the current brightness value of the LCD

setText

public void setText(String text,
                    int alignment)
Set the text of the LCD screen to the given String. The first 12 characters will be placed on the top line, and the second 12 characters will be displayed on the bottom line. Any additional characters will be ignored. The alignment should be one of the constants defined in this class (LEFT_ALIGNMENT, RIGHT_ALIGNMENT, or CENTER_ALIGNMENT).

Parameters:
text - the text to display on the LCD.
alignment - LEFT_ALIGNMENT, RIGHT_ALIGNMENT, or CENTER_ALIGNMENT
Throws:
IllegalArgumentException - thrown if the alignment is not one of the predefined constants

setTopLineText

public void setTopLineText(String text,
                           int alignment)
Set the top line of the LCD to the given line of text. Only the first 12 characters of the text will be used. All other characters are discarded. The alignment should be one of the constants defined in this class (left, right, and centered).

Parameters:
text - the text to set the top line of the LCD to
alignment - LEFT_ALIGNMENT, RIGHT_ALIGNMENT, or CENTER_ALIGNMENT
Throws:
IllegalArgumentException - thrown if the alignment is not one of the predefined constants

getTopLineText

public String getTopLineText()
Get the current text of the top line.

Returns:
the current text of the top line

getTopLineAlignment

public int getTopLineAlignment()
Get the current alignment of the top line.

Returns:
the top line alignment.

setBottomLineText

public void setBottomLineText(String text,
                              int alignment)
Set the bottom line of the LCD to the given line of text. Only the first 12 characters of the text will be used. All other characters are discarded. The alignment should be one of the constants defined in this class (left, right, and centered).

Parameters:
text - the text to set the bottom line of the LCD to
alignment - LEFT_ALIGNMENT, RIGHT_ALIGNMENT, or CENTER_ALIGNMENT
Throws:
IllegalArgumentException - thrown if the alignment is not one of the predefined constants

getBottomLineText

public String getBottomLineText()
Get the current text of the bottom line.

Returns:
the current text of the bottom line

getBottomLineAlignment

public int getBottomLineAlignment()
Get the current alignment of the bottom line.

Returns:
the bottom line alignment.

clearAll

public void clearAll()
Clear all text on the LCD screen.


clearTopLine

public void clearTopLine()
Clear all text on the top line of the LCD screen.


clearBottomLine

public void clearBottomLine()
Clear all text on the bottom line of the LCD screen.


freeze

public void freeze()
Nothing needs to be done on freeze.

Specified by:
freeze in class Device

readStateFromRobot

public void readStateFromRobot()
Read the data from the buttons on the LCD display and update the values. All other data is updated directly when it is set by the mutator methods above.

Specified by:
readStateFromRobot in class Device

getButtonValue

public boolean getButtonValue(int button)
Get the value of the given button number. This will either be true (pressed) or false (not pressed). Buttons are labeled from left to right looking towards the robot starting from 0.

Parameters:
button - the button number to check
Returns:
true if the button is pressed, false if it is not.

createGUIObjects

protected DeviceDisplay[] createGUIObjects()
Get the object that is the GUI for this HemissonLCD display.

Specified by:
createGUIObjects in class Device
Returns:
the object that is the GUI for this HemissonLCD display.

main

public static void main(String[] args)
                 throws Exception
A test method that creates a Hemission and a HemissonLCD and displays the GUI so that the LCD can be tested.

Parameters:
args - none
Throws:
Exception

dLife Home Page