From: Keith Packard Date: Fri, 26 Jun 2015 01:40:21 +0000 (-0700) Subject: telegps: Add receiver battery to Status display X-Git-Tag: 1.6.0.4~16 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=002c523fae9369f0261c28f33152289d965d406b 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 --- 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++)); } }