icommand.nxt
Class RCXLink

java.lang.Object
  extended by icommand.nxt.I2CSensor
      extended by icommand.nxt.RCXLink

public class RCXLink
extends I2CSensor

NRLink by Mindsensors.com is a bridge between NXT and RCX bricks. The adapter allows the NXT to control the motors on an RCX brick (not sensors) via the IR port on the RCX. e.g. RCXLink rcx = new RCXLink(Port.S1); rcx.A.forward();

Author:
BB

Nested Class Summary
 class RCXLink.Motor
           
 
Field Summary
 RCXLink.Motor A
           
 RCXLink.Motor B
           
static byte BEEP
          NOTE: The BEEP macro is very unreliable.
 RCXLink.Motor C
           
static byte EPROM_GET_BATTERY_POWER
           
static byte EPROM_MOTOR_A_FLIP_DIRECTION
           
static byte EPROM_MOTOR_A_FORWARD
           
static byte EPROM_MOTOR_A_OFF
           
static byte EPROM_MOTOR_A_ON
           
static byte EPROM_MOTOR_A_REVERSED
           
static byte EPROM_MOTOR_B_FLIP_DIRECTION
           
static byte EPROM_MOTOR_B_FORWARD
           
static byte EPROM_MOTOR_B_OFF
           
static byte EPROM_MOTOR_B_ON
           
static byte EPROM_MOTOR_B_REVERSED
           
static byte EPROM_MOTOR_C_FLIP_DIRECTION
           
static byte EPROM_MOTOR_C_FORWARD
           
static byte EPROM_MOTOR_C_OFF
           
static byte EPROM_MOTOR_C_ON
           
static byte EPROM_MOTOR_C_REVERSED
           
static byte LONG_RANGE_IR
           
static byte MOTOR_A_FORWARD
           
static byte MOTOR_A_REVERSED
           
static byte MOTOR_B_FORWARD
           
static byte MOTOR_B_REVERSED
           
static byte MOTOR_C_FORWARD
           
static byte MOTOR_C_REVERSED
           
static byte POWER_OFF_RCX
           
static byte RUN_PROGRAM_1
           
static byte RUN_PROGRAM_2
           
static byte RUN_PROGRAM_3
           
static byte RUN_PROGRAM_4
           
static byte RUN_PROGRAM_5
           
static byte SHORT_RANGE_IR
           
static byte STOP_ALL_PROGRAMS
           
 
Fields inherited from class icommand.nxt.I2CSensor
DEFAULT_ADDRESS, PRODUCT_ID, SENSOR_TYPE, STOP, VERSION
 
Constructor Summary
RCXLink(SensorPort s)
          Initializes the RCXLink.
 
Method Summary
 void beep()
          Makes the RCX chirp.
 void flush()
          Flush the FIFO (First In First Out) buffer
protected  byte[] getData(byte register, int length)
          Override method because of unreliability retrieving more than a single byte at a time with some I2C Sensors (bug in Lego firmware).
 byte[] getMacroData()
          Test method to retrieve macro data.
 void powerOff()
          Sends command to turn off the RCX brick.
 void runMacro(byte macro)
          Run the ROM/EEPROM macro at address 0xXX
 void runProgram(int programNumber)
          Runs a program on the RCX.
 void sendMacro(byte[] macroCommands)
          Transmit Unassembled raw macro data.
 void setHighSpeed(boolean highspeed)
          Sets the communications speed of the RCXLink.
 void setLongRange(boolean longrange)
          Sets the range of the IR light on the RCXLink.
 void stopAllPrograms()
          Stops any currently executing programs on the RCX.
 
Methods inherited from class icommand.nxt.I2CSensor
fetchString, getData, getId, getProductID, getSensorType, getVersion, sendData, sendData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

A

public RCXLink.Motor A

B

public RCXLink.Motor B

C

public RCXLink.Motor C

SHORT_RANGE_IR

public static final byte SHORT_RANGE_IR
See Also:
Constant Field Values

LONG_RANGE_IR

public static final byte LONG_RANGE_IR
See Also:
Constant Field Values

POWER_OFF_RCX

public static final byte POWER_OFF_RCX
See Also:
Constant Field Values

RUN_PROGRAM_1

public static final byte RUN_PROGRAM_1
See Also:
Constant Field Values

RUN_PROGRAM_2

public static final byte RUN_PROGRAM_2
See Also:
Constant Field Values

RUN_PROGRAM_3

public static final byte RUN_PROGRAM_3
See Also:
Constant Field Values

RUN_PROGRAM_4

public static final byte RUN_PROGRAM_4
See Also:
Constant Field Values

RUN_PROGRAM_5

public static final byte RUN_PROGRAM_5
See Also:
Constant Field Values

STOP_ALL_PROGRAMS

public static final byte STOP_ALL_PROGRAMS
See Also:
Constant Field Values

MOTOR_A_FORWARD

