ECRobot C++ API for LEGO MINDSTORMS NXT  1.0.10
ecrobot::SoundSensor Class Reference

NXT Sound sensor class. More...

#include <SoundSensor.h>

Inheritance diagram for ecrobot::SoundSensor:
ecrobot::Sensor

List of all members.

Public Member Functions

 SoundSensor (ePortS port, bool dba=false)
 Constructor.
 ~SoundSensor (void)
 Destructor.
S16 getLevel (void) const
 Get sound level as percent.
void setDBA (bool dba)
 set the DBA.
S16 get (void) const
 Get raw A/D value.

Protected Member Functions

ePortS getPort (void) const
 Get the sensor connected port.

Detailed Description

NXT Sound sensor class.

Note:
I2C (derived) class and Clock class internally use RTOS features. Thus, user needs to implement a C function and RTOS provided events.

[ Example for TOPPERS/ATK(OSEK) ]
Invoke SleeperMonitor function in user_1msec_isr_type2 hook.
  void user_1ms_isr_type2(void)
  {
    SleeperMonitor(); // needed for I2C devices and Clock class
  }

Define EventSleepI2C and EventSleep Events in user oil file.
  EVENT EventSleepI2C
  {
    MASK = AUTO;
  };

  EVENT EventSleep
  {
    MASK = AUTO;
  };

  TASK TaskMain
  {
    AUTOSTART = TRUE
    {
      APPMODE = appmode1;
    };
    PRIORITY = 1;
    ACTIVATION = 1;
    SCHEDULE = FULL;
    STACKSIZE = 512;
    EVENT = EventSleepI2C; <- Here it is
    EVENT = EventSleep; <- Here it is
  };


Constructor & Destructor Documentation

ecrobot::SoundSensor::SoundSensor ( ePortS  port,
bool  dba = false 
) [explicit]

Constructor.

Note:
This class must be constructed as a global object. Otherwise, a device assertion will be displayed
in the LCD when the object is constructed as a non global object.

Parameters:
portSound sensor connected port
dba
Returns:
-

Destructor.

Parameters:
-
Returns:
-

Member Function Documentation

S16 ecrobot::Sensor::get ( void  ) const [inline, inherited]

Get raw A/D value.

Parameters:
-
Returns:
raw A/D value (0 to 1023)
S16 ecrobot::SoundSensor::getLevel ( void  ) const

Get sound level as percent.

Parameters:
-
Returns:
greater value means louder.
ePortS ecrobot::Sensor::getPort ( void  ) const [inline, protected, inherited]

Get the sensor connected port.

Parameters:
-
Returns:
Sensor connected port
void ecrobot::SoundSensor::setDBA ( bool  dba)

set the DBA.

Parameters:
dba
Returns:
-

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Enumerator Friends Defines