Overview   Project   Class   Tree   Index 
NXT C++ Bluetooth Library
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

NXT C++ Bluetooth Library
Class Compass

Sensor
   |
   +--I2c
         |
         +--Compass

   in compass.h
   in compass.cpp

class Compass
extends I2c

Class for HiTechnic compass 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
 
Constructor Summary
Compass( Sensor_port port, Connection* connection, unsigned int wait_time = 40, unsigned char i2c_address = 0x02 )
          Constructor for the compass sensor
~Compass()
          
 
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()
          Read the sensor value (init method will be called if the sensor has not been initialized)
   
Methods inherited from class I2c
init, i2c_write, i2c_read, wait_for_bytes, update_sensor_status, get_i2c_address, get_type
   
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
 

Constructor Detail

Compass

public Compass( 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)]

~Compass

public ~Compass();


Method Detail

get_type

public Sensor_type get_type();
Get the sensor type
Returns:
COMPASS

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 + " degrees"

read

public int read();
Read the sensor value (init method will be called if the sensor has not been initialized)
Returns:
degree (0-360) 0= North

 Overview   Project   Class   Tree   Index 
NXT C++ Bluetooth Library
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD