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

NXT C++ Bluetooth Library
Class Sonar

Sensor
   |
   +--I2c
         |
         +--Sonar

   in sonar.h
   in sonar.cpp

class Sonar
extends I2c

Class for the NXT sonar (ultrasonic) 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
Sonar( Sensor_port port, Connection* connection, Sonar_mode mode = METRIC )
          Constructor for the sonar sensor (percent mode and LED on is default)
~Sonar()
          
 
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)
 void set( unsigned int value )
          Set the return value to be either inch or centimeter
   
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

Sonar

public Sonar( Sensor_port port, Connection* connection, Sonar_mode mode = METRIC );
Constructor for the sonar sensor (percent mode and LED on is default)
Parameters:
port - [which sensor port to use]
*connection - [attach a connection]
mode - [set the sonar mode to either METRIC or INCH (default is METRIC)]

~Sonar

public ~Sonar();


Method Detail

get_type

public Sensor_type get_type();
Get the sensor type
Returns:
either SONAR_METRIC or SONAR_INCH

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 + either " CM" or " inch(s)"

read

public int read();
Read the sensor value (init method will be called if the sensor has not been initialized)
Returns:
the sensor reading in either inches or centimeters

set

public void set( unsigned int value );
Set the return value to be either inch or centimeter
Parameters:
value - [use either METRIC or INCH to indicate the return value of read()]
See Also:
Sonar_mode

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