diff options
| author | Keith Packard <keithp@keithp.com> | 2013-12-20 19:40:31 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-12-20 19:40:31 -0800 | 
| commit | 8e5f3b922100f9de54b9650df14749e81b1a6562 (patch) | |
| tree | 4511d5710ab444de6b7c207d08fa033b5a8240ba /altosui/AltosGraph.java | |
| parent | f65880cf5bfcba5005c32db2b300448e585f3e45 (diff) | |
altosui: Add imu and mag sensor values to plots
Makes for a lot of potential graph elements.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosGraph.java')
| -rw-r--r-- | altosui/AltosGraph.java | 153 | 
1 files changed, 153 insertions, 0 deletions
diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index c505d2d8..fa1a5b72 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -127,6 +127,75 @@ class AltosDbm extends AltosUnits {  	}  } +class AltosGyroUnits extends AltosUnits { + +	public double value(double p, boolean imperial_units) { +		return p; +	} + +	public double inverse(double p, boolean imperial_units) { +		return p; +	} + +	public String show_units(boolean imperial_units) { +		return "°/sec"; +	} + +	public String say_units(boolean imperial_units) { +		return "degrees per second"; +	} + +	public int show_fraction(int width, boolean imperial_units) { +		return 1; +	} +} + +class AltosOrientUnits extends AltosUnits { + +	public double value(double p, boolean imperial_units) { +		return p; +	} + +	public double inverse(double p, boolean imperial_units) { +		return p; +	} + +	public String show_units(boolean imperial_units) { +		return "°"; +	} + +	public String say_units(boolean imperial_units) { +		return "degrees"; +	} + +	public int show_fraction(int width, boolean imperial_units) { +		return 1; +	} +} + +class AltosMagUnits extends AltosUnits { + +	public double value(double p, boolean imperial_units) { +		return p; +	} + +	public double inverse(double p, boolean imperial_units) { +		return p; +	} + +	public String show_units(boolean imperial_units) { +		return "Ga"; +	} + +	public String say_units(boolean imperial_units) { +		return "gauss"; +	} + +	public int show_fraction(int width, boolean imperial_units) { +		return 2; +	} +} +  public class AltosGraph extends AltosUIGraph {  	static final private Color height_color = new Color(194,31,31); @@ -146,14 +215,28 @@ public class AltosGraph extends AltosUIGraph {  	static final private Color temperature_color = new Color (31, 194, 194);  	static final private Color dbm_color = new Color(31, 100, 100);  	static final private Color state_color = new Color(0,0,0); +	static final private Color accel_x_color = new Color(255, 0, 0); +	static final private Color accel_y_color = new Color(0, 255, 0); +	static final private Color accel_z_color = new Color(0, 0, 255); +	static final private Color gyro_x_color = new Color(192, 0, 0); +	static final private Color gyro_y_color = new Color(0, 192, 0); +	static final private Color gyro_z_color = new Color(0, 0, 192); +	static final private Color mag_x_color = new Color(128, 0, 0); +	static final private Color mag_y_color = new Color(0, 128, 0); +	static final private Color mag_z_color = new Color(0, 0, 128); +	static final private Color orient_color = new Color(31, 31, 31);  	static AltosVoltage voltage_units = new AltosVoltage();  	static AltosPressure pressure_units = new AltosPressure();  	static AltosNsat nsat_units = new AltosNsat();  	static AltosDbm dbm_units = new AltosDbm(); +	static AltosGyroUnits gyro_units = new AltosGyroUnits(); +	static AltosOrientUnits orient_units = new AltosOrientUnits(); +	static AltosMagUnits mag_units = new AltosMagUnits();  	AltosUIAxis	height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis;  	AltosUIAxis	distance_axis, pressure_axis; +	AltosUIAxis	gyro_axis, orient_axis, mag_axis;  	public AltosGraph(AltosUIEnable enable, AltosFlightStats stats, AltosGraphDataSet dataSet) {  		super(enable); @@ -169,6 +252,10 @@ public class AltosGraph extends AltosUIGraph {  		dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0);  		distance_axis = newAxis("Distance", AltosConvert.distance, range_color); +		gyro_axis = newAxis("Rotation Rate", gyro_units, gyro_z_color, 0); +		orient_axis = newAxis("Tilt Angle", orient_units, orient_color, 0); +		mag_axis = newAxis("Magnetic Field", mag_units, mag_x_color, 0); +  		addMarker("State", AltosGraphDataPoint.data_state, state_color);  		addSeries("Height",  			  AltosGraphDataPoint.data_height, @@ -260,6 +347,72 @@ public class AltosGraph extends AltosUIGraph {  				  voltage_axis);  		} +		if (stats.has_imu) { +			addSeries("Acceleration X", +				  AltosGraphDataPoint.data_accel_x, +				  AltosConvert.accel, +				  accel_x_color, +				  false, +				  accel_axis); +			addSeries("Acceleration Y", +				  AltosGraphDataPoint.data_accel_y, +				  AltosConvert.accel, +				  accel_y_color, +				  false, +				  accel_axis); +			addSeries("Acceleration Z", +				  AltosGraphDataPoint.data_accel_z, +				  AltosConvert.accel, +				  accel_z_color, +				  false, +				  accel_axis); +			addSeries("Rotation Rate X", +				  AltosGraphDataPoint.data_gyro_x, +				  gyro_units, +				  gyro_x_color, +				  false, +				  gyro_axis); +			addSeries("Rotation Rate Y", +				  AltosGraphDataPoint.data_gyro_y, +				  gyro_units, +				  gyro_y_color, +				  false, +				  gyro_axis); +			addSeries("Rotation Rate Z", +				  AltosGraphDataPoint.data_gyro_z, +				  gyro_units, +				  gyro_z_color, +				  false, +				  gyro_axis); +		} +		if (stats.has_mag) { +			addSeries("Magnetometer X", +				  AltosGraphDataPoint.data_mag_x, +				  mag_units, +				  mag_x_color, +				  false, +				  mag_axis); +			addSeries("Magnetometer Y", +				  AltosGraphDataPoint.data_mag_y, +				  mag_units, +				  mag_y_color, +				  false, +				  mag_axis); +			addSeries("Magnetometer Z", +				  AltosGraphDataPoint.data_mag_z, +				  mag_units, +				  mag_z_color, +				  false, +				  mag_axis); +		} +		if (stats.has_orient) +			addSeries("Tilt Angle", +				  AltosGraphDataPoint.data_orient, +				  orient_units, +				  orient_color, +				  false, +				  orient_axis); +  		setDataSet(dataSet);  	}  }
\ No newline at end of file  | 
