#pragma config(Sensor, S1, DTMP, sensorAnalogInactive)
#include "drivers/dexterind-temp.h"
task main() {
float temp;
byte state = 0;
nxtDisplayTextLine(0, "Dexter Industries");
nxtDisplayCenteredBigTextLine(1, "T Probe");
nxtDisplayCenteredTextLine(3, "Test 1");
nxtDisplayCenteredTextLine(5, "Connect sensor");
nxtDisplayCenteredTextLine(6, "to S1");
wait1Msec(2000);
eraseDisplay();
nxtDisplayTextLine(0, "Dexter Industries");
nxtDisplayCenteredTextLine(7, "< switch scale >");
while (true) {
switch(nNxtButtonPressed) {
case kRightButton:
if (++state > 2)
state = 0;
while (nNxtButtonPressed != kNoButton) EndTimeSlice();
break;
case kLeftButton:
if (--state < 0)
state = 2;
while (nNxtButtonPressed != kNoButton) EndTimeSlice();
break;
}
nxtDisplayCenteredBigTextLine(1, "Temp:");
switch(state) {
case 0: DTMPreadTemp(DTMP, temp);
nxtDisplayCenteredBigTextLine(3, "%4.2f", temp);
nxtDisplayCenteredBigTextLine(5, "Celcius");
break;
case 1: DTMPreadTempF(DTMP, temp);
nxtDisplayCenteredBigTextLine(3, "%4.2f", temp);
nxtDisplayCenteredBigTextLine(5, "Fahrenh.");
break;
case 2: DTMPreadTempK(DTMP, temp);
nxtDisplayCenteredBigTextLine(3, "%4.2f", temp);
nxtDisplayCenteredBigTextLine(5, "Kelvin");
break;
}
wait1Msec(10);
}
}