From c8078d352a7f54a4a97d25af080155d3f875536a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 16 Jun 2014 22:49:34 -0700 Subject: java: Bump java library versions for next release Prepare for future release by bumping java versions now Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index e1043958..d8b0b081 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_4; +package org.altusmetrum.altoslib_5; import java.util.*; import java.text.*; -- cgit v1.2.3 From 6cc2d671c0e335fbedb0e97699f8f273502c6807 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 22 Jun 2014 21:06:24 -0700 Subject: altosui/telegps: Expose configurable APRS SSID Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 8 +++++++ altoslib/AltosConfigValues.java | 4 ++++ altosui/AltosConfigUI.java | 53 +++++++++++++++++++++++++++++++++++++++++ telegps/TeleGPSConfigUI.java | 53 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index d8b0b081..3bf8ea43 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -71,6 +71,7 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ public int aprs_interval; + public int aprs_ssid; /* HAS_BEEP */ public int beep; @@ -250,6 +251,7 @@ public class AltosConfigData implements Iterable { pyro_firing_time = -1; aprs_interval = -1; + aprs_ssid = -1; beep = -1; @@ -333,6 +335,7 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} + try { aprs_ssid = get_int(line, "APRS SSID:"); } catch (Exception e) {} /* HAS_BEEP */ try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {} @@ -459,6 +462,8 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ if (aprs_interval >= 0) aprs_interval = source.aprs_interval(); + if (aprs_ssid >= 0) + aprs_ssid = source.aprs_ssid(); /* HAS_BEEP */ if (beep >= 0) @@ -507,6 +512,7 @@ public class AltosConfigData implements Iterable { dest.set_pyros(null); dest.set_pyro_firing_time(pyro_firing_time); dest.set_aprs_interval(aprs_interval); + dest.set_aprs_ssid(aprs_ssid); dest.set_beep(beep); dest.set_tracker_motion(tracker_motion); dest.set_tracker_interval(tracker_interval); @@ -577,6 +583,8 @@ public class AltosConfigData implements Iterable { /* HAS_APRS */ if (aprs_interval >= 0) link.printf("c A %d\n", aprs_interval); + if (aprs_ssid >= 0) + link.printf("c S %d\n", aprs_ssid); /* HAS_BEEP */ if (beep >= 0) diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index dcb4d48f..b0c49e98 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -81,6 +81,10 @@ public interface AltosConfigValues { public abstract void set_aprs_interval(int new_aprs_interval); + public abstract int aprs_ssid() throws AltosConfigDataException; + + public abstract void set_aprs_ssid(int new_aprs_ssid); + public abstract int beep() throws AltosConfigDataException; public abstract void set_beep(int new_beep); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index a4e7aca6..6e1b47c2 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -41,6 +41,7 @@ public class AltosConfigUI JLabel radio_frequency_label; JLabel radio_enable_label; JLabel aprs_interval_label; + JLabel aprs_ssid_label; JLabel flight_log_max_label; JLabel ignite_mode_label; JLabel pad_orientation_label; @@ -62,6 +63,7 @@ public class AltosConfigUI JTextField radio_calibration_value; JRadioButton radio_enable_value; JComboBox aprs_interval_value; + JComboBox aprs_ssid_value; JComboBox flight_log_max_value; JComboBox ignite_mode_value; JComboBox pad_orientation_value; @@ -113,6 +115,10 @@ public class AltosConfigUI "10" }; + static Integer[] aprs_ssid_values = { + 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + }; + static String[] beep_values = { "3750", "4000", @@ -201,6 +207,15 @@ public class AltosConfigUI aprs_interval_value.setToolTipText("Hardware doesn't support APRS"); } + void set_aprs_ssid_tool_tip() { + if (aprs_ssid_value.isEnabled()) + aprs_interval_value.setToolTipText("Set the APRS SSID (secondary station identifier)"); + else if (aprs_interval_value.isEnabled()) + aprs_interval_value.setToolTipText("Software version doesn't support setting the APRS SSID"); + else + aprs_interval_value.setToolTipText("Hardware doesn't support APRS"); + } + void set_flight_log_max_tool_tip() { if (flight_log_max_value.isEnabled()) flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)"); @@ -504,6 +519,33 @@ public class AltosConfigUI set_aprs_interval_tool_tip(); row++; + /* APRS SSID */ + 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; + aprs_ssid_label = new JLabel("APRS SSID:"); + pane.add(aprs_ssid_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; + aprs_ssid_value = new JComboBox(aprs_ssid_values); + aprs_ssid_value.setEditable(false); + aprs_ssid_value.addItemListener(this); + aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length); + pane.add(aprs_ssid_value, c); + set_aprs_ssid_tool_tip(); + row++; + /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -1180,4 +1222,15 @@ public class AltosConfigUI return 0; return parse_int("aprs interval", s, false); } + + public void set_aprs_ssid(int new_aprs_ssid) { + aprs_ssid_value.setSelectedItem(Math.max(0,new_aprs_ssid)); + aprs_ssid_value.setVisible(new_aprs_ssid >= 0); + set_aprs_ssid_tool_tip(); + } + + public int aprs_ssid() throws AltosConfigDataException { + Integer i = (Integer) aprs_ssid_value.getSelectedItem(); + return i; + } } diff --git a/telegps/TeleGPSConfigUI.java b/telegps/TeleGPSConfigUI.java index dfbff12d..1fdfd70c 100644 --- a/telegps/TeleGPSConfigUI.java +++ b/telegps/TeleGPSConfigUI.java @@ -38,6 +38,7 @@ public class TeleGPSConfigUI JLabel radio_frequency_label; JLabel radio_enable_label; JLabel aprs_interval_label; + JLabel aprs_ssid_label; JLabel flight_log_max_label; JLabel callsign_label; JLabel tracker_motion_label; @@ -53,6 +54,7 @@ public class TeleGPSConfigUI JTextField radio_calibration_value; JRadioButton radio_enable_value; JComboBox aprs_interval_value; + JComboBox aprs_ssid_value; JComboBox flight_log_max_value; JTextField callsign_value; JComboBox tracker_motion_value; @@ -72,6 +74,10 @@ public class TeleGPSConfigUI "10" }; + static Integer[] aprs_ssid_values = { + 0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 + }; + static String[] tracker_motion_values_m = { "2", "5", @@ -148,6 +154,15 @@ public class TeleGPSConfigUI aprs_interval_value.setToolTipText("Hardware doesn't support APRS"); } + void set_aprs_ssid_tool_tip() { + if (aprs_ssid_value.isEnabled()) + aprs_interval_value.setToolTipText("Set the APRS SSID (secondary station identifier)"); + else if (aprs_interval_value.isEnabled()) + aprs_interval_value.setToolTipText("Software version doesn't support setting the APRS SSID"); + else + aprs_interval_value.setToolTipText("Hardware doesn't support APRS"); + } + void set_flight_log_max_tool_tip() { if (flight_log_max_value.isEnabled()) flight_log_max_value.setToolTipText("Size reserved for each flight log (in kB)"); @@ -341,6 +356,33 @@ public class TeleGPSConfigUI set_aprs_interval_tool_tip(); row++; + /* APRS SSID */ + 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; + aprs_ssid_label = new JLabel("APRS SSID:"); + pane.add(aprs_ssid_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; + aprs_ssid_value = new JComboBox(aprs_ssid_values); + aprs_ssid_value.setEditable(false); + aprs_ssid_value.addItemListener(this); + aprs_ssid_value.setMaximumRowCount(aprs_ssid_values.length); + pane.add(aprs_ssid_value, c); + set_aprs_ssid_tool_tip(); + row++; + /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -786,4 +828,15 @@ public class TeleGPSConfigUI return 0; return parse_int("aprs interval", s, false); } + + public void set_aprs_ssid(int new_aprs_ssid) { + aprs_ssid_value.setSelectedItem(Math.max(0,new_aprs_ssid)); + aprs_ssid_value.setVisible(new_aprs_ssid >= 0); + set_aprs_ssid_tool_tip(); + } + + public int aprs_ssid() throws AltosConfigDataException { + Integer i = (Integer) aprs_ssid_value.getSelectedItem(); + return i; + } } -- cgit v1.2.3 From 55e6558fa7cb23fb1363a86c83fbd6abf67ea324 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 2 Jul 2014 22:48:13 -0700 Subject: altoslib: Support multiple telemetry rates Altos now supports 2400 and 9600 baud in addition to the classic 38400 baud rate. Add support to altoslib for these as well Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 9 +++++++ altoslib/AltosConfigValues.java | 4 ++++ altoslib/AltosFlightReader.java | 6 +++++ altoslib/AltosLib.java | 9 +++++++ altoslib/AltosLink.java | 14 ++++++++++- altoslib/AltosPreferences.java | 48 ++++++++++++++++++++++++++++++++++++++ altoslib/AltosTelemetryReader.java | 29 +++++++++++++++++++++++ 7 files changed, 118 insertions(+), 1 deletion(-) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 3bf8ea43..847436cd 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -46,6 +46,7 @@ public class AltosConfigData implements Iterable { public String callsign; public int radio_enable; public int radio_calibration; + public int telemetry_rate; /* Old HAS_RADIO values */ public int radio_channel; public int radio_setting; @@ -235,6 +236,7 @@ public class AltosConfigData implements Iterable { radio_calibration = -1; radio_channel = -1; radio_setting = -1; + telemetry_rate = -1; accel_cal_plus = -1; accel_cal_minus = -1; @@ -292,6 +294,7 @@ public class AltosConfigData implements Iterable { try { callsign = get_string(line, "Callsign:"); } catch (Exception e) {} try { radio_enable = get_int(line, "Radio enable:"); } catch (Exception e) {} try { radio_calibration = get_int(line, "Radio cal:"); } catch (Exception e) {} + try { telemetry_rate = get_int(line, "Telemetry rate:"); } catch (Exception e) {} /* Old HAS_RADIO values */ try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {} @@ -440,6 +443,8 @@ public class AltosConfigData implements Iterable { callsign = source.callsign(); if (radio_calibration >= 0) radio_calibration = source.radio_calibration(); + if (telemetry_rate >= 0) + telemetry_rate = source.telemetry_rate(); /* HAS_ACCEL */ if (pad_orientation >= 0) @@ -484,6 +489,7 @@ public class AltosConfigData implements Iterable { dest.set_apogee_lockout(apogee_lockout); dest.set_radio_calibration(radio_calibration); dest.set_radio_frequency(frequency()); + dest.set_telemetry_rate(telemetry_rate); boolean max_enabled = true; if (log_space() == 0) @@ -554,6 +560,9 @@ public class AltosConfigData implements Iterable { if (radio_enable >= 0) link.printf("c e %d\n", radio_enable); + if (telemetry_rate >= 0) + link.printf("c T %d\n", telemetry_rate); + /* HAS_ACCEL */ /* UI doesn't support accel cal */ if (pad_orientation >= 0) diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index b0c49e98..987da53b 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -53,6 +53,10 @@ public interface AltosConfigValues { public abstract String callsign(); + public abstract void set_telemetry_rate(int new_telemetry_rate); + + public abstract int telemetry_rate() throws AltosConfigDataException; + public abstract void set_flight_log_max(int new_flight_log_max); public abstract void set_flight_log_max_enabled(boolean enable); diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index ac151396..c0565e88 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -38,12 +38,18 @@ public class AltosFlightReader { public void set_telemetry(int telemetry) { } + public void set_telemetry_rate(int telemetry_rate) throws InterruptedException, TimeoutException { } + public void save_telemetry() { } + public void save_telemetry_rate() { } + public void update(AltosState state) throws InterruptedException { } public boolean supports_telemetry(int telemetry) { return false; } + public boolean supports_telemetry_rate(int telemetry_rate) { return false; } + public File backing_file() { return null; } public boolean has_monitor_battery() throws InterruptedException { return false; } diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index ec32fffc..c2ec0e3b 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -161,6 +161,15 @@ public class AltosLib { "Off", "Standard Telemetry", "TeleMetrum v0.9", "TeleMetrum v0.8" }; + public static final int ao_telemetry_rate_38400 = 0; + public static final int ao_telemetry_rate_9600 = 1; + public static final int ao_telemetry_rate_2400 = 2; + public static final int ao_telemetry_rate_max = 2; + + public static final Integer[] ao_telemetry_rate_values = { + 38400, 9600, 2400 + }; + public static final String launch_sites_url = "http://www.altusmetrum.org/AltOS/launch-sites.txt"; public static final int ao_telemetry_standard_len = 32; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index ef40c8cb..eadab5df 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -274,6 +274,8 @@ public abstract class AltosLink implements Runnable { } public void flush_output() { + if (pending_output == null) + return; for (String s : pending_output) System.out.print(s); pending_output.clear(); @@ -305,6 +307,7 @@ public abstract class AltosLink implements Runnable { */ public boolean monitor_mode = false; public int telemetry = AltosLib.ao_telemetry_standard; + public int telemetry_rate = AltosLib.ao_telemetry_rate_38400; public double frequency; public String callsign; AltosConfigData config_data; @@ -356,6 +359,15 @@ public abstract class AltosLink implements Runnable { flush_output(); } + public void set_telemetry_rate(int in_telemetry_rate) { + telemetry_rate = in_telemetry_rate; + if (monitor_mode) + printf("m 0\nc T %d\nm %x\n", telemetry_rate, telemetry_len()); + else + printf("c T %d\n", telemetry_rate); + flush_output(); + } + public void set_monitor(boolean monitor) { monitor_mode = monitor; if (monitor) @@ -383,7 +395,7 @@ public abstract class AltosLink implements Runnable { flush_output(); } - public AltosConfigData config_data() throws InterruptedException, TimeoutException { + public AltosConfigData config_data() throws InterruptedException, TimeoutException { synchronized(config_data_lock) { if (config_data == null) { printf("m 0\n"); diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 159951e4..72cfeb4b 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -35,6 +35,9 @@ public class AltosPreferences { /* telemetry format preference name */ public final static String telemetryPreferenceFormat = "TELEMETRY-%d"; + /* telemetry rate format preference name */ + public final static String telemetryRatePreferenceFormat = "RATE-%d"; + /* voice preference name */ public final static String voicePreference = "VOICE"; @@ -50,6 +53,9 @@ public class AltosPreferences { /* scanning telemetry preferences name */ public final static String scanningTelemetryPreference = "SCANNING-TELEMETRY"; + /* scanning telemetry rate preferences name */ + public final static String scanningTelemetryRatePreference = "SCANNING-RATE"; + /* Launcher serial preference name */ public final static String launcherSerialPreference = "LAUNCHER-SERIAL"; @@ -74,6 +80,9 @@ public class AltosPreferences { /* Telemetry (map serial to telemetry format) */ public static Hashtable telemetries; + /* Telemetry rate (map serial to telemetry format) */ + public static Hashtable telemetry_rates; + /* Voice preference */ public static boolean voice; @@ -86,6 +95,8 @@ public class AltosPreferences { /* Scanning telemetry */ public static int scanning_telemetry; + public static int scanning_telemetry_rate; + /* List of frequencies */ public final static String common_frequencies_node_name = "COMMON-FREQUENCIES"; public static AltosFrequency[] common_frequencies; @@ -159,12 +170,16 @@ public class AltosPreferences { telemetries = new Hashtable(); + telemetry_rates = new Hashtable(); + voice = backend.getBoolean(voicePreference, true); callsign = backend.getString(callsignPreference,"N0CALL"); scanning_telemetry = backend.getInt(scanningTelemetryPreference,(1 << AltosLib.ao_telemetry_standard)); + scanning_telemetry_rate = backend.getInt(scanningTelemetryRatePreference,(1 << AltosLib.ao_telemetry_rate_38400)); + launcher_serial = backend.getInt(launcherSerialPreference, 0); launcher_channel = backend.getInt(launcherChannelPreference, 0); @@ -266,6 +281,25 @@ public class AltosPreferences { } } + public static void set_telemetry_rate(int serial, int new_telemetry_rate) { + synchronized (backend) { + telemetry_rates.put(serial, new_telemetry_rate); + backend.putInt(String.format(telemetryRatePreferenceFormat, serial), new_telemetry_rate); + flush_preferences(); + } + } + + public static int telemetry_rate(int serial) { + synchronized (backend) { + if (telemetry_rates.containsKey(serial)) + return telemetry_rates.get(serial); + int telemetry_rate = backend.getInt(String.format(telemetryRatePreferenceFormat, serial), + AltosLib.ao_telemetry_rate_38400); + telemetry_rates.put(serial, telemetry_rate); + return telemetry_rate; + } + } + public static void set_scanning_telemetry(int new_scanning_telemetry) { synchronized (backend) { scanning_telemetry = new_scanning_telemetry; @@ -280,6 +314,20 @@ public class AltosPreferences { } } + public static void set_scanning_telemetry_rate(int new_scanning_telemetry_rate) { + synchronized (backend) { + scanning_telemetry_rate = new_scanning_telemetry_rate; + backend.putInt(scanningTelemetryRatePreference, scanning_telemetry_rate); + flush_preferences(); + } + } + + public static int scanning_telemetry_rate() { + synchronized(backend) { + return scanning_telemetry_rate; + } + } + public static void set_voice(boolean new_voice) { synchronized (backend) { voice = new_voice; diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 589f57f2..5ed50134 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -26,6 +26,7 @@ public class AltosTelemetryReader extends AltosFlightReader { AltosLog log; double frequency; int telemetry; + int telemetry_rate; AltosState state = null; LinkedBlockingQueue telem; @@ -92,6 +93,23 @@ public class AltosTelemetryReader extends AltosFlightReader { } } + public boolean supports_telemetry_rate(int telemetry_rate) { + try { + /* Version 1.4.1.1 supports all rates, older versions don't */ + if (link.config_data().compare_version("1.4.1.1") >= 0) + return true; + + if (telemetry_rate == AltosLib.ao_telemetry_rate_38400) + return true; + else + return false; + } catch (InterruptedException ie) { + return false; + } catch (TimeoutException te) { + return true; + } + } + public void save_frequency() { AltosPreferences.set_frequency(link.serial, frequency); } @@ -105,6 +123,15 @@ public class AltosTelemetryReader extends AltosFlightReader { AltosPreferences.set_telemetry(link.serial, telemetry); } + public void set_telemetry_rate(int in_telemetry_rate) { + telemetry_rate = in_telemetry_rate; + link.set_telemetry_rate(telemetry_rate); + } + + public void save_telemetry_rate() { + AltosPreferences.set_telemetry_rate(link.serial, telemetry_rate); + } + public void set_monitor(boolean monitor) { link.set_monitor(monitor); } @@ -133,6 +160,8 @@ public class AltosTelemetryReader extends AltosFlightReader { set_frequency(frequency); telemetry = AltosPreferences.telemetry(link.serial); set_telemetry(telemetry); + telemetry_rate = AltosPreferences.telemetry_rate(link.serial); + set_telemetry_rate(telemetry_rate); link.add_monitor(telem); success = true; } finally { -- cgit v1.2.3 From 59702e5ff8d0522b0aa9dcca863309eaafbcda09 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jul 2014 17:27:43 -0700 Subject: altoslib: Extend telemetry heights from 16 to 32 bits Uses the GPS data and/or previous kalman data to compute the upper 16 bits of the truncated telemetry altitude value. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 3 +++ altoslib/AltosConfigValues.java | 2 ++ altoslib/AltosState.java | 28 ++++++++++++++++++++++++---- altoslib/AltosTelemetry.java | 29 +++++++++++++++++++++++++++++ altoslib/AltosTelemetryMegaData.java | 13 ++++++++++--- altoslib/AltosTelemetryMetrumSensor.java | 7 ++++--- altosui/AltosConfigUI.java | 3 +++ 7 files changed, 75 insertions(+), 10 deletions(-) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 847436cd..134a0ed2 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -31,6 +31,7 @@ public class AltosConfigData implements Iterable { public int log_format; public int log_space; public String version; + public int altitude_32; /* Strings returned */ public LinkedList lines; @@ -274,6 +275,7 @@ public class AltosConfigData implements Iterable { try { flight = get_int(line, "current-flight"); } catch (Exception e) {} try { log_format = get_int(line, "log-format"); } catch (Exception e) {} try { log_space = get_int(line, "log-space"); } catch (Exception e) {} + try { altitude_32 = get_int(line, "altitude-32"); } catch (Exception e) {} try { version = get_string(line, "software-version"); } catch (Exception e) {} /* Version also contains MS5607 info, which we ignore here */ @@ -484,6 +486,7 @@ public class AltosConfigData implements Iterable { dest.set_serial(serial); dest.set_product(product); dest.set_version(version); + dest.set_altitude_32(altitude_32); dest.set_main_deploy(main_deploy); dest.set_apogee_delay(apogee_delay); dest.set_apogee_lockout(apogee_lockout); diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 987da53b..3f0a7075 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -25,6 +25,8 @@ public interface AltosConfigValues { public abstract void set_serial(int serial); + public abstract void set_altitude_32(int altitude_32); + public abstract void set_main_deploy(int new_main_deploy); public abstract int main_deploy() throws AltosConfigDataException; diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 2fc13b44..5fce15c4 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -271,6 +271,7 @@ public class AltosState implements Cloneable { public int state; public int flight; public int serial; + public int altitude_32; public int receiver_serial; public boolean landed; public boolean ascent; /* going up? */ @@ -472,15 +473,23 @@ public class AltosState implements Cloneable { pressure.set(p, time); } + public double baro_height() { + double a = altitude(); + double g = ground_altitude(); + if (a != AltosLib.MISSING && g != AltosLib.MISSING) + return a - g; + return AltosLib.MISSING; + } + public double height() { double k = kalman_height.value(); if (k != AltosLib.MISSING) return k; - double a = altitude(); - double g = ground_altitude(); - if (a != AltosLib.MISSING && g != AltosLib.MISSING) - return a - g; + double b = baro_height(); + if (b != AltosLib.MISSING) + return b; + return gps_height(); } @@ -762,6 +771,7 @@ public class AltosState implements Cloneable { product = null; serial = AltosLib.MISSING; receiver_serial = AltosLib.MISSING; + altitude_32 = AltosLib.MISSING; baro = null; companion = null; @@ -899,6 +909,7 @@ public class AltosState implements Cloneable { product = old.product; serial = old.serial; receiver_serial = old.receiver_serial; + altitude_32 = old.altitude_32; baro = old.baro; companion = old.companion; @@ -1066,6 +1077,15 @@ public class AltosState implements Cloneable { receiver_serial = serial; } + public boolean altitude_32() { + return altitude_32 == 1; + } + + public void set_altitude_32(int altitude_32) { + if (altitude_32 != AltosLib.MISSING) + this.altitude_32 = altitude_32; + } + public int rssi() { if (rssi == AltosLib.MISSING) return 0; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 4d50a059..2f15cd89 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -114,6 +114,35 @@ public abstract class AltosTelemetry implements AltosStateUpdate { return telem; } + public static int extend_height(AltosState state, int height_16) { + double compare_height; + int height = height_16; + + System.out.printf("state kalman height %g altitude %g ground_altitude %g gps_height %g\n", + state.kalman_height.value(), state.altitude(), state.ground_altitude(), state.gps_height()); + if (state.gps != null && state.gps.alt != AltosLib.MISSING) { + compare_height = state.gps_height(); + } else { + compare_height = state.height(); + } + + if (compare_height != AltosLib.MISSING) { + int high_bits = (int) Math.floor (compare_height / 65536.0); + + height = (high_bits << 16) | (height_16 & 0xffff); + + if (Math.abs(height + 65536 - compare_height) < Math.abs(height - compare_height)) + height += 65536; + else if (Math.abs(height - 65536 - compare_height) < Math.abs(height - compare_height)) + height -= 65536; + if (height != height_16) { + System.out.printf("Height adjusted from %d to %d with %g\n", + height_16, height, compare_height); + } + } + return height; + } + public static AltosTelemetry parse(String line) throws ParseException, AltosCRCException { String[] word = line.split("\\s+"); int i =0; diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index 93610118..8b1869bb 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -31,7 +31,7 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { int acceleration; int speed; - int height; + int height_16; public AltosTelemetryMegaData(int[] bytes) { super(bytes); @@ -55,7 +55,8 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { acceleration = int16(26); speed = int16(28); - height = int16(30); + + height_16 = int16(30); } public void update_state(AltosState state) { @@ -79,7 +80,13 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { state.set_ground_pressure(ground_pres); state.set_accel_g(accel_plus_g, accel_minus_g); - state.set_kalman(height, speed/16.0, acceleration / 16.0); + /* Fill in the high bits of height from recent GPS + * data if available, otherwise guess using the + * previous kalman height + */ + + state.set_kalman(extend_height(state, height_16), + speed/16.0, acceleration / 16.0); } } diff --git a/altoslib/AltosTelemetryMetrumSensor.java b/altoslib/AltosTelemetryMetrumSensor.java index 3e0abedc..beab6da9 100644 --- a/altoslib/AltosTelemetryMetrumSensor.java +++ b/altoslib/AltosTelemetryMetrumSensor.java @@ -27,7 +27,7 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { int acceleration; int speed; - int height; + int height_16; int v_batt; int sense_a; @@ -43,7 +43,7 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { acceleration = int16(14); speed = int16(16); - height = int16(18); + height_16 = int16(18); v_batt = int16(20); sense_a = int16(22); @@ -59,7 +59,8 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { state.set_pressure(pres); state.set_temperature(temp/100.0); - state.set_kalman(height, speed/16.0, acceleration/16.0); + state.set_kalman(extend_height(state, height_16), + speed/16.0, acceleration/16.0); state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt)); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 043cb876..9fcace61 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -926,6 +926,9 @@ public class AltosConfigUI serial_value.setText(String.format("%d", serial)); } + public void set_altitude_32(int altitude_32) { + } + public void set_main_deploy(int new_main_deploy) { main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy)); main_deploy_value.setEnabled(new_main_deploy >= 0); -- cgit v1.2.3 From 935f769fee351545622e223a283fca64608ca410 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 17 Aug 2014 20:49:27 -0700 Subject: altoslib: Parse 'Log fixed:' configuration value TeleGPS holds a single flight record and constantly appends data to it instead of having separate flight records on the board. It reports 'Log fixed: 1' to let AltosLib know that the size of the per-flight log is not configurable. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 134a0ed2..fd38635c 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -58,6 +58,7 @@ public class AltosConfigData implements Iterable { /* HAS_LOG */ public int flight_log_max; + public int log_fixed; /* HAS_IGNITE */ public int ignite_mode; @@ -244,6 +245,7 @@ public class AltosConfigData implements Iterable { pad_orientation = -1; flight_log_max = -1; + log_fixed = -1; ignite_mode = -1; aes_key = ""; @@ -316,6 +318,7 @@ public class AltosConfigData implements Iterable { /* HAS_LOG */ try { flight_log_max = get_int(line, "Max flight log:"); } catch (Exception e) {} + try { log_fixed = get_int(line, "Log fixed:"); } catch (Exception e) {} /* HAS_IGNITE */ try { ignite_mode = get_int(line, "Ignite mode:"); } catch (Exception e) {} @@ -498,6 +501,9 @@ public class AltosConfigData implements Iterable { if (log_space() == 0) max_enabled = false; + if (log_fixed > 0) + max_enabled = false; + switch (log_format) { case AltosLib.AO_LOG_FORMAT_TINY: max_enabled = false; -- cgit v1.2.3 From 46f08f8709c538f3fee8e166598f0bb930df6e3c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 6 Sep 2014 20:41:58 -0700 Subject: altoslib: Update local callsign/baud rate when using remote protocol We've had code to synchronously update the local and remote radio frequencies when doing configuration over the remote link. This patch adds the same code when changing the call sign and baud rate. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index fd38635c..4ada1d3b 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -386,6 +386,10 @@ public class AltosConfigData implements Iterable { return radio_frequency >= 0 || radio_setting >= 0 || radio_channel >= 0; } + public boolean has_telemetry_rate() { + return telemetry_rate >= 0; + } + public void set_frequency(double freq) { int frequency = radio_frequency; int setting = radio_setting; @@ -558,20 +562,39 @@ public class AltosConfigData implements Iterable { radio_calibration); /* When remote, reset the dongle frequency at the same time */ if (remote) { + link.flush_output(); link.stop_remote(); link.set_radio_frequency(frequency); + link.flush_output(); link.start_remote(); } } - if (callsign != null) + if (telemetry_rate >= 0) { + link.printf("c T %d\n", telemetry_rate); + if (remote) { + link.flush_output(); + link.stop_remote(); + link.set_telemetry_rate(telemetry_rate); + link.flush_output(); + link.start_remote(); + } + } + + if (callsign != null) { link.printf("c c %s\n", callsign); + if (remote) { + link.flush_output(); + link.stop_remote(); + link.set_callsign(callsign); + link.flush_output(); + link.start_remote(); + } + } + if (radio_enable >= 0) link.printf("c e %d\n", radio_enable); - if (telemetry_rate >= 0) - link.printf("c T %d\n", telemetry_rate); - /* HAS_ACCEL */ /* UI doesn't support accel cal */ if (pad_orientation >= 0) -- cgit v1.2.3 From cef3be371cb3a9e481c2bd6abdf22c51953773f1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 9 Sep 2014 09:37:13 -0700 Subject: altoslib/altosuilib: Add EasyMega support This makes flashing find the right files, and Monitor Idle show all of the state data. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 2 ++ altoslib/AltosIdleFetch.java | 4 ++++ altoslib/AltosLib.java | 4 +++- altosuilib/AltosFlashUI.java | 1 + altosuilib/AltosUSBDevice.java | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) (limited to 'altoslib/AltosConfigData.java') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 4ada1d3b..fc1f2442 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -429,6 +429,8 @@ public class AltosConfigData implements Iterable { return false; if (product.startsWith("TeleMetrum-v2")) return false; + if (product.startsWith("EasyMega")) + return false; return true; } diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 1cb43d6d..50745d97 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -118,6 +118,10 @@ public class AltosIdleFetch implements AltosStateUpdate { AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, AltosIdler.idle_imu, AltosIdler.idle_mag, AltosIdler.idle_sensor_mega), + new AltosIdler("EasyMega", + AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, + AltosIdler.idle_imu, AltosIdler.idle_mag, + AltosIdler.idle_sensor_mega), }; AltosLink link; diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index c3c1226e..2e9dc648 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -112,6 +112,7 @@ public class AltosLib { public final static int product_telegps = 0x0025; public final static int product_easymini = 0x0026; public final static int product_telemini = 0x0027; + public final static int product_easymega = 0x0028; public final static int product_altusmetrum_min = 0x000a; public final static int product_altusmetrum_max = 0x002c; @@ -143,7 +144,8 @@ public class AltosLib { new Product("megadongle", product_megadongle), new Product("telegps", product_telegps), new Product("easymini", product_easymini), - new Product("telemini", product_telemini) + new Product("telemini", product_telemini), + new Product("easymega", product_easymega) }; public static int name_to_product(String name) { diff --git a/altosuilib/AltosFlashUI.java b/altosuilib/AltosFlashUI.java index 0ed4e75d..44be2a90 100644 --- a/altosuilib/AltosFlashUI.java +++ b/altosuilib/AltosFlashUI.java @@ -213,6 +213,7 @@ public class AltosFlashUI new AltosHexfileFilter(AltosLib.product_teledongle, "teledongle", "TeleDongle Image"), new AltosHexfileFilter(AltosLib.product_telemega, "telemega", "TeleMega Image"), new AltosHexfileFilter(AltosLib.product_easymini, "easymini", "EasyMini Image"), + new AltosHexfileFilter(AltosLib.product_easymega, "easymega", "EasyMega Image"), }; boolean select_source_file() { diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index a8323704..f4906a73 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -79,6 +79,7 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { if (want_product == AltosUILib.product_altimeter) return have_product == AltosUILib.product_telemetrum || have_product == AltosUILib.product_telemega || + have_product == AltosUILib.product_easymega || have_product == AltosUILib.product_telegps || have_product == AltosUILib.product_easymini || have_product == AltosUILib.product_telemini; -- cgit v1.2.3