ecrobot::SonarSensor Class Reference
NXT Sonar(Ultrasonic) sensor class.
More...
#include <SonarSensor.h>
List of all members.
Public Member Functions |
| SonarSensor (ePortS port) |
| Constructor (activate I2C).
|
S16 | getDistance (void) const |
| Get distance in cm.
|
void | get (U8 data[1]) const |
| Get raw I2C data.
|
bool | send (U32 address, U8 *data, U32 length) |
| Send data.
|
bool | receive (U32 address, U8 *data, U32 length) const |
| Receive data.
|
Protected Member Functions |
ePortS | getPort (void) const |
| Get the I2C device connected port.
|
Detailed Description
NXT Sonar(Ultrasonic) sensor class.
[ How to use with TOPPERS/ATK1(OSEK) ]
I2C (derived/compositted) class and Clock class internally use RTOS features. Thus, user needs to implement a C function and RTOS provided events.
+ 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
};
[ How to use with TOPPERS/JSP(ITRON) ]
In case of using this class with TOPPERS/JSP(ITRON), RTOS specific definitions for the class are not needed.
Constructor & Destructor Documentation
ecrobot::SonarSensor::SonarSensor |
( |
ePortS |
port |
) |
[explicit] |
Constructor (activate I2C).
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.
When the object is destructed while the system is shut down, the device is de-activated automatically.
- Parameters:
-
| port | Sonar sensor connected port |
- Returns:
- -
Member Function Documentation
void ecrobot::SonarSensor::get |
( |
U8 |
data[1] |
) |
const [inline] |
Get raw I2C data.
- Parameters:
-
| data | Data representation from the sensor:
data[0]: distance |
- Returns:
- -
S16 ecrobot::SonarSensor::getDistance |
( |
void |
|
) |
const |
Get distance in cm.
- Parameters:
-
- Returns:
- distance in cm
ePortS ecrobot::I2c::getPort |
( |
void |
|
) |
const [inline, protected, inherited] |
Get the I2C device connected port.
- Parameters:
-
- Returns:
- I2C device connected port
bool ecrobot::I2c::receive |
( |
U32 |
address, |
|
|
U8 * |
data, |
|
|
U32 |
length | |
|
) |
| | const [inherited] |
Receive data.
- Parameters:
-
| address | I2C address |
| data | Data to be received |
| length | Length of data to be received |
- Returns:
- The result of receive data: true(succeded)/false(failed)
bool ecrobot::I2c::send |
( |
U32 |
address, |
|
|
U8 * |
data, |
|
|
U32 |
length | |
|
) |
| | [inherited] |
Send data.
- Parameters:
-
| address | I2C address |
| data | Data to be sent |
| length | Length of data to be sent |
- Returns:
- The result of send data: true(succeded)/false(failed)
The documentation for this class was generated from the following file: