altoslib, altosui, telegps: Add configuration support for APRS offset
[fw/altos] / telegps / TeleGPSConfigUI.java
index dc982dea911dca866d093c2ae14dfec7c433be0d..1a951309e331cec9644e7cbafd4f9705ead52558 100644 (file)
@@ -43,6 +43,7 @@ public class TeleGPSConfigUI
        JLabel                  aprs_interval_label;
        JLabel                  aprs_ssid_label;
        JLabel                  aprs_format_label;
+       JLabel                  aprs_offset_label;
        JLabel                  flight_log_max_label;
        JLabel                  callsign_label;
        JLabel                  tracker_motion_label;
@@ -61,6 +62,7 @@ public class TeleGPSConfigUI
        JComboBox<String>       aprs_interval_value;
        JComboBox<Integer>      aprs_ssid_value;
        JComboBox<String>       aprs_format_value;
+       JComboBox<Integer>      aprs_offset_value;
        JComboBox<String>       flight_log_max_value;
        JTextField              callsign_value;
        JComboBox<String>       tracker_motion_value;
@@ -84,6 +86,10 @@ public class TeleGPSConfigUI
                0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
        };
 
+       static Integer[]        aprs_offset_values = {
+               0, 2, 4, 6, 8, 10, 12, 14, 16, 18
+       };
+
        static String[]         tracker_motion_values_m = {
                "2",
                "5",
@@ -178,6 +184,15 @@ public class TeleGPSConfigUI
                        aprs_format_value.setToolTipText("Hardware doesn't support APRS");
        }
 
+       void set_aprs_offset_tool_tip() {
+               if (aprs_offset_value.isVisible())
+                       aprs_offset_value.setToolTipText("Set the APRS offset from top of minute");
+               else if (aprs_offset_value.isVisible())
+                       aprs_offset_value.setToolTipText("Software version doesn't support setting the APRS offset");
+               else
+                       aprs_offset_value.setToolTipText("Hardware doesn't support APRS");
+       }
+
        void set_flight_log_max_tool_tip() {
                if (flight_log_max_value.isVisible())
                        flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
@@ -444,6 +459,33 @@ public class TeleGPSConfigUI
                set_aprs_format_tool_tip();
                row++;
 
+               /* APRS offset */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = row;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
+               aprs_offset_label = new JLabel("APRS offset:");
+               pane.add(aprs_offset_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 4; c.gridy = row;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               aprs_offset_value = new JComboBox<Integer>(aprs_offset_values);
+               aprs_offset_value.setEditable(false);
+               aprs_offset_value.addItemListener(this);
+               aprs_offset_value.setMaximumRowCount(aprs_offset_values.length);
+               pane.add(aprs_offset_value, c);
+               set_aprs_offset_tool_tip();
+               row++;
+
                /* Callsign */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = row;
@@ -963,4 +1005,19 @@ public class TeleGPSConfigUI
                        return aprs_format_value.getSelectedIndex();
                return AltosLib.MISSING;
        }
+       public void set_aprs_offset(int new_aprs_offset) {
+               if (new_aprs_offset != AltosLib.MISSING)
+                       aprs_offset_value.setSelectedItem(new_aprs_offset);
+               aprs_offset_value.setVisible(new_aprs_offset != AltosLib.MISSING);
+               aprs_offset_label.setVisible(new_aprs_offset != AltosLib.MISSING);
+               set_aprs_offset_tool_tip();
+       }
+
+       public int aprs_offset() throws AltosConfigDataException {
+               if (aprs_offset_value.isVisible()) {
+                       Integer i = (Integer) aprs_offset_value.getSelectedItem();
+                       return i;
+               }
+               return AltosLib.MISSING;
+       }
 }