lejos.nxt.addon
Class PFLink

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.PFLink
All Implemented Interfaces:
SensorConstants

public class PFLink
extends I2CSensor

Class for controlling PF Motors with MindSensors NRLink-Nx

Author:
Alexander Vegh

Field Summary
static int COMBO_CH1_A_FORWARD_B_FORWARD
           
static int COMBO_CH1_A_FORWARD_B_REVERSE
           
static int COMBO_CH1_A_REVERSE_B_FORWARD
           
static int COMBO_CH1_A_REVERSE_B_REVERSE
           
static int COMBO_CH2_A_FORWARD_B_FORWARD
           
static int COMBO_CH2_A_FORWARD_B_REVERSE
           
static int COMBO_CH2_A_REVERSE_B_FORWARD
           
static int COMBO_CH2_A_REVERSE_B_REVERSE
           
static int COMBO_CH3_A_FORWARD_B_FORWARD
           
static int COMBO_CH3_A_FORWARD_B_REVERSE
           
static int COMBO_CH3_A_REVERSE_B_FORWARD
           
static int COMBO_CH3_A_REVERSE_B_REVERSE
           
static int COMBO_CH4_A_FORWARD_B_FORWARD
           
static int COMBO_CH4_A_FORWARD_B_REVERSE
           
static int COMBO_CH4_A_REVERSE_B_FORWARD
           
static int COMBO_CH4_A_REVERSE_B_REVERSE
           
static int MOTOR_CH1_A_BRAKE
           
static int MOTOR_CH1_A_FLOAT
           
static int MOTOR_CH1_A_FORWARD
           
static int MOTOR_CH1_A_REVERSE
           
static int MOTOR_CH1_B_BRAKE
           
static int MOTOR_CH1_B_FLOAT
           
static int MOTOR_CH1_B_FORWARD
           
static int MOTOR_CH1_B_REVERSE
           
static int MOTOR_CH2_A_BRAKE
           
static int MOTOR_CH2_A_FLOAT
           
static int MOTOR_CH2_A_FORWARD
           
static int MOTOR_CH2_A_REVERSE
           
static int MOTOR_CH2_B_BRAKE
           
static int MOTOR_CH2_B_FLOAT
           
static int MOTOR_CH2_B_FORWARD
           
static int MOTOR_CH2_B_REVERSE
           
static int MOTOR_CH3_A_BRAKE
           
static int MOTOR_CH3_A_FLOAT
           
static int MOTOR_CH3_A_FORWARD
           
static int MOTOR_CH3_A_REVERSE
           
static int MOTOR_CH3_B_BRAKE
           
static int MOTOR_CH3_B_FLOAT
           
static int MOTOR_CH3_B_FORWARD
           
static int MOTOR_CH3_B_REVERSE
           
static int MOTOR_CH4_A_BRAKE
           
static int MOTOR_CH4_A_FLOAT
           
static int MOTOR_CH4_A_FORWARD
           
static int MOTOR_CH4_A_REVERSE
           
static int MOTOR_CH4_B_BRAKE
           
static int MOTOR_CH4_B_FLOAT
           
static int MOTOR_CH4_B_FORWARD
           
static int MOTOR_CH4_B_REVERSE
           
static byte NR_RANGE_LONG
           
static byte NR_RANGE_SHORT
           
 
Fields inherited from class lejos.nxt.I2CSensor
PRODUCT_ID, SENSOR_TYPE, VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE
 
Constructor Summary
PFLink(I2CPort _Port)
           
 
Method Summary
 void initialize(byte _Range)
          Should be called once to set up the NRLink for usage in the program
 void installDefaultMacros()
          Installs the macro definitions used by this class.
 void installMacro(int _Address, byte[] _Macro)
          Installs a macro into the NRLink You really should call this only once for a new NRLink since it stores them in EEPROM even if turned of.
 int runCommand(int command)
          Executes a command
 void runMacro(int _Address)
          Runs a macro which has been previously installed on the NRLink.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getData, getPort, getProductID, getSensorType, getVersion, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NR_RANGE_SHORT

public static final byte NR_RANGE_SHORT
See Also:
Constant Field Values

