ECRobot C++ API for LEGO MINDSTORMS NXT
1.0.10
|
NXT Sound sensor class. More...
#include <SoundSensor.h>
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. |
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
};
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.
port | Sound sensor connected port |
dba |
ecrobot::SoundSensor::~SoundSensor | ( | void | ) |
Destructor.
- |
S16 ecrobot::Sensor::get | ( | void | ) | const [inline, inherited] |
Get raw A/D value.
- |
S16 ecrobot::SoundSensor::getLevel | ( | void | ) | const |
Get sound level as percent.
- |
ePortS ecrobot::Sensor::getPort | ( | void | ) | const [inline, protected, inherited] |
void ecrobot::SoundSensor::setDBA | ( | bool | dba | ) |
set the DBA.
dba |