private volatile long turns = 0;
private volatile double[] xyz = new double[3];
- private float zeroReferenceConst = 0;;
+ private double zeroReferenceConst = 0;
public class SystemStatus {
public int system_status;
executor = new java.util.Timer();
executor.schedule(new BNO055UpdateTask(this), 0L, THREAD_PERIOD);
- Timer.delay(2);
-
setZeroReferenceConst();
}
- public void setZeroReferenceConst() {
- double zeroReferenceConst = getHeading();
+ /***
+ * Sets the starting heading to the zero reference angle of the readings
+ * This method should be left private and only be ran once
+ */
+ private void setZeroReferenceConst() {
+ zeroReferenceConst = getHeading();
}
/**
public static BNO055 getInstance(opmode_t mode, vector_type_t vectorType,
I2C.Port port, byte address) {
if (instance == null) {
+ System.out.println("gyro called");
instance = new BNO055(port, address);
}
requestedMode = mode;
// blocking manner. This sequence of events follows the process
// defined in the original adafruit source as closely as possible.
// XXX: It's likely some of these delays can be optimized out.
+ System.out.println("State: " + state);
switch (state) {
case 0:
// Wait for the sensor to be present
break;
case 8:
if (currentTime >= nextTime) {
+ nextTime = Timer.getFPGATimestamp() + 1.05;
state++;
}
case 9:
* @return heading in degrees
*/
public double getHeading() {
+ double reading = (xyz[0] + turns * 360);
+ if (zeroReferenceConst == 0)
+ return (xyz[0] + turns * 360);
+
return (xyz[0] + turns * 360) - zeroReferenceConst;
}