Пример #1
0
  /*
   * reads the value of the digital input of the specified channel
   * requires that the readArudiono() method has already been called
   * param 1: the channel to be read
   * return: value of the specified digital input
   */
  public boolean getInput(int channelID) {
    byte temp;

    if (timer.get() > 2.0) {
      DriverStationLCD.getInstance()
          .println(DriverStationLCD.Line.kUser3, 1, "                     ");
      DriverStationLCD.getInstance().updateLCD();
      timer.stop();
      timer.reset();
    }

    if (Math.abs(channelID - (13 / 2)) - (13 / 2)
        > 0) // returns true if less than zero or greater than thirteen
    {
      timer.start();
      DriverStationLCD.getInstance().println(DriverStationLCD.Line.kUser3, 1, "Invalid ID");
      DriverStationLCD.getInstance().updateLCD();
      return false;
    } else if (channelID < 8) {
      temp = (byte) (loByte & (1 << channelID));
      return temp != 0;
    } else {
      temp = (byte) (hiByte & (1 << channelID - 8));
      return temp != 0;
    }
  }
Пример #2
0
  /**
   * This function is run when the robot is first started up and should be used for any
   * initialization code.
   */
  public void robotInit() {
    black = new Jaguar(4, 1);
    red = new Jaguar(4, 2);
    leftEncoder = new Encoder(4, 5);
    rightEncoder = new Encoder(6, 7);
    left = new Joystick(1);
    right = new Joystick(2);
    gamePad = new Joystick(3);
    watchdog = Watchdog.getInstance();
    dsLCD = DriverStationLCD.getInstance();
    photoreceptorL = new DigitalInput(4, 1);
    photoreceptorM = new DigitalInput(4, 2);
    photoreceptorR = new DigitalInput(4, 3);
    camera = AxisCamera.getInstance();
    driveMode = 0; // 0 = Tank; 1 = Arcade; 2 = Kaj
    driveToggle = false;
    cruiseControl = false;

    camera.writeResolution(AxisCamera.ResolutionT.k160x120);
    camera.writeWhiteBalance(AxisCamera.WhiteBalanceT.hold);
    camera.writeExposureControl(AxisCamera.ExposureT.hold);
    camera.writeExposurePriority(AxisCamera.ExposurePriorityT.frameRate);

    leftEncoder.start();
    rightEncoder.start();
  }
Пример #3
0
  /*
   * reads the arduino and recieves 2 bytes to represent the digital inputs attached to it
   * saves the 2 bytes to 'loByte' and 'hiByte'
   * return: true if and only if it's successful
   */
  public boolean readArduino() {
    byte[] buffer = {0, 0};

    successful =
        !m_I2C.transaction(
            null, 0, buffer,
            2); // doesn't send anything and recieves 2 bytes of data; successful==true if
    // transaction is succesful
    DriverStationLCD.getInstance()
        .println(DriverStationLCD.Line.kUser1, 1, "                     ");
    DriverStationLCD.getInstance()
        .println(DriverStationLCD.Line.kUser2, 1, "                     ");
    DriverStationLCD.getInstance()
        .println(DriverStationLCD.Line.kUser1, 1, "success=" + successful);
    DriverStationLCD.getInstance()
        .println(DriverStationLCD.Line.kUser2, 1, "buffer=" + buffer[1] + ", " + buffer[0]);
    DriverStationLCD.getInstance().updateLCD();
    hiByte = buffer[1];
    loByte = buffer[0];

    return successful;
  }