lejos.nxt
Class LCD

java.lang.Object
  extended by lejos.nxt.LCD

public class LCD
extends Object

Text and graphics output to the LCD display.

Author:
Andre Nijholt and BB bitBlt and other mods Andy Shaw

Field Summary
static int CELL_HEIGHT
           
static int CELL_WIDTH
           
static int DEFAULT_REFRESH_PERIOD
           
static int DISPLAY_CHAR_DEPTH
           
static int DISPLAY_CHAR_WIDTH
           
static int FONT_HEIGHT
           
static int FONT_WIDTH
           
static int NOOF_CHARS
           
static int ROP_AND
           
static int ROP_ANDINVERTED
           
static int ROP_ANDREVERSE
           
static int ROP_CLEAR
          Common raster operations for use with bitBlt
static int ROP_COPY
           
static int ROP_COPYINVERTED
           
static int ROP_EQUIV
           
static int ROP_INVERT
           
static int ROP_NAND
           
static int ROP_NOOP
           
static int ROP_NOR
           
static int ROP_OR
           
static int ROP_ORINVERTED
           
static int ROP_ORREVERSE
           
static int ROP_SET
           
static int ROP_XOR
           
static int SCREEN_HEIGHT
           
static int SCREEN_WIDTH
           
 
Constructor Summary
LCD()
           
 
Method Summary
static void asyncRefresh()
          Start the process of updating the display.
static void asyncRefreshWait()
          Wait for the current refresh cycle to complete.
static void bitBlt(byte[] src, int sw, int sh, int sx, int sy, byte[] dst, int dw, int dh, int dx, int dy, int w, int h, int rop)
          Standard two input BitBlt function.
static void bitBlt(byte[] src, int sw, int sh, int sx, int sy, int dx, int dy, int w, int h, int rop)
          Standard two input BitBlt function with the LCD display as the destination.
static void clear()
          Clear the display.
static void clear(int y)
          Clear an LCD display row
static void clear(int x, int y, int n)
          Clear a contiguous set of characters
static void clearDisplay()
           
static void drawChar(char c, int x, int y)
          Draw a single char on the LCD at specified x,y co-ordinate.
static void drawInt(int i, int x, int y)
          Display an int on the LCD at specified x,y co-ordinate.
static void drawInt(int i, int places, int x, int y)
          Display an in on the LCD at x,y with leading spaces to occupy at least the number of characters specified by the places parameter.
static void drawString(String str, int x, int y)
          Display a string on the LCD at specified x,y co-ordinate.
static void drawString(String str, int x, int y, boolean inverted)
          Display an optionally inverted string on the LCD at specified x,y co-ordinate.
static byte[] getDisplay()
          Provide access to the LCD display frame buffer.
static int getPixel(int x, int y)
          Method to get a pixel from the screen.
static int getRefreshCompleteTime()
          Obtain the system time when the current display refresh operation will be complete.
static byte[] getSystemFont()
          Provide access to the LCD system font.
static void refresh()
          Refresh the display.
static void scroll()
          Scrolls the screen up one text line
static void setAutoRefresh(boolean on)
          Turn on/off the automatic refresh of the LCD display.
static int setAutoRefreshPeriod(int period)
          Set the period used to perform automatic refreshing of the display.
static void setContrast(int contrast)
          Set the LCD contrast.
static void setPixel(int x, int y, int color)
          Method to set a pixel on the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCREEN_WIDTH

public static final int SCREEN_WIDTH
See Also:
Constant Field Values

SCREEN_HEIGHT

public static final int SCREEN_HEIGHT
See Also:
Constant Field Values

NOOF_CHARS

public static final int NOOF_CHARS
See Also:
Constant Field Values

FONT_WIDTH

public static final int FONT_WIDTH
See Also:
Constant Field Values

FONT_HEIGHT

public static final int FONT_HEIGHT
See Also:
Constant Field Values

CELL_WIDTH

public static final int CELL_WIDTH
See Also:
Constant Field Values

CELL_HEIGHT

public static final int CELL_HEIGHT
See Also:
Constant Field Values

DISPLAY_CHAR_WIDTH

public static final int DISPLAY_CHAR_WIDTH
See Also:
Constant Field Values

DISPLAY_CHAR_DEPTH

public static final int DISPLAY_CHAR_DEPTH
See Also:
Constant Field Values

DEFAULT_REFRESH_PERIOD

public static final int DEFAULT_REFRESH_PERIOD
See Also:
Constant Field Values

ROP_CLEAR

public static final int ROP_CLEAR
Common raster operations for use with bitBlt

See Also:
Constant Field Values

ROP_AND

public static final int ROP_AND
See Also:
Constant Field Values

ROP_ANDREVERSE

public static final int ROP_ANDREVERSE
See Also:
Constant Field Values

ROP_COPY

public static final int ROP_COPY
See Also:
Constant Field Values

ROP_ANDINVERTED

public static final int ROP_ANDINVERTED
See Also:
Constant Field Values

ROP_NOOP

public static final int ROP_NOOP
See Also:
Constant Field Values

ROP_XOR

public static final int ROP_XOR
See Also:
Constant Field Values

ROP_OR

public static final int ROP_OR
See Also:
Constant Field Values

ROP_NOR

public static final int ROP_NOR
See Also:
Constant Field Values

ROP_EQUIV

public static final int ROP_EQUIV
See Also:
Constant Field Values

ROP_INVERT

public static final int ROP_INVERT
See Also:
Constant Field Values

ROP_ORREVERSE

