src: Add easymini-v3.0
[fw/altos] / telegps / TeleGPSConfigUI.java
index a68c82cb1145cc17ee67927b94b0f984dd188e8e..5617b8e435e09818b53b7e94932819675a1d18e7 100644 (file)
@@ -23,8 +23,8 @@ import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 import javax.swing.event.*;
-import org.altusmetrum.altoslib_11.*;
-import org.altusmetrum.altosuilib_11.*;
+import org.altusmetrum.altoslib_14.*;
+import org.altusmetrum.altosuilib_14.*;
 
 public class TeleGPSConfigUI
        extends AltosUIDialog
@@ -39,10 +39,12 @@ public class TeleGPSConfigUI
        JLabel                  radio_calibration_label;
        JLabel                  radio_frequency_label;
        JLabel                  radio_enable_label;
+       JLabel                  radio_10mw_label;
        JLabel                  rate_label;
        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;
@@ -57,10 +59,12 @@ public class TeleGPSConfigUI
        AltosUIFreqList         radio_frequency_value;
        JLabel                  radio_calibration_value;
        JRadioButton            radio_enable_value;
+       JRadioButton            radio_10mw_value;
        AltosUIRateList         rate_value;
        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 +88,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",
@@ -146,6 +154,13 @@ public class TeleGPSConfigUI
                        radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
        }
 
+       void set_radio_10mw_tool_tip() {
+               if (radio_10mw_value.isVisible())
+                       radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
+               else
+                       radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
+       }
+
        void set_rate_tool_tip() {
                if (rate_value.isVisible())
                        rate_value.setToolTipText("Select telemetry baud rate");
@@ -178,6 +193,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)");
@@ -196,7 +220,7 @@ public class TeleGPSConfigUI
                Insets il = new Insets(4,4,4,4);
                Insets ir = new Insets(4,4,4,4);
 
-               pane = getContentPane();
+               pane = getScrollablePane();
                pane.setLayout(new GridBagLayout());
 
                /* Product */
@@ -339,6 +363,31 @@ public class TeleGPSConfigUI
                set_radio_enable_tool_tip();
                row++;
 
+               /* Radio 10mW limit */
+               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;
+               radio_10mw_label = new JLabel("Limit transmit to 10mW:");
+               pane.add(radio_10mw_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;
+               radio_10mw_value = new JRadioButton("Limited");
+               radio_10mw_value.addItemListener(this);
+               pane.add(radio_10mw_value, c);
+               set_radio_10mw_tool_tip();
+               row++;
+
                /* Telemetry Rate */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = row;
@@ -444,6 +493,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;
@@ -619,7 +695,7 @@ public class TeleGPSConfigUI
                return true;
        }
 
-       void set_dirty() {
+       public void set_dirty() {
                dirty = true;
                save.setEnabled(true);
        }
@@ -634,6 +710,17 @@ public class TeleGPSConfigUI
                super.dispose();
        }
 
+       public int accel_cal_plus() {
+               return AltosLib.MISSING;
+       }
+
+       public int accel_cal_minus() {
+               return AltosLib.MISSING;
+       }
+
+       public void set_accel_cal(int accel_plus, int accel_minus) {
+       }
+
        /* Listen for events from our buttons */
        public void actionPerformed(ActionEvent e) {
                String  cmd = e.getActionCommand();
@@ -758,6 +845,22 @@ public class TeleGPSConfigUI
                        return AltosLib.MISSING;
        }
 
+       public void set_radio_10mw(int new_radio_10mw) {
+               if (new_radio_10mw != AltosLib.MISSING) {
+                       radio_10mw_value.setSelected(new_radio_10mw != 0);
+               }
+               radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
+               radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
+               set_radio_10mw_tool_tip();
+       }
+
+       public int radio_10mw() {
+               if (radio_10mw_value.isVisible())
+                       return radio_10mw_value.isSelected() ? 1 : 0;
+               else
+                       return AltosLib.MISSING;
+       }
+
        public void set_telemetry_rate(int new_rate) {
                if (new_rate != AltosLib.MISSING)
                        rate_value.set_rate(new_rate);
@@ -821,14 +924,18 @@ public class TeleGPSConfigUI
                return parse_int("flight log max", flight_log_max_value.getSelectedItem().toString(), true);
        }
 
-       public void set_flight_log_max_limit(int new_flight_log_max_limit) {
+       public void set_flight_log_max_limit(int new_flight_log_max_limit, int new_storage_erase_unit) {
                flight_log_max_limit = new_flight_log_max_limit;
-               flight_log_max_value.removeAllItems();
-               for (int i = 8; i >= 1; i--) {
-                       int     size = flight_log_max_limit / i;
-                       flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+               if (new_flight_log_max_limit != AltosLib.MISSING) {
+                       flight_log_max_value.removeAllItems();
+                       for (int i = 8; i >= 1; i--) {
+                               int     size = flight_log_max_limit / i;
+                               if (new_storage_erase_unit != 0)
+                                       size &= ~(new_storage_erase_unit - 1);
+                               flight_log_max_value.addItem(String.format("%d (%d flights)", size, i));
+                       }
                }
-               if (flight_log_max != 0)
+               if (flight_log_max != 0 && flight_log_max != AltosLib.MISSING)
                        set_flight_log_max(flight_log_max);
        }
 
@@ -952,4 +1059,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;
+       }
 }