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

HiTechnic Acceleration sensor (http://www.hitechnic.com/) class. More...

#include <AccelSensor.h>

List of all members.

Public Member Functions

 AccelSensor (ePortS port)
 Constructor (activate I2C).
void getAccel (S16 axes[3]) const
 Get acceleration in 3 axes(X/Y/Z).
void get (U8 data[6]) const
 Get raw I2C data.

Detailed Description

HiTechnic Acceleration sensor (http://www.hitechnic.com/) 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

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:
portAccel sensor connected port
Returns:
-

Member Function Documentation

void ecrobot::AccelSensor::get ( U8  data[6]) const [inline]

Get raw I2C data.

Parameters:
dataData representation from the sensor, per Hi-Technic's documentation:
data[0]: X axis upper 8 bits
data[1]: Y axis upper 8 bits
data[2]: Z axis upper 8 bits
data[3]: X axis lower 2 bits
data[4]: Y axis lower 2 bits
data[5]: Z axis lower 2 bits
Returns:
-
void ecrobot::AccelSensor::getAccel ( S16  axes[3]) const

Get acceleration in 3 axes(X/Y/Z).

Parameters:
axesaxes[0]: X
axes[1]: Y
axes[2]: Z
Returns:
-

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