NR_RANGE_LONG

public static final byte NR_RANGE_LONG
See Also:
Constant Field Values

MOTOR_CH1_A_FLOAT

public static final int MOTOR_CH1_A_FLOAT
See Also:
Constant Field Values

MOTOR_CH1_A_FORWARD

public static final int MOTOR_CH1_A_FORWARD
See Also:
Constant Field Values

MOTOR_CH1_A_REVERSE

public static final int MOTOR_CH1_A_REVERSE
See Also:
Constant Field Values

MOTOR_CH1_A_BRAKE

public static final int MOTOR_CH1_A_BRAKE
See Also:
Constant Field Values

MOTOR_CH1_B_FLOAT

public static final int MOTOR_CH1_B_FLOAT
See Also:
Constant Field Values

MOTOR_CH1_B_FORWARD

public static final int MOTOR_CH1_B_FORWARD
See Also:
Constant Field Values

MOTOR_CH1_B_REVERSE

public static final int MOTOR_CH1_B_REVERSE
See Also:
Constant Field Values

MOTOR_CH1_B_BRAKE

public static final int MOTOR_CH1_B_BRAKE
See Also:
Constant Field Values

MOTOR_CH2_A_FLOAT

public static final int MOTOR_CH2_A_FLOAT
See Also:
Constant Field Values

MOTOR_CH2_A_FORWARD

public static final int MOTOR_CH2_A_FORWARD
See Also:
Constant Field Values

MOTOR_CH2_A_REVERSE

public static final int MOTOR_CH2_A_REVERSE
See Also:
Constant Field Values

MOTOR_CH2_A_BRAKE

public static final int MOTOR_CH2_A_BRAKE
See Also:
Constant Field Values

MOTOR_CH2_B_FLOAT

public static final int MOTOR_CH2_B_FLOAT
See Also:
Constant Field Values

MOTOR_CH2_B_FORWARD

public static final int MOTOR_CH2_B_FORWARD
See Also:
Constant Field Values

MOTOR_CH2_B_REVERSE

public static final int MOTOR_CH2_B_REVERSE
See Also:
Constant Field Values

MOTOR_CH2_B_BRAKE

public static final int MOTOR_CH2_B_BRAKE
See Also:
Constant Field Values

MOTOR_CH3_A_FLOAT

public static final int MOTOR_CH3_A_FLOAT
See Also:
Constant Field Values

MOTOR_CH3_A_FORWARD

public static final int MOTOR_CH3_A_FORWARD
See Also:
Constant Field Values

MOTOR_CH3_A_REVERSE

public static final int MOTOR_CH3_A_REVERSE
See Also:
Constant Field Values

MOTOR_CH3_A_BRAKE

public static final int MOTOR_CH3_A_BRAKE
See Also:
Constant Field Values

MOTOR_CH3_B_FLOAT

public static final int MOTOR_CH3_B_FLOAT
See Also:
Constant Field Values

MOTOR_CH3_B_FORWARD

public static final int MOTOR_CH3_B_FORWARD
See Also:
Constant Field Values

MOTOR_CH3_B_REVERSE

public static final int MOTOR_CH3_B_REVERSE
See Also:
Constant Field Values

MOTOR_CH3_B_BRAKE

public static final int MOTOR_CH3_B_BRAKE
See Also:
Constant Field Values

MOTOR_CH4_A_FLOAT

public static final int MOTOR_CH4_A_FLOAT
See Also:
Constant Field Values

MOTOR_CH4_A_FORWARD

public static final int MOTOR_CH4_A_FORWARD
See Also:
Constant Field Values

MOTOR_CH4_A_REVERSE

public static final int MOTOR_CH4_A_REVERSE
See Also:
Constant Field Values

MOTOR_CH4_A_BRAKE

public static final int MOTOR_CH4_A_BRAKE
See Also:
Constant Field Values

MOTOR_CH4_B_FLOAT

public static final int MOTOR_CH4_B_FLOAT
See Also:
Constant Field Values

MOTOR_CH4_B_FORWARD

public static final int MOTOR_CH4_B_FORWARD
See Also:
Constant Field Values

