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

NXT C++ Bluetooth Library
Class Sensor

   in sensor.h
   in sensor.cpp
Direct Known Subclasses:
Gyro, I2c, Light, Light_rcx, Rotation, Sound, Temperature, Touch

class Sensor

Class for analog sensors - also works as the base class for all other sensors


Constructor Summary
Sensor( Sensor_port port, Connection* connection, Sensor_type sensor_type, Sensor_mode sensor_mode )
          Sensor constructor
virtual ~Sensor()
          
 
Method Summary
 virtual unsigned char get_i2c_address()
          Get the I2C address (Dummy method does nothing - is implemented in some sub class )
 virtual Sensor_mode get_mode()
          Get the sensor mode
 virtual Sensor_port get_port()
          Get the sensor port
 virtual Sensor_type get_type()
          Get the sensor type
 virtual void init( bool reply = false )
          Initiate the sensor (sets its type and mode)
 virtual string print()
          Get the sensor reading as a string (init method will be called if the sensor has not been initialized)
 virtual int read()
          Get the sensor reading (mode dependent) (init method will be called if the sensor has not been initialized)
 virtual int read( Result& result )
          Get multiple sensor readings (Dummy method does nothing - is implemented in some sub classes)
 virtual void set( unsigned int value )
          Set a parameter on the sensor (Dummy method does nothing - is implemented in some sub classes)
 

Constructor Detail

Sensor

public Sensor( Sensor_port port, Connection* connection, Sensor_type sensor_type, Sensor_mode sensor_mode );
Sensor constructor
Parameters:
port - [which sensor port to use]
*connection - [attach a connection]
sensor_type - [set the sensor type]
sensor - mode [set the sensor mode]

~Sensor

public virtual ~Sensor();


Method Detail

get_i2c_address

public virtual unsigned char get_i2c_address();
Get the I2C address (Dummy method does nothing - is implemented in some sub class )
Returns:
the I2C address

get_mode

public virtual Sensor_mode get_mode();
Get the sensor mode
Returns:
the sensor mode

get_port

public virtual Sensor_port get_port();
Get the sensor port
Returns:
the sensor port

get_type

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

init

public virtual void init( bool reply = false );
Initiate the sensor (sets its type and mode)
Parameters:
reply - [true = require reply from NXT; false = no reply from NXT]

print

public virtual string print();
Get the sensor reading as a string (init method will be called if the sensor has not been initialized)
Returns:
the sensor reading as a string

read

public virtual int read();
Get the sensor reading (mode dependent) (init method will be called if the sensor has not been initialized)
Returns:
the mode dependent sensor reading

read

public virtual int read( Result& result );
Get multiple sensor readings (Dummy method does nothing - is implemented in some sub classes)
Parameters:
&result - [reference where the sensor readings are placed]
Returns:
1 if sensor readings are placed in &result otherwise 0

set

public virtual void set( unsigned int value );
Set a parameter on the sensor (Dummy method does nothing - is implemented in some sub classes)

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