From 99c729495a8cc589718607ee35d22454c6af2994 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 6 Apr 2014 23:46:48 -0700 Subject: [PATCH 1/1] altosui: Disable flight log configuration while flights are stored 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 --- altoslib/AltosConfigData.java | 24 +++++++++++++++++++++--- altosui/AltosConfigUI.java | 29 ++++++++++++++++++----------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index c4e108f8..edaf4601 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -351,9 +351,22 @@ public class AltosConfigData implements Iterable { 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 { 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()); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 21ea50e6..656b0b6f 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -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(); } -- 2.30.2