telegps: Auto-connect to any base stations plugged in at startup
[fw/altos] / telegps / TeleGPS.java
index 34509e4ec92ca95817bc9dc77c5ea3dce0b91ded..de2b4aa33f84d05c9ed1a8d658a39d5143613df8 100644 (file)
@@ -53,6 +53,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
        JTabbedPane     pane;
 
        AltosSiteMap    sitemap;
+       TeleGPSInfo     gps_info;
        boolean         has_map;
 
        JMenuBar        menu_bar;
@@ -115,10 +116,12 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
 
        public void reset() {
                sitemap.reset();
+               gps_info.reset();
        }
 
        public void set_font() {
                sitemap.set_font();
+               gps_info.set_font();
        }
 
        public void font_size_changed(int font_size) {
@@ -135,6 +138,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
                        state = new AltosState();
 
                sitemap.show(state, listener_state);
+               gps_info.show(state, listener_state);
                telegps_status.show(state, listener_state);
        }
 
@@ -217,6 +221,7 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
        }
 
        void download(){
+               new AltosEepromManage(this, AltosLib.product_telegps);
        }
 
        void configure() {
@@ -224,6 +229,12 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
        }
 
        void export() {
+               AltosDataChooser chooser;
+               chooser = new AltosDataChooser(this);
+               AltosStateIterable states = chooser.runDialog();
+               if (states == null)
+                       return;
+               new AltosCSVUI(this, states, chooser.file());
        }
 
        void graph() {
@@ -393,6 +404,9 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
                sitemap = new AltosSiteMap();
                pane.add("Site Map", sitemap);
 
+               gps_info = new TeleGPSInfo();
+               pane.add("Info", gps_info);
+
                setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
 
                AltosUIPreferences.register_font_listener(this);
@@ -419,6 +433,11 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
                set_reader(reader);
        }
 
+       public TeleGPS(AltosDevice device) {
+               this();
+               connect(device);
+       }
+
        static AltosStateIterable record_iterable(File file) {
                FileInputStream in;
                try {
@@ -548,7 +567,15 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
                }
                if (errors != 0)
                        System.exit(errors);
-               if (!any_created)
-                       new TeleGPS();
+               if (!any_created) {
+                       java.util.List<AltosDevice> devices = AltosUSBDevice.list(AltosLib.product_basestation);
+                       if (devices != null)
+                               for (AltosDevice device : devices) {
+                                       new TeleGPS(device);
+                                       any_created = true;
+                               }
+                       if (!any_created)
+                               new TeleGPS();
+               }
        }
 }