--- /dev/null
+package lejos.nxt;\r
+\r
+/**\r
+ * Supports the mindsensors RCX Motor Multiplexer\r
+ * \r
+ * @author Lawrie Griffiths\r
+ *\r
+ */\r
+public class RCXMotorMultiplexer extends I2CSensor {\r
+ private byte[] buf = new byte[1];\r
+ \r
+ public RCXMotor A = new RCXMotor(new RCXPlexedMotorPort(this,0));\r
+ public RCXMotor B = new RCXMotor(new RCXPlexedMotorPort(this,1));\r
+ public RCXMotor C = new RCXMotor(new RCXPlexedMotorPort(this,2));\r
+ public RCXMotor D = new RCXMotor(new RCXPlexedMotorPort(this,3));\r
+ \r
+ \r
+ public RCXMotorMultiplexer(I2CPort port) {\r
+ super(port);\r
+ setAddress(0x5A);\r
+ }\r
+ \r
+ public void setSpeed(int speed, int id) {\r
+ buf[0] = (byte) speed;\r
+ sendData(0x43 + (id*2), buf, 1);\r
+ }\r
+ \r
+ public int getSpeed(int id) {\r
+ getData(0x43 + (id*2), buf, 1);\r
+ return buf[0] & 0xFF;\r
+ }\r
+ \r
+ public void setDirection(int direction, int id) {\r
+ buf[0] = (byte) direction;\r
+ sendData(0x42 + (id*2), buf, 1);\r
+ }\r
+ \r
+ public int getDirection(int id) {\r
+ getData(0x42 + (id*2), buf, 1);\r
+ return buf[0] & 0xFF;\r
+ }\r
+}\r