altos, altosui: Add igniter mode (dual, apogee, main) split-telemetry
authorKeith Packard <keithp@keithp.com>
Mon, 23 May 2011 18:32:29 +0000 (11:32 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 17 Jul 2011 15:14:09 +0000 (08:14 -0700)
This provides for redundant charges for either apogee or main.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosConfig.java
altosui/AltosConfigData.java
altosui/AltosConfigUI.java
src/ao.h
src/ao_config.c
src/ao_ignite.c

index c5de83f..e3c30d4 100644 (file)
@@ -70,6 +70,7 @@ public class AltosConfig implements ActionListener {
        int_ref         radio_channel;
        int_ref         radio_calibration;
        int_ref         flight_log_max;
+       int_ref         ignite_mode;
        string_ref      version;
        string_ref      product;
        string_ref      callsign;
@@ -130,6 +131,7 @@ public class AltosConfig implements ActionListener {
                config_ui.set_radio_channel(radio_channel.get());
                config_ui.set_radio_calibration(radio_calibration.get());
                config_ui.set_flight_log_max(flight_log_max.get());
+               config_ui.set_ignite_mode(ignite_mode.get());
                config_ui.set_callsign(callsign.get());
                config_ui.set_clean();
                config_ui.make_visible();
@@ -153,6 +155,7 @@ public class AltosConfig implements ActionListener {
                get_int(line, "Radio channel:", radio_channel);
                get_int(line, "Radio cal:", radio_calibration);
                get_int(line, "Max flight log:", flight_log_max);
+               get_int(line, "Ignite mode:", ignite_mode);
                get_string(line, "Callsign:", callsign);
                get_string(line,"software-version", version);
                get_string(line,"product", product);
@@ -224,6 +227,8 @@ public class AltosConfig implements ActionListener {
                                serial_line.printf("c c %s\n", callsign.get());
                                if (flight_log_max.get() != 0)
                                        serial_line.printf("c l %d\n", flight_log_max.get());
+                               if (ignite_mode.get() >= 0)
+                                       serial_line.printf("c i %d\n", ignite_mode.get());
                                serial_line.printf("c w\n");
                        } catch (InterruptedException ie) {
                        } finally {
@@ -306,6 +311,7 @@ public class AltosConfig implements ActionListener {
                radio_channel.set(config_ui.radio_channel());
                radio_calibration.set(config_ui.radio_calibration());
                flight_log_max.set(config_ui.flight_log_max());
+               ignite_mode.set(config_ui.ignite_mode());
                callsign.set(config_ui.callsign());
                run_serial_thread(serial_mode_save);
        }
@@ -340,6 +346,7 @@ public class AltosConfig implements ActionListener {
                radio_channel = new int_ref(0);
                radio_calibration = new int_ref(1186611);
                flight_log_max = new int_ref(0);
+               ignite_mode = new int_ref(-1);
                callsign = new string_ref("N0CALL");
                version = new string_ref("unknown");
                product = new string_ref("unknown");
index 8c32ed8..3f0e9af 100644 (file)
@@ -51,6 +51,7 @@ public class AltosConfigData implements Iterable<String> {
        int     accel_cal_plus, accel_cal_minus;
        int     radio_calibration;
        int     flight_log_max;
+       int     ignite_mode;
 
 
        static String get_string(String line, String label) throws  ParseException {
@@ -96,6 +97,7 @@ public class AltosConfigData implements Iterable<String> {
                        try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {}
                        try { radio_calibration = get_int(line, "Radio cal:"); } catch (Exception e) {}
                        try { flight_log_max = get_int(line, "Max flight log:"); } catch (Exception e) {}
+                       try { ignite_mode = get_int(line, "Ignite mode:"); } catch (Exception e) {}
                        try { callsign = get_string(line, "Callsign:"); } catch (Exception e) {}
                        try { version = get_string(line,"software-version"); } catch (Exception e) {}
                        try { product = get_string(line,"product"); } catch (Exception e) {}
index f835ee2..6f635b9 100644 (file)
@@ -46,6 +46,7 @@ public class AltosConfigUI
        JLabel          radio_channel_label;
        JLabel          radio_calibration_label;
        JLabel          flight_log_max_label;
+       JLabel          ignite_mode_label;
        JLabel          callsign_label;
 
        public boolean          dirty;
@@ -59,6 +60,7 @@ public class AltosConfigUI
        JComboBox       radio_channel_value;
        JTextField      radio_calibration_value;
        JComboBox       flight_log_max_value;
+       JComboBox       ignite_mode_value;
        JTextField      callsign_value;
 
        JButton         save;
@@ -83,6 +85,12 @@ public class AltosConfigUI
                "704", "768", "832", "896", "960",
        };
 
+       static String[] ignite_mode_values = {
+               "Dual Deploy",
+               "Redundant Apogee",
+               "Redundant Main",
+       };
+
        static String[] radio_channel_values = new String[10];
                {
                        for (int i = 0; i <= 9; i++)
@@ -326,9 +334,33 @@ public class AltosConfigUI
                flight_log_max_value.addItemListener(this);
                pane.add(flight_log_max_value, c);
 
-               /* Buttons */
+               /* Ignite mode */
                c = new GridBagConstraints();
                c.gridx = 0; c.gridy = 9;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.NONE;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = il;
+               c.ipady = 5;
+               ignite_mode_label = new JLabel("Igniter Firing Mode:");
+               pane.add(ignite_mode_label, c);
+
+               c = new GridBagConstraints();
+               c.gridx = 4; c.gridy = 9;
+               c.gridwidth = 4;
+               c.fill = GridBagConstraints.HORIZONTAL;
+               c.weightx = 1;
+               c.anchor = GridBagConstraints.LINE_START;
+               c.insets = ir;
+               c.ipady = 5;
+               ignite_mode_value = new JComboBox(ignite_mode_values);
+               ignite_mode_value.setEditable(false);
+               ignite_mode_value.addItemListener(this);
+               pane.add(ignite_mode_value, c);
+
+               /* Buttons */
+               c = new GridBagConstraints();
+               c.gridx = 0; c.gridy = 10;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_START;
@@ -339,7 +371,7 @@ public class AltosConfigUI
                save.setActionCommand("Save");
 
                c = new GridBagConstraints();
-               c.gridx = 2; c.gridy = 9;
+               c.gridx = 2; c.gridy = 10;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -350,7 +382,7 @@ public class AltosConfigUI
                reset.setActionCommand("Reset");
 
                c = new GridBagConstraints();
-               c.gridx = 4; c.gridy = 9;
+               c.gridx = 4; c.gridy = 10;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.CENTER;
@@ -361,7 +393,7 @@ public class AltosConfigUI
                reboot.setActionCommand("Reboot");
 
                c = new GridBagConstraints();
-               c.gridx = 6; c.gridy = 9;
+               c.gridx = 6; c.gridy = 10;
                c.gridwidth = 2;
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.LINE_END;
@@ -499,6 +531,20 @@ public class AltosConfigUI
                return Integer.parseInt(flight_log_max_value.getSelectedItem().toString());
        }
 
+       public void set_ignite_mode(int new_ignite_mode) {
+               if (new_ignite_mode < 0) {
+                       ignite_mode_value.setEnabled(false);
+                       new_ignite_mode = 0;
+               } else {
+                       ignite_mode_value.setEnabled(true);
+               }
+               ignite_mode_value.setSelectedItem(Integer.toString(new_ignite_mode));
+       }
+
+       public int ignite_mode() {
+               return ignite_mode_value.getSelectedIndex();
+       }
+
        public void set_clean() {
                dirty = false;
        }
index e52a219..d3e588b 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -1357,7 +1357,7 @@ ao_igniter_init(void);
  */
 
 #define AO_CONFIG_MAJOR        1
-#define AO_CONFIG_MINOR        4
+#define AO_CONFIG_MINOR        5
 
 struct ao_config {
        uint8_t         major;
@@ -1370,8 +1370,13 @@ struct ao_config {
        int16_t         accel_minus_g;          /* minor version 2 */
        uint32_t        radio_cal;              /* minor version 3 */
        uint32_t        flight_log_max;         /* minor version 4 */
+       uint8_t         ignite_mode;            /* minor version 5 */
 };
 
+#define AO_IGNITE_MODE_DUAL            0
+#define AO_IGNITE_MODE_APOGEE          1
+#define AO_IGNITE_MODE_MAIN            2
+
 extern __xdata struct ao_config ao_config;
 
 #define AO_CONFIG_MAX_SIZE     128
index 813164e..4834988 100644 (file)
@@ -27,6 +27,7 @@ __xdata uint8_t ao_config_mutex;
 #define AO_CONFIG_DEFAULT_CALLSIGN     "N0CALL"
 #define AO_CONFIG_DEFAULT_ACCEL_ZERO_G 16000
 #define AO_CONFIG_DEFAULT_APOGEE_DELAY 0
+#define AO_CONFIG_DEFAULT_IGNITE_MODE  AO_IGNITE_MODE_DUAL
 #if USE_INTERNAL_EEPROM
 #define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX       ao_storage_config
 #else
@@ -75,6 +76,7 @@ _ao_config_get(void)
                ao_config.apogee_delay = AO_CONFIG_DEFAULT_APOGEE_DELAY;
                ao_config.radio_cal = ao_radio_cal;
                ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
+               ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
                ao_config_dirty = 1;
        }
        if (ao_config.minor < AO_CONFIG_MINOR) {
@@ -92,6 +94,9 @@ _ao_config_get(void)
                /* Fixups for minor version 4 */
                if (ao_config.minor < 4)
                        ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
+               /* Fixupes for minor version 5 */
+               if (ao_config.minor < 5)
+                       ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
                ao_config.minor = AO_CONFIG_MINOR;
                ao_config_dirty = 1;
        }
@@ -334,6 +339,28 @@ ao_config_log_set(void) __reentrant
 }
 #endif /* HAS_EEPROM */
 
+#if HAS_IGNITE
+void
+ao_config_ignite_mode_show(void) __reentrant
+{
+       printf("Ignite mode: %d\n", ao_config.ignite_mode);
+}
+
+void
+ao_config_ignite_mode_set(void) __reentrant
+{
+       ao_cmd_decimal();
+       if (ao_cmd_status != ao_cmd_success)
+               return;
+       ao_mutex_get(&ao_config_mutex);
+       _ao_config_get();
+       ao_config.ignite_mode = ao_cmd_lex_i;
+       ao_config_dirty = 1;
+       ao_mutex_put(&ao_config_mutex);
+       ao_config_log_show();
+}
+#endif
+
 struct ao_config_var {
        __code char     *str;
        void            (*set)(void) __reentrant;
@@ -369,6 +396,10 @@ __code struct ao_config_var ao_config_vars[] = {
 #if HAS_EEPROM
        { "l <size>\0Flight log size in kB",
          ao_config_log_set,            ao_config_log_show },
+#endif
+#if HAS_IGNITE
+       { "i <0 dual, 1 apogee, 2 main>\0Set igniter mode",
+         ao_config_ignite_mode_set,    ao_config_ignite_mode_show },
 #endif
        { "s\0Show",
          ao_config_show,               ao_config_show },
index e1b91be..512ec62 100644 (file)
@@ -51,7 +51,7 @@ void
 ao_ignite(enum ao_igniter igniter) __critical
 {
        ao_ignition[igniter].request = 1;
-       ao_wakeup(&ao_ignition[0]);
+       ao_wakeup(&ao_ignition);
 }
 
 enum ao_igniter_status
@@ -91,16 +91,46 @@ void
 ao_igniter_fire(enum ao_igniter igniter) __critical
 {
        ao_ignition[igniter].firing = 1;
-       switch (igniter) {
-       case ao_igniter_drogue:
-               AO_IGNITER_DROGUE = 1;
-               ao_delay(AO_IGNITER_FIRE_TIME);
-               AO_IGNITER_DROGUE = 0;
+       switch(ao_config.ignite_mode) {
+       case AO_IGNITE_MODE_DUAL:
+               switch (igniter) {
+               case ao_igniter_drogue:
+                       AO_IGNITER_DROGUE = 1;
+                       ao_delay(AO_IGNITER_FIRE_TIME);
+                       AO_IGNITER_DROGUE = 0;
+                       break;
+               case ao_igniter_main:
+                       AO_IGNITER_MAIN = 1;
+                       ao_delay(AO_IGNITER_FIRE_TIME);
+                       AO_IGNITER_MAIN = 0;
+                       break;
+               }
                break;
-       case ao_igniter_main:
-               AO_IGNITER_MAIN = 1;
-               ao_delay(AO_IGNITER_FIRE_TIME);
-               AO_IGNITER_MAIN = 0;
+       case AO_IGNITE_MODE_APOGEE:
+               switch (igniter) {
+               case ao_igniter_drogue:
+                       AO_IGNITER_DROGUE = 1;
+                       ao_delay(AO_IGNITER_FIRE_TIME);
+                       AO_IGNITER_DROGUE = 0;
+                       ao_delay(AO_IGNITER_CHARGE_TIME);
+                       AO_IGNITER_MAIN = 1;
+                       ao_delay(AO_IGNITER_FIRE_TIME);
+                       AO_IGNITER_MAIN = 0;
+                       break;
+               }
+               break;
+       case AO_IGNITE_MODE_MAIN:
+               switch (igniter) {
+               case ao_igniter_main:
+                       AO_IGNITER_DROGUE = 1;
+                       ao_delay(AO_IGNITER_FIRE_TIME);
+                       AO_IGNITER_DROGUE = 0;
+                       ao_delay(AO_IGNITER_CHARGE_TIME);
+                       AO_IGNITER_MAIN = 1;
+                       ao_delay(AO_IGNITER_FIRE_TIME);
+                       AO_IGNITER_MAIN = 0;
+                       break;
+               }
                break;
        }
        ao_ignition[igniter].firing = 0;