int_ref radio_calibration;
int_ref flight_log_max;
int_ref ignite_mode;
+ int_ref pad_orientation;
string_ref version;
string_ref product;
string_ref callsign;
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_pad_orientation(pad_orientation.get());
config_ui.set_callsign(callsign.get());
config_ui.set_clean();
config_ui.make_visible();
void process_line(String line) {
if (line == null) {
- System.out.printf("timeout\n");
abort();
return;
}
if (line.equals("done")) {
- System.out.printf("done\n");
if (serial_line != null)
update_ui();
return;
get_int(line, "Radio cal:", radio_calibration);
get_int(line, "Max flight log:", flight_log_max);
get_int(line, "Ignite mode:", ignite_mode);
+ get_int(line, "Pad orientation:", pad_orientation);
get_string(line, "Callsign:", callsign);
get_string(line,"software-version", version);
get_string(line,"product", product);
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());
+ if (pad_orientation.get() >= 0)
+ serial_line.printf("c o %d\n", pad_orientation.get());
serial_line.printf("c w\n");
} catch (InterruptedException ie) {
} finally {
radio_calibration.set(config_ui.radio_calibration());
flight_log_max.set(config_ui.flight_log_max());
ignite_mode.set(config_ui.ignite_mode());
+ pad_orientation.set(config_ui.pad_orientation());
callsign.set(config_ui.callsign());
run_serial_thread(serial_mode_save);
}
radio_calibration = new int_ref(1186611);
flight_log_max = new int_ref(0);
ignite_mode = new int_ref(-1);
+ pad_orientation = new int_ref(-1);
callsign = new string_ref("N0CALL");
version = new string_ref("unknown");
product = new string_ref("unknown");
JLabel radio_calibration_label;
JLabel flight_log_max_label;
JLabel ignite_mode_label;
+ JLabel pad_orientation_label;
JLabel callsign_label;
public boolean dirty;
JTextField radio_calibration_value;
JComboBox flight_log_max_value;
JComboBox ignite_mode_value;
+ JComboBox pad_orientation_value;
JTextField callsign_value;
JButton save;
"Redundant Main",
};
+ static String[] pad_orientation_values = {
+ "Antenna Up",
+ "Antenna Down",
+ };
+
static String[] radio_channel_values = new String[10];
{
for (int i = 0; i <= 9; i++)
ignite_mode_value.addItemListener(this);
pane.add(ignite_mode_value, c);
- /* Buttons */
+ /* Pad orientation */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = 10;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ pad_orientation_label = new JLabel("Pad Orientation:");
+ pane.add(pad_orientation_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = 10;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ pad_orientation_value = new JComboBox(pad_orientation_values);
+ pad_orientation_value.setEditable(false);
+ pad_orientation_value.addItemListener(this);
+ pane.add(pad_orientation_value, c);
+
+ /* Buttons */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = 11;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_START;
save.setActionCommand("Save");
c = new GridBagConstraints();
- c.gridx = 2; c.gridy = 10;
+ c.gridx = 2; c.gridy = 11;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
reset.setActionCommand("Reset");
c = new GridBagConstraints();
- c.gridx = 4; c.gridy = 10;
+ c.gridx = 4; c.gridy = 11;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.CENTER;
reboot.setActionCommand("Reboot");
c = new GridBagConstraints();
- c.gridx = 6; c.gridy = 10;
+ c.gridx = 6; c.gridy = 11;
c.gridwidth = 2;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.LINE_END;
} else {
ignite_mode_value.setEnabled(true);
}
- ignite_mode_value.setSelectedItem(Integer.toString(new_ignite_mode));
+ ignite_mode_value.setSelectedIndex(new_ignite_mode);
}
public int ignite_mode() {
return ignite_mode_value.getSelectedIndex();
}
+
+ public void set_pad_orientation(int new_pad_orientation) {
+ if (new_pad_orientation < 0) {
+ pad_orientation_value.setEnabled(false);
+ new_pad_orientation = 0;
+ } else {
+ pad_orientation_value.setEnabled(true);
+ }
+ pad_orientation_value.setSelectedIndex(new_pad_orientation);
+ }
+
+ public int pad_orientation() {
+ return pad_orientation_value.getSelectedIndex();
+ }
+
public void set_clean() {
dirty = false;
}
abort = false;
timeout_started = false;
for (;;) {
- System.out.printf("timeout %d\n", timeout);
AltosLine line = reply_queue.poll(timeout, TimeUnit.MILLISECONDS);
if (line != null) {
stop_timeout_dialog();
*/
#define AO_CONFIG_MAJOR 1
-#define AO_CONFIG_MINOR 5
+#define AO_CONFIG_MINOR 6
struct ao_config {
uint8_t major;
uint32_t radio_cal; /* minor version 3 */
uint32_t flight_log_max; /* minor version 4 */
uint8_t ignite_mode; /* minor version 5 */
+ uint8_t pad_orientation; /* minor version 6 */
};
#define AO_IGNITE_MODE_DUAL 0
#define AO_IGNITE_MODE_APOGEE 1
#define AO_IGNITE_MODE_MAIN 2
+#define AO_PAD_ORIENTATION_ANTENNA_UP 0
+#define AO_PAD_ORIENTATION_ANTENNA_DOWN 1
+
extern __xdata struct ao_config ao_config;
#define AO_CONFIG_MAX_SIZE 128
#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
+#define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP
#if USE_INTERNAL_EEPROM
#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ao_storage_config
#else
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.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
ao_config_dirty = 1;
}
if (ao_config.minor < AO_CONFIG_MINOR) {
/* Fixupes for minor version 5 */
if (ao_config.minor < 5)
ao_config.ignite_mode = AO_CONFIG_DEFAULT_IGNITE_MODE;
+ if (ao_config.minor < 6)
+ ao_config.pad_orientation = AO_CONFIG_DEFAULT_PAD_ORIENTATION;
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
}
ao_config.ignite_mode = ao_cmd_lex_i;
ao_config_dirty = 1;
ao_mutex_put(&ao_config_mutex);
- ao_config_log_show();
+ ao_config_ignite_mode_show();
+}
+#endif
+
+#if HAS_IGNITE
+void
+ao_config_pad_orientation_show(void) __reentrant
+{
+ printf("Pad orientation: %d\n", ao_config.pad_orientation);
+}
+
+void
+ao_config_pad_orientation_set(void) __reentrant
+{
+ ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ ao_mutex_get(&ao_config_mutex);
+ _ao_config_get();
+ ao_cmd_lex_i &= 1;
+ if (ao_config.pad_orientation != ao_cmd_lex_i) {
+ uint16_t t;
+ t = ao_config.accel_plus_g;
+ ao_config.accel_plus_g = 0x7fff - ao_config.accel_minus_g;
+ ao_config.accel_minus_g = 0x7fff - t;
+ }
+ ao_config.pad_orientation = ao_cmd_lex_i;
+ ao_config_dirty = 1;
+ ao_mutex_put(&ao_config_mutex);
+ ao_config_pad_orientation_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
+#if HAS_ACCEL
+ { "o <0 antenna up, 1 antenna down>\0Set pad orientation",
+ ao_config_pad_orientation_set,ao_config_pad_orientation_show },
#endif
{ "s\0Show",
ao_config_show, ao_config_show },
uint16_t main_deploy;
int16_t accel_plus_g;
int16_t accel_minus_g;
+ uint8_t pad_orientation;
};
+#define AO_PAD_ORIENTATION_ANTENNA_UP 0
+#define AO_PAD_ORIENTATION_ANTENNA_DOWN 1
+
#define ao_config_get()
struct ao_config ao_config;
* just dropped a bit of noise off the low end.
*/
ao_sample_accel = (uint16_t) ((((uint32_t) ao_sample_accel << 16) / (ao_accel_ref[ao_sample_adc] << 1))) >> 1;
+ if (ao_config.pad_orientation != AO_PAD_ORIENTATION_ANTENNA_UP)
+ ao_sample_accel = 0x7fff - ao_sample_accel;
ao_adc->accel = ao_sample_accel;
#endif
#endif