public static final byte MOTOR_A_FORWARD
See Also:
Constant Field Values

MOTOR_A_REVERSED

public static final byte MOTOR_A_REVERSED
See Also:
Constant Field Values

MOTOR_B_FORWARD

public static final byte MOTOR_B_FORWARD
See Also:
Constant Field Values

MOTOR_B_REVERSED

public static final byte MOTOR_B_REVERSED
See Also:
Constant Field Values

MOTOR_C_FORWARD

public static final byte MOTOR_C_FORWARD
See Also:
Constant Field Values

MOTOR_C_REVERSED

public static final byte MOTOR_C_REVERSED
See Also:
Constant Field Values

BEEP

public static final byte BEEP
NOTE: The BEEP macro is very unreliable. It seems to work one time and then stop working.

See Also:
Constant Field Values

EPROM_MOTOR_A_ON

public static final byte EPROM_MOTOR_A_ON
See Also:
Constant Field Values

EPROM_MOTOR_A_FORWARD

public static final byte EPROM_MOTOR_A_FORWARD
See Also:
Constant Field Values

EPROM_MOTOR_A_REVERSED

public static final byte EPROM_MOTOR_A_REVERSED
See Also:
Constant Field Values

EPROM_MOTOR_A_FLIP_DIRECTION

public static final byte EPROM_MOTOR_A_FLIP_DIRECTION
See Also:
Constant Field Values

EPROM_MOTOR_A_OFF

public static final byte EPROM_MOTOR_A_OFF
See Also:
Constant Field Values

EPROM_MOTOR_B_ON

public static final byte EPROM_MOTOR_B_ON
See Also:
Constant Field Values

EPROM_MOTOR_B_FORWARD

public static final byte EPROM_MOTOR_B_FORWARD
See Also:
Constant Field Values

EPROM_MOTOR_B_REVERSED

public static final byte EPROM_MOTOR_B_REVERSED
See Also:
Constant Field Values

EPROM_MOTOR_B_FLIP_DIRECTION

public static final byte EPROM_MOTOR_B_FLIP_DIRECTION
See Also:
Constant Field Values

EPROM_MOTOR_B_OFF

public static final byte EPROM_MOTOR_B_OFF
See Also:
Constant Field Values

EPROM_MOTOR_C_ON

public static final byte EPROM_MOTOR_C_ON
See Also:
Constant Field Values

EPROM_MOTOR_C_FORWARD

public static final byte EPROM_MOTOR_C_FORWARD
See Also:
Constant Field Values

EPROM_MOTOR_C_REVERSED

public static final byte EPROM_MOTOR_C_REVERSED
See Also:
Constant Field Values

EPROM_MOTOR_C_FLIP_DIRECTION

public static final byte EPROM_MOTOR_C_FLIP_DIRECTION
See Also:
Constant Field Values

EPROM_MOTOR_C_OFF

public static final byte EPROM_MOTOR_C_OFF
See Also:
Constant Field Values

EPROM_GET_BATTERY_POWER

public static final byte EPROM_GET_BATTERY_POWER
See Also:
Constant Field Values
Constructor Detail

RCXLink

public RCXLink(SensorPort s)
Initializes the RCXLink.

Method Detail

runProgram

public void runProgram(int programNumber)
Runs a program on the RCX.

Parameters:
programNumber - 1-5

stopAllPrograms

public void stopAllPrograms()
Stops any currently executing programs on the RCX.


powerOff

public void powerOff()
Sends command to turn off the RCX brick.


beep

public void beep()
Makes the RCX chirp. NOTE: Unreliable. Works maybe once then stops working.


setLongRange

public void setLongRange(boolean longrange)
Sets the range of the IR light on the RCXLink. Long range uses 25mA, short range 15mA.

Parameters:
longrange - true = long range, false = short range

setHighSpeed

public void setHighSpeed(boolean highspeed)
Sets the communications speed of the RCXLink.

Parameters:
highspeed - true = 4800 baud, false = 2400 baud (default)

sendMacro

public void sendMacro(byte[] macroCommands)
Transmit Unassembled raw macro data. Up to 175 macro commands may be sent to the RCX. NOT IMPLEMENTED


runMacro

public void runMacro(byte macro)
Run the ROM/EEPROM macro at address 0xXX


flush

public void flush()
Flush the FIFO (First In First Out) buffer


getMacroData

public byte[] getMacroData()
Test method to retrieve macro data.

Returns:
All 175 bytes right now

getData

protected byte[] getData(byte register,
                         int length)
Override method because of unreliability retrieving more than a single byte at a time with some I2C Sensors (bug in Lego firmware). Note: This is slower because it takes more Bluetooth calls.

Overrides:
getData in class I2CSensor
Parameters:
register - e.g. FACTORY_SCALE_DIVISOR, BYTE0, etc....
length - Length of data to read (minimum 1, maximum 16)
Returns:


Copyright © 2006. All Rights Reserved.