altosui: Add configuration of flight log size
authorKeith Packard <keithp@keithp.com>
Sat, 8 Jan 2011 04:46:29 +0000 (20:46 -0800)
committerKeith Packard <keithp@keithp.com>
Sat, 8 Jan 2011 04:47:55 +0000 (20:47 -0800)
This adds to the TeleMetrum configuration UI the ability to set the
maximum flight log size.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosConfig.java
altosui/AltosConfigUI.java

index 38e1484e3a7e87235dcc7ffea883040bf8f1f779..47de6156dd005003ee5ea8b9b741a36ecf6d5fb3 100644 (file)
@@ -69,6 +69,7 @@ public class AltosConfig implements ActionListener {
        int_ref         apogee_delay;
        int_ref         radio_channel;
        int_ref         radio_calibration;
+       int_ref         flight_log_max;
        string_ref      version;
        string_ref      product;
        string_ref      callsign;
@@ -138,6 +139,7 @@ public class AltosConfig implements ActionListener {
                                get_int(line, "Apogee delay:", apogee_delay);
                                get_int(line, "Radio channel:", radio_channel);
                                get_int(line, "Radio cal:", radio_calibration);
+                               get_int(line, "Max flight log:", flight_log_max);
                                get_string(line, "Callsign:", callsign);
                                get_string(line,"software-version", version);
                                get_string(line,"product", product);
@@ -181,6 +183,7 @@ public class AltosConfig implements ActionListener {
                config_ui.set_apogee_delay(apogee_delay.get());
                config_ui.set_radio_channel(radio_channel.get());
                config_ui.set_radio_calibration(radio_calibration.get());
+               config_ui.set_flight_log_max(flight_log_max.get());
                config_ui.set_callsign(callsign.get());
                config_ui.set_clean();
        }
@@ -193,6 +196,7 @@ public class AltosConfig implements ActionListener {
                apogee_delay.set(config_ui.apogee_delay());
                radio_channel.set(config_ui.radio_channel());
                radio_calibration.set(config_ui.radio_calibration());
+               flight_log_max.set(config_ui.flight_log_max());
                callsign.set(config_ui.callsign());
                try {
                        start_serial();
@@ -203,6 +207,8 @@ public class AltosConfig implements ActionListener {
                                serial_line.printf("c f %d\n", radio_calibration.get());
                        }
                        serial_line.printf("c c %s\n", callsign.get());
+                       if (flight_log_max.get() != 0)
+                               serial_line.printf("c l %d\n", flight_log_max.get());
                        serial_line.printf("c w\n");
                } catch (InterruptedException ie) {
                } finally {
@@ -248,6 +254,7 @@ public class AltosConfig implements ActionListener {
                apogee_delay = new int_ref(0);
                radio_channel = new int_ref(0);
                radio_calibration = new int_ref(1186611);
+               flight_log_max = new int_ref(0);
                callsign = new string_ref("N0CALL");
                version = new string_ref("unknown");
                product = new string_ref("unknown");
index cfa5d7b9ee7b5982d7b497d8aaeeb448ef35f38e..e09eab25dc65b9835dda10a656742f3d9ad84371 100644 (file)
@@ -45,6 +45,7 @@ public class AltosConfigUI
        JLabel          apogee_delay_label;
        JLabel          radio_channel_label;
        JLabel          radio_calibration_label;
+       JLabel          flight_log_max_label;
        JLabel          callsign_label;
 
        public boolean          dirty;
@@ -57,6 +58,7 @@ public class AltosConfigUI
        JComboBox       apogee_delay_value;
        JComboBox       radio_channel_value;
        JTextField      radio_calibration_value;
+       JComboBox       flight_log_max_value;
        JTextField      callsign_value;
 
        JButton         save;
@@ -75,6 +77,12 @@ public class AltosConfigUI
                "0", "1", "2", "3", "4", "5"
        };
 
+       static String[] flight_log_max_values = {
+               "64", "128", "192", "256", "320",
+               "384", "448", "512", "576", "640",
+               "704", "768", "832", "896", "960",
+       };
+
        static String[] radio_channel_values = new String[10];
                {
                        for (int i = 0; i <= 9; i++)
@@ -296,9 +304,33 @@ public class AltosConfigUI
                callsign_value.getDocument().addDocumentListener(this);
                pane.add(callsign_value, c);
 
-               /* Buttons */
+               /* Flight log max */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = 8;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
+               flight_log_max_label = new JLabel("Maximum Flight Log Size:");
+               pane.add(flight_log_max_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 4; c.gridy = 8;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               flight_log_max_value = new JComboBox(flight_log_max_values);
+               flight_log_max_value.setEditable(true);
+               flight_log_max_value.addItemListener(this);
+               pane.add(flight_log_max_value, c);
+
+               /* Buttons */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = 9;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
@@ -309,7 +341,7 @@ public class AltosConfigUI
                save.setActionCommand("Save");
 
                c = new GridBagConstraints();
-               c.gridx = 2; c.gridy = 8;
+               c.gridx = 2; c.gridy = 9;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -320,7 +352,7 @@ public class AltosConfigUI
                reset.setActionCommand("Reset");
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 8;
+               c.gridx = 4; c.gridy = 9;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -331,7 +363,7 @@ public class AltosConfigUI
                reboot.setActionCommand("Reboot");
 
                c = new GridBagConstraints();
-               c.gridx = 6; c.gridy = 8;
+               c.gridx = 6; c.gridy = 9;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_END;
@@ -459,8 +491,17 @@ public class AltosConfigUI
                return callsign_value.getText();
        }
 
+       public void set_flight_log_max(int new_flight_log_max) {
+               if (new_flight_log_max == 0)
+                       flight_log_max_value.setEnabled(false);
+               flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max));
+       }
+
+       public int flight_log_max() {
+               return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
+       }
+
        public void set_clean() {
                dirty = false;
        }
-
- }
\ No newline at end of file
+}