telegps: Add receiver battery to Status display
authorKeith Packard <keithp@keithp.com>
Fri, 26 Jun 2015 01:40:21 +0000 (18:40 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 26 Jun 2015 01:43:13 +0000 (18:43 -0700)
Makes it a bit cramped, but it's useful to have if you're using TeleBT.

Signed-off-by: Keith Packard <keithp@keithp.com>
telegps/TeleGPS.java
telegps/TeleGPSState.java

index 078f40618e3914a39abcc0879c2529f96541372f..4f83e8e58eb6945d36be998fc59481bd8ced0927 100644 (file)
@@ -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) {
index 6fbd0b5ecc7e4290329e17952383aab3adcab9ed..7c410e9815a8bc45b0ba7bc439687a711a87e9b9 100644 (file)
@@ -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++));
        }
 }