#pragma config(Sensor, S1, HTANG, sensorI2CCustom)
#include "drivers/hitechnic-angle.h"
task main () {
nNxtButtonTask = -2;
nxtDisplayCenteredTextLine(0, "HiTechnic");
nxtDisplayCenteredBigTextLine(1, "Angle");
nxtDisplayCenteredTextLine(3, "Test 1");
nxtDisplayCenteredTextLine(5, "Connect sensor");
nxtDisplayCenteredTextLine(6, "to S1");
wait1Msec(2000);
eraseDisplay();
nxtDisplayCenteredTextLine(0, "HiTechnic Angle");
nxtDisplayTextLine(1, "-------------------");
nxtDisplayTextLine(5, "-------------------");
while (true) {
if (nNxtButtonPressed == kLeftButton) {
HTANGresetAngle(HTANG);
while (nNxtButtonPressed != kNoButton) EndTimeSlice();
} else if (nNxtButtonPressed == kRightButton) {
HTANGresetAccumulatedAngle(HTANG);
while (nNxtButtonPressed != kNoButton) EndTimeSlice();
}
nxtDisplayTextLine(2, "Ang: %7d deg", HTANGreadAngle(HTANG));
nxtDisplayTextLine(3, "Tot: %7d deg", HTANGreadAccumulatedAngle(HTANG));
nxtDisplayTextLine(4, "RPM: %7d", HTANGreadRPM(HTANG));
nxtDisplayTextLine(6, " < Set angle");
nxtDisplayTextLine(7, " Reset total >");
wait1Msec(50);
}
}