diff options
| author | Keith Packard <keithp@keithp.com> | 2016-05-10 23:04:23 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2016-05-11 23:22:15 -0700 | 
| commit | b2710128a715a109745ec40553a3d4149a7f49ab (patch) | |
| tree | d0e9434210cecffec90d48a3c52b32811c631f48 | |
| parent | 895cb58a6cd7424ee63c24d791b5988f41f85d31 (diff) | |
altosuilib: Don't flicker missing voltages when changing units
For some reason, a value of MISSING -1 was getting used, which caused
displays to light up briefly with a weird value when switching between
metric and imperial units.
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | altosuilib/AltosUIUnitsIndicator.java | 18 | ||||
| -rw-r--r-- | altosuilib/AltosUIVoltageIndicator.java | 2 | 
2 files changed, 13 insertions, 7 deletions
diff --git a/altosuilib/AltosUIUnitsIndicator.java b/altosuilib/AltosUIUnitsIndicator.java index a84bd0b2..1b900e54 100644 --- a/altosuilib/AltosUIUnitsIndicator.java +++ b/altosuilib/AltosUIUnitsIndicator.java @@ -46,10 +46,10 @@ public abstract class AltosUIUnitsIndicator extends AltosUIIndicator {  	public double[] last_values; -	public void show(double... v) { +	private void show(boolean force, double... v) {  		show();  		for (int i = 0; i < values.length; i++) { -			if (v[i] != last_values[i]) { +			if (force || v[i] != last_values[i]) {  				String	value_text;  				boolean	good = false; @@ -68,13 +68,19 @@ public abstract class AltosUIUnitsIndicator extends AltosUIIndicator {  		}  	} +	boolean hide = false; + +	public void show(double... v) { +		show(false, v); +	} +  	public void units_changed(boolean imperial_units) { -		show(last_values); +		if (!hide) +			show(true, last_values);  	}  	public void show (AltosState state, AltosListenerState listener_state) {  		double[] v = new double[values.length]; -		boolean hide = false;  		for (int i = 0; i < values.length; i++) {  			if (state != null) @@ -93,7 +99,7 @@ public abstract class AltosUIUnitsIndicator extends AltosUIIndicator {  	public void reset() {  		for (int i = 0; i < last_values.length; i++) -			last_values[i] = AltosLib.MISSING - 1; +			last_values[i] = AltosLib.MISSING;  	}  	public AltosUIUnitsIndicator (Container container, int x, int y, int label_width, AltosUnits units, String name, int number_values, boolean has_lights, int width) { @@ -101,7 +107,7 @@ public abstract class AltosUIUnitsIndicator extends AltosUIIndicator {  		this.units = units;  		last_values = new double[values.length];  		for (int i = 0; i < last_values.length; i++) -			last_values[i] = AltosLib.MISSING - 1; +			last_values[i] = AltosLib.MISSING;  	}  	public AltosUIUnitsIndicator (Container container, int x, int y, AltosUnits units, String name, int number_values, boolean has_lights, int width) { diff --git a/altosuilib/AltosUIVoltageIndicator.java b/altosuilib/AltosUIVoltageIndicator.java index d753b759..ecf8bce9 100644 --- a/altosuilib/AltosUIVoltageIndicator.java +++ b/altosuilib/AltosUIVoltageIndicator.java @@ -30,7 +30,7 @@ public abstract class AltosUIVoltageIndicator extends AltosUIUnitsIndicator {  		return voltage(state);  	} -	double last_voltage = -1; +	double last_voltage = AltosLib.MISSING;  	public AltosUIVoltageIndicator (Container container, int x, int y, String name, int width) {  		super(container, x, y, AltosConvert.voltage, name, 1, true, width);  | 
