|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.nxt.Part ch.aplu.nxt.Sensor ch.aplu.nxt.I2CSensor ch.aplu.nxt.PrototypeSensor
public class PrototypeSensor
Class that represents a prototype sensor (HiTechnic NXT Prototyping Board).
The following register layout is assumed:
0x00-0x07 Version number
0x08-0x0F Manufacturer
0x10-0x17 Sensor type
0x42 Analog channel 0, pin A0, upper 8bits
0x43 Analog channel 0, pin A0, lower 2bits
0x44 Analog channel 1, pin A1, upper 8bits
0x45 Analog channel 1, pin A1, lower 2bits
0x46 Analog channel 2, pin A2, upper 8bits
0x47 Analog channel 2, pin A2, lower 2bits
0x48 Analog channel 3, pin A3, upper 8bits
0x49 Analog channel 3, pin A3, lower 2bits
0x4A Analog channel 4, pin A4, upper 8bits
0x4B Analog channel 4, pin A4, lower 2bits
0x4C Digital input channels, bits 0..5
0x4D Digitag output channels, bits 0..5
0x4E Digital control, bits 0..5, low: input (default), high: output
0x4F Sampling time 4..100(ms)
Analog inputs in range 0..3.3V, 10 bit (0..1023)
Digital inputs/outputs 0/3.3V, pin B0..B5, max. 12mA per output (high or low)
Field Summary |
---|
Fields inherited from class ch.aplu.nxt.Part |
---|
robot |
Constructor Summary | |
---|---|
PrototypeSensor()
Creates a sensor instance connected to port S1. |
|
PrototypeSensor(SensorPort port)
Creates a sensor instance connected to the given port. |
Method Summary | |
---|---|
void |
addPrototypeListener(PrototypeListener prototypeListener)
Registers the given prototype listener. |
protected void |
cleanup()
|
protected void |
init()
|
void |
read(int[] ain,
int[] din)
Reads the sensor. |
void |
readAnalog(int[] ain)
Reads the sensor. |
void |
readDigital(int[] din)
Reads the sensor. |
void |
setDIO(int[] ioControl)
Sets the direction of the 6 digital input/output channels. |
void |
setSamplingPeriod(int period)
Sets the sampling period of the ADC (4..100 ms, default 4 ms). |
protected void |
startPrototypeThread()
|
protected void |
stopPrototypeThread()
|
void |
write(int[] dout)
Writes the given bit state (low/high) to the digital output channels. |
Methods inherited from class ch.aplu.nxt.I2CSensor |
---|
fetchString, getData, sendData, sendData |
Methods inherited from class ch.aplu.nxt.Sensor |
---|
getPort, getPortId, getPortLabel, LSRead, LSWrite, readBooleanValue, readNormalizedValue, readRawValue, readScaledValue, setTypeAndMode |
Methods inherited from class ch.aplu.nxt.Part |
---|
setRobot |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrototypeSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic PrototypeSensor()
Method Detail |
---|
protected void init()
init
in class I2CSensor
protected void cleanup()
cleanup
in class I2CSensor
public void setDIO(int[] ioControl)
ioControl
- the direction of each channel. 0: input, 1: outputpublic void readAnalog(int[] ain)
public void readDigital(int[] din)
public void setSamplingPeriod(int period)
period
- the new sampling periodpublic void read(int[] ain, int[] din)
public void write(int[] dout)
dout
- an integer array of length 6 that holds the bit state: 0->low, 1->highpublic void addPrototypeListener(PrototypeListener prototypeListener)
prototypeListener
- the PrototypeListener to become registered.protected void startPrototypeThread()
protected void stopPrototypeThread()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |