The leJOS Tutorial

| Start of Tutorial > Start of Trail

Trail: Essential leJOS classes
Lesson: Controlling the Hardware

# Controlling the Hardware: The LCD

The display on the the upper side of the RCX is more or less the only possibility to show messages directly to the user (a fact which makes debugging with leJOS rather challenging); it is able to display up to five numbers or letters.

## LCD

The static `LCD` class offers various methods to access each of these segments or the complete display area:

- public static void clear()
- public static void clearSegment(int aCode)
- public static void refresh()

for clearing and refreshing and

- public static void setNumber(int aCode,int aValue,int aPoint)
- public static void setSegment(int aCode)
- public static void showNumber(int aValue)
- public static void showProgramNumber(int aValue)

for displaying.
The segment codes are constants defined in the `Segment` interface, e.g. `Segment.BATTERY`,`Segment.WALKING`, `Segment.STANDING` and so on.
Note that you have to call `refresh()` after setting the segment!

There is a memory saving alternative to the `LCD` class: the `MinLCD` class contains only the `public static void setNumber(int aCode,int aValue,int aPoint)` and the `refresh()` method.

## TextLCD

Another class for sending output to the display is the `TextLCD` class. It offers methods to write chars or even Strings up to five characters:

- public static void print(char[] aText)
- public static void printChar(char aChar, int aPosition) )
- public static void print(String aString)

## A complete example which uses the LCD class

is PerformanceTest.java which may be found in the `examples/performance_test` section of the leJOS tree.

## The API

may be found here for LCD and for TextLCD.

The leJOS Tutorial

| Start of Tutorial > Start of Trail