From 67f28c58db0deca8f8050d33e97ad96017f4baaa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Aug 2011 11:19:57 -0700 Subject: [PATCH] altosui: Disable 'max flight log' config when there are stored flights When flights are stored in flash, the maximum flight log value cannot be changed as the flight data might need to be moved around in memory. Check for this case by looking for stored flights and disabling the combo box when storage is not empty. Signed-off-by: Keith Packard --- altosui/AltosConfig.java | 7 ++++++- altosui/AltosConfigUI.java | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 9a44c1c5..84c8a4a3 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -78,6 +78,7 @@ public class AltosConfig implements ActionListener { int_ref radio_setting; int_ref storage_size; int_ref storage_erase_unit; + int_ref stored_flight; string_ref version; string_ref product; string_ref callsign; @@ -146,6 +147,7 @@ public class AltosConfig implements ActionListener { config_ui.set_apogee_delay(apogee_delay.get()); config_ui.set_radio_calibration(radio_calibration.get()); config_ui.set_radio_frequency(frequency()); + config_ui.set_flight_log_max_enabled(stored_flight.get() < 0); config_ui.set_flight_log_max_limit(log_limit()); config_ui.set_flight_log_max(flight_log_max.get()); config_ui.set_ignite_mode(ignite_mode.get()); @@ -177,6 +179,7 @@ public class AltosConfig implements ActionListener { get_int(line, "Radio setting:", radio_setting); get_int(line, "Storage size:", storage_size); get_int(line, "Storage erase unit:", storage_erase_unit); + get_int(line, "flight", stored_flight); get_string(line, "Callsign:", callsign); get_string(line,"software-version", version); get_string(line,"product", product); @@ -206,7 +209,8 @@ public class AltosConfig implements ActionListener { void get_data() { try { config.start_serial(); - config.serial_line.printf("c s\nf\nv\n"); + stored_flight.set(-1); + config.serial_line.printf("c s\nf\nl\nv\n"); for (;;) { try { String line = config.serial_line.get_reply(5000); @@ -413,6 +417,7 @@ public class AltosConfig implements ActionListener { pad_orientation = new int_ref(-1); storage_size = new int_ref(-1); storage_erase_unit = new int_ref(-1); + stored_flight = new int_ref(-1); callsign = new string_ref("N0CALL"); version = new string_ref("unknown"); product = new string_ref("unknown"); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 63e0ba78..69afd691 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -573,6 +573,10 @@ public class AltosConfigUI flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max)); } + public void set_flight_log_max_enabled(boolean enable) { + flight_log_max_value.setEnabled(enable); + } + public int flight_log_max() { return Integer.parseInt(flight_log_max_value.getSelectedItem().toString()); } -- 2.30.2