- public void update_state(AltosState state) {
- super.update_state(state);
-
- state.set_accel(accel);
- state.set_pressure(pres);
- state.set_temperature(temp / 100.0);
-
- state.set_orient(orient);
-
- AltosIMU imu = new AltosIMU();
-
- imu.accel_x = AltosIMU.convert_accel(accel_x);
- imu.accel_y = AltosIMU.convert_accel(accel_y);
- imu.accel_z = AltosIMU.convert_accel(accel_z);
-
- imu.gyro_x = AltosIMU.convert_gyro(gyro_x);
- imu.gyro_y = AltosIMU.convert_gyro(gyro_y);
- imu.gyro_z = AltosIMU.convert_gyro(gyro_z);
-
- state.imu = imu;
-
- AltosMag mag = new AltosMag();
-
- mag.x = AltosMag.convert_gauss(mag_x);
- mag.y = AltosMag.convert_gauss(mag_y);
- mag.z = AltosMag.convert_gauss(mag_z);
-
- state.mag = mag;
+ public void provide_data(AltosDataListener listener) {
+ super.provide_data(listener);
+
+ AltosCalData cal_data = listener.cal_data();
+
+ listener.set_acceleration(cal_data.acceleration(accel()));
+ listener.set_pressure(pres());
+ listener.set_temperature(temp() / 100.0);
+
+ listener.set_orient(orient());
+ cal_data.set_imu_type(imu_type);
+
+ /* XXX we have no calibration data for these values */
+
+ if (cal_data.accel_zero_along == AltosLib.MISSING)
+ cal_data.set_accel_zero(0, 0, 0);
+ if (cal_data.gyro_zero_roll == AltosLib.MISSING)
+ cal_data.set_gyro_zero(0, 0, 0);
+
+ int accel_along = accel_y();
+ int accel_across = accel_x();
+ int accel_through = accel_z();
+ int gyro_roll = gyro_y();
+ int gyro_pitch = gyro_x();
+ int gyro_yaw = gyro_z();
+
+ int mag_along = mag_y();
+ int mag_across = mag_x();
+ int mag_through = mag_z();
+
+ listener.set_accel(cal_data.accel_along(accel_along),
+ cal_data.accel_across(accel_across),
+ cal_data.accel_through(accel_through));
+ listener.set_gyro(cal_data.gyro_roll(gyro_roll),
+ cal_data.gyro_pitch(gyro_pitch),
+ cal_data.gyro_yaw(gyro_yaw));
+ listener.set_mag(cal_data.mag_along(mag_along),
+ cal_data.mag_across(mag_across),
+ cal_data.mag_through(mag_through));