From 110e4818b85781c33d683b7b7e7f2864a1223c5c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 5 Apr 2018 16:41:20 -0700 Subject: micropeak: Make reported 'max height' value show filtered max height MicroPeak tries to filter out bogus pressure data so that the value reported on the LED is reasonable. We want to report that same value in the UI, which means replacing the normal mechanism for computing max height from the time series of height data with the value computed from the saved minimum pressure value recorded in the device. Signed-off-by: Keith Packard --- altoslib/AltosFlightSeries.java | 9 +++++++++ altoslib/AltosFlightStats.java | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosFlightSeries.java b/altoslib/AltosFlightSeries.java index d130d3ad..182bdd19 100644 --- a/altoslib/AltosFlightSeries.java +++ b/altoslib/AltosFlightSeries.java @@ -257,6 +257,15 @@ public class AltosFlightSeries extends AltosDataListener { public AltosTimeSeries height_series; + public double max_height = AltosLib.MISSING; + + public void set_min_pressure(double pa) { + double ground_altitude = cal_data().ground_altitude; + if (ground_altitude != AltosLib.MISSING) + max_height = AltosConvert.pressure_to_altitude(pa) - + ground_altitude; + } + public static final String height_name = "Height"; public void set_pressure(double pa) { diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java index 6bb83581..2760321d 100644 --- a/altoslib/AltosFlightStats.java +++ b/altoslib/AltosFlightStats.java @@ -266,8 +266,8 @@ public class AltosFlightStats { } } - max_height = AltosLib.MISSING; - if (series.height_series != null) + max_height = series.max_height; + if (max_height == AltosLib.MISSING && series.height_series != null) max_height = series.height_series.max().value; max_gps_height = AltosLib.MISSING; if (series.gps_height != null) { -- cgit v1.2.3 From 57218127ee39724e985fefcf203991401f01cc84 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 22 Apr 2018 20:01:01 -0700 Subject: altoslib: Clarify terms in Mega pyro config Suggestions from Bob Brown et al Speed -> ascent rate Height -> height above ground Acceleration -> Vertical acceleration Signed-off-by: Keith Packard --- altoslib/AltosPyro.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 0ea3bfc1..18f0da56 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -29,24 +29,24 @@ public class AltosPyro { public static final int pyro_accel_greater = 0x00000002; public static final String pyro_accel_less_string = "a<"; public static final String pyro_accel_greater_string = "a>"; - public static final String pyro_accel_less_name = "Acceleration less than"; - public static final String pyro_accel_greater_name = "Acceleration greater than"; + public static final String pyro_accel_less_name = "Vertical acceleration less than"; + public static final String pyro_accel_greater_name = "Vertical acceleration greater than"; public static final double pyro_accel_scale = 16.0; public static final int pyro_speed_less = 0x00000004; public static final int pyro_speed_greater = 0x00000008; public static final String pyro_speed_less_string = "s<"; public static final String pyro_speed_greater_string = "s>"; - public static final String pyro_speed_less_name = "Speed less than"; - public static final String pyro_speed_greater_name = "Speed greater than"; + public static final String pyro_speed_less_name = "Ascent rate less than"; + public static final String pyro_speed_greater_name = "Ascent rate greater than"; public static final double pyro_speed_scale = 16.0; public static final int pyro_height_less = 0x00000010; public static final int pyro_height_greater = 0x00000020; public static final String pyro_height_less_string = "h<"; public static final String pyro_height_greater_string = "h>"; - public static final String pyro_height_less_name = "Height less than"; - public static final String pyro_height_greater_name = "Height greater than"; + public static final String pyro_height_less_name = "Height above pad less than"; + public static final String pyro_height_greater_name = "Height above pad greater than"; public static final double pyro_height_scale = 1.0; public static final int pyro_orient_less = 0x00000040; @@ -90,7 +90,10 @@ public class AltosPyro { public static final String pyro_state_greater_or_equal_name = "Flight state after"; public static final double pyro_state_scale = 1.0; + public static final int pyro_deprecate = pyro_ascending | pyro_descending; + public static final int pyro_all = 0x0000ffff; + public static final int pyro_all_useful = pyro_all ^ pyro_deprecate; public static final int pyro_no_value = (pyro_ascending | pyro_descending); -- cgit v1.2.3 From b3474fb33a58e78b3b8f36958dd44768e49f3edc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 25 Apr 2018 23:07:46 -0700 Subject: altoslib: Flush settings restoration commands after accel cal To avoid mangling settings when the user doesn't 'save' things, restore the original accel cal values and orientation after finishing accelerometer calibration. Signed-off-by: Keith Packard --- altoslib/AltosAccelCal.java | 1 + 1 file changed, 1 insertion(+) (limited to 'altoslib') diff --git a/altoslib/AltosAccelCal.java b/altoslib/AltosAccelCal.java index 03d9fbf2..75592d9e 100644 --- a/altoslib/AltosAccelCal.java +++ b/altoslib/AltosAccelCal.java @@ -183,6 +183,7 @@ public class AltosAccelCal implements Runnable { if (config_data.accel_cal_plus != AltosLib.MISSING && config_data.accel_cal_minus != AltosLib.MISSING) link.printf("c a %d %d\n", config_data.accel_cal_plus, config_data.accel_cal_minus); + link.flush_output(); stop_link(); } if (new_config != null) { -- cgit v1.2.3 From eee9f6128da146b0e9c711d49b2a3eb49a95aaf3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 26 Apr 2018 16:30:54 -0700 Subject: altoslib: Keep config data accel cal in antenna up form. Instead of letting the accel cal data live in whatever form it was fetched in, keep it in antenna up form and provide it in whatever orientation is necessary. This fixes bugs in changing pad configuration where the accel cal values from the old orientation would get used in the new orientation and wreck them. Signed-off-by: Keith Packard --- altoslib/AltosAccelCal.java | 20 ++++---- altoslib/AltosCalData.java | 2 +- altoslib/AltosConfigData.java | 105 +++++++++++++++++++++++++++++++++++++----- altoslib/AltosLib.java | 3 ++ 4 files changed, 107 insertions(+), 23 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosAccelCal.java b/altoslib/AltosAccelCal.java index 75592d9e..f98090ef 100644 --- a/altoslib/AltosAccelCal.java +++ b/altoslib/AltosAccelCal.java @@ -174,23 +174,23 @@ public class AltosAccelCal implements Runnable { if (worked) new_config = new AltosConfigData(link); } finally { + int plus = config_data.accel_cal_plus(config_data.pad_orientation); + int minus = config_data.accel_cal_minus(config_data.pad_orientation); System.out.printf("Restore orientation %d +g %d -g %d\n", config_data.pad_orientation, - config_data.accel_cal_plus, - config_data.accel_cal_minus); - if (config_data.pad_orientation != AltosLib.MISSING && config_data.pad_orientation != 0) + plus, minus); + if (config_data.pad_orientation != AltosLib.MISSING) link.printf("c o %d\n", config_data.pad_orientation); - if (config_data.accel_cal_plus != AltosLib.MISSING && config_data.accel_cal_minus != AltosLib.MISSING) - link.printf("c a %d %d\n", - config_data.accel_cal_plus, config_data.accel_cal_minus); + if (plus != AltosLib.MISSING && minus != AltosLib.MISSING) + link.printf("c a %d %d\n", plus, minus); link.flush_output(); stop_link(); } if (new_config != null) { - System.out.printf("*** +1g %d -1g %d\n", - new_config.accel_cal_plus, - new_config.accel_cal_minus); - listener.cal_done(this, new_config.accel_cal_plus, new_config.accel_cal_minus); + int plus = new_config.accel_cal_plus(AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP); + int minus = new_config.accel_cal_minus(AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP); + System.out.printf("*** +1g %d -1g %d\n", plus, minus); + listener.cal_done(this, plus, minus); if (!wait_signal()) throw new InterruptedException("aborted"); } else diff --git a/altoslib/AltosCalData.java b/altoslib/AltosCalData.java index 03e2cbd7..5bc6c4fd 100644 --- a/altoslib/AltosCalData.java +++ b/altoslib/AltosCalData.java @@ -397,7 +397,7 @@ public class AltosCalData { set_flight_params(config_data.apogee_delay / ticks_per_sec, config_data.apogee_lockout / ticks_per_sec); set_pad_orientation(config_data.pad_orientation); set_product(config_data.product); - set_accel_plus_minus(config_data.accel_cal_plus, config_data.accel_cal_minus); + set_accel_plus_minus(config_data.accel_cal_plus(config_data.pad_orientation), config_data.accel_cal_minus(config_data.pad_orientation)); set_accel_zero(config_data.accel_zero_along, config_data.accel_zero_across, config_data.accel_zero_through); set_ms5607(config_data.ms5607); try { diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index dc036867..35a8602d 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -52,7 +52,9 @@ public class AltosConfigData { public int radio_setting; /* HAS_ACCEL */ - public int accel_cal_plus, accel_cal_minus; + private int accel_cal_plus_raw, accel_cal_minus_raw; + private int accel_cal_plus_cooked, accel_cal_minus_cooked; + private boolean accel_cal_adjusted; public int pad_orientation; /* HAS_LOG */ @@ -186,6 +188,23 @@ public class AltosConfigData { } } + public int invert_accel_value(int value) { + if (value == AltosLib.MISSING) + return AltosLib.MISSING; + + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_FULL: + return 0x7fff - value; + case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: + case AltosLib.AO_LOG_FORMAT_TELEMETRUM: + case AltosLib.AO_LOG_FORMAT_TELEMEGA: + case AltosLib.AO_LOG_FORMAT_TELEMEGA_3: + return 4095 - value; + default: + return AltosLib.MISSING; + } + } + public boolean has_monitor_battery() { if (product.startsWith("TeleBT")) return true; @@ -252,9 +271,12 @@ public class AltosConfigData { radio_setting = AltosLib.MISSING; telemetry_rate = AltosLib.MISSING; - accel_cal_plus = AltosLib.MISSING; - accel_cal_minus = AltosLib.MISSING; + accel_cal_plus_cooked = AltosLib.MISSING; + accel_cal_minus_cooked = AltosLib.MISSING; + accel_cal_plus_raw = AltosLib.MISSING; + accel_cal_minus_raw = AltosLib.MISSING; pad_orientation = AltosLib.MISSING; + accel_cal_adjusted = false; flight_log_max = AltosLib.MISSING; log_fixed = AltosLib.MISSING; @@ -285,6 +307,57 @@ public class AltosConfigData { accel_zero_through = AltosLib.MISSING; } + /* Return + accel calibration relative to a specific pad orientation */ + public int accel_cal_plus(int pad_orientation) { + switch (pad_orientation) { + case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: + return accel_cal_plus_cooked; + case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN: + return invert_accel_value(accel_cal_minus_cooked); + default: + return AltosLib.MISSING; + } + } + + /* Return - accel calibration relative to a specific pad orientation */ + public int accel_cal_minus(int pad_orientation) { + switch (pad_orientation) { + case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: + return accel_cal_minus_cooked; + case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN: + return invert_accel_value(accel_cal_plus_cooked); + default: + return AltosLib.MISSING; + } + } + + /* Once we have all of the values from the config data, compute the + * accel cal values relative to Antenna Up orientation. + */ + private void adjust_accel_cal() { + if (!accel_cal_adjusted && + pad_orientation != AltosLib.MISSING && + accel_cal_plus_raw != AltosLib.MISSING && + accel_cal_minus_raw != AltosLib.MISSING && + log_format != AltosLib.AO_LOG_FORMAT_UNKNOWN) + { + switch (pad_orientation) { + case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: + accel_cal_plus_cooked = accel_cal_plus_raw; + accel_cal_minus_cooked = accel_cal_minus_raw; + accel_cal_adjusted = true; + break; + case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN: + accel_cal_plus_cooked = invert_accel_value(accel_cal_minus_raw); + accel_cal_minus_cooked = invert_accel_value(accel_cal_plus_raw); + accel_cal_adjusted = true; + break; + default: + break; + } + } + } + public void parse_line(String line) { /* Version replies */ @@ -349,8 +422,9 @@ public class AltosConfigData { if (line.startsWith("Accel cal")) { String[] bits = line.split("\\s+"); if (bits.length >= 6) { - accel_cal_plus = Integer.parseInt(bits[3]); - accel_cal_minus = Integer.parseInt(bits[5]); + accel_cal_plus_raw = Integer.parseInt(bits[3]); + accel_cal_minus_raw = Integer.parseInt(bits[5]); + accel_cal_adjusted = false; } } } catch (Exception e) {} @@ -414,6 +488,9 @@ public class AltosConfigData { } } } catch (Exception e) {} + + /* Fix accel cal as soon as all of the necessary values appear */ + adjust_accel_cal(); } public AltosConfigData() { @@ -525,11 +602,11 @@ public class AltosConfigData { if (pad_orientation != AltosLib.MISSING) pad_orientation = source.pad_orientation(); - if (accel_cal_plus != AltosLib.MISSING) - accel_cal_plus = source.accel_cal_plus(); + if (accel_cal_plus_cooked != AltosLib.MISSING) + accel_cal_plus_cooked = source.accel_cal_plus(); - if (accel_cal_minus != AltosLib.MISSING) - accel_cal_minus = source.accel_cal_minus(); + if (accel_cal_minus_cooked != AltosLib.MISSING) + accel_cal_minus_cooked = source.accel_cal_minus(); /* HAS_LOG */ if (flight_log_max != AltosLib.MISSING) @@ -598,7 +675,8 @@ public class AltosConfigData { dest.set_flight_log_max(flight_log_max); dest.set_ignite_mode(ignite_mode); dest.set_pad_orientation(pad_orientation); - dest.set_accel_cal(accel_cal_plus, accel_cal_minus); + dest.set_accel_cal(accel_cal_plus(AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP), + accel_cal_minus(AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP)); dest.set_callsign(callsign); if (npyro != AltosLib.MISSING) dest.set_pyros(pyros); @@ -676,10 +754,13 @@ public class AltosConfigData { link.printf("c e %d\n", radio_enable); /* HAS_ACCEL */ + /* set orientation first so that we know how to set the accel cal */ if (pad_orientation != AltosLib.MISSING) link.printf("c o %d\n", pad_orientation); - if (accel_cal_plus != AltosLib.MISSING && accel_cal_minus != AltosLib.MISSING) - link.printf("c a %d %d\n", accel_cal_plus, accel_cal_minus); + int plus = accel_cal_plus(pad_orientation); + int minus = accel_cal_minus(pad_orientation); + if (plus != AltosLib.MISSING && minus != AltosLib.MISSING) + link.printf("c a %d %d\n", plus, minus); /* HAS_LOG */ if (flight_log_max != 0) diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index c25a6273..7d2b68e0 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -348,6 +348,9 @@ public class AltosLib { public static final int AO_GPS_NUM_SAT_SHIFT = 0; public static final int AO_GPS_NUM_SAT_MASK = 0xf; + public static final int AO_PAD_ORIENTATION_ANTENNA_UP = 0; + public static final int AO_PAD_ORIENTATION_ANTENNA_DOWN = 1; + public static final int AO_LOG_FORMAT_UNKNOWN = 0; public static final int AO_LOG_FORMAT_FULL = 1; public static final int AO_LOG_FORMAT_TINY = 2; -- cgit v1.2.3 From 8612c1287a1c458a17f33af1d679d30a13dea772 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 26 Apr 2018 17:24:51 -0700 Subject: altoslib: Fix data fetching during flashing of cc1111-based devices We want to get enough information about the target device to verify that the new firmware matches, so fetch 512 bytes instead of just barely enough to cover the romconfig data. Also catch out-of-bounds accesses and handle them, in case even this large array isn't enough. Signed-off-by: Keith Packard --- altoslib/AltosDebug.java | 4 ++-- altoslib/AltosHexfile.java | 20 ++++++++++++-------- altoslib/AltosRomconfig.java | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosDebug.java b/altoslib/AltosDebug.java index 24a25933..a44eb12f 100644 --- a/altoslib/AltosDebug.java +++ b/altoslib/AltosDebug.java @@ -264,8 +264,8 @@ public class AltosDebug { public AltosRomconfig romconfig() throws InterruptedException { try { - byte[] bytes = read_memory(0xa0, 10); - AltosHexfile hexfile = new AltosHexfile (bytes, 0xa0); + byte[] bytes = read_memory(0x00, 0x200); + AltosHexfile hexfile = new AltosHexfile (bytes, 0x00); return new AltosRomconfig(hexfile); } catch (IOException ie) { } diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 6aa98383..f2ab4bea 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -294,15 +294,19 @@ public class AltosHexfile { if (usb_descriptors == null) return -1; - /* Walk the descriptors looking for the device */ - a = usb_descriptors.address; - while (get_u8(a+1) != AO_USB_DESC_DEVICE) { - int delta = get_u8(a); - a += delta; - if (delta == 0 || a >= max_address) - return -1; + try { + /* Walk the descriptors looking for the device */ + a = usb_descriptors.address; + while (get_u8(a+1) != AO_USB_DESC_DEVICE) { + int delta = get_u8(a); + a += delta; + if (delta == 0 || a >= max_address) + return -1; + } + return a; + } catch (ArrayIndexOutOfBoundsException ae) { + return -1; } - return a; } public AltosUsbId find_usb_id() { diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index 1fbb4115..44a3fa60 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -35,12 +35,12 @@ public class AltosRomconfig { System.out.printf("no symbol %s\n", name); throw new AltosNoSymbol(name); } - if (hexfile.address <= symbol.address && symbol.address + len < hexfile.max_address) { + if (hexfile.address <= symbol.address && symbol.address + len <= hexfile.max_address) { System.out.printf("%s: %x\n", name, symbol.address); return symbol.address; } - System.out.printf("invalid symbol addr %x range is %x - %x\n", - symbol.address, hexfile.address, hexfile.max_address); + System.out.printf("invalid symbol addr %x len %d range is %x - %x\n", + symbol.address, len, hexfile.address, hexfile.max_address); throw new AltosNoSymbol(name); } -- cgit v1.2.3 From 312f303be7f2a641020903ed2daccb8a4d67ec42 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 28 Apr 2018 12:03:10 -0700 Subject: altoslib: Fix Idle Monitor on TeleMega v3 The new IMU includes a mag sensor, and there's no separate mag sensor. Add support for reading the mag sensor values from the IMU, separate out v3 from previous TeleMega versions so that the code can stop trying to read the mag sensor. Signed-off-by: Keith Packard --- altoslib/AltosIMU.java | 35 +++++++++++++++++++++++++++++------ altoslib/AltosIdleFetch.java | 20 +++++++++++++++++++- 2 files changed, 48 insertions(+), 7 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index ba6f1a82..df81c9dd 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -22,13 +22,17 @@ import java.util.concurrent.*; import java.io.*; public class AltosIMU implements Cloneable { - public int accel_x; - public int accel_y; - public int accel_z; + public int accel_x = AltosLib.MISSING; + public int accel_y = AltosLib.MISSING; + public int accel_z = AltosLib.MISSING; - public int gyro_x; - public int gyro_y; - public int gyro_z; + public int gyro_x = AltosLib.MISSING; + public int gyro_y = AltosLib.MISSING; + public int gyro_z = AltosLib.MISSING; + + public int mag_x = AltosLib.MISSING; + public int mag_y = AltosLib.MISSING; + public int mag_z = AltosLib.MISSING; public static final double counts_per_g = 2048.0; @@ -58,6 +62,11 @@ public class AltosIMU implements Cloneable { gyro_y = Integer.parseInt(items[6]); gyro_z = Integer.parseInt(items[7]); } + if (items.length >= 12) { + mag_x = Integer.parseInt(items[9]); + mag_y = Integer.parseInt(items[10]); + mag_z = Integer.parseInt(items[11]); + } return true; } @@ -71,6 +80,11 @@ public class AltosIMU implements Cloneable { n.gyro_x = gyro_x; n.gyro_y = gyro_y; n.gyro_z = gyro_z; + + n.mag_x = mag_x; + n.mag_y = mag_y; + n.mag_z = mag_z; + return n; } @@ -86,6 +100,11 @@ public class AltosIMU implements Cloneable { listener.set_accel_ground(imu.accel_y, imu.accel_x, imu.accel_z); + if (imu.mag_x != AltosLib.MISSING) { + listener.set_mag(cal_data.mag_along(imu.mag_y), + cal_data.mag_across(imu.mag_x), + cal_data.mag_through(imu.mag_z)); + } } } catch (TimeoutException te) { } @@ -99,6 +118,10 @@ public class AltosIMU implements Cloneable { gyro_x = AltosLib.MISSING; gyro_y = AltosLib.MISSING; gyro_z = AltosLib.MISSING; + + mag_x = AltosLib.MISSING; + mag_y = AltosLib.MISSING; + mag_z = AltosLib.MISSING; } public AltosIMU(AltosLink link) throws InterruptedException, TimeoutException { diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 058df0a1..88a5dab4 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -133,12 +133,30 @@ public class AltosIdleFetch implements AltosDataProvider { AltosIdler.idle_ms5607, AltosIdler.idle_sensor_metrum), - new AltosIdler("TeleMega", + new AltosIdler("TeleMega-v0", AltosIdler.idle_gps, AltosIdler.idle_mma655x, AltosIdler.idle_ms5607, AltosIdler.idle_imu, AltosIdler.idle_mag, AltosIdler.idle_sensor_mega), + new AltosIdler("TeleMega-v1", + AltosIdler.idle_gps, + AltosIdler.idle_mma655x, + AltosIdler.idle_ms5607, + AltosIdler.idle_imu, AltosIdler.idle_mag, + AltosIdler.idle_sensor_mega), + new AltosIdler("TeleMega-v2", + AltosIdler.idle_gps, + AltosIdler.idle_mma655x, + AltosIdler.idle_ms5607, + AltosIdler.idle_imu, AltosIdler.idle_mag, + AltosIdler.idle_sensor_mega), + new AltosIdler("TeleMega-v3", + AltosIdler.idle_gps, + AltosIdler.idle_mma655x, + AltosIdler.idle_ms5607, + AltosIdler.idle_imu, + AltosIdler.idle_sensor_mega), new AltosIdler("EasyMega", AltosIdler.idle_mma655x, AltosIdler.idle_ms5607, -- cgit v1.2.3 From 82ed4f5c45b1a9f114577a59fac546c81d69f810 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 30 May 2018 11:38:24 -0700 Subject: altoslib: Revert field name changes for accel cal values These names get written in the JSON part of all .eeprom files, so we can't change the names or the values won't be read and written correctly. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 35a8602d..8d0bb479 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -22,6 +22,7 @@ import java.util.*; import java.text.*; import java.util.concurrent.*; +/* Don't change the field names in this structure; they're part of all .eeprom files */ public class AltosConfigData { /* Version information */ @@ -52,7 +53,7 @@ public class AltosConfigData { public int radio_setting; /* HAS_ACCEL */ - private int accel_cal_plus_raw, accel_cal_minus_raw; + public int accel_cal_plus, accel_cal_minus; private int accel_cal_plus_cooked, accel_cal_minus_cooked; private boolean accel_cal_adjusted; public int pad_orientation; @@ -273,8 +274,8 @@ public class AltosConfigData { accel_cal_plus_cooked = AltosLib.MISSING; accel_cal_minus_cooked = AltosLib.MISSING; - accel_cal_plus_raw = AltosLib.MISSING; - accel_cal_minus_raw = AltosLib.MISSING; + accel_cal_plus = AltosLib.MISSING; + accel_cal_minus = AltosLib.MISSING; pad_orientation = AltosLib.MISSING; accel_cal_adjusted = false; @@ -309,6 +310,7 @@ public class AltosConfigData { /* Return + accel calibration relative to a specific pad orientation */ public int accel_cal_plus(int pad_orientation) { + adjust_accel_cal(); switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: return accel_cal_plus_cooked; @@ -321,6 +323,7 @@ public class AltosConfigData { /* Return - accel calibration relative to a specific pad orientation */ public int accel_cal_minus(int pad_orientation) { + adjust_accel_cal(); switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: return accel_cal_minus_cooked; @@ -337,19 +340,19 @@ public class AltosConfigData { private void adjust_accel_cal() { if (!accel_cal_adjusted && pad_orientation != AltosLib.MISSING && - accel_cal_plus_raw != AltosLib.MISSING && - accel_cal_minus_raw != AltosLib.MISSING && + accel_cal_plus != AltosLib.MISSING && + accel_cal_minus != AltosLib.MISSING && log_format != AltosLib.AO_LOG_FORMAT_UNKNOWN) { switch (pad_orientation) { case AltosLib.AO_PAD_ORIENTATION_ANTENNA_UP: - accel_cal_plus_cooked = accel_cal_plus_raw; - accel_cal_minus_cooked = accel_cal_minus_raw; + accel_cal_plus_cooked = accel_cal_plus; + accel_cal_minus_cooked = accel_cal_minus; accel_cal_adjusted = true; break; case AltosLib.AO_PAD_ORIENTATION_ANTENNA_DOWN: - accel_cal_plus_cooked = invert_accel_value(accel_cal_minus_raw); - accel_cal_minus_cooked = invert_accel_value(accel_cal_plus_raw); + accel_cal_plus_cooked = invert_accel_value(accel_cal_minus); + accel_cal_minus_cooked = invert_accel_value(accel_cal_plus); accel_cal_adjusted = true; break; default: @@ -422,8 +425,8 @@ public class AltosConfigData { if (line.startsWith("Accel cal")) { String[] bits = line.split("\\s+"); if (bits.length >= 6) { - accel_cal_plus_raw = Integer.parseInt(bits[3]); - accel_cal_minus_raw = Integer.parseInt(bits[5]); + accel_cal_plus = Integer.parseInt(bits[3]); + accel_cal_minus = Integer.parseInt(bits[5]); accel_cal_adjusted = false; } } -- cgit v1.2.3 From 08e7fdb9f2db4b54279c0c5b18735aa1d5abc19e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 4 Jul 2018 20:25:58 -0700 Subject: altoslib: Make stop_remote delay depend on the data rate It takes longer to flush commands at 2400 baud, so wait longer when disabling remote mode. Signed-off-by: Keith Packard --- altoslib/AltosLink.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 829a1a63..3ad34891 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -339,9 +339,22 @@ public abstract class AltosLink implements Runnable { public void flush_input() throws InterruptedException { - if (remote) - flush_input(500); - else + if (remote) { + int timeout = 500; + switch (telemetry_rate) { + case AltosLib.ao_telemetry_rate_38400: + default: + timeout = 500; + break; + case AltosLib.ao_telemetry_rate_9600: + timeout = 1000; + break; + case AltosLib.ao_telemetry_rate_2400: + timeout = 2000; + break; + } + flush_input(timeout); + } else flush_input(100); } -- cgit v1.2.3 From 0d57c78dde3c6e61576a4769b0e0fae7e88c107d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 5 Aug 2018 11:09:34 +0800 Subject: altos: Add separate 'ao_launch_tick'. Use in pyro and lockout. Prior to this, there was only ao_boost_tick, which got reset at each motor burn start. That meant there wasn't any way to measure total flight time for pyro channels and 'apogee lockout' was based on time since most recent motor start instead of total flight time. Now pyro channels and apogee lockout both use total flight time, while motor burn length still uses time since most recent motor burn start (as it should). Docs and UI updated to use 'launch' instead of 'boost' to try and make the change clear. Signed-off-by: Keith Packard --- altoslib/AltosPyro.java | 4 ++-- altosui/AltosConfigFCUI.java | 2 +- doc/config-device.inc | 8 +++++++- doc/pyro-channels.inc | 10 +++++++--- src/kernel/ao_flight.c | 7 ++++--- src/kernel/ao_flight.h | 1 + src/kernel/ao_pyro.c | 8 ++++---- 7 files changed, 26 insertions(+), 14 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 18f0da56..fea4fd59 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -61,8 +61,8 @@ public class AltosPyro { public static final int pyro_time_greater = 0x00000200; public static final String pyro_time_less_string = "t<"; public static final String pyro_time_greater_string = "t>"; - public static final String pyro_time_less_name = "Time since boost less than (s)"; - public static final String pyro_time_greater_name = "Time since boost greater than (s)"; + public static final String pyro_time_less_name = "Time since launch less than (s)"; + public static final String pyro_time_greater_name = "Time since launch greater than (s)"; public static final double pyro_time_scale = 100.0; public static final int pyro_ascending = 0x00000400; diff --git a/altosui/AltosConfigFCUI.java b/altosui/AltosConfigFCUI.java index 1e875dec..9bd265f0 100644 --- a/altosui/AltosConfigFCUI.java +++ b/altosui/AltosConfigFCUI.java @@ -440,7 +440,7 @@ public class AltosConfigFCUI apogee_lockout_value.setEditable(true); apogee_lockout_value.addItemListener(this); pane.add(apogee_lockout_value, c); - apogee_lockout_value.setToolTipText("Time after boost while apogee detection is locked out"); + apogee_lockout_value.setToolTipText("Time after launch while apogee detection is locked out"); row++; /* Frequency */ diff --git a/doc/config-device.inc b/doc/config-device.inc index 99d5c008..0ca6afff 100644 --- a/doc/config-device.inc +++ b/doc/config-device.inc @@ -23,7 +23,7 @@ ifdef::altusmetrum[] ==== Apogee Lockout - Apogee lockout is the number of seconds after boost + Apogee lockout is the number of seconds after launch where the flight computer will not fire the apogee charge, even if the rocket appears to be at apogee. This is often called 'Mach Delay', as it is @@ -35,6 +35,12 @@ ifdef::altusmetrum[] pressure increase, and so this setting should be left at the default value of zero to disable it. + [WARNING] + Firmware versions older than 1.8.6 have a + bug which resets the time since launch to zero each + time a motor starts burning. Update firmware to get + the correct behavior. + endif::altusmetrum[] ifdef::radio[] diff --git a/doc/pyro-channels.inc b/doc/pyro-channels.inc index 68bbf910..ab5baef0 100644 --- a/doc/pyro-channels.inc +++ b/doc/pyro-channels.inc @@ -42,9 +42,13 @@ launch pad and initialize the system. of less than that value. ==== -Flight Time:: Time since boost was detected. Select a value and choose -whether to activate the pyro channel before or after that amount of -time. +Flight Time:: Time since launch. Select a value and choose whether to +activate the pyro channel before or after that amount of time. + +[WARNING] +Firmware versions older than 1.8.6 have a bug which resets the time +since launch to zero each time a motor starts burning. Update firmware +to get the correct behavior. Ascending:: A deprecated configuration value which was the same as setting Ascent rate > 0. Existing configurations using this will be diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index 7b3cb9fa..c2700d20 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -48,7 +48,8 @@ /* Main flight thread. */ __pdata enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint16_t ao_boost_tick; /* time of launch detect */ +__pdata uint16_t ao_boost_tick; /* time of most recent boost detect */ +__pdata uint16_t ao_launch_tick; /* time of first boost detect */ __pdata uint16_t ao_motor_number; /* number of motors burned so far */ #if HAS_SENSOR_ERRORS @@ -199,7 +200,7 @@ ao_flight(void) ) { ao_flight_state = ao_flight_boost; - ao_boost_tick = ao_sample_tick; + ao_launch_tick = ao_boost_tick = ao_sample_tick; /* start logging data */ ao_log_start(); @@ -269,7 +270,7 @@ ao_flight(void) * number of seconds. */ if (ao_config.apogee_lockout) { - if ((int16_t) (ao_sample_tick - ao_boost_tick) < + if ((int16_t) (ao_sample_tick - ao_launch_tick) < AO_SEC_TO_TICKS(ao_config.apogee_lockout)) break; } diff --git a/src/kernel/ao_flight.h b/src/kernel/ao_flight.h index 6894fe59..005c7e84 100644 --- a/src/kernel/ao_flight.h +++ b/src/kernel/ao_flight.h @@ -40,6 +40,7 @@ enum ao_flight_state { extern __pdata enum ao_flight_state ao_flight_state; extern __pdata uint16_t ao_boost_tick; +extern __pdata uint16_t ao_launch_tick; extern __pdata uint16_t ao_motor_number; #if HAS_IMU || HAS_MMA655X diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 3c872354..527112ac 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -160,14 +160,14 @@ ao_pyro_ready(struct ao_pyro *pyro) #endif case ao_pyro_time_less: - if ((int16_t) (ao_time() - ao_boost_tick) <= pyro->time_less) + if ((int16_t) (ao_time() - ao_launch_tick) <= pyro->time_less) continue; - DBG("time %d > %d\n", (int16_t)(ao_time() - ao_boost_tick), pyro->time_less); + DBG("time %d > %d\n", (int16_t)(ao_time() - ao_launch_tick), pyro->time_less); break; case ao_pyro_time_greater: - if ((int16_t) (ao_time() - ao_boost_tick) >= pyro->time_greater) + if ((int16_t) (ao_time() - ao_launch_tick) >= pyro->time_greater) continue; - DBG("time %d < %d\n", (int16_t)(ao_time() - ao_boost_tick), pyro->time_greater); + DBG("time %d < %d\n", (int16_t)(ao_time() - ao_launch_tick), pyro->time_greater); break; case ao_pyro_ascending: -- cgit v1.2.3