leJOS Utilities


leJOS Utilities

ButtonCounter

This class allows simple data entry by pressing the NXT buttons. It counts the number of presses of the Left and Right buttons, Pressing Left (or Right) simultaneously with Enter decrements the count.

To start counting, call one of these methods:

  • void count(String message)

  • void count(String message, int left, int right)

These methods exit when the user presses ESC. Then the values can be retrieved by

  • int getLeftCount()

  • int getRightCount()

The complete API for Button Counter is here

DataLogger

This class stores float values in an array and transmits them to the DataViewer application running on a PC. It will use BlueTooth or USB as selected by the user at run time. The default size of the array is 512, but this can be set to any value, limited by available memory, by a constructor.

Methods:

  • void writeLog(float value)

    Writes a value to the array

  • void reset()

    Clear the array. The next value is written at the beginning.

  • void transmit()

    Transmits the data to the PC.

The complete API of Data:logger is here.

Stopwatch

This class represents an elapsed time stopwatch. You can construct as many instances as you need.

There are only two methods

  • void reset()

    resets the watch to zero

  • int elapsed()

    returns the elapsed time (since the last reset() in milliseconds.

The API of Stopwatch is here.

Timer

This class is used with a Timer Listener, to which it sends timedOut() message periodically. It uses a private thread.

Methods:

  • void start()

    call this first.

  • void setDelay(int delay)

    set the interval between calls to the listener.

  • void stop()

The Timer API is here.

Timer Listener

To use the Timer, you need a class that implements this interface. This interface has only one method.

  • void timedOut()

    which is called every time the Timer fires.

Back to top

Java Utilities

leJOS NXJ supports several of the Java data structures. They are:

It also supports two other Java utilities:

Back to top