|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecticommand.nxtcomm.NXTCommand
public class NXTCommand
NXTCommand contains easily accessible commands for the Lego NXT.
Field Summary |
---|
Method Summary | |
---|---|
static void |
close()
Call the close() command when your program ends, otherwise you will have to turn the NXT brick off/on before you run another program using iCommand. |
static byte |
closeFile(byte handle)
Closes an open file. |
static byte |
delete(java.lang.String fileName)
|
static byte |
deleteUserFlash()
Deletes user flash memory (not including system modules). |
static FileInfo |
findFirst(java.lang.String wildCard)
When no files exist within the system, an error message is returned in the package saying "File not found". |
static FileInfo |
findNext(byte handle)
When no files exist within the system, an error message is returned in the package saying "File not found". |
static int |
getBatteryLevel()
|
static java.lang.String |
getCurrentProgramName()
Name of current running program. |
static DeviceInfo |
getDeviceInfo()
|
static FirmwareInfo |
getFirmwareVersion()
|
static InputValues |
getInputValues(int port)
|
static OutputState |
getOutputState(int port)
Retrieves the current output state for a port. |
static boolean |
isVerify()
|
static long |
keepAlive()
Keeps the NXT from shutting off. |
static byte[] |
LSGetStatus(byte port)
Returns the status for an Inter-Integrated Circuit (I2C) sensor (the ultrasound sensor) via the Low Speed (LS) data port. |
static byte[] |
LSRead(byte port)
Reads data from an Inter-Integrated Circuit (I2C) sensor (the ultrasound sensor) via the Low Speed (LS) data port. |
static byte |
LSWrite(byte port,
byte[] txData,
byte rxDataLength)
Used to request data from an Inter-Integrated Circuit (I2C) sensor (the ultrasound sensor) via the Low Speed (LS) data port. |
static java.lang.String |
messageRead(byte remoteInbox,
byte localInbox,
boolean remove)
UNTESTED |
static byte |
messageWrite(java.lang.String message,
byte inbox)
Sends a message to an inbox on the NXT for storage(?) For future reference, message size must be capped at 59 for USB. |
static FileInfo |
openRead(java.lang.String fileName)
Opens a file on the NXT for reading. |
static byte |
openWrite(java.lang.String fileName,
int size)
Opens a file on the NXT for writing. |
static byte |
playSoundFile(java.lang.String fileName,
boolean repeat)
|
static byte |
playTone(int frequency,
int duration)
Plays a tone on NXT speaker. |
static byte[] |
poll(byte bufferNumber,
byte commandLength)
Reads bytes from the low-speed or high-speed buffer. |
static byte |
pollLength(byte bufferNumber)
Returns the number of bytes for a command in the low-speed buffer or the high-speed buffer (0 = no command is ready). |
static byte[] |
readFile(byte handle,
int length)
Returns requested number of bytes from a file. |
static byte |
resetMotorPosition(int port,
boolean relative)
Resets the tachometer? |
static byte |
resetScaledInputValue(int port)
UNTESTED |
static byte |
setBrickName(java.lang.String name)
|
static byte |
setInputMode(int port,
int sensorType,
int sensorMode)
Tells the NXT what type of sensor you are using and the mode to operate in. |
static byte |
setOutputState(int port,
byte power,
int mode,
int regulationMode,
int turnRatio,
int runState,
int tachoLimit)
|
static void |
setVerify(boolean verify)
|
static byte |
startProgram(java.lang.String fileName)
Starts a program already on the NXT. |
static byte |
stopProgram()
Forces the currently executing program to stop. |
static byte |
stopSoundPlayback()
Stops sound file playing. |
static byte |
writeFile(byte handle,
byte[] data)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static byte startProgram(java.lang.String fileName)
fileName
-
public static byte stopProgram()
public static java.lang.String getCurrentProgramName()
public static FileInfo openRead(java.lang.String fileName)
fileName
- e.g. "Woops.rso"
public static byte openWrite(java.lang.String fileName, int size)
fileName
- e.g. "Woops.rso"
public static byte[] readFile(byte handle, int length)
handle
- File handle number (from openRead method)length
- Number of bytes to read.
public static byte writeFile(byte handle, byte[] data)
public static byte closeFile(byte handle)
handle
- File handle number.
public static byte delete(java.lang.String fileName)
public static FirmwareInfo getFirmwareVersion()
public static byte setBrickName(java.lang.String name)
public static DeviceInfo getDeviceInfo()
public static byte deleteUserFlash()
public static byte pollLength(byte bufferNumber)
bufferNumber
- 0 = poll buffer (low-speed) 1 = high-speed buffer
public static byte[] poll(byte bufferNumber, byte commandLength)
bufferNumber
- 0 = poll buffer (low-speed) 1 = high-speed buffercommandLength
- Number of bytes obtained from pollLength()
public static FileInfo findFirst(java.lang.String wildCard)
wildCard
- [filename].[extension], *.[extension], [filename].*, *.*
public static FileInfo findNext(byte handle)
handle
- Handle number from the previous found file or fromthe Find First command.
public static byte playSoundFile(java.lang.String fileName, boolean repeat)
public static byte stopSoundPlayback()
public static byte setOutputState(int port, byte power, int mode, int regulationMode, int turnRatio, int runState, int tachoLimit)
port
- - Output port (0 - 2 or 0xFF for all three)power
- - Setpoint for power. (-100 to 100)mode
- - Setting the modes MOTORON, BRAKE, and/or REGULATED. This parameter is a bitfield, so to put it in brake mode and regulated, use BRAKEMODE + REGULATEDregulationMode
- - see NXTProtocol for enumerationsturnRatio
- - Need two motors? (-100 to 100)runState
- - see NXTProtocol for enumerationstachoLimit
- - Number of degrees(?) to rotate before stopping.public static byte setInputMode(int port, int sensorType, int sensorMode)
port
- - 0 to 3sensorType
- - Enumeration for sensor type (see NXTProtocol)sensorMode
- - Enumeration for sensor mode (see NXTProtocol)public static OutputState getOutputState(int port)
port
- - 0 to 3
public static InputValues getInputValues(int port)
public static byte resetScaledInputValue(int port)
port
-
public static byte messageWrite(java.lang.String message, byte inbox)
message
- String to send. A null termination is automatically appended.inbox
- Inbox Number 0 - 9
public static java.lang.String messageRead(byte remoteInbox, byte localInbox, boolean remove)
remoteInbox
- 0-9localInbox
- 0-9remove
- True clears the message from the remote inbox.
public static byte resetMotorPosition(int port, boolean relative)
port
- Output port (0-2)relative
- TRUE: position relative to last movement, FALSE: absolute positionpublic static byte playTone(int frequency, int duration)
frequency
- - 100 to 2000?duration
- - In milliseconds.verifyCommand
- - A boolean value to indicate you want to know if the command worked.
public static int getBatteryLevel()
public static long keepAlive()
public static byte[] LSGetStatus(byte port)
port
- 0-3
public static byte LSWrite(byte port, byte[] txData, byte rxDataLength)
txData
- Transmitted data.rxDataLength
- Receive data length.port
- 0-3
public static byte[] LSRead(byte port)
port
-
public static void setVerify(boolean verify)
public static boolean isVerify()
public static void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |