From 002c523fae9369f0261c28f33152289d965d406b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 25 Jun 2015 18:40:21 -0700 Subject: [PATCH] telegps: Add receiver battery to Status display Makes it a bit cramped, but it's useful to have if you're using TeleBT. Signed-off-by: Keith Packard --- telegps/TeleGPS.java | 1 - telegps/TeleGPSState.java | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/telegps/TeleGPS.java b/telegps/TeleGPS.java index 078f4061..4f83e8e5 100644 --- a/telegps/TeleGPS.java +++ b/telegps/TeleGPS.java @@ -373,7 +373,6 @@ public class TeleGPS public void actionPerformed(ActionEvent e) { int rate = rates.rate(); try { - System.out.printf("set rate %d\n", rate); reader.set_telemetry_rate(rate); } catch (TimeoutException te) { } catch (InterruptedException ie) { diff --git a/telegps/TeleGPSState.java b/telegps/TeleGPSState.java index 6fbd0b5e..7c410e98 100644 --- a/telegps/TeleGPSState.java +++ b/telegps/TeleGPSState.java @@ -161,6 +161,26 @@ public class TeleGPSState extends AltosUIFlightTab { } } + class ReceiverBattery extends AltosUIVoltageIndicator { + + public double voltage(AltosState state) { return AltosLib.MISSING; } + + public double good() { return AltosLib.ao_battery_good; } + + public boolean hide(AltosState state, AltosListenerState listener_state, int i) { + return value(state, listener_state, i) == AltosLib.MISSING; + } + + public double value(AltosState state, AltosListenerState listener_state, int i) { + if (listener_state == null) + return AltosLib.MISSING; + return listener_state.battery; + } + + public ReceiverBattery (AltosUIFlightTab container, int y) { + super(container, y, "Receiver Battery", 2); + } + } public void labels(Container container, int y) { GridBagLayout layout = (GridBagLayout)(container.getLayout()); @@ -203,5 +223,6 @@ public class TeleGPSState extends AltosUIFlightTab { add(new FirmwareVersion(this, y++)); add(new FlightLogMax(this, y++)); add(new BatteryVoltage(this, y++)); + add(new ReceiverBattery(this, y++)); } } -- 2.30.2