public class NxtApplication extends NxtOperation
The application receives commands from the PC application and act upon them
| Modifier and Type | Field and Description |
|---|---|
private static ColorSensor |
colorSensor |
private static char[] |
hexArray |
private static NXTRegulatedMotor[] |
motors |
private static UltrasonicSensor |
ultrasonicSensor |
OPERATION_ID_FORWARD, OPERATION_ID_GET_DISTANCE, OPERATION_ID_GET_TACHO_COUNT, OPERATION_ID_READ_COLOR, OPERATION_ID_READ_COLOR_ID, OPERATION_ID_RESET_TACHO_COUNT, OPERATION_ID_ROTATE, OPERATION_ID_ROTATE_TO, OPERATION_ID_SET_SPEED, OPERATION_TYPE_CLOSE_CONNECTION, OPERATION_TYPE_COLOR_SENSOR, OPERATION_TYPE_MOTOR, OPERATION_TYPE_ULTRASONIC_SENSOR| Constructor and Description |
|---|
NxtApplication() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
addEscButtonListener()
Ass listener to the ESC button
|
static String |
bytesToHex(byte[] bytes)
Convert byte array to Hexadecimal
|
private static void |
initMotors()
Initialize NXT's motors
|
static void |
main(String[] args)
Main function of the NXT application
|
private static void |
printToLcd(String line0,
int delay)
Print to LCD
|
private static void |
printToLcd(String line0,
String line1,
int delay)
Print to LCD
|
private static void |
printToLcd(String line0,
String line1,
String line2,
int delay)
Print to LCD
|
private static void |
printToLcd(String line0,
String line1,
String line2,
String line3,
int delay)
Print to LCD
|
static int[] |
readRgbAverage(int numberOfSamples)
Read color from sensor
|
private static void |
runCommandListener()
Run the main loop waiting for command from PC
|
private static final NXTRegulatedMotor[] motors
private static final ColorSensor colorSensor
private static final UltrasonicSensor ultrasonicSensor
private static final char[] hexArray
public static String bytesToHex(byte[] bytes)
bytes - The byte array to print as Hexadecimalprivate static void initMotors()
private static void printToLcd(String line0, int delay)
line0 - 1st line to printdelay - Delay time in MS after the printprivate static void printToLcd(String line0, String line1, int delay)
line0 - 1st line to printline1 - 2nd line to printdelay - Delay time in MS after the printprivate static void printToLcd(String line0, String line1, String line2, int delay)
line0 - 1st line to printline1 - 2nd line to printline2 - 3rd line to printdelay - Delay time in MS after the printprivate static void printToLcd(String line0, String line1, String line2, String line3, int delay)
line0 - 1st line to printline1 - 2nd line to printline2 - 3rd line to printline3 - 4th line to printdelay - Delay time in MS after the printprivate static void addEscButtonListener()
public static int[] readRgbAverage(int numberOfSamples)
numberOfSamples - Number of reading to performprivate static void runCommandListener()
This function exits upon pressing the ESC button on the NXT
public static void main(String[] args)