NXT C++ Bluetooth Library
Class Color_sensor
Sensor
|
+--I2c
|
+--Color_sensor
in color.h
in color.cpp
- class Color_sensor
- extends I2c
Class for HiTechnic color sensor
Fields inherited from class I2c |
wait_time , bytes_ready , i2c_address
|
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 |
Sensor_type |
get_type()
Get the sensor type |
void |
init( bool reply = false )
Initiate the sensor |
std::string |
print()
Get the sensor reading as a string
(init method will be called if the sensor has not been initialized) |
int |
read()
Get the color number (0-17)
(init method will be called if the sensor has not been initialized) |
int |
read( Result& result )
Get the RGB color
(init method will be called if the sensor has not been initialized) |
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 |
Color_sensor
public Color_sensor( Sensor_port port, Connection* connection, unsigned int wait_time = 40, unsigned char i2c_address = 0x02 );
- Constructor for the compass sensor
- Parameters:
port
- [which sensor port to use]
*connection
- [attach a connection]
wait_time
- [the time in ms between checking for reply]
(use default wait time otherwise COMMUNICATION_BUS_ERROR will frequently be thrown if sensor is pulled continuously)
i2c_address
- [set the I2C address of the sensor (just use the default address unless you have done a hack)]
~Color_sensor
public ~Color_sensor();
get_type
public Sensor_type get_type();
- Get the sensor type
- Returns:
- COLOR
init
public void init( bool reply = false );
- Initiate the sensor
- Parameters:
reply
- [true = require reply from NXT; false = no reply from NXT]
print
public std::string print();
- Get the sensor reading as a string
(init method will be called if the sensor has not been initialized)
- Returns:
- sensor reading as a string - "red='some value' green='some value' blue='some value'"
read
public int read();
- Get the color number (0-17)
(init method will be called if the sensor has not been initialized)
- Returns:
- the color number (0-17)
- See Also:
- color number chart can be found on the HiTechnic website
read
public int read( Result& result );
- Get the RGB color
(init method will be called if the sensor has not been initialized)
- Parameters:
&result
- [must be of type Rgb_color - RGB colors are "stored" in result]
- See Also:
Rgb_color