task main() { while ( true ) { nxtDisplayCenteredTextLine(0, (string)HTMAGreadVal(Magnet)); } }
task main () { int magFieldValue = 0; int calibrationValue = 0; nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "MAGNETIC"); nxtDisplayCenteredTextLine(3, "Field Sensor"); nxtDisplayCenteredTextLine(4, "Test 1"); nxtDisplayCenteredTextLine(5, "Connect Sensor"); nxtDisplayCenteredTextLine(6, "to S1"); wait1Msec(2000); nxtDisplayCenteredTextLine(5, "Press enter"); nxtDisplayCenteredTextLine(6, "to set bias"); wait1Msec(2000); eraseDisplay(); while(true) { eraseDisplay(); nxtDisplayTextLine(1, "Resetting"); nxtDisplayTextLine(2, "bias"); wait1Msec(500); // Start the calibration and display the offset calibrationValue = HTMAGstartCal(HTMAG); nxtDisplayTextLine(2, "Bias: %4d", calibrationValue); PlaySound(soundBlip); while(bSoundActive) EndTimeSlice(); while(nNxtButtonPressed != kNoButton) EndTimeSlice(); while(nNxtButtonPressed != kEnterButton) { eraseDisplay(); // Read the current calibration offset calibrationValue = HTMAGreadCal(HTMAG); // Read the current magnetic field strength magFieldValue = HTMAGreadVal(HTMAG); nxtDisplayTextLine(1, "Reading"); // Display the current calibration value nxtDisplayTextLine(2, "Bias: %4d", calibrationValue); nxtDisplayClearTextLine(4); // Display the current magnetic field strength nxtDisplayTextLine(4, "Mag: %4d", magFieldValue); nxtDisplayTextLine(6, "Press enter"); nxtDisplayTextLine(7, "to recalibrate"); wait1Msec(100); } } }
task main () { nxtDisplayCenteredTextLine(0, "HiTechnic"); nxtDisplayCenteredBigTextLine(1, "MAGNETIC"); nxtDisplayCenteredTextLine(3, "Field Sensor"); nxtDisplayCenteredTextLine(4, "SMUX Test"); nxtDisplayCenteredTextLine(5, "Connect SMUX to"); nxtDisplayCenteredTextLine(6, "S1 and sensor to"); nxtDisplayCenteredTextLine(7, "SMUX Port 1"); wait1Msec(2000); eraseDisplay(); time1[T1] = 0; while(true) { eraseDisplay(); nxtDisplayTextLine(1, "Resetting"); nxtDisplayTextLine(2, "bias"); wait1Msec(500); // Start the calibration and display the offset nxtDisplayTextLine(2, "Bias: %4d", HTMAGstartCal(HTMAG)); PlaySound(soundBlip); while(bSoundActive) EndTimeSlice(); while(nNxtButtonPressed != kNoButton) EndTimeSlice(); while(nNxtButtonPressed != kEnterButton) { eraseDisplay(); nxtDisplayTextLine(1, "Reading"); // Read the current calibration offset and display it nxtDisplayTextLine(2, "Bias: %4d", HTMAGreadCal(HTMAG)); nxtDisplayClearTextLine(4); // Read the current rotational speed and display it nxtDisplayTextLine(4, "Mag: %4d", HTMAGreadVal(HTMAG)); nxtDisplayTextLine(6, "Press enter"); nxtDisplayTextLine(7, "to recalibrate"); wait1Msec(100); } } }