MOTOR_CH4_B_REVERSE

public static final int MOTOR_CH4_B_REVERSE
See Also:
Constant Field Values

MOTOR_CH4_B_BRAKE

public static final int MOTOR_CH4_B_BRAKE
See Also:
Constant Field Values

COMBO_CH1_A_FORWARD_B_FORWARD

public static final int COMBO_CH1_A_FORWARD_B_FORWARD
See Also:
Constant Field Values

COMBO_CH1_A_FORWARD_B_REVERSE

public static final int COMBO_CH1_A_FORWARD_B_REVERSE
See Also:
Constant Field Values

COMBO_CH1_A_REVERSE_B_FORWARD

public static final int COMBO_CH1_A_REVERSE_B_FORWARD
See Also:
Constant Field Values

COMBO_CH1_A_REVERSE_B_REVERSE

public static final int COMBO_CH1_A_REVERSE_B_REVERSE
See Also:
Constant Field Values

COMBO_CH2_A_FORWARD_B_FORWARD

public static final int COMBO_CH2_A_FORWARD_B_FORWARD
See Also:
Constant Field Values

COMBO_CH2_A_FORWARD_B_REVERSE

public static final int COMBO_CH2_A_FORWARD_B_REVERSE
See Also:
Constant Field Values

COMBO_CH2_A_REVERSE_B_FORWARD

public static final int COMBO_CH2_A_REVERSE_B_FORWARD
See Also:
Constant Field Values

COMBO_CH2_A_REVERSE_B_REVERSE

public static final int COMBO_CH2_A_REVERSE_B_REVERSE
See Also:
Constant Field Values

COMBO_CH3_A_FORWARD_B_FORWARD

public static final int COMBO_CH3_A_FORWARD_B_FORWARD
See Also:
Constant Field Values

COMBO_CH3_A_FORWARD_B_REVERSE

public static final int COMBO_CH3_A_FORWARD_B_REVERSE
See Also:
Constant Field Values

COMBO_CH3_A_REVERSE_B_FORWARD

public static final int COMBO_CH3_A_REVERSE_B_FORWARD
See Also:
Constant Field Values

COMBO_CH3_A_REVERSE_B_REVERSE

public static final int COMBO_CH3_A_REVERSE_B_REVERSE
See Also:
Constant Field Values

COMBO_CH4_A_FORWARD_B_FORWARD

public static final int COMBO_CH4_A_FORWARD_B_FORWARD
See Also:
Constant Field Values

COMBO_CH4_A_FORWARD_B_REVERSE

public static final int COMBO_CH4_A_FORWARD_B_REVERSE
See Also:
Constant Field Values

COMBO_CH4_A_REVERSE_B_FORWARD

public static final int COMBO_CH4_A_REVERSE_B_FORWARD
See Also:
Constant Field Values

COMBO_CH4_A_REVERSE_B_REVERSE

public static final int COMBO_CH4_A_REVERSE_B_REVERSE
See Also:
Constant Field Values
Constructor Detail

PFLink

public PFLink(I2CPort _Port)
Method Detail

initialize

public void initialize(byte _Range)
Should be called once to set up the NRLink for usage in the program

Parameters:
_Range - Either NR_RANGE_SHORT or NR_RANGE_LONG, which uses more power

runCommand

public int runCommand(int command)
Executes a command

Parameters:
command -
Returns:
the status (zero = success)

installMacro

public void installMacro(int _Address,
                         byte[] _Macro)
Installs a macro into the NRLink You really should call this only once for a new NRLink since it stores them in EEPROM even if turned of. And I have no idea how often you can overwrite them before they burn out...

Parameters:
_Address - The address up from 0x40 for the macro
_Macro - The macro

installDefaultMacros

public void installDefaultMacros()
Installs the macro definitions used by this class. You really should call this only once for a new NRLink since it stores them in EEPROM even if turned of. And I have no idea how often you can overwrite them before they burn out...


runMacro

public void runMacro(int _Address)
Runs a macro which has been previously installed on the NRLink.

Parameters:
_Address - The address of the macro, one of the MOTOR_* for a single motor or one of the COMBO_* macros which work on both motors simultaneously