diff options
Diffstat (limited to 'altoslib/AltosEepromRecordMega.java')
| -rw-r--r-- | altoslib/AltosEepromRecordMega.java | 92 | 
1 files changed, 56 insertions, 36 deletions
| diff --git a/altoslib/AltosEepromRecordMega.java b/altoslib/AltosEepromRecordMega.java index 3c5f60b3..371810ab 100644 --- a/altoslib/AltosEepromRecordMega.java +++ b/altoslib/AltosEepromRecordMega.java @@ -109,12 +109,13 @@ public class AltosEepromRecordMega extends AltosEepromRecord {  	private int svid(int n) { return data8(2 + n * 2); }  	private int c_n(int n) { return data8(2 + n * 2 + 1); } -	public void update_state(AltosFlightListener state) { -		super.update_state(state); +	public void provide_data(AltosDataListener listener, AltosCalData cal_data) { +		super.provide_data(listener, cal_data); +  		AltosGPS	gps;  		/* Flush any pending GPS changes */ -		if (state.gps_pending()) { +		if (cal_data.gps_pending()) {  			switch (cmd()) {  			case AltosLib.AO_LOG_GPS_LAT:  			case AltosLib.AO_LOG_GPS_LON: @@ -123,66 +124,85 @@ public class AltosEepromRecordMega extends AltosEepromRecord {  			case AltosLib.AO_LOG_GPS_DATE:  				break;  			default: -				state.set_temp_gps(); +				listener.set_gps(cal_data.temp_gps()); +				cal_data.reset_temp_gps();  				break;  			}  		}  		switch (cmd()) {  		case AltosLib.AO_LOG_FLIGHT: -			state.set_flight(flight()); -			state.set_ground_accel(ground_accel()); -			state.set_ground_pressure(ground_pres()); -			state.set_accel_ground(ground_accel_along(), -					       ground_accel_across(), -					       ground_accel_through()); -			state.set_gyro_zero(ground_roll() / 512.0, -					    ground_pitch() / 512.0, -					    ground_yaw() / 512.0); +			cal_data.set_flight(flight()); +			cal_data.set_ground_accel(ground_accel()); +			cal_data.set_ground_pressure(ground_pres()); +			listener.set_accel_ground(ground_accel_along(), +						  ground_accel_across(), +						  ground_accel_through()); +			cal_data.set_gyro_zero(ground_roll() / 512.0, +					       ground_pitch() / 512.0, +					       ground_yaw() / 512.0);  			break;  		case AltosLib.AO_LOG_STATE: -			state.set_state(state()); +			listener.set_state(state());  			break;  		case AltosLib.AO_LOG_SENSOR: -			state.set_ms5607(pres(), temp()); - -			AltosIMU	imu = new AltosIMU(accel_y(),	/* along */ -							   accel_x(),	/* across */ -							   accel_z(),	/* through */ -							   gyro_y(),	/* roll */ -							   gyro_x(),	/* pitch */ -							   gyro_z());	/* yaw */ +			AltosConfigData config_data = eeprom.config_data(); +			AltosPresTemp pt = config_data.ms5607().pres_temp(pres(), temp());; +			listener.set_pressure(pt.pres); +			listener.set_temperature(pt.temp); + +			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_x(); +			int	mag_across = mag_y(); +			int	mag_through = mag_z();  			if (log_format == AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD) -				state.check_imu_wrap(imu); +				cal_data.check_imu_wrap(gyro_roll, gyro_pitch, gyro_yaw); + +			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)); -			state.set_imu(imu); +			listener.set_mag(cal_data.mag_along(mag_along), +					 cal_data.mag_across(mag_across), +					 cal_data.mag_through(mag_through)); -			state.set_mag(new AltosMag(mag_x(), -						   mag_y(), -						   mag_z())); -			state.set_accel(accel()); +			double acceleration = AltosConvert.acceleration_from_sensor( +				accel(), +				config_data.accel_cal_plus, +				config_data.accel_cal_minus, +				AltosLib.MISSING); +			listener.set_acceleration(acceleration);  			break;  		case AltosLib.AO_LOG_TEMP_VOLT: -			state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt())); -			state.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pbatt())); +			listener.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt())); +			listener.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pbatt()));  			int nsense = nsense(); -			state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sense(nsense-2))); -			state.set_main_voltage(AltosConvert.mega_pyro_voltage(sense(nsense-1))); +			listener.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sense(nsense-2))); +			listener.set_main_voltage(AltosConvert.mega_pyro_voltage(sense(nsense-1)));  			double voltages[] = new double[nsense-2];  			for (int i = 0; i < nsense-2; i++)  				voltages[i] = AltosConvert.mega_pyro_voltage(sense(i)); -			state.set_ignitor_voltage(voltages); -			state.set_pyro_fired(pyro()); +			listener.set_ignitor_voltage(voltages); +			listener.set_pyro_fired(pyro());  			break;  		case AltosLib.AO_LOG_GPS_TIME: -			gps = state.make_temp_gps(false); +			gps = cal_data.make_temp_gps(tick(), false);  			gps.lat = latitude() / 1e7;  			gps.lon = longitude() / 1e7; @@ -225,7 +245,7 @@ public class AltosEepromRecordMega extends AltosEepromRecord {  			}  			break;  		case AltosLib.AO_LOG_GPS_SAT: -			gps = state.make_temp_gps(true); +			gps = cal_data.make_temp_gps(tick(), true);  			int n = nsat();  			if (n > max_sat) | 
