Available on all products, plus config UI changes.
Signed-off-by: Keith Packard <keithp@keithp.com>
/* HAS_RADIO_10MW */
public int radio_10mw;
+ public int report_feet;
+
/* Storage info replies */
public int storage_size;
public int storage_erase_unit;
radio_10mw = AltosLib.MISSING;
+ report_feet = AltosLib.MISSING;
+
tracker_motion = AltosLib.MISSING;
tracker_interval = AltosLib.MISSING;
/* HAS_RADIO_10MW */
try { radio_10mw = get_int(line, "Radio 10mw limit:"); } catch (Exception e) {}
+ try { report_feet = get_int(line, "Report in feet:"); } catch (Exception e) {}
+
/* HAS_TRACKER */
try {
int[] values = get_values(line, "Tracker setting:");
if (radio_10mw != AltosLib.MISSING)
radio_10mw = source.radio_10mw();
+ if (report_feet != AltosLib.MISSING)
+ report_feet = source.report_feet();
+
/* HAS_TRACKER */
if (tracker_motion != AltosLib.MISSING)
tracker_motion = source.tracker_motion();
dest.set_aprs_offset(aprs_offset);
dest.set_beep(beep);
dest.set_radio_10mw(radio_10mw);
+ dest.set_report_feet(report_feet);
dest.set_tracker_motion(tracker_motion);
dest.set_tracker_interval(tracker_interval);
}
if (radio_10mw != AltosLib.MISSING)
link.printf("c p %d\n", radio_10mw);
+ /* HAS_RADIO_10MW */
+ if (report_feet != AltosLib.MISSING)
+ link.printf("c u %d\n", report_feet);
+
/* HAS_TRACKER */
if (tracker_motion != AltosLib.MISSING && tracker_interval != AltosLib.MISSING)
link.printf("c t %d %d\n", tracker_motion, tracker_interval);
public abstract int radio_10mw() throws AltosConfigDataException;
public abstract void set_radio_10mw(int radio_10mw);
+
+ public abstract int report_feet() throws AltosConfigDataException;
+
+ public abstract void set_report_feet(int radio_10mw);
}
JLabel radio_frequency_label;
JLabel radio_enable_label;
JLabel radio_10mw_label;
+ JLabel report_feet_label;
JLabel rate_label;
JLabel aprs_interval_label;
JLabel aprs_ssid_label;
JLabel radio_calibration_value;
JRadioButton radio_enable_value;
JRadioButton radio_10mw_value;
+ JComboBox<String> report_feet_value;
AltosUIRateList rate_value;
JComboBox<String> aprs_interval_value;
JComboBox<Integer> aprs_ssid_value;
"10"
};
+ static String[] report_feet_values = {
+ "Meters",
+ "Feet",
+ };
+
/* A window listener to catch closing events and tell the config code */
class ConfigListener extends WindowAdapter {
AltosConfigFCUI ui;
radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
}
+ void set_report_feet_tool_tip() {
+ if (report_feet_value.isVisible())
+ report_feet_value.setToolTipText("Units used after landing to beep max height");
+ else
+ report_feet_value.setToolTipText("Older firmware always beeps max height in meters");
+ }
+
/* Build the UI using a grid bag */
public AltosConfigFCUI(JFrame in_owner, boolean remote) {
super (in_owner, title, false);
set_radio_10mw_tool_tip();
row++;
+ /* Report feet */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ report_feet_label = new JLabel("Beep max height in:");
+ pane.add(report_feet_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ report_feet_value = new JComboBox<String>(report_feet_values);
+ report_feet_value.setEditable(false);
+ report_feet_value.addItemListener(this);
+ pane.add(report_feet_value, c);
+ set_report_feet_tool_tip();
+ row++;
+
/* Telemetry Rate */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;
return AltosLib.MISSING;
}
+ public void set_report_feet(int new_report_feet) {
+ if (new_report_feet != AltosLib.MISSING) {
+ if (new_report_feet >= report_feet_values.length)
+ new_report_feet = 0;
+ if (new_report_feet < 0) {
+ report_feet_value.setEnabled(false);
+ new_report_feet = 0;
+ } else {
+ report_feet_value.setEnabled(true);
+ }
+ report_feet_value.setSelectedIndex(new_report_feet);
+ }
+ report_feet_value.setVisible(new_report_feet != AltosLib.MISSING);
+ report_feet_label.setVisible(new_report_feet != AltosLib.MISSING);
+
+ set_report_feet_tool_tip();
+ }
+
+ public int report_feet() {
+ if (report_feet_value.isVisible())
+ return report_feet_value.getSelectedIndex();
+ else
+ return AltosLib.MISSING;
+ }
+
String[] tracker_motion_values() {
if (AltosConvert.imperial_units)
return tracker_motion_values_ft;
#define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP
#define AO_CONFIG_DEFAULT_PYRO_TIME AO_MS_TO_TICKS(50)
#define AO_CONFIG_DEFAULT_RADIO_10MW 0
+#define AO_CONFIG_DEFAULT_REPORT_FEET 0
#if HAS_CONFIG_SAVE
#ifndef USE_INTERNAL_FLASH
#error Please define USE_INTERNAL_FLASH
if (minor < 25)
ao_config.radio_10mw = AO_CONFIG_DEFAULT_RADIO_10MW;
#endif
+ if (minor < 26)
+ ao_config.report_feet = AO_CONFIG_DEFAULT_REPORT_FEET;
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
}
#endif
+static void
+ao_config_report_feet_show(void)
+{
+ printf ("Report in feet: %d\n", ao_config.report_feet);
+}
+
+static void
+ao_config_report_feet_set(void)
+{
+ uint32_t r = ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ _ao_config_edit_start();
+ ao_config.report_feet = !!r;
+ _ao_config_edit_finish();
+}
+
+
#if HAS_BEEP
static void
ao_config_beep_show(void)
{ "p <0 no limit, 1 limit>\0Limit radio power to 10mW",
ao_config_radio_10mw_set, ao_config_radio_10mw_show },
#endif
+ { "u <0 meters, 1 feet>\0Units to report height after landing",
+ ao_config_report_feet_set, ao_config_report_feet_show },
{ "s\0Show",
ao_config_show, 0 },
#if HAS_CONFIG_SAVE
#endif
#define AO_CONFIG_MAJOR 1
-#define AO_CONFIG_MINOR 25
+#define AO_CONFIG_MINOR 26
/* All cc1200 devices support limiting TX power to 10mW */
#if !defined(HAS_RADIO_10MW) && defined(AO_CC1200_SPI)
#if HAS_RADIO_10MW
uint8_t radio_10mw; /* minor version 25 */
#endif
+ uint8_t report_feet; /* minor version 26 */
};
struct ao_config_1_24 {
#endif /* AO_DATA_RING */
+#define AO_ALT_TYPE int32_t
+
+typedef AO_ALT_TYPE alt_t;
+
#if !HAS_BARO && HAS_MS5607
/* Either an MS5607 or an MS5611 hooked to a SPI port
typedef int32_t pres_t;
-#define AO_ALT_TYPE int32_t
-
-typedef AO_ALT_TYPE alt_t;
-
#define ao_data_pres_cook(packet) ao_ms5607_convert(&packet->ms5607_raw, &packet->ms5607_cooked)
#define ao_data_pres(packet) ((packet)->ms5607_cooked.pres)
}
static void
-ao_report_number(ao_v_t n)
+ao_report_number(int32_t n)
{
uint8_t digits[10];
uint8_t ndigits, i;
static void
ao_report_altitude(void)
{
- ao_report_number(ao_max_height);
+ alt_t max_h = ao_max_height;
+ if (ao_config.report_feet) {
+ max_h = max_h * 39 / 12;
+ /* report a leading zero to distinguish */
+ if (max_h)
+ ao_report_digit(0);
+ }
+ ao_report_number(max_h);
}
#if HAS_BATTERY_REPORT