Ejemplo n.º 1
0
  public static void main(String args[]) {
    Display display = IntelliBrain.getLcdDisplay();
    IBB ibb = new IBB();

    try {
      SerialPort comPort = IntelliBrain.getCom1();

      // Serial Parameters
      comPort.setSerialPortParams(
          38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

      InputStream inputStream = comPort.getInputStream();
      OutputStream outputStream = comPort.getOutputStream();

      // clear screen
      display.print(0, "");
      display.print(1, "");

      // test the readLine routine
      byte[] buf = new byte[128];

      while (true) {
        int len = readLine(inputStream, outputStream, display, true, buf, 128);

        if (len == 0) continue;

        switch (buf[0]) {
          case 'B':
            ibb.getVersion(outputStream, buf, len);
            break;
          case 'D':
            ibb.setSpeed(outputStream, buf, len);
            break;
          case 'H':
            ibb.sysBeep(outputStream, buf, len);
            break;
          case 'L':
            ibb.setLedState(outputStream, buf, len);
            break;
          case 'N':
            ibb.readProximitySensors(outputStream, buf, len);
            break;
          case 'O':
            ibb.readLightSensors(outputStream, buf, len);
            break;
          case 'Z':
            ibb.motorsOff(outputStream, buf, len);
            break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  public IBB() {
    leftPreDist = 40;
    rightPreDist = 40;

    leftMotor = new ContinuousRotationServo(IntelliBrain.getServo(1), false, 14);
    rightMotor = new ContinuousRotationServo(IntelliBrain.getServo(2), true, 14);

    statusLED = IntelliBrain.getStatusLed();
    faultLED = IntelliBrain.getFaultLed();

    buzzer = IntelliBrain.getBuzzer();

    try {
      leftRangeFinder = new SharpGP2D12(IntelliBrain.getAnalogInput(1), null);
      rightRangeFinder = new SharpGP2D12(IntelliBrain.getAnalogInput(2), null);

      leftLightSensor = IntelliBrain.getAnalogInput(6);
      rightLightSensor = IntelliBrain.getAnalogInput(7);
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }