Esempio n. 1
0
task main() {
  int raw = 0;
  int nrm = 0;

  nNxtButtonTask  = -2;

  eraseDisplay();
  nxtDisplayTextLine(0, "Dexter Industries");
  nxtDisplayCenteredBigTextLine(1, "dFlex");
  nxtDisplayCenteredTextLine(3, "Test 1");
  nxtDisplayCenteredTextLine(5, "Connect sensor");
  nxtDisplayCenteredTextLine(6, "to S1");
  wait1Msec(2000);

  eraseDisplay();
  nxtDisplayTextLine(0, "dFlex Sensor");

  while (true) {
    nxtDisplayClearTextLine(5);
    nxtDisplayClearTextLine(6);

    // Get the raw value from the sensor
    raw = DFLEXvalRaw(LEGOLS);

    // Get the normalised value from the sensor
    nrm = DFLEXvalNorm(LEGOLS);

    nxtDisplayTextLine(2, "Raw:  %4d", raw);
    nxtDisplayTextLine(4, "Norm: %4d", nrm);
    wait1Msec(50);
  }
}
Esempio n. 2
0
task main () {
  int raw = 0;
  int nrm = 0;
  // Get control over the buttons
  nNxtButtonTask  = -2;

  eraseDisplay();
  nxtDisplayTextLine(0, "Dexter Industries");
  nxtDisplayCenteredBigTextLine(1, "dFlex");
  nxtDisplayCenteredTextLine(3, "Test 2");
  nxtDisplayCenteredTextLine(5, "Connect sensor");
  nxtDisplayCenteredTextLine(6, "to S1");
  wait1Msec(2000);

  eraseDisplay();
  nxtDisplayTextLine(0, "dFlex Calibration");
  nxtDisplayTextLine(2, "Left:  set min");
  nxtDisplayTextLine(3, "Right: set max");
  nxtDisplayTextLine(7, "Grey:  exit");

  while (true) {
    switch(nNxtButtonPressed) {
      // if the left button is pressed calibrate the black value for the sensor
      case kLeftButton:
                        DFLEXcalLow(DFLEX);
                        PlaySound(soundBeepBeep);
                        while(bSoundActive);
                        break;

      // if the left button is pressed calibrate the white value for the sensor
      case kRightButton:
                        DFLEXcalHigh(DFLEX);
                        PlaySound(soundBeepBeep);
                        while(bSoundActive);
                        break;
    }

    nxtDisplayClearTextLine(5);
    nxtDisplayClearTextLine(6);

    // Read the raw value of the sensor
    raw = DFLEXvalRaw(DFLEX);

    // Read the normalised value of the sensor
    nrm = DFLEXvalNorm(DFLEX);

    // Display the raw and normalised values
    nxtDisplayTextLine(5, "R: %4d N: %4d", raw, nrm);

    // Display the values for black and white
    nxtDisplayTextLine(6, "B: %4d W: %4d", dflexlow, dflexhigh);
    wait1Msec(50);
  }
}