private byte[] output_voltage() {
    String voltage = Double.toString(_ds.getBatteryVoltage());
    if (voltage.length() != 4) {
      voltage = voltage.substring(0, 4);
    }

    byte[] output = new byte[10];

    byte second_digit_two = CHARS[voltage.charAt(1) - 48][1];
    second_digit_two |= (byte) 0b01000000;

    output[0] = (byte) (0b0000111100001111);

    output[2] = CHARS[31][0]; // V
    output[3] = CHARS[31][1]; // V
    output[4] = CHARS[voltage.charAt(3) - 48][0];
    ; // third digit
    output[5] = CHARS[voltage.charAt(3) - 48][1];
    ; // third digit
    output[6] = CHARS[voltage.charAt(1) - 48][0]; // second digit of voltage
    output[7] = second_digit_two; // second digit of voltage, with decimal point.
    output[8] = CHARS[voltage.charAt(0) - 48][0]; // first digit of voltage
    output[9] = CHARS[voltage.charAt(0) - 48][1]; // first digit of voltage

    return output;
  }
Example #2
0
 public void logData(
     DriverStation ds,
     Joystick left,
     Joystick right,
     Joystick co,
     DriveTrain dt,
     SuperStructure ss) {
   System.out.println(
       "Data: B:" + ds.getBatteryVoltage() + " L:" + left.getY() + " R:" + right.getY());
 }