#pragma config(Sensor, S1, MICC, sensorI2CCustom)
#include "drivers/microinfinity-cruizcore.h"
int angleI = 0;
int rotI = 0;
int x_accel = 0;
int y_accel = 0;
int z_accel = 0;
task updateHUD () {
int x = 0;
int y = 0;
while (true) {
nxtEraseRect(4,50, 44,10);
nxtDisplayTextLine(2, " H: %3d", angleI/100);
nxtDisplayTextLine(3, " X: %3d", x_accel/100);
nxtDisplayTextLine(4, " Y: %3d", y_accel/100);
nxtDisplayTextLine(5, " Z: %3d", z_accel/100);
nxtDrawCircle(84, 50, 4);
nxtDrawCircle(4, 50, 40);
x = (cosDegrees(-1 * (angleI/100 - 90)) * 20) + 24;
y = (sinDegrees(-1 * (angleI/100 - 90)) * 20) + 30;
nxtDrawLine(24, 30, x, y);
nxtEraseRect(0,0, 99, 8);
nxtDrawRect(0,0, 99, 8);
nxtFillRect(50,0, (float)(rotI / 150)/100.0 *50 + 50, 8);
wait1Msec(100);
}
}
task main () {
nxtDisplayCenteredTextLine(0, "MicroInfinity");
nxtDisplayTextLine(1, "CruizCore XG1300L");
nxtDisplayCenteredTextLine(3, "Test 2");
wait1Msec(2000);
eraseDisplay();
MICCsetRange8G(MICC);
MICCreset(MICC);
StartTask(updateHUD);
nxtDisplayTextLine(0, "CruizCore XG1300L");
while (true) {
angleI = MICCreadRelativeHeading(MICC);
rotI = MICCreadTurnRate(MICC);
if (!MICCreadAccel(MICC, x_accel, y_accel, z_accel)) {
StopTask(updateHUD);
wait1Msec(100);
eraseDisplay();
nxtDisplayTextLine(4, "ERROR!!");
wait1Msec(2000);
StopAllTasks();
}
wait1Msec(50);
}
}