コード例 #1
0
ファイル: RCXTempTest.java プロジェクト: Ghostbomb/workspace
 public static void main(String[] args) throws Exception {
   RCXTemperatureSensor temperature = new RCXTemperatureSensor(SensorPort.S1);
   boolean s = true;
   while (!Button.ESCAPE.isDown()) {
     LCD.clear();
     if (s) LCD.drawString("C " + temperature.getCelcius(), 0, 0);
     else LCD.drawString("F " + temperature.getFahrenheit(), 0, 0);
     s = !s;
     LCD.refresh();
     Thread.sleep(2000);
   }
 }
コード例 #2
0
ファイル: t5-s-slavecomplete.java プロジェクト: jd7h/des
  public static void Measurement() {
    // execute all actions of this state
    LCD.drawString("Measurement", 0, 3);
    btThread.popElement();
    Sound.beep();
    Sound.beep();
    // lower sensor by RCX motor
    tempMotor.setPower(-100);
    tempMotor.setPower(0);
    for (int i = 0; i < nrcolors; i++) {
      if (colorsens.getColorID() == lakes[i].color && !lakes[i].found) // kleuren komen overeen
      lakes[i].celsius = tempSensor.getCelcius();
      lakes[i].found = true;
      return;
    }
    // raise temp sensor
    tempMotor.setPower(100);
    btThread.write(500); // sends the message 'action done'

    // leg de huidige tijd vast voor alle transitions met een timeoutcondition
    long starttime = System.currentTimeMillis();

    // when done, wait for a trigger for a transition
    boolean transitionTaken = false;
    while (!transitionTaken) {
      if ((lakes[0].found && lakes[1].found && lakes[2].found)) {
        current = State.FINISHED;
        transitionTaken = true;
      } else if ((true)) {
        current = State.WATCH;
        transitionTaken = true;
      }
    }
  }