NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages

This is an example of how to use the SetSensorDIAccl, SetSensorDIAcclEx, SetSensorDIAcclDrift, ReadSensorDIAcclDrift, SensorDIAcclStatus, ReadSensorDIAccl8Raw, ReadSensorDIAccl8, ReadSensorDIAcclRaw, and ReadSensorDIAccl functions.

#define DEFAULT
//#define RAW8
#define RAW10
#ifdef RAW10
#undef RAW8
void CalibrateDIAccl(const byte port, int iter)
TextOut(0, LCD_LINE1, "Calibrating...");
SetSensorDIAcclDrift(port, 0, 0, 0);
int x = 0, y = 0, z = 0;
x += raw.X;
y += raw.Y;
z += raw.Z;
x = (0-(x/iter))*2;
y = (0-(y/iter))*2;
z = (60-(z/iter))*2;
NumOut(0, LCD_LINE2, x);
NumOut(0, LCD_LINE3, y);
NumOut(0, LCD_LINE4, z);
SetSensorDIAcclDrift(port, x, y, z);
TextOut(0, LCD_LINE5, "Completed!");
task main()
#ifdef DEFAULT
VectorType val, raw;
int dx, dy, dz;
int i = 0;
int temp;
byte status;
bool done = false;
CalibrateDIAccl(S1, 100);
while (!done){
// Read the GYROSCOPE
#ifdef RAW8
#ifdef RAW10
ReadSensorDIAcclDrift(S1, dx, dy, dz);
NumOut(0, LCD_LINE1, val.X);
NumOut(0, LCD_LINE2, val.Y);
NumOut(0, LCD_LINE3, val.Z);
NumOut(0, LCD_LINE4, raw.X);
NumOut(0, LCD_LINE5, raw.Y);
NumOut(0, LCD_LINE6, raw.Z);
NumOut(50, LCD_LINE4, dx);
NumOut(50, LCD_LINE5, dy);
NumOut(50, LCD_LINE6, dz);