summaryrefslogtreecommitdiff
path: root/altosui/AltosPad.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-10 22:46:58 -0700
committerKeith Packard <keithp@keithp.com>2016-05-11 23:22:15 -0700
commit60f4d69592c440ab7bb67a04f4c07fc7279d2c20 (patch)
tree8edfca4a59b5d15d251607075453aeab1a9f376f /altosui/AltosPad.java
parent6a6da23335e6e5864387c7a22946f80f51056a4f (diff)
altoslib: Switch distance from m/ft to km/miles for large values
This adds lots of infrastructure to deal with making the unit used depend on the value itself, and then uses it only for distances. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosPad.java')
-rw-r--r--altosui/AltosPad.java52
1 files changed, 22 insertions, 30 deletions
diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java
index 4f55636d..9a8c8087 100644
--- a/altosui/AltosPad.java
+++ b/altosui/AltosPad.java
@@ -101,7 +101,11 @@ public class AltosPad extends AltosUIFlightTab {
class ReceiverBattery extends AltosUIVoltageIndicator {
- public double voltage(AltosState state) { return AltosLib.MISSING; }
+ double last_voltage = AltosLib.MISSING;
+
+ public double voltage(AltosState state) {
+ return last_voltage;
+ }
public double good() { return AltosLib.ao_battery_good; }
@@ -111,8 +115,10 @@ public class AltosPad extends AltosUIFlightTab {
public double value(AltosState state, AltosListenerState listener_state, int i) {
if (listener_state == null)
- return AltosLib.MISSING;
- return listener_state.battery;
+ last_voltage = AltosLib.MISSING;
+ else
+ last_voltage = listener_state.battery;
+ return last_voltage;
}
public ReceiverBattery (AltosUIFlightTab container, int y) {
@@ -205,40 +211,26 @@ public class AltosPad extends AltosUIFlightTab {
}
}
- class PadAlt extends AltosUIIndicator {
+ class PadAlt extends AltosUIUnitsIndicator {
- double last_alt = AltosLib.MISSING - 1;
+ public double value(AltosState state, int i) {
+ if (report_pad(state))
+ return state.pad_alt;
+ else
+ return state.gps.alt;
+ }
public void show (AltosState state, AltosListenerState listener_state) {
- double alt = AltosLib.MISSING;
- String label = null;
+ String label = "Altitude";
- if (state != null) {
- if (report_pad(state)) {
- alt = state.pad_alt;
- label = "Pad Altitude";
- } else {
- alt = state.gps.alt;
- label = "Altitude";
- }
- }
- if (alt != last_alt) {
- if (alt != AltosLib.MISSING) {
- show(AltosConvert.height.show(5, alt));
- set_label(label);
- } else
- hide();
- last_alt = alt;
- }
- }
-
- public void reset() {
- super.reset();
- last_alt = AltosLib.MISSING - 1;
+ if (state != null && report_pad(state))
+ label = "Pad Altitude";
+ set_label(label);
+ super.show(state, listener_state);
}
public PadAlt (AltosUIFlightTab container, int y) {
- super (container, y, "Pad Altitude", 1, false, 2);
+ super (container, y, AltosConvert.height, "Pad Altitude", 1, false, 2);
}
}
public String getName() { return "Pad"; }