public static final int ROP_ORREVERSE
See Also:
Constant Field Values

ROP_COPYINVERTED

public static final int ROP_COPYINVERTED
See Also:
Constant Field Values

ROP_ORINVERTED

public static final int ROP_ORINVERTED
See Also:
Constant Field Values

ROP_NAND

public static final int ROP_NAND
See Also:
Constant Field Values

ROP_SET

public static final int ROP_SET
See Also:
Constant Field Values
Constructor Detail

LCD

public LCD()
Method Detail

bitBlt

public static void bitBlt(byte[] src,
                          int sw,
                          int sh,
                          int sx,
                          int sy,
                          int dx,
                          int dy,
                          int w,
                          int h,
                          int rop)
Standard two input BitBlt function with the LCD display as the destination. Supports standard raster ops and overlapping images. Images are held in native leJOS/Lego format.

Parameters:
src - byte array containing the source image
sw - Width of the source image
sh - Height of the source image
sx - X position to start the copy from
sy - Y Position to start the copy from
dx - X destination
dy - Y destination
w - width of the area to copy
h - height of the area to copy
rop - raster operation.

drawChar

public static void drawChar(char c,
                            int x,
                            int y)
Draw a single char on the LCD at specified x,y co-ordinate.

Parameters:
c - Character to display
x - X location
y - Y location

clearDisplay

public static void clearDisplay()

drawString

public static void drawString(String str,
                              int x,
                              int y,
                              boolean inverted)
Display an optionally inverted string on the LCD at specified x,y co-ordinate.

Parameters:
str - The string to be displayed
x - The x character co-ordinate to display at.
y - The y character co-ordinate to display at.
inverted - if true the string is displayed inverted.

drawString

public static void drawString(String str,
                              int x,
                              int y)
Display a string on the LCD at specified x,y co-ordinate.

Parameters:
str - The string to be displayed
x - The x character co-ordinate to display at.
y - The y character co-ordinate to display at.

drawInt

public static void drawInt(int i,
                           int x,
                           int y)
Display an int on the LCD at specified x,y co-ordinate.

Parameters:
i - The value to display.
x - The x character co-ordinate to display at.
y - The y character co-ordinate to display at.

drawInt

public static void drawInt(int i,
                           int places,
                           int x,
                           int y)
Display an in on the LCD at x,y with leading spaces to occupy at least the number of characters specified by the places parameter.

Parameters:
i - The value to display
places - number of places to use to display the value
x - The x character co-ordinate to display at.
y - The y character co-ordinate to display at.

asyncRefresh

public static void asyncRefresh()
Start the process of updating the display. This will always return immediately after starting the refresh process.


getRefreshCompleteTime

public static int getRefreshCompleteTime()
Obtain the system time when the current display refresh operation will be complete. Not that this may be in the past.

Returns:
the system time in ms when the refresh will be complete.

asyncRefreshWait

public static void asyncRefreshWait()
Wait for the current refresh cycle to complete.


refresh

public static void refresh()
Refresh the display. If auto refresh is off, this method will wait until the display refresh has completed. If auto refresh is on it will return immediately.


clear

public static void clear()
Clear the display.


getDisplay

public static byte[] getDisplay()
Provide access to the LCD display frame buffer. Allows both the firmware and Java to make changes.

Returns:
byte array that is the frame buffer.

getSystemFont

public static byte[] getSystemFont()
Provide access to the LCD system font. Allows both the firmware and Java to share the same font bitmaps.

Returns:
byte array that is the frame buffer.

setAutoRefreshPeriod

public static int setAutoRefreshPeriod(int period)
Set the period used to perform automatic refreshing of the display. A period of 0 disables the refresh.

Parameters:
period - time in ms
Returns:
the previous refresh period.

setAutoRefresh

public static void setAutoRefresh(boolean on)
Turn on/off the automatic refresh of the LCD display. At system startup auto refresh is on.

Parameters:
on - true to enable, false to disable

setPixel

public static void setPixel(int x,
                            int y,
                            int color)
Method to set a pixel on the screen.

Parameters:
x - the x coordinate
y - the y coordinate
color - the pixel color (0 = white, 1 = black)

getPixel

public static int getPixel(int x,
                           int y)
Method to get a pixel from the screen.

Parameters:
x - the x coordinate
y - the y coordinate
Returns:
the pixel color (0 = white, 1 = black)

bitBlt

public static void bitBlt(byte[] src,
                          int sw,
                          int sh,
                          int sx,
                          int sy,
                          byte[] dst,
                          int dw,
                          int dh,
                          int dx,
                          int dy,
                          int w,
                          int h,
                          int rop)
Standard two input BitBlt function. Supports standard raster ops and overlapping images. Images are held in native leJOS/Lego format.

Parameters:
src - byte array containing the source image
sw - Width of the source image
sh - Height of the source image
sx - X position to start the copy from
sy - Y Position to start the copy from
dst - byte array containing the destination image
dw - Width of the destination image
dh - Height of the destination image
dx - X destination
dy - Y destination
w - width of the area to copy
h - height of the area to copy
rop - raster operation.

scroll

public static void scroll()
Scrolls the screen up one text line


clear

public static void clear(int x,
                         int y,
                         int n)
Clear a contiguous set of characters

Parameters:
x - the x character coordinate
y - the y character coordinate
n - the number of characters

clear

public static void clear(int y)
Clear an LCD display row

Parameters:
y - the row to clear

setContrast

public static void setContrast(int contrast)
Set the LCD contrast.

Parameters:
contrast - 0 blank 0x60 full on