altosui: Disable flight log configuration while flights are stored
authorKeith Packard <keithp@keithp.com>
Mon, 7 Apr 2014 06:46:48 +0000 (23:46 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 7 Apr 2014 06:46:48 +0000 (23:46 -0700)
The log code won't let you resize the maximum flight log while there
is still data on the flight computer; the code to figure that out in
the UI was busted, leaving users confused about why it wasn't working.

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

index c4e108f848e40313b6113ad9e8539231c30f1dcb..edaf4601bbebc9632fb6b9ee8a8e83bc10cdf613 100644 (file)
@@ -351,9 +351,22 @@ public class AltosConfigData implements Iterable<String> {
                                                       channel);
        }
 
+       boolean use_flash_for_config() {
+               if (product.startsWith("TeleMega"))
+                       return false;
+               if (product.startsWith("TeleMetrum-v2"))
+                       return false;
+               return true;
+       }
+
+
        public int log_limit() {
-               if (storage_size > 0 && storage_erase_unit > 0) {
-                       int     log_limit = storage_size - storage_erase_unit;
+               if (storage_size > 0) {
+                       int     log_limit = storage_size;
+
+                       if (storage_erase_unit > 0 && use_flash_for_config())
+                               log_limit -= storage_erase_unit;
+
                        if (log_limit > 0)
                                return log_limit / 1024;
                }
@@ -410,15 +423,20 @@ public class AltosConfigData implements Iterable<String> {
                dest.set_radio_calibration(radio_calibration);
                dest.set_radio_frequency(frequency());
                boolean max_enabled = true;
+
+               if (log_limit() == 0)
+                       max_enabled = false;
+
                switch (log_format) {
                case AltosLib.AO_LOG_FORMAT_TINY:
                        max_enabled = false;
                        break;
                default:
-                       if (stored_flight >= 0)
+                       if (stored_flight > 0)
                                max_enabled = false;
                        break;
                }
+
                dest.set_flight_log_max_enabled(max_enabled);
                dest.set_radio_enable(radio_enable);
                dest.set_flight_log_max_limit(log_limit());
index 21ea50e638f6bb21ddcab43dd0c5009c2b67bfb9..656b0b6f6baa321100bb71975d46534d1c0e037a 100644 (file)
@@ -132,11 +132,21 @@ public class AltosConfigUI
                }
        }
 
+       boolean is_telemini_v1() {
+               String  product = product_value.getText();
+               return product != null && product.startsWith("TeleMini-v1");
+       }
+
        boolean is_telemini() {
                String  product = product_value.getText();
                return product != null && product.startsWith("TeleMini");
        }
 
+       boolean is_easymini() {
+               String  product = product_value.getText();
+               return product != null && product.startsWith("EasyMini");
+       }
+
        boolean is_telemetrum() {
                String  product = product_value.getText();
                return product != null && product.startsWith("TeleMetrum");
@@ -167,12 +177,10 @@ public class AltosConfigUI
                if (flight_log_max_value.isEnabled())
                        flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)");
                else {
-                       if (is_telemetrum())
-                               flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
-                       else if (is_telemini())
-                               flight_log_max_value.setToolTipText("TeleMini stores only one flight");
+                       if (is_telemini_v1())
+                               flight_log_max_value.setToolTipText("TeleMini-v1 stores only one flight");
                        else
-                               flight_log_max_value.setToolTipText("Cannot set max flight log value");
+                               flight_log_max_value.setToolTipText("Cannot set max value with flight logs in memory");
                }
        }
 
@@ -189,8 +197,8 @@ public class AltosConfigUI
                else {
                        if (is_telemetrum())
                                pad_orientation_value.setToolTipText("Older TeleMetrum firmware must fly antenna forward");
-                       else if (is_telemini())
-                               pad_orientation_value.setToolTipText("TeleMini doesn't care how it is mounted");
+                       else if (is_telemini() || is_easymini())
+                               pad_orientation_value.setToolTipText("TeleMini and EasyMini don't care how they are mounted");
                        else
                                pad_orientation_value.setToolTipText("Can't select orientation");
                }
@@ -742,14 +750,14 @@ public class AltosConfigUI
        String get_main_deploy_label() {
                return String.format("Main Deploy Altitude(%s):", AltosConvert.height.show_units());
        }
-       
+
        String[] main_deploy_values() {
                if (AltosConvert.imperial_units)
                        return main_deploy_values_ft;
                else
                        return main_deploy_values_m;
        }
-                       
+
        void set_main_deploy_values() {
                String[]        v = main_deploy_values();
                while (main_deploy_value.getItemCount() > 0)
@@ -758,7 +766,7 @@ public class AltosConfigUI
                        main_deploy_value.addItem(v[i]);
                main_deploy_value.setMaximumRowCount(v.length);
        }
-       
+
        public void units_changed(boolean imperial_units) {
                String v = main_deploy_value.getSelectedItem().toString();
                main_deploy_label.setText(get_main_deploy_label());
@@ -834,7 +842,6 @@ public class AltosConfigUI
        }
 
        public void set_flight_log_max(int new_flight_log_max) {
-               flight_log_max_value.setEnabled(new_flight_log_max > 0);
                flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max));
                set_flight_log_max_tool_tip();
        }