task main () { nNxtButtonTask = -2; nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "Angle"); nxtDisplayCenteredTextLine(3, "SMUX Test"); nxtDisplayCenteredTextLine(5, "Connect SMUX to"); nxtDisplayCenteredTextLine(6, "S1 and ANG to"); nxtDisplayCenteredTextLine(7, "SMUX Port 1"); wait1Msec(2000); // Before using the SMUX, you need to initialise the driver HTSMUXinit(); // Tell the SMUX to scan its ports for connected sensors HTSMUXscanPorts(HTSMUX); eraseDisplay(); nxtDisplayCenteredTextLine(0, "HiTechnic Angle"); nxtDisplayTextLine(1, "-------------------"); nxtDisplayTextLine(5, "-------------------"); while (true) { // The accumulated angle or the zero point cannot be reset when connected // to a SMUX // Read the current angle, accumulated angle and RPM and display them nxtDisplayTextLine(2, "Ang: %7d deg", HTANGreadAngle(msensor_S1_1)); nxtDisplayTextLine(3, "Tot: %7d deg", HTANGreadAccumulatedAngle(msensor_S1_1)); nxtDisplayTextLine(4, "RPM: %7d", HTANGreadRPM(msensor_S1_1)); wait1Msec(50); } }
task main () { nNxtButtonTask = -2; nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "Angle"); nxtDisplayCenteredTextLine(3, "SMUX Test"); nxtDisplayCenteredTextLine(5, "Connect SMUX to"); nxtDisplayCenteredTextLine(6, "S1 and ANG to"); nxtDisplayCenteredTextLine(7, "SMUX Port 1"); wait1Msec(2000); eraseDisplay(); nxtDisplayCenteredTextLine(0, "HiTechnic Angle"); nxtDisplayTextLine(1, "-------------------"); nxtDisplayTextLine(5, "-------------------"); while (true) { // The accumulated angle or the zero point cannot be reset when connected // to a SMUX // Read the current angle, accumulated angle and RPM and display them nxtDisplayTextLine(2, "Ang: %7d deg", HTANGreadAngle(HTANG)); nxtDisplayTextLine(3, "Tot: %7d deg", HTANGreadAccumulatedAngle(HTANG)); nxtDisplayTextLine(4, "RPM: %7d", HTANGreadRPM(HTANG)); wait1Msec(50); } }
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 the left button is pressed, set the 0 point to the current angle if (nNxtButtonPressed == kLeftButton) { HTANGresetAngle(HTANG); while (nNxtButtonPressed != kNoButton); // Reset the total accumulated angle to 0 } else if (nNxtButtonPressed == kRightButton) { HTANGresetAccumulatedAngle(HTANG); while (nNxtButtonPressed != kNoButton); } // Read the current angle, accumulated angle and RPM and display them 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); } }