#pragma config(Sensor, S1, DPRESS, sensorAnalogInactive)
#include "drivers/dexterind-pressure.h"
task main() {
float pressure;
byte state = 0;
nxtDisplayTextLine(0, "Dexter Industries");
nxtDisplayCenteredTextLine(1, "dPressure 250");
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 > 1)
state = 0;
while (nNxtButtonPressed != kNoButton) EndTimeSlice();
break;
case kLeftButton:
if (--state < 0)
state = 1;
while (nNxtButtonPressed != kNoButton) EndTimeSlice();
break;
}
nxtDisplayCenteredBigTextLine(1, "Pressure:");
switch(state) {
case 0: DPRESSreadPress250kPa(DPRESS, pressure);
nxtDisplayCenteredBigTextLine(3, "%4.2f", pressure);
nxtDisplayCenteredBigTextLine(5, "kPa");
break;
case 1: DPRESSreadPress250PSI(DPRESS, pressure);
nxtDisplayCenteredBigTextLine(3, "%4.2f", pressure);
nxtDisplayCenteredBigTextLine(5, "PSI.");
break;
}
wait1Msec(10);
}
}