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

This is an example of how to use the ResetMIXG1300L, SetSensorMIXG1300LScale, SensorMIXG1300LScale, and ReadSensorMIXG1300L functions.

/*
struct XGPacketType {
int AccAngle;
int TurnRate;
int XAxis;
int YAxis;
int ZAxis;
};
*/
task main()
{
string msg;
int i = 0;
//Initialize system
//Resets sensor and waits for hardware to settle
//Main loop
while (true)
{
if (ReadSensorMIXG1300L(S1, data))
{
TextOut(0, LCD_LINE1,"<<RESET SENSOR", false);
//Print sensor data
TextOut(0, LCD_LINE2,"ANGLE:");
TextOut(0, LCD_LINE3,"RATE:");
TextOut(0, LCD_LINE6,"ACC_X:");
NumOut(40, LCD_LINE6,data.XAxis);
TextOut(0, LCD_LINE7,"ACC_Y:");
NumOut(40, LCD_LINE7,data.YAxis);
TextOut(0, LCD_LINE8,"ACC_Z:");
NumOut(40, LCD_LINE8,data.ZAxis);
//Reset sensor if user presses the left key
rbArgs.Index = BTNLEFT;
SysReadButton(rbArgs);
if (rbArgs.Pressed)
{
i = 0;
TextOut(0, LCD_LINE1,"Resetting Device ", false);
}
//Change accelerometer range if user presses the right key
rbArgs.Index = BTNRIGHT;
SysReadButton(rbArgs);
if (rbArgs.Pressed)
{
i++;
i%=3;
TextOut(0, LCD_LINE5,"Range == " ,false);
if (i == 0) {
}
else if (i == 1) {
}
else
}
}
}
}