NXT C++ Bluetooth Library
Class I2c
Sensor
|
+--I2c
in i2c.h
in i2c.cpp
- Direct Known Subclasses:
- Adc_8591, Color_sensor, Compass, Io_8574, Sonar, Tilt
- class I2c
- extends Sensor
Abstract class for digital I2C sensors
| Fields inherited from class Sensor |
has_init, connection, sensor_type, sensor_mode, sensor_port, raw_AD_value, normalized_AD_value, scaled_value, calibrated_value |
|
Method Summary |
unsigned char |
get_i2c_address()
Get the I2C address |
virtual Sensor_type |
get_type()= 0
Get the sensor type
(must be implemented in sub class) |
virtual void |
init( bool reply = false )
Initiate the sensor |
| Methods inherited from class Sensor |
init, read, read, print, set, get_port, get_mode, set_type_and_mode, get_sensor_value, read_mode, read_raw, read_normalized, get_type, reset, get_i2c_address |
I2c
public I2c( Sensor_port port, Connection* connection, Sensor_type sensor_type, unsigned char i2c_address, unsigned int wait_time = 0 );
- I2C constructor
- Parameters:
port - [which sensor port to use]
*connection - [attach a connection]
sensor_type - [set the sensor type (should be LOWSPEED or LOWSPEED_9V )]
i2c_address - [the I2C address of the sensor]
wait_time - [the time in ms between checking for reply (should normally be zero but some sensor will produce COMMUNICATION_BUS_ERROR if pulled continuously) ]
~I2c
public ~I2c();
get_i2c_address
public unsigned char get_i2c_address();
- Get the I2C address
- Returns:
- the I2C address
get_type
public virtual Sensor_type get_type()= 0;
- Get the sensor type
(must be implemented in sub class)
- Returns:
- the sensor type
init
public virtual void init( bool reply = false );
- Initiate the sensor
- Parameters:
reply - [true = require reply from NXT; false = no reply from NXT]