From ec036e8fe057f4b641ba9ee17d6dce2689816047 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 14 Sep 2012 00:25:49 +1200 Subject: altoslib/altosui: begin moving preferences "backend" into interface Signed-off-by: Mike Beattie --- altoslib/AltosPreferences.java | 130 +++++++++++++++------------------- altoslib/AltosPreferencesBackend.java | 38 ++++++++++ 2 files changed, 95 insertions(+), 73 deletions(-) create mode 100644 altoslib/AltosPreferencesBackend.java (limited to 'altoslib') diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 0e7b2bd3..ef30f8e9 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -19,11 +19,10 @@ package org.altusmetrum.AltosLib; import java.io.*; import java.util.*; -import java.util.prefs.*; import javax.swing.filechooser.FileSystemView; public class AltosPreferences { - public static Preferences preferences; + public static AltosPreferencesBackend backend = null; /* logdir preference name */ public final static String logdirPreference = "LOGDIR"; @@ -100,13 +99,10 @@ public class AltosPreferences { public static AltosFrequency[] load_common_frequencies() { AltosFrequency[] frequencies = null; boolean existing = false; - try { - existing = preferences.nodeExists(common_frequencies_node_name); - } catch (BackingStoreException be) { - existing = false; - } + existing = backend.nodeExists(common_frequencies_node_name); + if (existing) { - Preferences node = preferences.node(common_frequencies_node_name); + AltosPreferencesBackend node = backend.node(common_frequencies_node_name); int count = node.getInt(frequency_count, 0); frequencies = new AltosFrequency[count]; @@ -115,7 +111,7 @@ public class AltosPreferences { String description; frequency = node.getDouble(String.format(frequency_format, i), 0.0); - description = node.get(String.format(description_format, i), null); + description = node.getString(String.format(description_format, i), null); frequencies[i] = new AltosFrequency(frequency, description); } } else { @@ -129,12 +125,12 @@ public class AltosPreferences { } public static void save_common_frequencies(AltosFrequency[] frequencies) { - Preferences node = preferences.node(common_frequencies_node_name); + AltosPreferencesBackend node = backend.node(common_frequencies_node_name); node.putInt(frequency_count, frequencies.length); for (int i = 0; i < frequencies.length; i++) { node.putDouble(String.format(frequency_format, i), frequencies[i].frequency); - node.put(String.format(description_format, i), frequencies[i].description); + node.putString(String.format(description_format, i), frequencies[i].description); } } public static int launcher_serial; @@ -142,10 +138,10 @@ public class AltosPreferences { public static int launcher_channel; public static void init() { - preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); + //preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); /* Initialize logdir from preferences */ - String logdir_string = preferences.get(logdirPreference, null); + String logdir_string = backend.getString(logdirPreference, null); if (logdir_string != null) logdir = new File(logdir_string); else { @@ -162,17 +158,17 @@ public class AltosPreferences { telemetries = new Hashtable(); - voice = preferences.getBoolean(voicePreference, true); + voice = backend.getBoolean(voicePreference, true); - callsign = preferences.get(callsignPreference,"N0CALL"); + callsign = backend.getString(callsignPreference,"N0CALL"); - scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << AltosLib.ao_telemetry_standard)); + scanning_telemetry = backend.getInt(scanningTelemetryPreference,(1 << AltosLib.ao_telemetry_standard)); - launcher_serial = preferences.getInt(launcherSerialPreference, 0); + launcher_serial = backend.getInt(launcherSerialPreference, 0); - launcher_channel = preferences.getInt(launcherChannelPreference, 0); + launcher_channel = backend.getInt(launcherChannelPreference, 0); - String firmwaredir_string = preferences.get(firmwaredirPreference, null); + String firmwaredir_string = backend.getString(firmwaredirPreference, null); if (firmwaredir_string != null) firmwaredir = new File(firmwaredir_string); else @@ -180,65 +176,53 @@ public class AltosPreferences { common_frequencies = load_common_frequencies(); - AltosConvert.imperial_units = preferences.getBoolean(unitsPreference, false); + AltosConvert.imperial_units = backend.getBoolean(unitsPreference, false); } static { init(); } public static void flush_preferences() { - try { - preferences.flush(); - } catch (BackingStoreException ee) { -/* - if (component != null) - JOptionPane.showMessageDialog(component, - preferences.absolutePath(), - "Cannot save prefernces", - JOptionPane.ERROR_MESSAGE); - else -*/ - System.err.printf("Cannot save preferences\n"); - } + backend.flush(); } public static void set_logdir(File new_logdir) { - synchronized (preferences) { + synchronized (backend) { logdir = new_logdir; mapdir = new File(logdir, "maps"); if (!mapdir.exists()) mapdir.mkdirs(); - preferences.put(logdirPreference, logdir.getPath()); + backend.putString(logdirPreference, logdir.getPath()); flush_preferences(); } } public static File logdir() { - synchronized (preferences) { + synchronized (backend) { return logdir; } } public static File mapdir() { - synchronized (preferences) { + synchronized (backend) { return mapdir; } } public static void set_frequency(int serial, double new_frequency) { - synchronized (preferences) { + synchronized (backend) { frequencies.put(serial, new_frequency); - preferences.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency); + backend.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency); flush_preferences(); } } public static double frequency(int serial) { - synchronized (preferences) { + synchronized (backend) { if (frequencies.containsKey(serial)) return frequencies.get(serial); - double frequency = preferences.getDouble(String.format(frequencyPreferenceFormat, serial), 0); + double frequency = backend.getDouble(String.format(frequencyPreferenceFormat, serial), 0); if (frequency == 0.0) { - int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0); + int channel = backend.getInt(String.format(channelPreferenceFormat, serial), 0); frequency = AltosConvert.radio_channel_to_frequency(channel); } frequencies.put(serial, frequency); @@ -247,122 +231,122 @@ public class AltosPreferences { } public static void set_telemetry(int serial, int new_telemetry) { - synchronized (preferences) { + synchronized (backend) { telemetries.put(serial, new_telemetry); - preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry); + backend.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry); flush_preferences(); } } public static int telemetry(int serial) { - synchronized (preferences) { + synchronized (backend) { if (telemetries.containsKey(serial)) return telemetries.get(serial); - int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial), - AltosLib.ao_telemetry_standard); + int telemetry = backend.getInt(String.format(telemetryPreferenceFormat, serial), + AltosLib.ao_telemetry_standard); telemetries.put(serial, telemetry); return telemetry; } } public static void set_scanning_telemetry(int new_scanning_telemetry) { - synchronized (preferences) { + synchronized (backend) { scanning_telemetry = new_scanning_telemetry; - preferences.putInt(scanningTelemetryPreference, scanning_telemetry); + backend.putInt(scanningTelemetryPreference, scanning_telemetry); flush_preferences(); } } public static int scanning_telemetry() { - synchronized (preferences) { + synchronized (backend) { return scanning_telemetry; } } public static void set_voice(boolean new_voice) { - synchronized (preferences) { + synchronized (backend) { voice = new_voice; - preferences.putBoolean(voicePreference, voice); + backend.putBoolean(voicePreference, voice); flush_preferences(); } } public static boolean voice() { - synchronized (preferences) { + synchronized (backend) { return voice; } } public static void set_callsign(String new_callsign) { - synchronized(preferences) { + synchronized(backend) { callsign = new_callsign; - preferences.put(callsignPreference, callsign); + backend.putString(callsignPreference, callsign); flush_preferences(); } } public static String callsign() { - synchronized(preferences) { + synchronized(backend) { return callsign; } } public static void set_firmwaredir(File new_firmwaredir) { - synchronized (preferences) { + synchronized (backend) { firmwaredir = new_firmwaredir; - preferences.put(firmwaredirPreference, firmwaredir.getPath()); + backend.putString(firmwaredirPreference, firmwaredir.getPath()); flush_preferences(); } } public static File firmwaredir() { - synchronized (preferences) { + synchronized (backend) { return firmwaredir; } } public static void set_launcher_serial(int new_launcher_serial) { - synchronized (preferences) { + synchronized (backend) { launcher_serial = new_launcher_serial; - preferences.putInt(launcherSerialPreference, launcher_serial); + backend.putInt(launcherSerialPreference, launcher_serial); flush_preferences(); } } public static int launcher_serial() { - synchronized (preferences) { + synchronized (backend) { return launcher_serial; } } public static void set_launcher_channel(int new_launcher_channel) { - synchronized (preferences) { + synchronized (backend) { launcher_channel = new_launcher_channel; - preferences.putInt(launcherChannelPreference, launcher_channel); + backend.putInt(launcherChannelPreference, launcher_channel); flush_preferences(); } } public static int launcher_channel() { - synchronized (preferences) { + synchronized (backend) { return launcher_channel; } } - public static Preferences bt_devices() { - synchronized (preferences) { - return preferences.node("bt_devices"); + public static AltosPreferencesBackend bt_devices() { + synchronized (backend) { + return backend.node("bt_devices"); } } public static AltosFrequency[] common_frequencies() { - synchronized (preferences) { + synchronized (backend) { return common_frequencies; } } public static void set_common_frequencies(AltosFrequency[] frequencies) { - synchronized(preferences) { + synchronized(backend) { common_frequencies = frequencies; save_common_frequencies(frequencies); flush_preferences(); @@ -388,15 +372,15 @@ public class AltosPreferences { } public static boolean imperial_units() { - synchronized(preferences) { + synchronized(backend) { return AltosConvert.imperial_units; } } public static void set_imperial_units(boolean imperial_units) { - synchronized (preferences) { + synchronized (backend) { AltosConvert.imperial_units = imperial_units; - preferences.putBoolean(unitsPreference, imperial_units); + backend.putBoolean(unitsPreference, imperial_units); flush_preferences(); } } diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java new file mode 100644 index 00000000..a8cfb31b --- /dev/null +++ b/altoslib/AltosPreferencesBackend.java @@ -0,0 +1,38 @@ +/* + * Copyright © 2010 Mike Beattie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +public interface AltosPreferencesBackend { + + public String getString(String key, String def); + public void putString(String key, String value); + + public int getInt(String key, int def); + public void putInt(String key, int value); + + public double getDouble(String key, double def); + public void putDouble(String key, double value); + + public boolean getBoolean(String key, boolean def); + public void putBoolean(String key, boolean value); + + public boolean nodeExists(String key); + public AltosPreferencesBackend node(String key); + + public void flush(); +} -- cgit v1.2.3 From d875b459b5e9f7bcbbbbe318f947b0451ce6738f Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 14 Sep 2012 00:44:59 +1200 Subject: altosui/altoslib: add methods to interface, fix imports/exceptions in BT code Signed-off-by: Mike Beattie --- altoslib/AltosPreferencesBackend.java | 3 +++ altosui/AltosBTKnown.java | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index a8cfb31b..3fc4b0aa 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -34,5 +34,8 @@ public interface AltosPreferencesBackend { public boolean nodeExists(String key); public AltosPreferencesBackend node(String key); + public String[] keys(); + public void remove(String key); + public void flush(); } diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index 7e5e9533..ae04ac8c 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -17,7 +17,7 @@ package altosui; import java.util.*; -import java.util.prefs.*; +import org.altusmetrum.AltosLib.*; public class AltosBTKnown implements Iterable { LinkedList devices = new LinkedList(); @@ -43,7 +43,6 @@ public class AltosBTKnown implements Iterable { String addr = get_address(name); devices.add(new AltosBTDevice(name, addr)); } - } catch (BackingStoreException be) { } catch (IllegalStateException ie) { } } -- cgit v1.2.3 From 17127847300de9a6782b901926a3fcb9ef021b78 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 14 Sep 2012 00:46:34 +1200 Subject: altoslib: Add AltosPreferencesBackend.java to Makefile.am Signed-off-by: Mike Beattie --- altoslib/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'altoslib') diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index a9f810f9..b56d8af1 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -42,6 +42,7 @@ AltosLib_JAVA = \ $(SRC)/AltosOrderedMegaRecord.java \ $(SRC)/AltosParse.java \ $(SRC)/AltosPreferences.java \ + $(SRC)/AltosPreferencesBackend.java \ $(SRC)/AltosRecordCompanion.java \ $(SRC)/AltosRecordIterable.java \ $(SRC)/AltosRecord.java \ -- cgit v1.2.3 From 08345b8909922f2ff8f9ed8b4497b9cbea6b26e9 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 14 Sep 2012 00:53:56 +1200 Subject: altosui/altoslib: Add call to …Preferences.init() with backend object, remove static init() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mike Beattie --- altoslib/AltosPreferences.java | 6 ++---- altosui/AltosUI.java | 1 + altosui/AltosUIPreferences.java | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index ef30f8e9..a82ea3f6 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -137,8 +137,8 @@ public class AltosPreferences { public static int launcher_channel; - public static void init() { - //preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); + public static void init(AltosPreferencesBackend in_backend) { + backend = in_backend; /* Initialize logdir from preferences */ String logdir_string = backend.getString(logdirPreference, null); @@ -179,8 +179,6 @@ public class AltosPreferences { AltosConvert.imperial_units = backend.getBoolean(unitsPreference, false); } - static { init(); } - public static void flush_preferences() { backend.flush(); } diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index b5cbefe7..52b6b128 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -98,6 +98,7 @@ public class AltosUI extends AltosFrame { load_library(null); + AltosUIPreferences.init(new AltosUIPreferencesBackend()); AltosUIPreferences.set_component(this); pane = getContentPane(); diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java index 6e4c9097..c1087dd6 100644 --- a/altosui/AltosUIPreferences.java +++ b/altosui/AltosUIPreferences.java @@ -45,7 +45,9 @@ public class AltosUIPreferences extends AltosPreferences { /* Serial debug */ static boolean serial_debug; - public static void init() { + public static void init(AltosUIPreferencesBackend in_backend) { + super(in_backend); + font_listeners = new LinkedList(); font_size = backend.getInt(fontSizePreference, Altos.font_size_medium); @@ -57,8 +59,6 @@ public class AltosUIPreferences extends AltosPreferences { AltosLink.set_debug(serial_debug); } - static { init(); } - static void set_component(Component in_component) { component = in_component; } -- cgit v1.2.3 From c058ec2d6070458a0b7d3ef56041e985412ee565 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Tue, 18 Sep 2012 23:46:17 +1200 Subject: altos{lib,ui,droid}: move OS specific code out of altoslib This is to allow the usage of AltosLog on Android - no swing, so we need to push the "home directory" code used to pick a default telemetry logging path - using the PreferencesBackend interface for now. Signed-off-by: Mike Beattie --- .../src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java | 6 ++++++ altoslib/AltosPreferences.java | 4 +--- altoslib/AltosPreferencesBackend.java | 4 ++++ altosui/AltosUIPreferencesBackend.java | 6 ++++++ 4 files changed, 17 insertions(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java index b8487d07..3b4bdcf8 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java @@ -17,9 +17,12 @@ package org.altusmetrum.AltosDroid; +import java.io.File; import java.util.Map; import android.content.Context; import android.content.SharedPreferences; +import android.os.Environment; + import org.altusmetrum.AltosLib.*; public class AltosDroidPreferences implements AltosPreferencesBackend { @@ -92,4 +95,7 @@ public class AltosDroidPreferences implements AltosPreferencesBackend { editor.apply(); } + public File homeDirectory() { + return Environment.getExternalStorageDirectory(); + } } diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index a82ea3f6..47196d6e 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -19,7 +19,6 @@ package org.altusmetrum.AltosLib; import java.io.*; import java.util.*; -import javax.swing.filechooser.FileSystemView; public class AltosPreferences { public static AltosPreferencesBackend backend = null; @@ -145,8 +144,7 @@ public class AltosPreferences { if (logdir_string != null) logdir = new File(logdir_string); else { - /* Use the file system view default directory */ - logdir = new File(FileSystemView.getFileSystemView().getDefaultDirectory(), logdirName); + logdir = new File(backend.homeDirectory(), logdirName); if (!logdir.exists()) logdir.mkdirs(); } diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index 3fc4b0aa..a1184c0b 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -17,6 +17,8 @@ package org.altusmetrum.AltosLib; +import java.io.File; + public interface AltosPreferencesBackend { public String getString(String key, String def); @@ -38,4 +40,6 @@ public interface AltosPreferencesBackend { public void remove(String key); public void flush(); + + public File homeDirectory(); } diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index 210dcb8b..3131fd32 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -17,8 +17,10 @@ package altosui; +import java.io.File; import java.util.prefs.*; import org.altusmetrum.AltosLib.*; +import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { @@ -92,4 +94,8 @@ public class AltosUIPreferencesBackend implements AltosPreferencesBackend { } } + public File homeDirectory() { + /* Use the file system view default directory */ + return FileSystemView.getFileSystemView().getDefaultDirectory(); + } } -- cgit v1.2.3 From 0541201d4afe3e5d7913465e1db10e586d7182bb Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Tue, 18 Sep 2012 23:47:06 +1200 Subject: altoslib: make parts of AltosLog public for usage outside altoslib. Signed-off-by: Mike Beattie --- altoslib/AltosLog.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 3c124700..1c7069ce 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -25,7 +25,7 @@ import java.util.concurrent.LinkedBlockingQueue; * This creates a thread to capture telemetry data and write it to * a log file */ -class AltosLog implements Runnable { +public class AltosLog implements Runnable { LinkedBlockingQueue input_queue; LinkedBlockingQueue pending_queue; @@ -45,7 +45,7 @@ class AltosLog implements Runnable { } } - void close() { + public void close() { close_log_file(); if (log_thread != null) { log_thread.interrupt(); @@ -53,7 +53,7 @@ class AltosLog implements Runnable { } } - File file() { + public File file() { return file; } -- cgit v1.2.3 From 440365bd17d804c2f574c35164612cf1682397d7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 16 Oct 2012 21:54:23 -0700 Subject: altosui: Accept serial number of zero for eeprom download AVR-based products don't have a valid serial number, and so usually report 0. Accept this by making the 'no serial number' case check for negative values. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 1 + altosui/AltosEepromDownload.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 6f343639..a962b105 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -134,6 +134,7 @@ public class AltosConfigData implements Iterable { radio_setting = 0; radio_frequency = 0; stored_flight = 0; + serial = -1; for (;;) { String line = link.get_reply(); if (line == null) diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index a8cb24ff..a5e99749 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -314,7 +314,7 @@ public class AltosEepromDownload implements Runnable { done = false; start = true; - if (flights.config_data.serial == 0) + if (flights.config_data.serial < 0) throw new IOException("no serial number found"); /* Reset per-capture variables */ -- cgit v1.2.3 From 1f5a453cb4650fc97cc990a9e42242278c29cc04 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 21 Oct 2012 13:42:00 -0700 Subject: altoslib: MegaMetrum eeprom never loses GPS date TeleMetrum had a firmware bug that would fail to record the GPS date and time correctly, that was hacked around in altosui, but isn't needed for MegaMetrum. Remove those hacks from the MM path. Signed-off-by: Keith Packard --- altoslib/AltosEepromMega.java | 7 +--- altoslib/AltosEepromMegaIterable.java | 76 ----------------------------------- altoslib/AltosOrderedMegaRecord.java | 12 ------ 3 files changed, 1 insertion(+), 94 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index 26bacf8d..25a29fb2 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -66,12 +66,7 @@ public class AltosEepromMega { public int mag_x() { return data16(20); } public int mag_y() { return data16(22); } public int mag_z() { return data16(24); } - public int accel() { - int a = data16(26); - if (a != 0xffff) - return a; - return accel_y(); - } + public int accel() { return data16(26); } /* AO_LOG_VOLT elements */ public int v_batt() { return data16(0); } diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index 1ab2fcc8..003bff44 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -347,40 +347,6 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { } } - /* - * Given an AO_LOG_GPS_TIME record with correct time, and one - * missing time, rewrite the missing time values with the good - * ones, assuming that the difference between them is 'diff' seconds - */ - void update_time(AltosOrderedMegaRecord good, AltosOrderedMegaRecord bad) { - - int diff = (bad.tick - good.tick + 50) / 100; - - int hour = (good.a & 0xff); - int minute = (good.a >> 8); - int second = (good.b & 0xff); - int flags = (good.b >> 8); - int seconds = hour * 3600 + minute * 60 + second; - - /* Make sure this looks like a good GPS value */ - if ((flags & AltosLib.AO_GPS_NUM_SAT_MASK) >> AltosLib.AO_GPS_NUM_SAT_SHIFT < 4) - flags = (flags & ~AltosLib.AO_GPS_NUM_SAT_MASK) | (4 << AltosLib.AO_GPS_NUM_SAT_SHIFT); - flags |= AltosLib.AO_GPS_RUNNING; - flags |= AltosLib.AO_GPS_VALID; - - int new_seconds = seconds + diff; - if (new_seconds < 0) - new_seconds += 24 * 3600; - int new_second = (new_seconds % 60); - int new_minutes = (new_seconds / 60); - int new_minute = (new_minutes % 60); - int new_hours = (new_minutes / 60); - int new_hour = (new_hours % 24); - - bad.a = new_hour + (new_minute << 8); - bad.b = new_second + (flags << 8); - } - /* * Read the whole file, dumping records into a RB tree so * we can enumerate them in time order -- the eeprom data @@ -416,48 +382,6 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { continue; } - /* Two firmware bugs caused the loss of some GPS data. - * The flight date would never be recorded, and often - * the flight time would get overwritten by another - * record. Detect the loss of the GPS date and fix up the - * missing time records - */ - if (record.cmd == AltosLib.AO_LOG_GPS_DATE) { - gps_date_record = record; - continue; - } - - /* go back and fix up any missing time values */ - if (record.cmd == AltosLib.AO_LOG_GPS_TIME) { - last_gps_time = record; - if (missing_time) { - Iterator iterator = records.iterator(); - while (iterator.hasNext()) { - AltosOrderedMegaRecord old = iterator.next(); - if (old.cmd == AltosLib.AO_LOG_GPS_TIME && - old.a == -1 && old.b == -1) - { - update_time(record, old); - } - } - missing_time = false; - } - } - - if (record.cmd == AltosLib.AO_LOG_GPS_LAT) { - if (last_gps_time == null || last_gps_time.tick != record.tick) { - AltosOrderedMegaRecord add_gps_time = new AltosOrderedMegaRecord(AltosLib.AO_LOG_GPS_TIME, - record.tick, - -1, -1, index-1); - if (last_gps_time != null) - update_time(last_gps_time, add_gps_time); - else - missing_time = true; - - records.add(add_gps_time); - record.index = index++; - } - } records.add(record); /* Bail after reading the 'landed' record; we're all done */ diff --git a/altoslib/AltosOrderedMegaRecord.java b/altoslib/AltosOrderedMegaRecord.java index 05423dd9..3aaf7b5b 100644 --- a/altoslib/AltosOrderedMegaRecord.java +++ b/altoslib/AltosOrderedMegaRecord.java @@ -43,18 +43,6 @@ class AltosOrderedMegaRecord extends AltosEepromMega implements Comparable Date: Sun, 21 Oct 2012 14:10:32 -0700 Subject: altoslib: remove a couple of TM log record types from MM log parsing PRESSURE and DEPLOY log records don't occurin MM eeprom files. Signed-off-by: Keith Packard --- altoslib/AltosEepromMegaIterable.java | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index 003bff44..50f9d33d 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -106,15 +106,6 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { eeprom.sensor_tick = record.tick; has_accel = true; break; - case AltosLib.AO_LOG_PRESSURE: - state.pres = record.b; - state.flight_pres = state.pres; - if (eeprom.n_pad_samples == 0) { - eeprom.n_pad_samples++; - state.ground_pres = state.pres; - } - eeprom.seen |= seen_sensor; - break; case AltosLib.AO_LOG_TEMP_VOLT: state.v_batt = record.v_batt(); state.v_pyro = record.v_pbatt(); @@ -122,14 +113,6 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { state.sense[i] = record.sense(i); eeprom.seen |= seen_temp_volt; break; -// -// case AltosLib.AO_LOG_DEPLOY: -// state.drogue = record.a; -// state.main = record.b; -// eeprom.seen |= seen_deploy; -// has_ignite = true; -// break; - case AltosLib.AO_LOG_STATE: state.state = record.state(); break; -- cgit v1.2.3 From dec2e455935a71dec13b84bb886252b7f4a1a641 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 21 Oct 2012 14:11:07 -0700 Subject: altoslib: Compute accelerometer speed from megametrum eeprom data Duplicates code from the TM eeprom state tracking code. Signed-off-by: Keith Packard --- altoslib/AltosRecordMM.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosRecordMM.java b/altoslib/AltosRecordMM.java index 5f952f7a..63b37f82 100644 --- a/altoslib/AltosRecordMM.java +++ b/altoslib/AltosRecordMM.java @@ -111,7 +111,11 @@ public class AltosRecordMM extends AltosRecord { } public double accel_speed() { - return speed; + if (speed != MISSING) + return speed; + if (flight_vel == MISSING) + return MISSING; + return flight_vel / (accel_counts_per_mss() * 100.0); } public void copy (AltosRecordMM old) { -- cgit v1.2.3 From 7894c27b2b2c3c46a7c107c8acd5977830f006cf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 21 Oct 2012 16:13:14 -0700 Subject: altoslib: Move computed state from AltosRecord to AltosState Make AltosRecord simply track the raw data and have AltosState hold all computed values, including cross-packet averages and computed speeds. Signed-off-by: Keith Packard --- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosRecord.java | 99 +++++++++++------------------- altoslib/AltosRecordMM.java | 18 +----- altoslib/AltosRecordTM.java | 21 +------ altoslib/AltosState.java | 69 ++++++++++++++++----- altoslib/AltosTelemetryRecordLegacy.java | 24 ++++---- altoslib/AltosTelemetryRecordMegaData.java | 6 +- altoslib/AltosTelemetryRecordRaw.java | 2 +- altoslib/AltosTelemetryRecordSensor.java | 6 +- altoslib/Makefile.am | 1 + altosui/AltosAscent.java | 2 +- altosui/AltosCSV.java | 8 +-- altosui/AltosDataPoint.java | 5 +- altosui/AltosDataPointReader.java | 47 +++++++------- altosui/AltosDescent.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosFlightStats.java | 10 +-- altosui/AltosGraphUI.java | 7 +-- altosui/AltosInfoTable.java | 4 +- altosui/AltosKML.java | 2 +- altosui/AltosLanded.java | 2 +- 21 files changed, 153 insertions(+), 186 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 2c4965ff..07d8930d 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -97,7 +97,7 @@ public class AltosIdleMonitor extends Thread { else if (has_sensor_mm(config_data)) record = sensor_mm(config_data); else - record = new AltosRecord(); + record = new AltosRecordNone(); if (has_gps(config_data)) gps = new AltosGPSQuery(link, config_data); diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 8bab1d0c..09169515 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -17,7 +17,7 @@ package org.altusmetrum.AltosLib; -public class AltosRecord implements Comparable , Cloneable { +public abstract class AltosRecord implements Comparable , Cloneable { public static final int seen_flight = 1; public static final int seen_sensor = 2; @@ -43,11 +43,6 @@ public class AltosRecord implements Comparable , Cloneable { public int state; public int tick; - /* Current flight dynamic state */ - public double acceleration; /* m/s² */ - public double speed; /* m/s */ - public double height; /* m */ - public AltosGPS gps; public boolean new_gps; @@ -63,6 +58,11 @@ public class AltosRecord implements Comparable , Cloneable { public AltosRecordCompanion companion; + /* Telemetry sources have these values recorded from the flight computer */ + public double kalman_height; + public double kalman_speed; + public double kalman_acceleration; + /* * Abstract methods that convert record data * to standard units: @@ -75,76 +75,48 @@ public class AltosRecord implements Comparable , Cloneable { * temperature: °C */ - public double raw_pressure() { return MISSING; } - - public double filtered_pressure() { return MISSING; } - - public double ground_pressure() { return MISSING; } - - public double battery_voltage() { return MISSING; } + abstract public double pressure(); + abstract public double ground_pressure(); + abstract public double acceleration(); - public double main_voltage() { return MISSING; } + public double altitude() { + double p = pressure(); - public double drogue_voltage() { return MISSING; } - - public double temperature() { return MISSING; } - - public double acceleration() { return MISSING; } - - public double accel_speed() { return MISSING; } - - public AltosIMU imu() { return null; } - - public AltosMag mag() { return null; } - - /* - * Convert various pressure values to altitude - */ - - public double raw_altitude() { - double p = raw_pressure(); if (p == MISSING) return MISSING; return AltosConvert.pressure_to_altitude(p); } public double ground_altitude() { - double p = ground_pressure(); + double p = ground_pressure(); + if (p == MISSING) return MISSING; return AltosConvert.pressure_to_altitude(p); } - public double filtered_altitude() { - double ga = ground_altitude(); - if (height != MISSING && ga != MISSING) - return height + ga; + public double height() { + double g = ground_altitude(); + double a = altitude(); - double p = filtered_pressure(); - if (p == MISSING) - return raw_altitude(); - return AltosConvert.pressure_to_altitude(p); + if (g == MISSING) + return MISSING; + if (a == MISSING) + return MISSING; + return a - g; } - public double filtered_height() { - if (height != MISSING) - return height; + public double battery_voltage() { return MISSING; } - double f = filtered_altitude(); - double g = ground_altitude(); - if (f == MISSING || g == MISSING) - return MISSING; - return f - g; - } + public double main_voltage() { return MISSING; } - public double raw_height() { - double r = raw_altitude(); - double g = ground_altitude(); + public double drogue_voltage() { return MISSING; } - if (r == MISSING || g == MISSING) - return height; - return r - g; - } + public double temperature() { return MISSING; } + + public AltosIMU imu() { return null; } + + public AltosMag mag() { return null; } public String state() { return AltosLib.state_name(state); @@ -164,12 +136,12 @@ public class AltosRecord implements Comparable , Cloneable { status = old.status; state = old.state; tick = old.tick; - acceleration = old.acceleration; - speed = old.speed; - height = old.height; gps = new AltosGPS(old.gps); new_gps = old.new_gps; companion = old.companion; + kalman_acceleration = old.kalman_acceleration; + kalman_speed = old.kalman_speed; + kalman_height = old.kalman_height; } public AltosRecord clone() { @@ -192,11 +164,12 @@ public class AltosRecord implements Comparable , Cloneable { status = 0; state = AltosLib.ao_flight_startup; tick = 0; - acceleration = MISSING; - speed = MISSING; - height = MISSING; gps = new AltosGPS(); new_gps = false; companion = null; + + kalman_acceleration = MISSING; + kalman_speed = MISSING; + kalman_height = MISSING; } } diff --git a/altoslib/AltosRecordMM.java b/altoslib/AltosRecordMM.java index 63b37f82..9f529234 100644 --- a/altoslib/AltosRecordMM.java +++ b/altoslib/AltosRecordMM.java @@ -19,6 +19,7 @@ package org.altusmetrum.AltosLib; public class AltosRecordMM extends AltosRecord { + /* Sensor values */ public int accel; public int pres; public int temp; @@ -45,16 +46,12 @@ public class AltosRecordMM extends AltosRecord { return raw / 4095.0; } - public double raw_pressure() { + public double pressure() { if (pres != MISSING) return pres; return MISSING; } - public double filtered_pressure() { - return raw_pressure(); - } - public double ground_pressure() { if (ground_pres != MISSING) return ground_pres; @@ -98,9 +95,6 @@ public class AltosRecordMM extends AltosRecord { } public double acceleration() { - if (acceleration != MISSING) - return acceleration; - if (ground_accel == MISSING || accel == MISSING) return MISSING; @@ -110,14 +104,6 @@ public class AltosRecordMM extends AltosRecord { return (ground_accel - accel) / accel_counts_per_mss(); } - public double accel_speed() { - if (speed != MISSING) - return speed; - if (flight_vel == MISSING) - return MISSING; - return flight_vel / (accel_counts_per_mss() * 100.0); - } - public void copy (AltosRecordMM old) { super.copy(old); diff --git a/altoslib/AltosRecordTM.java b/altoslib/AltosRecordTM.java index 37accef6..9530be31 100644 --- a/altoslib/AltosRecordTM.java +++ b/altoslib/AltosRecordTM.java @@ -18,6 +18,8 @@ package org.altusmetrum.AltosLib; public class AltosRecordTM extends AltosRecord { + + /* Sensor values */ public int accel; public int pres; public int temp; @@ -57,18 +59,12 @@ public class AltosRecordTM extends AltosRecord { return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0; } - public double raw_pressure() { + public double pressure() { if (pres == MISSING) return MISSING; return barometer_to_pressure(pres); } - public double filtered_pressure() { - if (flight_pres == MISSING) - return MISSING; - return barometer_to_pressure(flight_pres); - } - public double ground_pressure() { if (ground_pres == MISSING) return MISSING; @@ -121,22 +117,11 @@ public class AltosRecordTM extends AltosRecord { } public double acceleration() { - if (acceleration != MISSING) - return acceleration; - if (ground_accel == MISSING || accel == MISSING) return MISSING; return (ground_accel - accel) / accel_counts_per_mss(); } - public double accel_speed() { - if (speed != MISSING) - return speed; - if (flight_vel == MISSING) - return MISSING; - return flight_vel / (accel_counts_per_mss() * 100.0); - } - public void copy(AltosRecordTM old) { super.copy(old); diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 2e4d8870..f28dd1c6 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -40,17 +40,17 @@ public class AltosState { public double ground_altitude; public double altitude; public double height; - public double speed; public double acceleration; public double battery; public double temperature; public double main_sense; public double drogue_sense; + public double accel_speed; public double baro_speed; public double max_height; public double max_acceleration; - public double max_speed; + public double max_accel_speed; public double max_baro_speed; public AltosGPS gps; @@ -76,20 +76,39 @@ public class AltosState { public int speak_tick; public double speak_altitude; - public void init (AltosRecord cur, AltosState prev_state) { - //int i; - //AltosRecord prev; + public double speed() { + if (ascent) + return accel_speed; + else + return baro_speed; + } + + public double max_speed() { + if (max_accel_speed != 0) + return max_accel_speed; + return max_baro_speed; + } + public void init (AltosRecord cur, AltosState prev_state) { data = cur; ground_altitude = data.ground_altitude(); - altitude = data.raw_altitude(); - height = data.filtered_height(); + + altitude = data.altitude(); + + if (data.kalman_height != AltosRecord.MISSING) + height = data.kalman_height; + else { + if (prev_state != null) + height = (prev_state.height * 15 + altitude - ground_altitude) / 16.0; + } report_time = System.currentTimeMillis(); - acceleration = data.acceleration(); - speed = data.accel_speed(); + if (data.kalman_acceleration != AltosRecord.MISSING) + acceleration = data.kalman_acceleration; + else + acceleration = data.acceleration(); temperature = data.temperature(); drogue_sense = data.drogue_voltage(); main_sense = data.main_voltage(); @@ -108,7 +127,7 @@ public class AltosState { pad_alt = prev_state.pad_alt; max_height = prev_state.max_height; max_acceleration = prev_state.max_acceleration; - max_speed = prev_state.max_speed; + max_accel_speed = prev_state.max_accel_speed; max_baro_speed = prev_state.max_baro_speed; imu = prev_state.imu; mag = prev_state.mag; @@ -119,23 +138,39 @@ public class AltosState { time_change = (tick - prev_state.tick) / 100.0; - /* compute barometric speed */ + if (data.kalman_speed != AltosRecord.MISSING) { + baro_speed = accel_speed = data.kalman_speed; + } else { + /* compute barometric speed */ - double height_change = height - prev_state.height; - if (data.speed != AltosRecord.MISSING) - baro_speed = data.speed; - else { + double height_change = height - prev_state.height; if (time_change > 0) baro_speed = (prev_state.baro_speed * 3 + (height_change / time_change)) / 4.0; else baro_speed = prev_state.baro_speed; + + if (acceleration == AltosRecord.MISSING) { + /* Fill in mising acceleration value */ + accel_speed = baro_speed; + if (time_change > 0) + acceleration = (accel_speed - prev_state.accel_speed) / time_change; + else + acceleration = prev_state.acceleration; + } else { + /* compute accelerometer speed */ + accel_speed = prev_state.accel_speed + acceleration * time_change; + } } + } else { npad = 0; ngps = 0; gps = null; baro_speed = 0; + accel_speed = 0; time_change = 0; + if (acceleration == AltosRecord.MISSING) + acceleration = 0; } time = tick / 100.0; @@ -180,8 +215,8 @@ public class AltosState { /* Only look at accelerometer data under boost */ if (boost && acceleration > max_acceleration && acceleration != AltosRecord.MISSING) max_acceleration = acceleration; - if (boost && speed > max_speed && speed != AltosRecord.MISSING) - max_speed = speed; + if (boost && accel_speed > max_accel_speed && accel_speed != AltosRecord.MISSING) + max_accel_speed = accel_speed; if (boost && baro_speed > max_baro_speed && baro_speed != AltosRecord.MISSING) max_baro_speed = baro_speed; diff --git a/altoslib/AltosTelemetryRecordLegacy.java b/altoslib/AltosTelemetryRecordLegacy.java index 21176069..43189794 100644 --- a/altoslib/AltosTelemetryRecordLegacy.java +++ b/altoslib/AltosTelemetryRecordLegacy.java @@ -257,9 +257,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { record.accel_minus_g = map.get_int(AO_TELEM_CAL_ACCEL_MINUS, AltosRecord.MISSING); /* flight computer values */ - record.acceleration = map.get_double(AO_TELEM_KALMAN_ACCEL, AltosRecord.MISSING, 1/16.0); - record.speed = map.get_double(AO_TELEM_KALMAN_SPEED, AltosRecord.MISSING, 1/16.0); - record.height = map.get_int(AO_TELEM_KALMAN_HEIGHT, AltosRecord.MISSING); + record.kalman_acceleration = map.get_double(AO_TELEM_KALMAN_ACCEL, AltosRecord.MISSING, 1/16.0); + record.kalman_speed = map.get_double(AO_TELEM_KALMAN_SPEED, AltosRecord.MISSING, 1/16.0); + record.kalman_height = map.get_int(AO_TELEM_KALMAN_HEIGHT, AltosRecord.MISSING); record.flight_accel = map.get_int(AO_TELEM_ADHOC_ACCEL, AltosRecord.MISSING); record.flight_vel = map.get_int(AO_TELEM_ADHOC_SPEED, AltosRecord.MISSING); @@ -334,9 +334,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { /* Old TeleDongle code with kalman-reporting TeleMetrum code */ if ((record.flight_vel & 0xffff0000) == 0x80000000) { - record.speed = ((short) record.flight_vel) / 16.0; - record.acceleration = record.flight_accel / 16.0; - record.height = record.flight_pres; + record.kalman_speed = ((short) record.flight_vel) / 16.0; + record.kalman_acceleration = record.flight_accel / 16.0; + record.kalman_height = record.flight_pres; record.flight_vel = AltosRecord.MISSING; record.flight_pres = AltosRecord.MISSING; record.flight_accel = AltosRecord.MISSING; @@ -455,9 +455,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { record.accel_minus_g = int16(19); if (uint16(11) == 0x8000) { - record.acceleration = int16(5); - record.speed = int16(9); - record.height = int16(13); + record.kalman_acceleration = int16(5); + record.kalman_speed = int16(9); + record.kalman_height = int16(13); record.flight_accel = AltosRecord.MISSING; record.flight_vel = AltosRecord.MISSING; record.flight_pres = AltosRecord.MISSING; @@ -465,9 +465,9 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { record.flight_accel = int16(5); record.flight_vel = uint32(9); record.flight_pres = int16(13); - record.acceleration = AltosRecord.MISSING; - record.speed = AltosRecord.MISSING; - record.height = AltosRecord.MISSING; + record.kalman_acceleration = AltosRecord.MISSING; + record.kalman_speed = AltosRecord.MISSING; + record.kalman_height = AltosRecord.MISSING; } record.gps = null; diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java index 8f55d238..16a7b80c 100644 --- a/altoslib/AltosTelemetryRecordMegaData.java +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -83,9 +83,9 @@ public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { next.accel_plus_g = accel_plus_g; next.accel_minus_g = accel_minus_g; - next.acceleration = acceleration / 16.0; - next.speed = speed / 16.0; - next.height = height; + next.kalman_acceleration = acceleration / 16.0; + next.kalman_speed = speed / 16.0; + next.kalman_height = height; next.seen |= AltosRecord.seen_flight | AltosRecord.seen_temp_volt; diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index fbb373d5..c21da6fc 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -65,7 +65,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { if (previous != null) next = previous.clone(); else - next = new AltosRecord(); + next = new AltosRecordNone(); next.serial = serial; next.tick = tick; return next; diff --git a/altoslib/AltosTelemetryRecordSensor.java b/altoslib/AltosTelemetryRecordSensor.java index 319a91b3..f1fc156c 100644 --- a/altoslib/AltosTelemetryRecordSensor.java +++ b/altoslib/AltosTelemetryRecordSensor.java @@ -86,9 +86,9 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { next.main = AltosRecord.MISSING; } - next.acceleration = acceleration / 16.0; - next.speed = speed / 16.0; - next.height = height; + next.kalman_acceleration = acceleration / 16.0; + next.kalman_speed = speed / 16.0; + next.kalman_height = height; next.ground_pres = ground_pres; if (type == packet_type_TM_sensor) { diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index b56d8af1..f04c10c6 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -46,6 +46,7 @@ AltosLib_JAVA = \ $(SRC)/AltosRecordCompanion.java \ $(SRC)/AltosRecordIterable.java \ $(SRC)/AltosRecord.java \ + $(SRC)/AltosRecordNone.java \ $(SRC)/AltosRecordTM.java \ $(SRC)/AltosRecordMM.java \ $(SRC)/AltosReplayReader.java \ diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 007c74ec..a05c4404 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -251,7 +251,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Speed extends AscentValueHold { void show (AltosState state, int crc_errors) { - double speed = state.speed; + double speed = state.accel_speed; if (!state.ascent) speed = state.baro_speed; show(AltosConvert.speed, speed); diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index f8cc1ed6..1c929a7c 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -128,10 +128,10 @@ public class AltosCSV implements AltosWriter { void write_basic(AltosRecord record) { out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f", record.acceleration(), - record.raw_pressure(), - record.raw_altitude(), - record.raw_height(), - record.accel_speed(), + record.pressure(), + record.altitude(), + record.height(), + state.accel_speed, state.baro_speed, record.temperature(), record.battery_voltage(), diff --git a/altosui/AltosDataPoint.java b/altosui/AltosDataPoint.java index 5e077320..4956e9f3 100644 --- a/altosui/AltosDataPoint.java +++ b/altosui/AltosDataPoint.java @@ -16,11 +16,8 @@ interface AltosDataPoint { String state_name(); double acceleration(); - double pressure(); - double altitude(); double height(); - double accel_speed(); - double baro_speed(); + double speed(); double temperature(); double battery_voltage(); double drogue_voltage(); diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index 2316cf97..88df081f 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -12,7 +12,6 @@ import org.altusmetrum.AltosLib.*; class AltosDataPointReader implements Iterable { Iterator iter; AltosState state; - AltosRecord record; boolean has_gps; boolean has_accel; boolean has_ignite; @@ -22,7 +21,7 @@ class AltosDataPointReader implements Iterable { public AltosDataPointReader(AltosRecordIterable reader) { this.iter = reader.iterator(); this.state = null; - has_accel = reader.has_accel(); + has_accel = true; has_gps = reader.has_gps(); has_ignite = reader.has_ignite(); } @@ -30,35 +29,31 @@ class AltosDataPointReader implements Iterable { private void read_next_record() throws NoSuchElementException { - record = iter.next(); - state = new AltosState(record, state); + state = new AltosState(iter.next(), state); } private AltosDataPoint current_dp() { - assert this.record != null; + assert this.state != null; return new AltosDataPoint() { - public int version() { return record.version; } - public int serial() { return record.serial; } - public int flight() { return record.flight; } - public String callsign() { return record.callsign; } - public double time() { return record.time; } - public double rssi() { return record.rssi; } + public int version() { return state.data.version; } + public int serial() { return state.data.serial; } + public int flight() { return state.data.flight; } + public String callsign() { return state.data.callsign; } + public double time() { return state.data.time; } + public double rssi() { return state.data.rssi; } - public int state() { return record.state; } - public String state_name() { return record.state(); } + public int state() { return state.state; } + public String state_name() { return state.data.state(); } - public double acceleration() { return record.acceleration(); } - public double pressure() { return record.raw_pressure(); } - public double altitude() { return record.raw_altitude(); } - public double height() { return record.raw_height(); } - public double accel_speed() { return record.accel_speed(); } - public double baro_speed() { return state.baro_speed; } - public double temperature() { return record.temperature(); } - public double battery_voltage() { return record.battery_voltage(); } - public double drogue_voltage() { return record.drogue_voltage(); } - public double main_voltage() { return record.main_voltage(); } - public boolean has_accel() { return has_accel; } + public double acceleration() { return state.acceleration; } + public double height() { return state.height; } + public double speed() { return state.speed(); } + public double temperature() { return state.temperature; } + public double battery_voltage() { return state.battery; } + public double drogue_voltage() { return state.drogue_sense; } + public double main_voltage() { return state.main_sense; } + public boolean has_accel() { return true; } // return state.acceleration != AltosRecord.MISSING; } }; } @@ -68,14 +63,14 @@ class AltosDataPointReader implements Iterable { throw new UnsupportedOperationException(); } public boolean hasNext() { - if (record != null && record.state == Altos.ao_flight_landed) + if (state != null && state.state == Altos.ao_flight_landed) return false; return iter.hasNext(); } public AltosDataPoint next() { do { read_next_record(); - } while (record.time < -1.0 && hasNext()); + } while (state.data.time < -1.0 && hasNext()); return current_dp(); } }; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index a71cdc10..2ea7cbfa 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -256,7 +256,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Speed extends DescentValue { void show (AltosState state, int crc_errors) { - double speed = state.speed; + double speed = state.accel_speed; if (!state.ascent) speed = state.baro_speed; show(AltosConvert.speed, speed); diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index f7a1d03e..1ba70c7e 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -197,7 +197,7 @@ public class AltosDisplayThread extends Thread { if ((old_state == null || old_state.state <= Altos.ao_flight_boost) && state.state > Altos.ao_flight_boost) { voice.speak("max speed: %s.", - AltosConvert.speed.say_units(state.max_speed + 0.5)); + AltosConvert.speed.say_units(state.max_accel_speed + 0.5)); ret = true; } else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) && state.state >= Altos.ao_flight_drogue) { diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java index e48cb608..1653ca57 100644 --- a/altosui/AltosFlightStats.java +++ b/altosui/AltosFlightStats.java @@ -24,7 +24,7 @@ public class AltosFlightStats { double max_height; double max_speed; double max_acceleration; - double[] state_speed = new double[Altos.ao_flight_invalid + 1]; + double[] state_accel_speed = new double[Altos.ao_flight_invalid + 1]; double[] state_baro_speed = new double[Altos.ao_flight_invalid + 1]; double[] state_accel = new double[Altos.ao_flight_invalid + 1]; int[] state_count = new int[Altos.ao_flight_invalid + 1]; @@ -123,7 +123,7 @@ public class AltosFlightStats { } } state_accel[state.state] += state.acceleration; - state_speed[state.state] += state.speed; + state_accel_speed[state.state] += state.accel_speed; state_baro_speed[state.state] += state.baro_speed; state_count[state.state]++; if (state_start[state.state] == 0.0) @@ -131,8 +131,8 @@ public class AltosFlightStats { if (state_end[state.state] < state.time) state_end[state.state] = state.time; max_height = state.max_height; - if (state.max_speed != 0) - max_speed = state.max_speed; + if (state.max_accel_speed != 0) + max_speed = state.max_accel_speed; else max_speed = state.max_baro_speed; max_acceleration = state.max_acceleration; @@ -140,7 +140,7 @@ public class AltosFlightStats { } for (int s = Altos.ao_flight_startup; s <= Altos.ao_flight_landed; s++) { if (state_count[s] > 0) { - state_speed[s] /= state_count[s]; + state_accel_speed[s] /= state_count[s]; state_baro_speed[s] /= state_count[s]; state_accel[s] /= state_count[s]; } diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index cb8e3d20..f59f70ba 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -40,12 +40,7 @@ public class AltosGraphUI extends AltosFrame AltosGraphTime.Element speed = new AltosGraphTime.TimeSeries(String.format("Speed (%s)", AltosConvert.speed.show_units()), "Vertical Speed", green) { public void gotTimeData(double time, AltosDataPoint d) { - double speed; - if (d.state() < Altos.ao_flight_drogue && d.has_accel()) { - speed = d.accel_speed(); - } else { - speed = d.baro_speed(); - } + double speed = d.speed(); if (speed != AltosRecord.MISSING) series.add(time, AltosConvert.speed.value(speed)); } diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 86e02ab1..11d1b0c1 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -114,8 +114,8 @@ public class AltosInfoTable extends JTable { info_add_row(0, "Max height", "%6.0f m", state.max_height); info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration); info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration); - info_add_row(0, "Speed", "%8.1f m/s", state.ascent ? state.speed : state.baro_speed); - info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed); + info_add_row(0, "Speed", "%8.1f m/s", state.speed()); + info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed); info_add_row(0, "Temperature", "%9.2f °C", state.temperature); info_add_row(0, "Battery", "%9.2f V", state.battery); if (state.drogue_sense != AltosRecord.MISSING) diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java index 57339b19..281638bf 100644 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@ -109,7 +109,7 @@ public class AltosKML implements AltosWriter { AltosGPS gps = record.gps; out.printf(kml_coord_fmt, gps.lon, gps.lat, - record.filtered_altitude(), (double) gps.alt, + record.altitude(), (double) gps.alt, record.time, gps.nsat); } diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 57c2d476..0111a08a 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -173,7 +173,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio class Speed extends LandedValue { void show (AltosState state, int crc_errors) { - show(AltosConvert.speed, state.max_speed); + show(AltosConvert.speed, state.max_speed()); } public Speed (GridBagLayout layout, int y) { super (layout, y, "Maximum Speed"); -- cgit v1.2.3 From 89c621be35e1a6d3394b0e143391fcf2d94d7b41 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 21 Oct 2012 16:53:23 -0700 Subject: altoslib: Parse GPS .mega file entries for reply/graphing The .mega file parsing had a pile of leftovers from when it was cloned from the .eeprom file parsing code. Replace all of that with the right parsing bits so that GPS data will be presented correctly. Signed-off-by: Keith Packard --- altoslib/AltosEepromMega.java | 52 +++++++++++------ altoslib/AltosEepromMegaIterable.java | 102 ++++++++++++++-------------------- 2 files changed, 77 insertions(+), 77 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index 25a29fb2..af4f8aca 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -24,7 +24,7 @@ public class AltosEepromMega { public int tick; public boolean valid; public String data; - public int a, b; + public int config_a, config_b; public int data8[]; @@ -74,6 +74,22 @@ public class AltosEepromMega { public int nsense() { return data16(4); } public int sense(int i) { return data16(6 + i * 2); } + /* AO_LOG_GPS_TIME elements */ + public int latitude() { return data32(0); } + public int longitude() { return data32(4); } + public int altitude() { return data16(8); } + public int hour() { return data8(10); } + public int minute() { return data8(11); } + public int second() { return data8(12); } + public int flags() { return data8(13); } + public int year() { return data8(14); } + public int month() { return data8(15); } + public int day() { return data8(16); } + + /* AO_LOG_GPS_SAT elements */ + public int nsat() { return data16(0); } + public int svid(int n) { return data8(2 + n * 2); } + public int c_n(int n) { return data8(2 + n * 2 + 1); } public AltosEepromMega (AltosEepromChunk chunk, int start) throws ParseException { cmd = chunk.data(start); @@ -121,26 +137,26 @@ public class AltosEepromMega { data = tokens[2]; } else if (tokens[0].equals("Main") && tokens[1].equals("deploy:")) { cmd = AltosLib.AO_LOG_MAIN_DEPLOY; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[0].equals("Apogee") && tokens[1].equals("delay:")) { cmd = AltosLib.AO_LOG_APOGEE_DELAY; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[0].equals("Radio") && tokens[1].equals("channel:")) { cmd = AltosLib.AO_LOG_RADIO_CHANNEL; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[0].equals("Callsign:")) { cmd = AltosLib.AO_LOG_CALLSIGN; data = tokens[1].replaceAll("\"",""); } else if (tokens[0].equals("Accel") && tokens[1].equals("cal")) { cmd = AltosLib.AO_LOG_ACCEL_CAL; - a = Integer.parseInt(tokens[3]); - b = Integer.parseInt(tokens[5]); + config_a = Integer.parseInt(tokens[3]); + config_b = Integer.parseInt(tokens[5]); } else if (tokens[0].equals("Radio") && tokens[1].equals("cal:")) { cmd = AltosLib.AO_LOG_RADIO_CAL; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[0].equals("Max") && tokens[1].equals("flight") && tokens[2].equals("log:")) { cmd = AltosLib.AO_LOG_MAX_FLIGHT_LOG; - a = Integer.parseInt(tokens[3]); + config_a = Integer.parseInt(tokens[3]); } else if (tokens[0].equals("manufacturer")) { cmd = AltosLib.AO_LOG_MANUFACTURER; data = tokens[1]; @@ -149,38 +165,38 @@ public class AltosEepromMega { data = tokens[1]; } else if (tokens[0].equals("serial-number")) { cmd = AltosLib.AO_LOG_SERIAL_NUMBER; - a = Integer.parseInt(tokens[1]); + config_a = Integer.parseInt(tokens[1]); } else if (tokens[0].equals("log-format")) { cmd = AltosLib.AO_LOG_LOG_FORMAT; - a = Integer.parseInt(tokens[1]); + config_a = Integer.parseInt(tokens[1]); } else if (tokens[0].equals("software-version")) { cmd = AltosLib.AO_LOG_SOFTWARE_VERSION; data = tokens[1]; } else if (tokens[0].equals("ms5607")) { if (tokens[1].equals("reserved:")) { cmd = AltosLib.AO_LOG_BARO_RESERVED; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("sens:")) { cmd = AltosLib.AO_LOG_BARO_SENS; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("off:")) { cmd = AltosLib.AO_LOG_BARO_OFF; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("tcs:")) { cmd = AltosLib.AO_LOG_BARO_TCS; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("tco:")) { cmd = AltosLib.AO_LOG_BARO_TCO; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("tref:")) { cmd = AltosLib.AO_LOG_BARO_TREF; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("tempsens:")) { cmd = AltosLib.AO_LOG_BARO_TEMPSENS; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else if (tokens[1].equals("crc:")) { cmd = AltosLib.AO_LOG_BARO_CRC; - a = Integer.parseInt(tokens[2]); + config_a = Integer.parseInt(tokens[2]); } else { cmd = AltosLib.AO_LOG_INVALID; data = line; diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index 50f9d33d..16809089 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -109,7 +109,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { case AltosLib.AO_LOG_TEMP_VOLT: state.v_batt = record.v_batt(); state.v_pyro = record.v_pbatt(); - for (int i = 0; i < AltosRecordMM.num_sense; i++) + for (int i = 0; i < record.nsense(); i++) state.sense[i] = record.sense(i); eeprom.seen |= seen_temp_volt; break; @@ -118,51 +118,35 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { break; case AltosLib.AO_LOG_GPS_TIME: eeprom.gps_tick = state.tick; - AltosGPS old = state.gps; state.gps = new AltosGPS(); - /* GPS date doesn't get repeated through the file */ - if (old != null) { - state.gps.year = old.year; - state.gps.month = old.month; - state.gps.day = old.day; - } - state.gps.hour = (record.a & 0xff); - state.gps.minute = (record.a >> 8); - state.gps.second = (record.b & 0xff); + state.gps.lat = record.latitude() / 1e7; + state.gps.lon = record.longitude() / 1e7; + state.gps.alt = record.altitude(); + state.gps.year = record.year() + 2000; + state.gps.month = record.month(); + state.gps.day = record.day(); + + state.gps.hour = record.hour(); + state.gps.minute = record.minute(); + state.gps.second = record.second(); - int flags = (record.b >> 8); + int flags = record.flags(); state.gps.connected = (flags & AltosLib.AO_GPS_RUNNING) != 0; state.gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0; state.gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >> AltosLib.AO_GPS_NUM_SAT_SHIFT; state.new_gps = true; has_gps = true; - break; - case AltosLib.AO_LOG_GPS_LAT: - int lat32 = record.a | (record.b << 16); - state.gps.lat = (double) lat32 / 1e7; - break; - case AltosLib.AO_LOG_GPS_LON: - int lon32 = record.a | (record.b << 16); - state.gps.lon = (double) lon32 / 1e7; - break; - case AltosLib.AO_LOG_GPS_ALT: - state.gps.alt = record.a; + eeprom.seen |= seen_gps_time | seen_gps_lat | seen_gps_lon; break; case AltosLib.AO_LOG_GPS_SAT: if (state.tick == eeprom.gps_tick) { - int svid = record.a; - int c_n0 = record.b >> 8; - state.gps.add_sat(svid, c_n0); + int nsat = record.nsat(); + for (int i = 0; i < nsat; i++) + state.gps.add_sat(record.svid(i), record.c_n(i)); } break; - case AltosLib.AO_LOG_GPS_DATE: - state.gps.year = (record.a & 0xff) + 2000; - state.gps.month = record.a >> 8; - state.gps.day = record.b & 0xff; - break; - case AltosLib.AO_LOG_CONFIG_VERSION: break; case AltosLib.AO_LOG_MAIN_DEPLOY: @@ -175,8 +159,8 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { state.callsign = record.data; break; case AltosLib.AO_LOG_ACCEL_CAL: - state.accel_plus_g = record.a; - state.accel_minus_g = record.b; + state.accel_plus_g = record.config_a; + state.accel_minus_g = record.config_b; break; case AltosLib.AO_LOG_RADIO_CAL: break; @@ -185,33 +169,33 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { case AltosLib.AO_LOG_PRODUCT: break; case AltosLib.AO_LOG_SERIAL_NUMBER: - state.serial = record.a; + state.serial = record.config_a; break; case AltosLib.AO_LOG_SOFTWARE_VERSION: break; case AltosLib.AO_LOG_BARO_RESERVED: - baro.reserved = record.a; + baro.reserved = record.config_a; break; case AltosLib.AO_LOG_BARO_SENS: - baro.sens =record.a; + baro.sens =record.config_a; break; case AltosLib.AO_LOG_BARO_OFF: - baro.off =record.a; + baro.off =record.config_a; break; case AltosLib.AO_LOG_BARO_TCS: - baro.tcs =record.a; + baro.tcs =record.config_a; break; case AltosLib.AO_LOG_BARO_TCO: - baro.tco =record.a; + baro.tco =record.config_a; break; case AltosLib.AO_LOG_BARO_TREF: - baro.tref =record.a; + baro.tref =record.config_a; break; case AltosLib.AO_LOG_BARO_TEMPSENS: - baro.tempsens =record.a; + baro.tempsens =record.config_a; break; case AltosLib.AO_LOG_BARO_CRC: - baro.crc =record.a; + baro.crc =record.config_a; break; } state.seen |= eeprom.seen; @@ -270,25 +254,25 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { out.printf("# Config version: %s\n", record.data); break; case AltosLib.AO_LOG_MAIN_DEPLOY: - out.printf("# Main deploy: %s\n", record.a); + out.printf("# Main deploy: %s\n", record.config_a); break; case AltosLib.AO_LOG_APOGEE_DELAY: - out.printf("# Apogee delay: %s\n", record.a); + out.printf("# Apogee delay: %s\n", record.config_a); break; case AltosLib.AO_LOG_RADIO_CHANNEL: - out.printf("# Radio channel: %s\n", record.a); + out.printf("# Radio channel: %s\n", record.config_a); break; case AltosLib.AO_LOG_CALLSIGN: out.printf("# Callsign: %s\n", record.data); break; case AltosLib.AO_LOG_ACCEL_CAL: - out.printf ("# Accel cal: %d %d\n", record.a, record.b); + out.printf ("# Accel cal: %d %d\n", record.config_a, record.config_b); break; case AltosLib.AO_LOG_RADIO_CAL: - out.printf ("# Radio cal: %d\n", record.a); + out.printf ("# Radio cal: %d\n", record.config_a); break; case AltosLib.AO_LOG_MAX_FLIGHT_LOG: - out.printf ("# Max flight log: %d\n", record.a); + out.printf ("# Max flight log: %d\n", record.config_a); break; case AltosLib.AO_LOG_MANUFACTURER: out.printf ("# Manufacturer: %s\n", record.data); @@ -297,34 +281,34 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { out.printf ("# Product: %s\n", record.data); break; case AltosLib.AO_LOG_SERIAL_NUMBER: - out.printf ("# Serial number: %d\n", record.a); + out.printf ("# Serial number: %d\n", record.config_a); break; case AltosLib.AO_LOG_SOFTWARE_VERSION: out.printf ("# Software version: %s\n", record.data); break; case AltosLib.AO_LOG_BARO_RESERVED: - out.printf ("# Baro reserved: %d\n", record.a); + out.printf ("# Baro reserved: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_SENS: - out.printf ("# Baro sens: %d\n", record.a); + out.printf ("# Baro sens: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_OFF: - out.printf ("# Baro off: %d\n", record.a); + out.printf ("# Baro off: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_TCS: - out.printf ("# Baro tcs: %d\n", record.a); + out.printf ("# Baro tcs: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_TCO: - out.printf ("# Baro tco: %d\n", record.a); + out.printf ("# Baro tco: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_TREF: - out.printf ("# Baro tref: %d\n", record.a); + out.printf ("# Baro tref: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_TEMPSENS: - out.printf ("# Baro tempsens: %d\n", record.a); + out.printf ("# Baro tempsens: %d\n", record.config_a); break; case AltosLib.AO_LOG_BARO_CRC: - out.printf ("# Baro crc: %d\n", record.a); + out.printf ("# Baro crc: %d\n", record.config_a); break; } } @@ -369,7 +353,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { /* Bail after reading the 'landed' record; we're all done */ if (record.cmd == AltosLib.AO_LOG_STATE && - record.a == AltosLib.ao_flight_landed) + record.state() == AltosLib.ao_flight_landed) break; } } catch (IOException io) { -- cgit v1.2.3 From e4ee3a35dbb1586f65adada0eaf34b7b4e5432eb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 21 Oct 2012 19:51:02 -0700 Subject: altoslib: Add AltosRecordNone.java oops. forgot a file. Signed-off-by: Keith Packard --- altoslib/AltosRecordNone.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 altoslib/AltosRecordNone.java (limited to 'altoslib') diff --git a/altoslib/AltosRecordNone.java b/altoslib/AltosRecordNone.java new file mode 100644 index 00000000..ca0a5fe3 --- /dev/null +++ b/altoslib/AltosRecordNone.java @@ -0,0 +1,34 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +public class AltosRecordNone extends AltosRecord { + + public double pressure() { return MISSING; } + public double ground_pressure() { return MISSING; } + public double temperature() { return MISSING; } + public double acceleration() { return MISSING; } + + public AltosRecordNone(AltosRecord old) { + super.copy(old); + } + + public AltosRecordNone() { + super(); + } +} -- cgit v1.2.3 From fe00d1169c65cb289f77093cf281efbd0a5d4e64 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 22 Oct 2012 21:35:06 -0700 Subject: altosui/altoslib: Add support for configuring pyro channels This provides a UI on devices which have pyro channels other than main/apogee. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 17 +++ altoslib/AltosPyro.java | 293 +++++++++++++++++++++++++++++++++++++++++ altoslib/Makefile.am | 3 +- altosui/AltosConfig.java | 32 +++++ altosui/AltosConfigPyroUI.java | 288 ++++++++++++++++++++++++++++++++++++++++ altosui/AltosConfigUI.java | 68 ++++++++-- altosui/AltosDialog.java | 6 + altosui/Makefile.am | 1 + 8 files changed, 697 insertions(+), 11 deletions(-) create mode 100644 altoslib/AltosPyro.java create mode 100644 altosui/AltosConfigPyroUI.java (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index a962b105..45a88783 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -50,6 +50,8 @@ public class AltosConfigData implements Iterable { public int storage_size; public int storage_erase_unit; + public AltosPyro[] pyros; + public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { String quoted = line.substring(label.length()).trim(); @@ -135,6 +137,10 @@ public class AltosConfigData implements Iterable { radio_frequency = 0; stored_flight = 0; serial = -1; + pyros = null; + + int npyro = 0; + int pyro = 0; for (;;) { String line = link.get_reply(); if (line == null) @@ -142,6 +148,16 @@ public class AltosConfigData implements Iterable { if (line.contains("Syntax error")) continue; lines.add(line); + if (pyro < npyro - 1) { + if (pyros == null) + pyros = new AltosPyro[npyro]; + try { + pyros[pyro] = new AltosPyro(pyro, line); + } catch (ParseException e) { + } + ++pyro; + continue; + } try { serial = get_int(line, "serial-number"); } catch (Exception e) {} try { log_format = get_int(line, "log-format"); } catch (Exception e) {} try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} @@ -173,6 +189,7 @@ public class AltosConfigData implements Iterable { try { get_int(line, "flight"); stored_flight++; } catch (Exception e) {} try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {} + try { npyro = get_int(line, "Pyro-count:"); pyro = 0; } catch (Exception e) {} /* signals the end of the version info */ if (line.startsWith("software-version")) diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java new file mode 100644 index 00000000..14051169 --- /dev/null +++ b/altoslib/AltosPyro.java @@ -0,0 +1,293 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +import java.util.*; +import java.text.*; +import java.util.concurrent.*; + +public class AltosPyro { + public static final int pyro_none = 0x00000000; + + public static final int pyro_accel_less = 0x00000001; + 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 (m/s²)"; + public static final String pyro_accel_greater_name = "Acceleration greater than (m/s²)"; + 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 (m/s)"; + public static final String pyro_speed_greater_name = "Speed greater than (m/s)"; + 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 (m)"; + public static final String pyro_height_greater_name = "Height greater than (m)"; + public static final double pyro_height_scale = 1.0; + + public static final int pyro_orient_less = 0x00000040; + public static final int pyro_orient_greater = 0x00000080; + public static final String pyro_orient_less_string = "o<"; + public static final String pyro_orient_greater_string = "o>"; + public static final String pyro_orient_less_name = "Angle from vertical less than (degrees)"; + public static final String pyro_orient_greater_name = "Angle from vertical greater than (degrees)"; + public static final double pyro_orient_scale = 1.0; + + public static final int pyro_time_less = 0x00000100; + 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 double pyro_time_scale = 100.0; + + public static final int pyro_ascending = 0x00000400; + public static final int pyro_descending = 0x00000800; + public static final String pyro_ascending_string = "A"; + public static final String pyro_descending_string = "D"; + public static final String pyro_ascending_name = "Ascending"; + public static final String pyro_descending_name = "Descending"; + + public static final int pyro_after_motor = 0x00001000; + public static final String pyro_after_motor_string = "m"; + public static final String pyro_after_motor_name = "After motor number"; + public static final double pyro_after_motor_scale = 1.0; + + public static final int pyro_delay = 0x00002000; + public static final String pyro_delay_string = "d"; + public static final String pyro_delay_name = "Delay after other conditions (s)"; + public static final double pyro_delay_scale = 100.0; + + public static final int pyro_state_less = 0x00004000; + public static final int pyro_state_greater_or_equal = 0x00008000; + public static final String pyro_state_less_string = "f<"; + public static final String pyro_state_greater_or_equal_string = "f>="; + public static final String pyro_state_less_name = "Flight state before"; + 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_all = 0x0000ffff; + + public static final int pyro_no_value = (pyro_ascending | + pyro_descending); + + public static final int pyro_state_value = pyro_state_less | pyro_state_greater_or_equal; + + private static HashMap string_to_pyro = new HashMap(); + + private static HashMap pyro_to_string = new HashMap(); + + private static HashMap pyro_to_name = new HashMap(); + + private static HashMap pyro_to_scale = new HashMap(); + + private static void insert_map(int flag, String string, String name, double scale) { + string_to_pyro.put(string, flag); + pyro_to_string.put(flag, string); + pyro_to_name.put(flag, name); + pyro_to_scale.put(flag, scale); + } + + public static int string_to_pyro(String name) { + if (string_to_pyro.containsKey(name)) + return string_to_pyro.get(name); + return pyro_none; + } + + public static String pyro_to_string(int flag) { + if (pyro_to_string.containsKey(flag)) + return pyro_to_string.get(flag); + return null; + } + + public static String pyro_to_name(int flag) { + if (pyro_to_name.containsKey(flag)) + return pyro_to_name.get(flag); + return null; + } + + public static double pyro_to_scale(int flag) { + if (pyro_to_scale.containsKey(flag)) + return pyro_to_scale.get(flag); + return 1.0; + } + + private static void initialize_maps() { + insert_map(pyro_accel_less, pyro_accel_less_string, pyro_accel_less_name, pyro_accel_scale); + insert_map(pyro_accel_greater, pyro_accel_greater_string, pyro_accel_greater_name, pyro_accel_scale); + + insert_map(pyro_speed_less, pyro_speed_less_string, pyro_speed_less_name, pyro_speed_scale); + insert_map(pyro_speed_greater, pyro_speed_greater_string, pyro_speed_greater_name, pyro_speed_scale); + + insert_map(pyro_height_less, pyro_height_less_string, pyro_height_less_name, pyro_height_scale); + insert_map(pyro_height_greater, pyro_height_greater_string, pyro_height_greater_name, pyro_height_scale); + + insert_map(pyro_orient_less, pyro_orient_less_string, pyro_orient_less_name, pyro_orient_scale); + insert_map(pyro_orient_greater, pyro_orient_greater_string, pyro_orient_greater_name, pyro_orient_scale); + + insert_map(pyro_time_less, pyro_time_less_string, pyro_time_less_name, pyro_time_scale); + insert_map(pyro_time_greater, pyro_time_greater_string, pyro_time_greater_name, pyro_time_scale); + + insert_map(pyro_ascending, pyro_ascending_string, pyro_ascending_name, 1.0); + insert_map(pyro_descending, pyro_descending_string, pyro_descending_name, 1.0); + + insert_map(pyro_after_motor, pyro_after_motor_string, pyro_after_motor_name, 1.0); + insert_map(pyro_delay, pyro_delay_string, pyro_delay_name, pyro_delay_scale); + + insert_map(pyro_state_less, pyro_state_less_string, pyro_state_less_name, 1.0); + insert_map(pyro_state_greater_or_equal, pyro_state_greater_or_equal_string, pyro_state_greater_or_equal_name, 1.0); + } + + { + initialize_maps(); + } + + public int channel; + public int flags; + public int accel_less, accel_greater; + public int speed_less, speed_greater; + public int height_less, height_greater; + public int orient_less, orient_greater; + public int time_less, time_greater; + public int delay; + public int state_less, state_greater_or_equal; + public int motor; + + public AltosPyro(int in_channel) { + channel = in_channel; + flags = 0; + } + + private boolean set_ivalue(int flag, int value) { + switch (flag) { + case pyro_accel_less: accel_less = value; break; + case pyro_accel_greater: accel_greater = value; break; + case pyro_speed_less: speed_less = value; break; + case pyro_speed_greater: speed_greater = value; break; + case pyro_height_less: height_less = value; break; + case pyro_height_greater: height_greater = value; break; + case pyro_orient_less: orient_less = value; break; + case pyro_orient_greater: orient_greater = value; break; + case pyro_time_less: time_less = value; break; + case pyro_time_greater: time_greater = value; break; + case pyro_after_motor: motor = value; break; + case pyro_delay: delay = value; break; + case pyro_state_less: state_less = value; break; + case pyro_state_greater_or_equal: state_greater_or_equal = value; break; + default: + return false; + } + return true; + } + + public boolean set_value(int flag, double dvalue) { + return set_ivalue(flag, (int) (dvalue * pyro_to_scale(flag))); + } + + private int get_ivalue (int flag) { + int value; + + switch (flag) { + case pyro_accel_less: value = accel_less; break; + case pyro_accel_greater: value = accel_greater; break; + case pyro_speed_less: value = speed_less; break; + case pyro_speed_greater: value = speed_greater; break; + case pyro_height_less: value = height_less; break; + case pyro_height_greater: value = height_greater; break; + case pyro_orient_less: value = orient_less; break; + case pyro_orient_greater: value = orient_greater; break; + case pyro_time_less: value = time_less; break; + case pyro_time_greater: value = time_greater; break; + case pyro_after_motor: value = motor; break; + case pyro_delay: value = delay; break; + case pyro_state_less: value = state_less; break; + case pyro_state_greater_or_equal: value = state_greater_or_equal; break; + default: value = 0; break; + } + return value; + } + + public double get_value(int flag) { + return get_ivalue(flag) / pyro_to_scale(flag); + } + + public AltosPyro(int in_channel, String line) throws ParseException { + String[] tokens = line.split("\\s+"); + + channel = in_channel; + flags = 0; + + int i = 0; + if (tokens[i].equals("Pyro")) + i += 2; + + for (; i < tokens.length; i++) { + + if (tokens[i].equals("")) + break; + + int flag = string_to_pyro(tokens[i]); + if (flag == pyro_none) + throw new ParseException(String.format("Invalid pyro token \"%s\"", + tokens[i]), i); + flags |= flag; + + if ((flag & pyro_no_value) == 0) { + int value = 0; + ++i; + try { + value = AltosLib.fromdec(tokens[i]); + } catch (NumberFormatException n) { + throw new ParseException(String.format("Invalid pyro value \"%s\"", + tokens[i]), i); + } + if (!set_ivalue(flag, value)) + throw new ParseException(String.format("Internal parser error \"%s\" \"%s\"", + tokens[i-1], tokens[i]), i-1); + } + } + } + + public String toString() { + String ret = String.format("%d", channel); + + for (int flag = 1; flag <= flags; flag <<= 1) { + if ((flags & flag) != 0) { + String add; + if ((flag & pyro_no_value) == 0) { + add = String.format(" %s %d", + pyro_to_string.get(flag), + get_ivalue(flag)); + } else { + add = String.format(" %s", + pyro_to_string.get(flag)); + } + ret = ret.concat(add); + } + } + return ret; + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index f04c10c6..2579a650 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -75,7 +75,8 @@ AltosLib_JAVA = \ $(SRC)/AltosDistance.java \ $(SRC)/AltosHeight.java \ $(SRC)/AltosSpeed.java \ - $(SRC)/AltosAccel.java + $(SRC)/AltosAccel.java \ + $(SRC)/AltosPyro.java JAR=AltosLib.jar diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 44e5a3fa..be9ab8bf 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -22,6 +22,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import org.altusmetrum.AltosLib.*; +import java.text.*; public class AltosConfig implements ActionListener { @@ -78,6 +79,8 @@ public class AltosConfig implements ActionListener { string_ref version; string_ref product; string_ref callsign; + int_ref npyro; + AltosPyro[] pyros; AltosConfigUI config_ui; boolean serial_started; boolean made_visible; @@ -162,6 +165,8 @@ public class AltosConfig implements ActionListener { 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_pyros(pyros); + config_ui.set_has_pyro(npyro.get() > 0); config_ui.set_clean(); if (!made_visible) { made_visible = true; @@ -169,6 +174,8 @@ public class AltosConfig implements ActionListener { } } + int pyro; + void process_line(String line) { if (line == null) { abort(); @@ -179,6 +186,18 @@ public class AltosConfig implements ActionListener { update_ui(); return; } + if (pyro < npyro.get()) { + if (pyros == null) + pyros = new AltosPyro[npyro.get()]; + + try { + pyros[pyro] = new AltosPyro(pyro, line); + } catch (ParseException e) { + System.out.printf ("pyro parse failed %s\n", line); + } + ++pyro; + return; + } get_int(line, "serial-number", serial); get_int(line, "log-format", log_format); get_int(line, "Main deploy:", main_deploy); @@ -200,6 +219,7 @@ public class AltosConfig implements ActionListener { get_string(line, "Callsign:", callsign); get_string(line,"software-version", version); get_string(line,"product", product); + get_int(line, "Pyro-count:", npyro); } final static int serial_mode_read = 0; @@ -243,6 +263,8 @@ public class AltosConfig implements ActionListener { callsign.set("N0CALL"); version.set("unknown"); product.set("unknown"); + pyro = 0; + npyro.set(0); } void get_data() { @@ -304,6 +326,12 @@ public class AltosConfig implements ActionListener { 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()); + if (pyros.length > 0) { + for (int p = 0; p < pyros.length; p++) { + serial_line.printf("c P %s\n", + pyros[p].toString()); + } + } serial_line.printf("c w\n"); } catch (InterruptedException ie) { } catch (TimeoutException te) { @@ -431,6 +459,9 @@ public class AltosConfig implements ActionListener { if (pad_orientation.get() >= 0) pad_orientation.set(config_ui.pad_orientation()); callsign.set(config_ui.callsign()); + if (npyro.get() > 0) { + pyros = config_ui.pyros(); + } run_serial_thread(serial_mode_save); } @@ -477,6 +508,7 @@ public class AltosConfig implements ActionListener { callsign = new string_ref("N0CALL"); version = new string_ref("unknown"); product = new string_ref("unknown"); + npyro = new int_ref(0); device = AltosDeviceDialog.show(owner, Altos.product_any); if (device != null) { diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java new file mode 100644 index 00000000..17adb15f --- /dev/null +++ b/altosui/AltosConfigPyroUI.java @@ -0,0 +1,288 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.*; +import org.altusmetrum.AltosLib.*; + +public class AltosConfigPyroUI + extends AltosDialog + implements ItemListener, DocumentListener +{ + AltosConfigUI owner; + Container pane; + + static Insets il = new Insets(4,4,4,4); + static Insets ir = new Insets(4,4,4,4); + + static String[] state_names; + + static void make_state_names() { + if (state_names == null) { + + state_names = new String[AltosLib.ao_flight_landed - AltosLib.ao_flight_boost + 1]; + for (int state = AltosLib.ao_flight_boost; state <= AltosLib.ao_flight_landed; state++) + state_names[state - AltosLib.ao_flight_boost] = AltosLib.state_name_capital(state); + } + } + + class PyroItem implements ItemListener, DocumentListener + { + public int flag; + public JRadioButton enable; + public JTextField value; + public JComboBox combo; + AltosConfigPyroUI ui; + + public void set_enable(boolean enable) { + if (value != null) + value.setEnabled(enable); + if (combo != null) + combo.setEnabled(enable); + } + + public void itemStateChanged(ItemEvent e) { + set_enable(enable.isSelected()); + ui.set_dirty(); + } + + public void changedUpdate(DocumentEvent e) { + ui.set_dirty(); + } + + public void insertUpdate(DocumentEvent e) { + ui.set_dirty(); + } + + public void removeUpdate(DocumentEvent e) { + ui.set_dirty(); + } + + public void set(boolean new_enable, double new_value) { + enable.setSelected(new_enable); + set_enable(new_enable); + if (value != null) { + double scale = AltosPyro.pyro_to_scale(flag); + String format = "%6.0f"; + if (scale >= 10) + format = "%6.1f"; + else if (scale >= 100) + format = "%6.2f"; + value.setText(String.format(format, new_value)); + } + if (combo != null) + if (new_value >= AltosLib.ao_flight_boost && new_value <= AltosLib.ao_flight_landed) + combo.setSelectedIndex((int) new_value - AltosLib.ao_flight_boost); + } + + public boolean enabled() { + return enable.isSelected(); + } + + public double value() { + if (value != null) + return Double.parseDouble(value.getText()); + if (combo != null) + return combo.getSelectedIndex() + AltosLib.ao_flight_boost; + return 0; + } + + public PyroItem(AltosConfigPyroUI in_ui, int in_flag, int x, int y) { + + ui = in_ui; + flag = in_flag; + + GridBagConstraints c; + c = new GridBagConstraints(); + c.gridx = x; c.gridy = y; + c.gridwidth = 1; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + enable = new JRadioButton(); + enable.addItemListener(this); + pane.add(enable, c); + + if ((flag & AltosPyro.pyro_no_value) == 0) { + c = new GridBagConstraints(); + c.gridx = x+1; c.gridy = y; + c.gridwidth = 1; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + if ((flag & AltosPyro.pyro_state_value) != 0) { + make_state_names(); + combo = new JComboBox(state_names); + combo.addItemListener(this); + pane.add(combo, c); + } else { + value = new JTextField(10); + value.getDocument().addDocumentListener(this); + pane.add(value, c); + } + } + } + } + + class PyroColumn { + public PyroItem[] items; + public JLabel label; + int channel; + + public void set(AltosPyro pyro) { + int row = 0; + for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) { + if ((AltosPyro.pyro_all & flag) != 0) { + items[row].set((pyro.flags & flag) != 0, + pyro.get_value(flag)); + row++; + } + } + } + + public AltosPyro get() { + AltosPyro p = new AltosPyro(channel); + + int row = 0; + for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) { + if ((AltosPyro.pyro_all & flag) != 0) { + if (items[row].enabled()) { + System.out.printf ("Flag %x enabled\n", flag); + p.flags |= flag; + p.set_value(flag, items[row].value()); + } + row++; + } + } + System.out.printf ("Pyro %x %s\n", p.flags, p.toString()); + return p; + } + + public PyroColumn(AltosConfigPyroUI ui, int x, int y, int in_channel) { + + channel = in_channel; + + int nrow = 0; + for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) + if ((flag & AltosPyro.pyro_all) != 0) + nrow++; + + items = new PyroItem[nrow]; + int row = 0; + + GridBagConstraints c; + c = new GridBagConstraints(); + c.gridx = x; c.gridy = y; + c.gridwidth = 2; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.insets = il; + label = new JLabel(String.format("Pyro Channel %d", channel)); + pane.add(label, c); + y++; + + for (int flag = 1; flag < AltosPyro.pyro_all; flag <<= 1) + if ((flag & AltosPyro.pyro_all) != 0) { + items[row] = new PyroItem(ui, flag, x, y + row); + row++; + } + } + } + + PyroColumn[] columns; + + public void set_pyros(AltosPyro[] pyros) { + for (int i = 0; i < pyros.length; i++) { + if (pyros[i].channel < columns.length) + columns[pyros[i].channel].set(pyros[i]); + } + } + + public AltosPyro[] get_pyros() { + AltosPyro[] pyros = new AltosPyro[columns.length]; + for (int c = 0; c < columns.length; c++) + pyros[c] = columns[c].get(); + return pyros; + } + + public void set_dirty() { + owner.set_dirty(); + } + + public void itemStateChanged(ItemEvent e) { + owner.set_dirty(); + } + + public void changedUpdate(DocumentEvent e) { + owner.set_dirty(); + } + + public void insertUpdate(DocumentEvent e) { + owner.set_dirty(); + } + + public void removeUpdate(DocumentEvent e) { + owner.set_dirty(); + } + + public AltosConfigPyroUI(AltosConfigUI in_owner, AltosPyro[] pyros) { + + super(in_owner, "Configure Pyro Channels", false); + + owner = in_owner; + + GridBagConstraints c; + + pane = getContentPane(); + pane.setLayout(new GridBagLayout()); + + int row = 1; + + for (int flag = 1; flag <= AltosPyro.pyro_all; flag <<= 1) { + String n; + + n = AltosPyro.pyro_to_name(flag); + if (n != null) { + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = row; + c.gridwidth = 1; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + JLabel label = new JLabel(n); + pane.add(label, c); + row++; + } + } + + columns = new PyroColumn[pyros.length]; + + for (int i = 0; i < pyros.length; i++) { + columns[i] = new PyroColumn(this, i*2 + 1, 0, i); + columns[i].set(pyros[i]); + } + } + + public void make_visible() { + pack(); + setVisible(true); + } +} diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index dd34a9cf..feac053b 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -29,7 +29,6 @@ public class AltosConfigUI { Container pane; - Box box; JLabel product_label; JLabel version_label; JLabel serial_label; @@ -62,11 +61,15 @@ public class AltosConfigUI JComboBox pad_orientation_value; JTextField callsign_value; + JButton pyro; + JButton save; JButton reset; JButton reboot; JButton close; + AltosPyro[] pyros; + ActionListener listener; static String[] main_deploy_values = { @@ -510,6 +513,20 @@ public class AltosConfigUI set_pad_orientation_tool_tip(); row++; + /* Pyro channels */ + c = new GridBagConstraints(); + c.gridx = 4; c.gridy = row; + c.gridwidth = 4; + c.fill = GridBagConstraints.HORIZONTAL; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + c.ipady = 5; + pyro = new JButton("Configure Pyro Channels"); + pane.add(pyro, c); + pyro.addActionListener(this); + pyro.setActionCommand("Pyro"); + row++; + /* Buttons */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -582,10 +599,30 @@ public class AltosConfigUI return true; } + void set_dirty() { + dirty = true; + save.setEnabled(true); + } + + public void set_clean() { + dirty = false; + save.setEnabled(false); + } + + AltosConfigPyroUI pyro_ui; + /* Listen for events from our buttons */ public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); + if (cmd.equals("Pyro")) { + if (pyro_ui == null && pyros != null) { + pyro_ui = new AltosConfigPyroUI(this, pyros); + pyro_ui.make_visible(); + } + return; + } + if (cmd.equals("Close") || cmd.equals("Reboot")) if (!check_dirty(cmd)) return; @@ -594,25 +631,25 @@ public class AltosConfigUI setVisible(false); dispose(); } - dirty = false; + set_clean(); } /* ItemListener interface method */ public void itemStateChanged(ItemEvent e) { - dirty = true; + set_dirty(); } /* DocumentListener interface methods */ public void changedUpdate(DocumentEvent e) { - dirty = true; + set_dirty(); } public void insertUpdate(DocumentEvent e) { - dirty = true; + set_dirty(); } public void removeUpdate(DocumentEvent e) { - dirty = true; + set_dirty(); } /* Let the config code hook on a listener */ @@ -725,8 +762,7 @@ public class AltosConfigUI } public void set_flight_log_max(int new_flight_log_max) { - if (new_flight_log_max == 0) - flight_log_max_value.setEnabled(false); + flight_log_max_value.setEnabled(new_flight_log_max > 0); flight_log_max_value.setSelectedItem(Integer.toString(new_flight_log_max)); set_flight_log_max_tool_tip(); } @@ -793,7 +829,19 @@ public class AltosConfigUI return -1; } - public void set_clean() { - dirty = false; + public void set_has_pyro(boolean has_pyro) { + pyro.setEnabled(has_pyro); + } + + public void set_pyros(AltosPyro[] new_pyros) { + pyros = new_pyros; + if (pyro_ui != null) + pyro_ui.set_pyros(pyros); + } + + public AltosPyro[] pyros() { + if (pyro_ui != null) + pyros = pyro_ui.get_pyros(); + return pyros; } } diff --git a/altosui/AltosDialog.java b/altosui/AltosDialog.java index eac371aa..c2a9d6e6 100644 --- a/altosui/AltosDialog.java +++ b/altosui/AltosDialog.java @@ -45,6 +45,12 @@ public class AltosDialog extends JDialog implements AltosUIListener { addWindowListener(new AltosDialogListener()); } + public AltosDialog(Dialog dialog, String label, boolean modal) { + super(dialog, label, modal); + AltosUIPreferences.register_ui_listener(this); + addWindowListener(new AltosDialogListener()); + } + public AltosDialog(Frame frame, boolean modal) { super(frame, modal); AltosUIPreferences.register_ui_listener(this); diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 9f03ceb6..2c46da4a 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -24,6 +24,7 @@ altosui_JAVA = \ AltosConfig.java \ AltosConfigFreqUI.java \ AltosConfigUI.java \ + AltosConfigPyroUI.java \ AltosConfigureUI.java \ AltosConfigTD.java \ AltosConfigTDUI.java \ -- cgit v1.2.3 From 20496608ca287e65302193ee1afe9f0cad3a36e1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 22 Oct 2012 21:36:12 -0700 Subject: altoslib: capitalize 'Invalid' state name appropriately It shouldn't ever appear, but it seemed wrong to have it not match the rest of the strings. Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 192c445e..07516aeb 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -199,7 +199,7 @@ public class AltosLib { public static String state_name_capital(int state) { if (state < 0 || state_to_string.length <= state) - return "invalid"; + return "Invalid"; return state_to_string_capital[state]; } -- cgit v1.2.3 From e037fbc004e1aa7d631ae999e587bdde2f6b71c9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 17 Nov 2012 17:34:01 -0800 Subject: altoslib: Add (disabled) conversion for MS5611 In case we actually end up shipping an MS5611-based board at some point, it will be nice to have the java code on hand Signed-off-by: Keith Packard --- altoslib/AltosMs5607.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 268e89f6..148a9f92 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -32,6 +32,8 @@ public class AltosMs5607 { public int pa; public int cc; + static final boolean ms5611 = false; + void convert() { int dT; int TEMP; @@ -41,20 +43,26 @@ public class AltosMs5607 { dT = raw_temp - ((int) tref << 8); - TEMP = (int) (2000 + (((long) dT * tempsens) >> 23)); + TEMP = (int) (2000 + (((long) dT * (long) tempsens) >> 23)); + + if (ms5611) { + OFF = ((long) off << 16) + (((long) tco * (long) dT) >> 7); - OFF = ((long) off << 17) + (((long) tco * dT) >> 6); + SENS = ((long) sens << 15) + (((long) tcs * (long) dT) >> 8); + } else { + OFF = ((long) off << 17) + (((long) tco * (long) dT) >> 6); - SENS = ((long) sens << 16) + (((long) tcs * dT) >> 7); + SENS = ((long) sens << 16) + (((long) tcs * (long) dT) >> 7); + } if (TEMP < 2000) { int T2 = (int) (((long) dT * (long) dT) >> 31); int TEMPM = TEMP - 2000; - long OFF2 = (61 * (long) TEMPM * (long) TEMPM) >> 4; - long SENS2 = 2 * (long) TEMPM * (long) TEMPM; + long OFF2 = ((long) 61 * (long) TEMPM * (long) TEMPM) >> 4; + long SENS2 = (long) 2 * (long) TEMPM * (long) TEMPM; if (TEMP < 1500) { int TEMPP = TEMP + 1500; - long TEMPP2 = TEMPP * TEMPP; + long TEMPP2 = (long) TEMPP * (long) TEMPP; OFF2 = OFF2 + 15 * TEMPP2; SENS2 = SENS2 + 8 * TEMPP2; } -- cgit v1.2.3 From c494eecc51f7d80e24e5db7af0021c56cb6871d4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 18 Nov 2012 10:08:38 -0800 Subject: altoslib: MegaMetrum data telem packets have sensor data, not flight no Setting the seen_flight bit without a flight number leads to bogus file names Signed-off-by: Keith Packard --- altoslib/AltosTelemetryRecordMegaData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java index 16a7b80c..98b9f4c5 100644 --- a/altoslib/AltosTelemetryRecordMegaData.java +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -87,7 +87,7 @@ public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { next.kalman_speed = speed / 16.0; next.kalman_height = height; - next.seen |= AltosRecord.seen_flight | AltosRecord.seen_temp_volt; + next.seen |= AltosRecord.seen_sensor | AltosRecord.seen_temp_volt; return next; } -- cgit v1.2.3 From fcb801b145e1ae6f1c0b3418a99245d34dbf5aa4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 18 Nov 2012 10:10:29 -0800 Subject: altoslib: Allow flight number to be zero It's zero when there's no storage space on the device. Instead of waiting for non-zero flight number, wait for the seen_flight bit to be set in the telem tracking state Signed-off-by: Keith Packard --- altoslib/AltosLog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 1c7069ce..aa30190c 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -85,7 +85,7 @@ public class AltosLog implements Runnable { continue; try { AltosRecord telem = AltosTelemetry.parse(line.line, previous); - if (telem.serial != 0 && telem.flight != 0 && + if ((telem.seen & AltosRecord.seen_flight) != 0 && (telem.serial != serial || telem.flight != flight || log_file == null)) { close_log_file(); -- cgit v1.2.3 From c4737c81ee2da826b38cc52efbfb09017e6825ca Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 18 Nov 2012 10:13:49 -0800 Subject: altoslib: Reset telem tracking state when switching altimeters This discards any local state when the new telem packet has a different serial number Signed-off-by: Keith Packard --- altoslib/AltosTelemetryRecordRaw.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index c21da6fc..51dd704d 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -62,7 +62,8 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { public AltosRecord update_state(AltosRecord previous) { AltosRecord next; - if (previous != null) + + if (previous != null && previous.serial == serial) next = previous.clone(); else next = new AltosRecordNone(); -- cgit v1.2.3 From cb4f2b62d50aca615bd4f9f230a1736880125e3e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 6 Dec 2012 17:07:25 -0800 Subject: altoslib: Make AltosMs5607 capable of parsing ms5607 info lines This moves the parsing from AltosMs5607Query Signed-off-by: Keith Packard --- altoslib/AltosMs5607.java | 37 +++++++++++++++++++++++++++++++++++++ altoslib/AltosMs5607Query.java | 33 +-------------------------------- 2 files changed, 38 insertions(+), 32 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 148a9f92..318fea4d 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -82,6 +82,43 @@ public class AltosMs5607 { return pa; } + public boolean parse_line(String line) { + String[] items = line.split("\\s+"); + if (line.startsWith("Pressure:")) { + if (items.length >= 2) + raw_pres = Integer.parseInt(items[1]); + } else if (line.startsWith("Temperature:")) { + if (items.length >= 2) + raw_temp = Integer.parseInt(items[1]); + } else if (line.startsWith("ms5607 reserved:")) { + if (items.length >= 3) + reserved = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 sens:")) { + if (items.length >= 3) + sens = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 off:")) { + if (items.length >= 3) + off = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 tcs:")) { + if (items.length >= 3) + tcs = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 tco:")) { + if (items.length >= 3) + tco = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 tref:")) { + if (items.length >= 3) + tref = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 tempsens:")) { + if (items.length >= 3) + tempsens = Integer.parseInt(items[2]); + } else if (line.startsWith("ms5607 crc:")) { + if (items.length >= 3) + crc = Integer.parseInt(items[2]); + } else if (line.startsWith("Altitude")) + return false; + return true; + } + public AltosMs5607() { raw_pres = AltosRecord.MISSING; raw_temp = AltosRecord.MISSING; diff --git a/altoslib/AltosMs5607Query.java b/altoslib/AltosMs5607Query.java index 3c746795..1aaec334 100644 --- a/altoslib/AltosMs5607Query.java +++ b/altoslib/AltosMs5607Query.java @@ -27,38 +27,7 @@ class AltosMs5607Query extends AltosMs5607 { if (line == null) { throw new TimeoutException(); } - String[] items = line.split("\\s+"); - if (line.startsWith("Pressure:")) { - if (items.length >= 2) - raw_pres = Integer.parseInt(items[1]); - } else if (line.startsWith("Temperature:")) { - if (items.length >= 2) - raw_temp = Integer.parseInt(items[1]); - } else if (line.startsWith("ms5607 reserved:")) { - if (items.length >= 3) - reserved = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 sens:")) { - if (items.length >= 3) - sens = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 off:")) { - if (items.length >= 3) - off = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 tcs:")) { - if (items.length >= 3) - tcs = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 tco:")) { - if (items.length >= 3) - tco = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 tref:")) { - if (items.length >= 3) - tref = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 tempsens:")) { - if (items.length >= 3) - tempsens = Integer.parseInt(items[2]); - } else if (line.startsWith("ms5607 crc:")) { - if (items.length >= 3) - crc = Integer.parseInt(items[2]); - } else if (line.startsWith("Altitude")) + if (!parse_line(line)) break; } convert(); -- cgit v1.2.3 From e572651b36ad557d716fb14e76e3eec132e5ebdf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 6 Dec 2012 17:08:39 -0800 Subject: altoslib: Make AltosConfigData parse all of the config data It was missing quite a few. This also speeds up parsing of config from TeleScience, TeleBT and TeleTerra by not listing flight info on those products (where it doesn't make sense). Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 197 +++++++++++++++++++++++++++++------------- 1 file changed, 138 insertions(+), 59 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 45a88783..b4478da9 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -26,31 +26,54 @@ public class AltosConfigData implements Iterable { /* Version information */ public String manufacturer; public String product; - public String version; - public int log_format; public int serial; + public int flight; + public int log_format; + public String version; /* Strings returned */ public LinkedList lines; /* Config information */ - public int config_major; - public int config_minor; + /* HAS_FLIGHT*/ public int main_deploy; public int apogee_delay; - public int radio_channel; - public int radio_setting; + public int apogee_lockout; + + /* HAS_RADIO */ public int radio_frequency; public String callsign; - public int accel_cal_plus, accel_cal_minus; + public int radio_enable; public int radio_calibration; + /* Old HAS_RADIO values */ + public int radio_channel; + public int radio_setting; + + /* HAS_ACCEL */ + public int accel_cal_plus, accel_cal_minus; + public int pad_orientation; + + /* HAS_LOG */ public int flight_log_max; + + /* HAS_IGNITE */ public int ignite_mode; - public int stored_flight; + + /* HAS_AES */ + public String aes_key; + + /* AO_PYRO_NUM */ + public AltosPyro[] pyros; + public int npyro; + public int pyro; + + /* Storage info replies */ public int storage_size; public int storage_erase_unit; - public AltosPyro[] pyros; + /* Log listing replies */ + public int stored_flight; + public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { @@ -85,6 +108,9 @@ public class AltosConfigData implements Iterable { if (stored_flight == 0) return 1; return 0; + case AltosLib.AO_LOG_FORMAT_TELEMETRY: + case AltosLib.AO_LOG_FORMAT_TELESCIENCE: + return 1; default: if (flight_log_max <= 0) return 1; @@ -130,71 +156,124 @@ public class AltosConfigData implements Iterable { return 0; } - public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException { - link.printf("c s\nf\nl\nv\n"); + public void reset() { lines = new LinkedList(); + + serial = -1; radio_setting = 0; radio_frequency = 0; - stored_flight = 0; - serial = -1; pyros = null; + npyro = 0; + pyro = 0; + } + + public void parse_line(String line) { + lines.add(line); + /* Version replies */ + try { manufacturer = get_string(line, "manufacturer"); } catch (Exception e) {} + try { product = get_string(line, "product"); } catch (Exception e) {} + try { serial = get_int(line, "serial-number"); } catch (Exception e) {} + try { flight = get_int(line, "current-flight"); } catch (Exception e) {} + try { log_format = get_int(line, "log-format"); } catch (Exception e) {} + try { version = get_string(line, "software-version"); } catch (Exception e) {} + + /* Version also contains MS5607 info, which we ignore here */ + + /* Config show replies */ - int npyro = 0; - int pyro = 0; + /* HAS_FLIGHT */ + try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} + try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {} + try { apogee_lockout = get_int(line, "Apogee lockout:"); } catch (Exception e) {} + + /* HAS_RADIO */ + try { + radio_frequency = get_int(line, "Frequency:"); + if (radio_frequency < 0) + radio_frequency = 434550; + } catch (Exception e) {} + 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) {} + + /* Old HAS_RADIO values */ + try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {} + try { radio_setting = get_int(line, "Radio setting:"); } catch (Exception e) {} + + /* HAS_ACCEL */ + try { + 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]); + } + } + } catch (Exception e) {} + try { pad_orientation = get_int(line, "Pad orientation:"); } catch (Exception e) {} + + /* HAS_LOG */ + try { flight_log_max = get_int(line, "Max flight log:"); } catch (Exception e) {} + + /* HAS_IGNITE */ + try { ignite_mode = get_int(line, "Ignite mode:"); } catch (Exception e) {} + + /* HAS_AES */ + try { aes_key = get_string(line, "AES key:"); } catch (Exception e) {} + + /* AO_PYRO_NUM */ + try { + npyro = get_int(line, "Pyro-count:"); + pyros = new AltosPyro[npyro]; + pyro = 0; + } catch (Exception e) {} + if (npyro > 0) { + try { + AltosPyro p = new AltosPyro(pyro, line); + if (pyro < npyro - 1) + pyros[pyro++] = p; + } catch (Exception e) {} + } + + /* Storage info replies */ + try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} + try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {} + + /* Log listing replies */ + try { get_int(line, "flight"); stored_flight++; } catch (Exception e) {} + } + + public AltosConfigData() { + this.reset(); + } + + private void read_link(AltosLink link, String finished) throws InterruptedException, TimeoutException { for (;;) { String line = link.get_reply(); if (line == null) throw new TimeoutException(); if (line.contains("Syntax error")) continue; - lines.add(line); - if (pyro < npyro - 1) { - if (pyros == null) - pyros = new AltosPyro[npyro]; - try { - pyros[pyro] = new AltosPyro(pyro, line); - } catch (ParseException e) { - } - ++pyro; - continue; - } - try { serial = get_int(line, "serial-number"); } catch (Exception e) {} - try { log_format = get_int(line, "log-format"); } catch (Exception e) {} - try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} - try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {} - try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {} - try { radio_setting = get_int(line, "Radio setting:"); } catch (Exception e) {} - try { - radio_frequency = get_int(line, "Frequency:"); - if (radio_frequency < 0) - radio_frequency = 434550; - } catch (Exception e) {} - try { - 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]); - } - } - } 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) {} - try { manufacturer = get_string(line,"manufacturer"); } catch (Exception e) {} - - try { get_int(line, "flight"); stored_flight++; } catch (Exception e) {} - try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} - try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {} - try { npyro = get_int(line, "Pyro-count:"); pyro = 0; } catch (Exception e) {} + this.parse_line(line); /* signals the end of the version info */ - if (line.startsWith("software-version")) + if (line.startsWith(finished)) break; } } + public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException { + this.reset(); + link.printf("c s\nf\nv\n"); + read_link(link, "software-version"); + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TELEMETRY: + case AltosLib.AO_LOG_FORMAT_TELESCIENCE: + break; + default: + link.printf("l\n"); + read_link(link, "done"); + } + } + } \ No newline at end of file -- cgit v1.2.3 From 16fd9009d8b034fd8d208115317f65fabe10072a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 7 Dec 2012 08:32:22 -0800 Subject: altosui: Use AltosConfigData for altosui configuration dialog Instead of a separate config language parser, share with altoslib Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 41 +++++- altosui/AltosConfig.java | 311 +++++++++++------------------------------- 2 files changed, 115 insertions(+), 237 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index b4478da9..ddc49e88 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -74,7 +74,6 @@ public class AltosConfigData implements Iterable { /* Log listing replies */ public int stored_flight; - public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { String quoted = line.substring(label.length()).trim(); @@ -159,12 +158,40 @@ public class AltosConfigData implements Iterable { public void reset() { lines = new LinkedList(); - serial = -1; - radio_setting = 0; + manufacturer = "unknown"; + product = "unknown"; + serial = 0; + flight = 0; + log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN; + version = "unknown"; + + main_deploy = 250; + apogee_delay = 0; + apogee_lockout = 0; + radio_frequency = 0; - pyros = null; - npyro = 0; + callsign = "N0CALL"; + radio_enable = -1; + radio_calibration = 0; + radio_channel = -1; + radio_setting = -1; + + accel_cal_plus = -1; + accel_cal_minus = -1; + pad_orientation = -1; + + flight_log_max = 0; + ignite_mode = -1; + + aes_key = ""; + pyro = 0; + npyro = 0; + pyros = null; + + storage_size = -1; + storage_erase_unit = -1; + stored_flight = -1; } public void parse_line(String line) { @@ -244,7 +271,7 @@ public class AltosConfigData implements Iterable { } public AltosConfigData() { - this.reset(); + reset(); } private void read_link(AltosLink link, String finished) throws InterruptedException, TimeoutException { @@ -263,7 +290,7 @@ public class AltosConfigData implements Iterable { } public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException { - this.reset(); + reset(); link.printf("c s\nf\nv\n"); read_link(link, "software-version"); switch (log_format) { diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 4b0edec0..92191564 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -58,64 +58,12 @@ public class AltosConfig implements ActionListener { AltosDevice device; AltosSerial serial_line; boolean remote; - AltosConfigData remote_config_data; - double remote_frequency; - int_ref serial; - int_ref log_format; - int_ref main_deploy; - int_ref apogee_delay; - int_ref apogee_lockout; - int_ref radio_channel; - int_ref radio_calibration; - int_ref flight_log_max; - int_ref ignite_mode; - int_ref pad_orientation; - int_ref radio_setting; - int_ref radio_frequency; - int_ref storage_size; - int_ref storage_erase_unit; - int_ref stored_flight; - int_ref radio_enable; - string_ref version; - string_ref product; - string_ref callsign; - int_ref npyro; - AltosPyro[] pyros; + + AltosConfigData data; AltosConfigUI config_ui; boolean serial_started; boolean made_visible; - boolean get_int(String line, String label, int_ref x) { - if (line.startsWith(label)) { - try { - String tail = line.substring(label.length()).trim(); - String[] tokens = tail.split("\\s+"); - if (tokens.length > 0) { - int i = Integer.parseInt(tokens[0]); - x.set(i); - return true; - } - } catch (NumberFormatException ne) { - } - } - return false; - } - - boolean get_string(String line, String label, string_ref s) { - if (line.startsWith(label)) { - String quoted = line.substring(label.length()).trim(); - - if (quoted.startsWith("\"")) - quoted = quoted.substring(1); - if (quoted.endsWith("\"")) - quoted = quoted.substring(0,quoted.length()-1); - s.set(quoted); - return true; - } else { - return false; - } - } - void start_serial() throws InterruptedException, TimeoutException { serial_started = true; if (remote) @@ -131,8 +79,8 @@ public class AltosConfig implements ActionListener { } int log_limit() { - if (storage_size.get() > 0 && storage_erase_unit.get() > 0) { - int log_limit = storage_size.get() - storage_erase_unit.get(); + if (data.storage_size > 0 && data.storage_erase_unit > 0) { + int log_limit = data.storage_size - data.storage_erase_unit; if (log_limit > 0) return log_limit / 1024; } @@ -140,33 +88,33 @@ public class AltosConfig implements ActionListener { } void update_ui() { - config_ui.set_serial(serial.get()); - config_ui.set_product(product.get()); - config_ui.set_version(version.get()); - config_ui.set_main_deploy(main_deploy.get()); - config_ui.set_apogee_delay(apogee_delay.get()); - config_ui.set_apogee_lockout(apogee_lockout.get()); - config_ui.set_radio_calibration(radio_calibration.get()); + config_ui.set_serial(data.serial); + config_ui.set_product(data.product); + config_ui.set_version(data.version); + config_ui.set_main_deploy(data.main_deploy); + config_ui.set_apogee_delay(data.apogee_delay); + config_ui.set_apogee_lockout(data.apogee_lockout); + config_ui.set_radio_calibration(data.radio_calibration); config_ui.set_radio_frequency(frequency()); boolean max_enabled = true; - switch (log_format.get()) { + switch (data.log_format) { case Altos.AO_LOG_FORMAT_TINY: max_enabled = false; break; default: - if (stored_flight.get() >= 0) + if (data.stored_flight >= 0) max_enabled = false; break; } config_ui.set_flight_log_max_enabled(max_enabled); - config_ui.set_radio_enable(radio_enable.get()); + config_ui.set_radio_enable(data.radio_enable); config_ui.set_flight_log_max_limit(log_limit()); - 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_pyros(pyros); - config_ui.set_has_pyro(npyro.get() > 0); + config_ui.set_flight_log_max(data.flight_log_max); + config_ui.set_ignite_mode(data.ignite_mode); + config_ui.set_pad_orientation(data.pad_orientation); + config_ui.set_callsign(data.callsign); + config_ui.set_pyros(data.pyros); + config_ui.set_has_pyro(data.npyro > 0); config_ui.set_clean(); if (!made_visible) { made_visible = true; @@ -176,52 +124,6 @@ public class AltosConfig implements ActionListener { int pyro; - void process_line(String line) { - if (line == null) { - abort(); - return; - } - if (line.equals("all finished")) { - if (serial_line != null) - update_ui(); - return; - } - if (pyro < npyro.get()) { - if (pyros == null) - pyros = new AltosPyro[npyro.get()]; - - try { - pyros[pyro] = new AltosPyro(pyro, line); - } catch (ParseException e) { - System.out.printf ("pyro parse failed %s\n", line); - } - ++pyro; - return; - } - get_int(line, "serial-number", serial); - get_int(line, "log-format", log_format); - get_int(line, "Main deploy:", main_deploy); - get_int(line, "Apogee delay:", apogee_delay); - get_int(line, "Apogee lockout:", apogee_lockout); - 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_int(line, "Pad orientation:", pad_orientation); - get_int(line, "Radio setting:", radio_setting); - if (get_int(line, "Frequency:", radio_frequency)) - if (radio_frequency.get() < 0) - radio_frequency.set(434550); - get_int(line, "Radio enable:", radio_enable); - get_int(line, "Storage size:", storage_size); - get_int(line, "Storage erase unit:", storage_erase_unit); - get_int(line, "flight", stored_flight); - get_string(line, "Callsign:", callsign); - get_string(line,"software-version", version); - get_string(line,"product", product); - get_int(line, "Pyro-count:", npyro); - } - final static int serial_mode_read = 0; final static int serial_mode_save = 1; final static int serial_mode_reboot = 2; @@ -230,63 +132,33 @@ public class AltosConfig implements ActionListener { AltosConfig config; int serial_mode; - void process_line(String line) { - config.process_line(line); - } - void callback(String in_line) { - final String line = in_line; + void callback(String in_cmd) { + final String cmd = in_cmd; Runnable r = new Runnable() { public void run() { - process_line(line); + if (cmd.equals("abort")) { + abort(); + } else if (cmd.equals("all finished")) { + if (serial_line != null) + update_ui(); + } } }; SwingUtilities.invokeLater(r); } - void reset_data() { - serial.set(0); - log_format.set(Altos.AO_LOG_FORMAT_UNKNOWN); - main_deploy.set(250); - apogee_delay.set(0); - apogee_lockout.set(0); - radio_channel.set(0); - radio_setting.set(0); - radio_frequency.set(0); - radio_calibration.set(1186611); - radio_enable.set(-1); - flight_log_max.set(0); - ignite_mode.set(-1); - pad_orientation.set(-1); - storage_size.set(-1); - storage_erase_unit.set(-1); - stored_flight.set(-1); - callsign.set("N0CALL"); - version.set("unknown"); - product.set("unknown"); - pyro = 0; - npyro.set(0); - } - void get_data() { + data = null; try { - config.start_serial(); - reset_data(); - - config.serial_line.printf("c s\nf\nl\nv\n"); - for (;;) { - try { - String line = config.serial_line.get_reply(5000); - if (line == null) - stop_serial(); - callback(line); - if (line.startsWith("software-version")) - break; - } catch (Exception e) { - break; - } - } + start_serial(); + data = new AltosConfigData(config.serial_line); } catch (InterruptedException ie) { } catch (TimeoutException te) { + try { + stop_serial(); + callback("abort"); + } catch (InterruptedException ie) { + } } finally { try { stop_serial(); @@ -299,37 +171,37 @@ public class AltosConfig implements ActionListener { void save_data() { try { double frequency = frequency(); - boolean has_frequency = radio_frequency.get() > 0; - boolean has_setting = radio_setting.get() > 0; + boolean has_frequency = data.radio_frequency > 0; + boolean has_setting = data.radio_setting > 0; start_serial(); - serial_line.printf("c m %d\n", main_deploy.get()); - serial_line.printf("c d %d\n", apogee_delay.get()); - serial_line.printf("c L %d\n", apogee_lockout.get()); + serial_line.printf("c m %d\n", data.main_deploy); + serial_line.printf("c d %d\n", data.apogee_delay); + serial_line.printf("c L %d\n", data.apogee_lockout); if (!remote) - serial_line.printf("c f %d\n", radio_calibration.get()); + serial_line.printf("c f %d\n", data.radio_calibration); serial_line.set_radio_frequency(frequency, has_frequency, has_setting, - radio_calibration.get()); + data.radio_calibration); if (remote) { serial_line.stop_remote(); serial_line.set_radio_frequency(frequency); AltosUIPreferences.set_frequency(device.getSerial(), frequency); serial_line.start_remote(); } - 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 (radio_enable.get() >= 0) - serial_line.printf("c e %d\n", radio_enable.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()); - if (pyros.length > 0) { - for (int p = 0; p < pyros.length; p++) { + serial_line.printf("c c %s\n", data.callsign); + if (data.flight_log_max != 0) + serial_line.printf("c l %d\n", data.flight_log_max); + if (data.radio_enable >= 0) + serial_line.printf("c e %d\n", data.radio_enable); + if (data.ignite_mode >= 0) + serial_line.printf("c i %d\n", data.ignite_mode); + if (data.pad_orientation >= 0) + serial_line.printf("c o %d\n", data.pad_orientation); + if (data.pyros.length > 0) { + for (int p = 0; p < data.pyros.length; p++) { serial_line.printf("c P %s\n", - pyros[p].toString()); + data.pyros[p].toString()); } } serial_line.printf("c w\n"); @@ -413,25 +285,25 @@ public class AltosConfig implements ActionListener { } double frequency() { - return AltosConvert.radio_to_frequency(radio_frequency.get(), - radio_setting.get(), - radio_calibration.get(), - radio_channel.get()); + return AltosConvert.radio_to_frequency(data.radio_frequency, + data.radio_setting, + data.radio_calibration, + data.radio_channel); } void set_frequency(double freq) { - int frequency = radio_frequency.get(); - int setting = radio_setting.get(); + int frequency = data.radio_frequency; + int setting = data.radio_setting; if (frequency > 0) { - radio_frequency.set((int) Math.floor (freq * 1000 + 0.5)); - radio_channel.set(0); + data.radio_frequency = (int) Math.floor (freq * 1000 + 0.5); + data.radio_channel = 0; } else if (setting > 0) { - radio_setting.set(AltosConvert.radio_frequency_to_setting(freq, - radio_calibration.get())); - radio_channel.set(0); + data.radio_setting =AltosConvert.radio_frequency_to_setting(freq, + data.radio_calibration); + data.radio_channel = 0; } else { - radio_channel.set(AltosConvert.radio_frequency_to_channel(freq)); + data.radio_channel = AltosConvert.radio_frequency_to_channel(freq); } } @@ -448,21 +320,21 @@ public class AltosConfig implements ActionListener { return; } - main_deploy.set(config_ui.main_deploy()); - apogee_delay.set(config_ui.apogee_delay()); - apogee_lockout.set(config_ui.apogee_lockout()); - radio_calibration.set(config_ui.radio_calibration()); + data.main_deploy = config_ui.main_deploy(); + data.apogee_delay = config_ui.apogee_delay(); + data.apogee_lockout = config_ui.apogee_lockout(); + data.radio_calibration = config_ui.radio_calibration(); set_frequency(config_ui.radio_frequency()); - flight_log_max.set(config_ui.flight_log_max()); - if (radio_enable.get() >= 0) - radio_enable.set(config_ui.radio_enable()); - if (ignite_mode.get() >= 0) - ignite_mode.set(config_ui.ignite_mode()); - if (pad_orientation.get() >= 0) - pad_orientation.set(config_ui.pad_orientation()); - callsign.set(config_ui.callsign()); - if (npyro.get() > 0) { - pyros = config_ui.pyros(); + data.flight_log_max = config_ui.flight_log_max(); + if (data.radio_enable >= 0) + data.radio_enable = config_ui.radio_enable(); + if (data.ignite_mode >= 0) + data.ignite_mode = config_ui.ignite_mode(); + if (data.pad_orientation >= 0) + data.pad_orientation = config_ui.pad_orientation(); + data.callsign = config_ui.callsign(); + if (data.npyro > 0) { + data.pyros = config_ui.pyros(); } run_serial_thread(serial_mode_save); } @@ -491,27 +363,6 @@ public class AltosConfig implements ActionListener { public AltosConfig(JFrame given_owner) { owner = given_owner; - serial = new int_ref(0); - log_format = new int_ref(Altos.AO_LOG_FORMAT_UNKNOWN); - main_deploy = new int_ref(250); - apogee_delay = new int_ref(0); - apogee_lockout = new int_ref(0); - radio_channel = new int_ref(0); - radio_setting = new int_ref(0); - radio_frequency = new int_ref(0); - radio_calibration = new int_ref(1186611); - radio_enable = new int_ref(-1); - flight_log_max = new int_ref(0); - ignite_mode = new int_ref(-1); - pad_orientation = new int_ref(-1); - storage_size = new int_ref(-1); - storage_erase_unit = new int_ref(-1); - stored_flight = new int_ref(-1); - callsign = new string_ref("N0CALL"); - version = new string_ref("unknown"); - product = new string_ref("unknown"); - npyro = new int_ref(0); - device = AltosDeviceDialog.show(owner, Altos.product_any); if (device != null) { try { -- cgit v1.2.3 From 1489c7f75f7b9ce547ac49c157b440c4f9131ef4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 7 Dec 2012 17:27:48 -0800 Subject: altosui: Call config UI from AltosConfigData directly Don't make AltosConfig have a pile of config code, stick that in AltosConfigData instead. This uses a new interface, AltosConfigValues to get from AltosConfigData to the UI. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 200 +++++++++++++++++++++++++++++++++++++--- altoslib/AltosConfigValues.java | 75 +++++++++++++++ altoslib/Makefile.am | 1 + altosui/AltosConfig.java | 115 +++-------------------- altosui/AltosConfigUI.java | 11 +-- 5 files changed, 280 insertions(+), 122 deletions(-) create mode 100644 altoslib/AltosConfigValues.java (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index ddc49e88..515ff480 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -39,7 +39,7 @@ public class AltosConfigData implements Iterable { public int main_deploy; public int apogee_delay; public int apogee_lockout; - + /* HAS_RADIO */ public int radio_frequency; public String callsign; @@ -136,7 +136,7 @@ public class AltosConfigData implements Iterable { return r; } - + public int compare_version(String other) { int[] me = parse_version(version); int[] them = parse_version(other); @@ -165,14 +165,14 @@ public class AltosConfigData implements Iterable { log_format = AltosLib.AO_LOG_FORMAT_UNKNOWN; version = "unknown"; - main_deploy = 250; - apogee_delay = 0; - apogee_lockout = 0; + main_deploy = -1; + apogee_delay = -1; + apogee_lockout = -1; - radio_frequency = 0; - callsign = "N0CALL"; + radio_frequency = -1; + callsign = null; radio_enable = -1; - radio_calibration = 0; + radio_calibration = -1; radio_channel = -1; radio_setting = -1; @@ -180,7 +180,7 @@ public class AltosConfigData implements Iterable { accel_cal_minus = -1; pad_orientation = -1; - flight_log_max = 0; + flight_log_max = -1; ignite_mode = -1; aes_key = ""; @@ -193,7 +193,7 @@ public class AltosConfigData implements Iterable { storage_erase_unit = -1; stored_flight = -1; } - + public void parse_line(String line) { lines.add(line); /* Version replies */ @@ -257,11 +257,11 @@ public class AltosConfigData implements Iterable { if (npyro > 0) { try { AltosPyro p = new AltosPyro(pyro, line); - if (pyro < npyro - 1) + if (pyro < npyro) pyros[pyro++] = p; } catch (Exception e) {} } - + /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {} @@ -289,6 +289,182 @@ public class AltosConfigData implements Iterable { } } + public boolean has_frequency() { + return radio_frequency >= 0 || radio_setting >= 0 || radio_channel >= 0; + } + + public void set_frequency(double freq) { + int frequency = radio_frequency; + int setting = radio_setting; + + if (frequency > 0) { + radio_frequency = (int) Math.floor (freq * 1000 + 0.5); + radio_channel = -1; + } else if (setting > 0) { + radio_setting =AltosConvert.radio_frequency_to_setting(freq, + radio_calibration); + radio_channel = -1; + } else { + radio_channel = AltosConvert.radio_frequency_to_channel(freq); + } + } + + public double frequency() { + int channel = radio_channel; + int setting = radio_setting; + if (channel < 0) + channel = 0; + if (setting < 0) + setting = 0; + + return AltosConvert.radio_to_frequency(radio_frequency, + setting, + radio_calibration, + channel); + } + + public int log_limit() { + if (storage_size > 0 && storage_erase_unit > 0) { + int log_limit = storage_size - storage_erase_unit; + if (log_limit > 0) + return log_limit / 1024; + } + return 1024; + } + + public void get_values(AltosConfigValues source) { + + /* HAS_FLIGHT */ + if (main_deploy >= 0) + main_deploy = source.main_deploy(); + if (apogee_delay >= 0) + apogee_delay = source.apogee_delay(); + if (apogee_lockout >= 0) + apogee_lockout = source.apogee_lockout(); + + /* HAS_RADIO */ + if (has_frequency()) + set_frequency(source.radio_frequency()); + if (radio_enable >= 0) + radio_enable = source.radio_enable(); + if (callsign != null) + callsign = source.callsign(); + if (radio_calibration >= 0) + radio_calibration = source.radio_calibration(); + + /* HAS_ACCEL */ + if (pad_orientation >= 0) + pad_orientation = source.pad_orientation(); + + /* HAS_LOG */ + if (flight_log_max >= 0) + flight_log_max = source.flight_log_max(); + + /* HAS_IGNITE */ + if (ignite_mode >= 0) + ignite_mode = source.ignite_mode(); + + /* AO_PYRO_NUM */ + if (npyro > 0) + pyros = source.pyros(); + } + + public void set_values(AltosConfigValues dest) { + dest.set_serial(serial); + dest.set_product(product); + dest.set_version(version); + dest.set_main_deploy(main_deploy); + dest.set_apogee_delay(apogee_delay); + dest.set_apogee_lockout(apogee_lockout); + dest.set_radio_calibration(radio_calibration); + dest.set_radio_frequency(frequency()); + boolean max_enabled = true; + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TINY: + max_enabled = false; + break; + default: + if (stored_flight >= 0) + max_enabled = false; + break; + } + dest.set_flight_log_max_enabled(max_enabled); + dest.set_radio_enable(radio_enable); + dest.set_flight_log_max_limit(log_limit()); + dest.set_flight_log_max(flight_log_max); + dest.set_ignite_mode(ignite_mode); + dest.set_pad_orientation(pad_orientation); + dest.set_callsign(callsign); + if (npyro > 0) + dest.set_pyros(pyros); + else + dest.set_pyros(null); + } + + public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { + + /* HAS_FLIGHT */ + if (main_deploy >= 0) + link.printf("c m %d\n", main_deploy); + if (apogee_delay >= 0) + link.printf("c d %d\n", apogee_delay); + if (apogee_lockout >= 0) + link.printf("c L %d\n", apogee_lockout); + + /* Don't mess with radio calibration when remote */ + if (radio_calibration > 0 && !remote) + link.printf("c f %d\n", radio_calibration); + + /* HAS_RADIO */ + if (has_frequency()) { + boolean has_frequency = radio_frequency >= 0; + boolean has_setting = radio_setting > 0; + double frequency = frequency(); + link.set_radio_frequency(frequency, + has_frequency, + has_setting, + radio_calibration); + /* When remote, reset the dongle frequency at the same time */ + if (remote) { + link.stop_remote(); + link.set_radio_frequency(frequency); + link.start_remote(); + } + } + + if (callsign != null) + link.printf("c c %s\n", callsign); + if (radio_enable >= 0) + link.printf("c e %d\n", radio_enable); + + /* HAS_ACCEL */ + /* UI doesn't support accel cal */ + if (pad_orientation >= 0) + link.printf("c o %d\n", pad_orientation); + + /* HAS_LOG */ + if (flight_log_max != 0) + link.printf("c l %d\n", flight_log_max); + + /* HAS_IGNITE */ + if (ignite_mode >= 0) + link.printf("c i %d\n", ignite_mode); + + /* HAS_AES */ + /* UI doesn't support AES key config */ + + /* AO_PYRO_NUM */ + if (pyros.length > 0) { + for (int p = 0; p < pyros.length; p++) { + link.printf("c P %s\n", + pyros[p].toString()); + } + } + + link.printf("c w\n"); + link.flush_output(); + } + public AltosConfigData(AltosLink link) throws InterruptedException, TimeoutException { reset(); link.printf("c s\nf\nv\n"); diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java new file mode 100644 index 00000000..69239f21 --- /dev/null +++ b/altoslib/AltosConfigValues.java @@ -0,0 +1,75 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +public interface AltosConfigValues { + /* set and get all of the dialog values */ + public abstract void set_product(String product); + + public abstract void set_version(String version); + + public abstract void set_serial(int serial); + + public abstract void set_main_deploy(int new_main_deploy); + + public abstract int main_deploy(); + + public abstract void set_apogee_delay(int new_apogee_delay); + + public abstract int apogee_delay(); + + public abstract void set_apogee_lockout(int new_apogee_lockout); + + public abstract int apogee_lockout(); + + public abstract void set_radio_frequency(double new_radio_frequency); + + public abstract double radio_frequency(); + + public abstract void set_radio_calibration(int new_radio_calibration); + + public abstract int radio_calibration(); + + public abstract void set_radio_enable(int new_radio_enable); + + public abstract int radio_enable(); + + public abstract void set_callsign(String new_callsign); + + public abstract String callsign(); + + public abstract void set_flight_log_max(int new_flight_log_max); + + public abstract void set_flight_log_max_enabled(boolean enable); + + public abstract int flight_log_max(); + + public abstract void set_flight_log_max_limit(int flight_log_max_limit); + + public abstract void set_ignite_mode(int new_ignite_mode); + + public abstract int ignite_mode(); + + public abstract void set_pad_orientation(int new_pad_orientation); + + public abstract int pad_orientation(); + + public abstract void set_pyros(AltosPyro[] new_pyros); + + public abstract AltosPyro[] pyros(); +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 2579a650..0086bc65 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -12,6 +12,7 @@ AltosLibdir = $(datadir)/java AltosLib_JAVA = \ $(SRC)/AltosLib.java \ $(SRC)/AltosConfigData.java \ + $(SRC)/AltosConfigValues.java \ $(SRC)/AltosConvert.java \ $(SRC)/AltosCRCException.java \ $(SRC)/AltosEepromChunk.java \ diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 92191564..e1ffebb4 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -78,43 +78,8 @@ public class AltosConfig implements ActionListener { serial_line.stop_remote(); } - int log_limit() { - if (data.storage_size > 0 && data.storage_erase_unit > 0) { - int log_limit = data.storage_size - data.storage_erase_unit; - if (log_limit > 0) - return log_limit / 1024; - } - return 1024; - } - void update_ui() { - config_ui.set_serial(data.serial); - config_ui.set_product(data.product); - config_ui.set_version(data.version); - config_ui.set_main_deploy(data.main_deploy); - config_ui.set_apogee_delay(data.apogee_delay); - config_ui.set_apogee_lockout(data.apogee_lockout); - config_ui.set_radio_calibration(data.radio_calibration); - config_ui.set_radio_frequency(frequency()); - boolean max_enabled = true; - switch (data.log_format) { - case Altos.AO_LOG_FORMAT_TINY: - max_enabled = false; - break; - default: - if (data.stored_flight >= 0) - max_enabled = false; - break; - } - config_ui.set_flight_log_max_enabled(max_enabled); - config_ui.set_radio_enable(data.radio_enable); - config_ui.set_flight_log_max_limit(log_limit()); - config_ui.set_flight_log_max(data.flight_log_max); - config_ui.set_ignite_mode(data.ignite_mode); - config_ui.set_pad_orientation(data.pad_orientation); - config_ui.set_callsign(data.callsign); - config_ui.set_pyros(data.pyros); - config_ui.set_has_pyro(data.npyro > 0); + data.set_values(config_ui); config_ui.set_clean(); if (!made_visible) { made_visible = true; @@ -170,41 +135,11 @@ public class AltosConfig implements ActionListener { void save_data() { try { - double frequency = frequency(); - boolean has_frequency = data.radio_frequency > 0; - boolean has_setting = data.radio_setting > 0; start_serial(); - serial_line.printf("c m %d\n", data.main_deploy); - serial_line.printf("c d %d\n", data.apogee_delay); - serial_line.printf("c L %d\n", data.apogee_lockout); - if (!remote) - serial_line.printf("c f %d\n", data.radio_calibration); - serial_line.set_radio_frequency(frequency, - has_frequency, - has_setting, - data.radio_calibration); - if (remote) { - serial_line.stop_remote(); - serial_line.set_radio_frequency(frequency); - AltosUIPreferences.set_frequency(device.getSerial(), frequency); - serial_line.start_remote(); - } - serial_line.printf("c c %s\n", data.callsign); - if (data.flight_log_max != 0) - serial_line.printf("c l %d\n", data.flight_log_max); - if (data.radio_enable >= 0) - serial_line.printf("c e %d\n", data.radio_enable); - if (data.ignite_mode >= 0) - serial_line.printf("c i %d\n", data.ignite_mode); - if (data.pad_orientation >= 0) - serial_line.printf("c o %d\n", data.pad_orientation); - if (data.pyros.length > 0) { - for (int p = 0; p < data.pyros.length; p++) { - serial_line.printf("c P %s\n", - data.pyros[p].toString()); - } - } - serial_line.printf("c w\n"); + data.save(serial_line, remote); + if (remote) + AltosUIPreferences.set_frequency(device.getSerial(), + data.frequency()); } catch (InterruptedException ie) { } catch (TimeoutException te) { } finally { @@ -291,51 +226,23 @@ public class AltosConfig implements ActionListener { data.radio_channel); } - void set_frequency(double freq) { - int frequency = data.radio_frequency; - int setting = data.radio_setting; - - if (frequency > 0) { - data.radio_frequency = (int) Math.floor (freq * 1000 + 0.5); - data.radio_channel = 0; - } else if (setting > 0) { - data.radio_setting =AltosConvert.radio_frequency_to_setting(freq, - data.radio_calibration); - data.radio_channel = 0; - } else { - data.radio_channel = AltosConvert.radio_frequency_to_channel(freq); - } - } - void save_data() { /* bounds check stuff */ - if (config_ui.flight_log_max() > log_limit()) { + if (config_ui.flight_log_max() > data.log_limit()) { JOptionPane.showMessageDialog(owner, String.format("Requested flight log, %dk, is larger than the available space, %dk.\n", config_ui.flight_log_max(), - log_limit()), + data.log_limit()), "Maximum Flight Log Too Large", JOptionPane.ERROR_MESSAGE); return; } - data.main_deploy = config_ui.main_deploy(); - data.apogee_delay = config_ui.apogee_delay(); - data.apogee_lockout = config_ui.apogee_lockout(); - data.radio_calibration = config_ui.radio_calibration(); - set_frequency(config_ui.radio_frequency()); - data.flight_log_max = config_ui.flight_log_max(); - if (data.radio_enable >= 0) - data.radio_enable = config_ui.radio_enable(); - if (data.ignite_mode >= 0) - data.ignite_mode = config_ui.ignite_mode(); - if (data.pad_orientation >= 0) - data.pad_orientation = config_ui.pad_orientation(); - data.callsign = config_ui.callsign(); - if (data.npyro > 0) { - data.pyros = config_ui.pyros(); - } + /* Pull data out of the UI and stuff back into our local data record */ + + data.get_values(config_ui); + run_serial_thread(serial_mode_save); } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index feac053b..2c3435c1 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -25,7 +25,7 @@ import org.altusmetrum.AltosLib.*; public class AltosConfigUI extends AltosDialog - implements ActionListener, ItemListener, DocumentListener + implements ActionListener, ItemListener, DocumentListener, AltosConfigValues { Container pane; @@ -684,6 +684,7 @@ public class AltosConfigUI public void set_apogee_delay(int new_apogee_delay) { apogee_delay_value.setSelectedItem(Integer.toString(new_apogee_delay)); + apogee_delay_value.setEnabled(new_apogee_delay >= 0); } public int apogee_delay() { @@ -692,6 +693,7 @@ public class AltosConfigUI public void set_apogee_lockout(int new_apogee_lockout) { apogee_lockout_value.setSelectedItem(Integer.toString(new_apogee_lockout)); + apogee_lockout_value.setEnabled(new_apogee_lockout >= 0); } public int apogee_lockout() { @@ -829,13 +831,10 @@ public class AltosConfigUI return -1; } - public void set_has_pyro(boolean has_pyro) { - pyro.setEnabled(has_pyro); - } - public void set_pyros(AltosPyro[] new_pyros) { pyros = new_pyros; - if (pyro_ui != null) + pyro.setEnabled(pyros != null); + if (pyros != null && pyro_ui != null) pyro_ui.set_pyros(pyros); } -- cgit v1.2.3 From abf82991b8e69754ebc4857ce78ac4a4b01f16e4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 7 Dec 2012 17:35:15 -0800 Subject: altosui: Add APRS interval configuration to UI Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 18 +++++++++++- altoslib/AltosConfigValues.java | 4 +++ altosui/AltosConfigUI.java | 64 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 84 insertions(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 515ff480..f940b150 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -67,6 +67,9 @@ public class AltosConfigData implements Iterable { public int npyro; public int pyro; + /* HAS_APRS */ + public int aprs_interval; + /* Storage info replies */ public int storage_size; public int storage_erase_unit; @@ -189,6 +192,8 @@ public class AltosConfigData implements Iterable { npyro = 0; pyros = null; + aprs_interval = -1; + storage_size = -1; storage_erase_unit = -1; stored_flight = -1; @@ -262,6 +267,9 @@ public class AltosConfigData implements Iterable { } catch (Exception e) {} } + /* HAS_APRS */ + try { aprs_interval = get_int(line, "APRS interval:"); } catch (Exception e) {} + /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {} @@ -367,6 +375,9 @@ public class AltosConfigData implements Iterable { /* AO_PYRO_NUM */ if (npyro > 0) pyros = source.pyros(); + + if (aprs_interval >= 0) + aprs_interval = source.aprs_interval(); } public void set_values(AltosConfigValues dest) { @@ -399,6 +410,7 @@ public class AltosConfigData implements Iterable { dest.set_pyros(pyros); else dest.set_pyros(null); + dest.set_aprs_interval(aprs_interval); } public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { @@ -461,6 +473,10 @@ public class AltosConfigData implements Iterable { } } + /* HAS_APRS */ + if (aprs_interval >= 0) + link.printf("c A %d\n", aprs_interval); + link.printf("c w\n"); link.flush_output(); } @@ -479,4 +495,4 @@ public class AltosConfigData implements Iterable { } } -} \ No newline at end of file +} diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 69239f21..40d5217e 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -72,4 +72,8 @@ public interface AltosConfigValues { public abstract void set_pyros(AltosPyro[] new_pyros); public abstract AltosPyro[] pyros(); + + public abstract int aprs_interval(); + + public abstract void set_aprs_interval(int new_aprs_interval); } diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 2c3435c1..95780e2b 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -39,6 +39,7 @@ public class AltosConfigUI JLabel radio_calibration_label; JLabel radio_frequency_label; JLabel radio_enable_label; + JLabel aprs_interval_label; JLabel flight_log_max_label; JLabel ignite_mode_label; JLabel pad_orientation_label; @@ -56,6 +57,7 @@ public class AltosConfigUI AltosFreqList radio_frequency_value; JTextField radio_calibration_value; JRadioButton radio_enable_value; + JComboBox aprs_interval_value; JComboBox flight_log_max_value; JComboBox ignite_mode_value; JComboBox pad_orientation_value; @@ -97,6 +99,13 @@ public class AltosConfigUI "Redundant Main", }; + static String[] aprs_interval_values = { + "Disabled", + "2", + "5", + "10" + }; + static String[] pad_orientation_values = { "Antenna Up", "Antenna Down", @@ -141,6 +150,13 @@ public class AltosConfigUI radio_enable_value.setToolTipText("Firmware version does not support disabling radio"); } + void set_aprs_interval_tool_tip() { + if (aprs_interval_value.isEnabled()) + aprs_interval_value.setToolTipText("Enable APRS and set the interval between APRS reports"); + 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)"); @@ -393,7 +409,7 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - radio_enable_label = new JLabel("Telemetry/RDF Enable:"); + radio_enable_label = new JLabel("Telemetry/RDF/APRS Enable:"); pane.add(radio_enable_label, c); c = new GridBagConstraints(); @@ -410,6 +426,32 @@ public class AltosConfigUI set_radio_enable_tool_tip(); row++; + /* APRS interval */ + 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_interval_label = new JLabel("APRS Interval(s):"); + pane.add(aprs_interval_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_interval_value = new JComboBox(aprs_interval_values); + aprs_interval_value.setEditable(true); + aprs_interval_value.addItemListener(this); + pane.add(aprs_interval_value, c); + set_aprs_interval_tool_tip(); + row++; + /* Callsign */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = row; @@ -843,4 +885,24 @@ public class AltosConfigUI pyros = pyro_ui.get_pyros(); return pyros; } + + public void set_aprs_interval(int new_aprs_interval) { + String s; + + if (new_aprs_interval <= 0) + s = "Disabled"; + else + s = Integer.toString(new_aprs_interval); + aprs_interval_value.setSelectedItem(s); + aprs_interval_value.setEnabled(new_aprs_interval >= 0); + set_aprs_interval_tool_tip(); + } + + public int aprs_interval() { + String s = aprs_interval_value.getSelectedItem().toString(); + + if (s.equals("Disabled")) + return 0; + return Integer.parseInt(s); + } } -- cgit v1.2.3 From 8dbe8abd034a2d1ee2ec0380ec376722a4ecbd71 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 14 Dec 2012 19:27:56 -0800 Subject: altoslib: Only list flight logs for boards that we know have them Boards that don't have flight logs will generate a nice 'Syntax Error' and fail to initialize. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 515ff480..758953e2 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -469,13 +469,15 @@ public class AltosConfigData implements Iterable { reset(); link.printf("c s\nf\nv\n"); read_link(link, "software-version"); + System.out.printf("Log format %d\n", log_format); switch (log_format) { - case AltosLib.AO_LOG_FORMAT_TELEMETRY: - case AltosLib.AO_LOG_FORMAT_TELESCIENCE: - break; - default: + case AltosLib.AO_LOG_FORMAT_FULL: + case AltosLib.AO_LOG_FORMAT_TINY: + case AltosLib.AO_LOG_FORMAT_MEGAMETRUM: link.printf("l\n"); read_link(link, "done"); + default: + break; } } -- cgit v1.2.3 From f1409311761d65e85ac08c38c9b9a0114cc8f535 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 14 Dec 2012 19:28:49 -0800 Subject: altoslib: Discard previous flight state on SN change A previous change discarded previous *telemetry* state, but failed to discard any previous overall flight state. This would reset some of the data fields, but wouldn't reset the GPS state and max measurements. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index f28dd1c6..218c598a 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -92,6 +92,9 @@ public class AltosState { public void init (AltosRecord cur, AltosState prev_state) { data = cur; + /* Discard previous state if it was for a different board */ + if (prev_state != null && prev_state.data.serial != data.serial) + prev_state = null; ground_altitude = data.ground_altitude(); altitude = data.altitude(); -- cgit v1.2.3 From 00bc1a090a294e103370b8ab0a0fe5d7a2acfe92 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 16 Dec 2012 13:25:54 -0800 Subject: altoslib: unconfigured radio frequency data is now -1, not 0 This changed when AltosConfigData was cleaned up, so now frequency settings must check for positive numbers rather than non-zero. Signed-off-by: Keith Packard --- altoslib/AltosLink.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 6d510563..1b722026 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -284,8 +284,8 @@ public abstract class AltosLink implements Runnable { frequency = in_frequency; config_data(); set_radio_frequency(frequency, - config_data.radio_frequency != 0, - config_data.radio_setting != 0, + config_data.radio_frequency > 0, + config_data.radio_setting > 0, config_data.radio_calibration); } @@ -339,10 +339,10 @@ public abstract class AltosLink implements Runnable { public String name; public void start_remote() throws TimeoutException, InterruptedException { - if (debug) - System.out.printf("start remote %7.3f\n", frequency); if (frequency == 0.0) frequency = AltosPreferences.frequency(serial); + if (debug) + System.out.printf("start remote %7.3f\n", frequency); set_radio_frequency(frequency); set_callsign(AltosPreferences.callsign()); printf("p\nE 0\n"); -- cgit v1.2.3 From 6db192898eebf750c4d51516eff7916bc4da493b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 31 Dec 2012 11:38:53 -0800 Subject: altoslib: Add units change notification list This allows the UI to automatically respond to changes in the preferred units. Signed-off-by: Keith Packard --- altoslib/AltosPreferences.java | 21 +++++++++++++++++++++ altoslib/AltosUnitsListener.java | 22 ++++++++++++++++++++++ altoslib/Makefile.am | 1 + 3 files changed, 44 insertions(+) create mode 100644 altoslib/AltosUnitsListener.java (limited to 'altoslib') diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 47196d6e..e50b9b5c 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -367,6 +367,8 @@ public class AltosPreferences { set_common_frequencies(new_frequencies); } + static LinkedList units_listeners; + public static boolean imperial_units() { synchronized(backend) { return AltosConvert.imperial_units; @@ -379,5 +381,24 @@ public class AltosPreferences { backend.putBoolean(unitsPreference, imperial_units); flush_preferences(); } + if (units_listeners != null) { + for (AltosUnitsListener l : units_listeners) { + l.units_changed(imperial_units); + } + } + } + + public static void register_units_listener(AltosUnitsListener l) { + synchronized(backend) { + if (units_listeners == null) + units_listeners = new LinkedList(); + units_listeners.add(l); + } + } + + public static void unregister_units_listener(AltosUnitsListener l) { + synchronized(backend) { + units_listeners.remove(l); + } } } diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java new file mode 100644 index 00000000..50a00cdf --- /dev/null +++ b/altoslib/AltosUnitsListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +public interface AltosUnitsListener { + public void units_changed(boolean imperial_units); +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 0086bc65..1b03c925 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -69,6 +69,7 @@ AltosLib_JAVA = \ $(SRC)/AltosTelemetryRecordSensor.java \ $(SRC)/AltosTelemetryRecordMegaSensor.java \ $(SRC)/AltosTelemetryRecordMegaData.java \ + $(SRC)/AltosUnitsListener.java \ $(SRC)/AltosMs5607.java \ $(SRC)/AltosIMU.java \ $(SRC)/AltosMag.java \ -- cgit v1.2.3 From d83587c3c66b730cc54ca153714eee520ee40b2c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 1 Jan 2013 15:30:11 -0800 Subject: micropeak is code complete now. Added save and download functionality. Removed 'new' from file menu. Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 1 + altosuilib/AltosDevice.java | 30 +++++++ altosuilib/AltosDeviceDialog.java | 163 ++++++++++++++++++++++++++++++++++++++ altosuilib/AltosUSBDevice.java | 112 ++++++++++++++++++++++++++ altosuilib/Makefile.am | 3 + libaltos/libaltos.c | 4 + micropeak/Makefile.am | 3 + micropeak/MicroData.java | 15 +++- micropeak/MicroDeviceDialog.java | 50 ++++++++++++ micropeak/MicroDownload.java | 139 ++++++++++++++++++++++++++++++++ micropeak/MicroGraph.java | 5 ++ micropeak/MicroPeak.java | 81 +++++++++++++++---- micropeak/MicroSave.java | 102 ++++++++++++++++++++++++ micropeak/MicroSerial.java | 12 ++- micropeak/MicroUSB.java | 19 +++-- 15 files changed, 708 insertions(+), 31 deletions(-) create mode 100644 altosuilib/AltosDevice.java create mode 100644 altosuilib/AltosDeviceDialog.java create mode 100644 altosuilib/AltosUSBDevice.java create mode 100644 micropeak/MicroDeviceDialog.java create mode 100644 micropeak/MicroDownload.java create mode 100644 micropeak/MicroSave.java (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 07516aeb..67138450 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -97,6 +97,7 @@ public class AltosLib { public final static int product_any = 0x10000; public final static int product_basestation = 0x10000 + 1; public final static int product_altimeter = 0x10000 + 2; + public final static int product_micropeak_serial = 0x10000 + 3; /* Bluetooth "identifier" (bluetooth sucks) */ public final static String bt_product_telebt = "TeleBT"; diff --git a/altosuilib/AltosDevice.java b/altosuilib/AltosDevice.java new file mode 100644 index 00000000..69b025ba --- /dev/null +++ b/altosuilib/AltosDevice.java @@ -0,0 +1,30 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib; + +import libaltosJNI.*; + +public interface AltosDevice { + public abstract String toString(); + public abstract String toShortString(); + public abstract int getSerial(); + public abstract String getPath(); + public abstract boolean matchProduct(int product); + public abstract String getErrorString(); + public SWIGTYPE_p_altos_file open(); +} diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java new file mode 100644 index 00000000..82620b8b --- /dev/null +++ b/altosuilib/AltosDeviceDialog.java @@ -0,0 +1,163 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionListener { + + private AltosDevice value; + private JList list; + private JButton cancel_button; + private JButton select_button; + private JButton manage_bluetooth_button; + private Frame frame; + private int product; + + public AltosDevice getValue() { + return value; + } + + public abstract AltosDevice[] devices(); + + private void update_devices() { + AltosDevice[] devices = devices(); + list.setListData(devices); + select_button.setEnabled(devices.length > 0); + } + + public AltosDeviceDialog (Frame in_frame, Component location, int in_product) { + super(in_frame, "Device Selection", true); + + product = in_product; + frame = in_frame; + value = null; + + AltosDevice[] devices = devices(); + + cancel_button = new JButton("Cancel"); + cancel_button.setActionCommand("cancel"); + cancel_button.addActionListener(this); + +// manage_bluetooth_button = new JButton("Manage Bluetooth"); +// manage_bluetooth_button.setActionCommand("manage"); +// manage_bluetooth_button.addActionListener(this); + + select_button = new JButton("Select"); + select_button.setActionCommand("select"); + select_button.addActionListener(this); + if (devices.length == 0) + select_button.setEnabled(false); + getRootPane().setDefaultButton(select_button); + + list = new JList(devices) { + //Subclass JList to workaround bug 4832765, which can cause the + //scroll pane to not let the user easily scroll up to the beginning + //of the list. An alternative would be to set the unitIncrement + //of the JScrollBar to a fixed value. You wouldn't get the nice + //aligned scrolling, but it should work. + public int getScrollableUnitIncrement(Rectangle visibleRect, + int orientation, + int direction) { + int row; + if (orientation == SwingConstants.VERTICAL && + direction < 0 && (row = getFirstVisibleIndex()) != -1) { + Rectangle r = getCellBounds(row, row); + if ((r.y == visibleRect.y) && (row != 0)) { + Point loc = r.getLocation(); + loc.y--; + int prevIndex = locationToIndex(loc); + Rectangle prevR = getCellBounds(prevIndex, prevIndex); + + if (prevR == null || prevR.y >= r.y) { + return 0; + } + return prevR.height; + } + } + return super.getScrollableUnitIncrement( + visibleRect, orientation, direction); + } + }; + + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + list.setLayoutOrientation(JList.HORIZONTAL_WRAP); + list.setVisibleRowCount(-1); + list.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + select_button.doClick(); //emulate button click + } + } + }); + JScrollPane listScroller = new JScrollPane(list); + listScroller.setPreferredSize(new Dimension(400, 80)); + listScroller.setAlignmentX(LEFT_ALIGNMENT); + + //Create a container so that we can add a title around + //the scroll pane. Can't add a title directly to the + //scroll pane because its background would be white. + //Lay out the label and scroll pane from top to bottom. + JPanel listPane = new JPanel(); + listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); + + JLabel label = new JLabel("Select Device"); + label.setLabelFor(list); + listPane.add(label); + listPane.add(Box.createRigidArea(new Dimension(0,5))); + listPane.add(listScroller); + listPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); + + //Lay out the buttons from left to right. + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); + buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); + buttonPane.add(Box.createHorizontalGlue()); + buttonPane.add(cancel_button); + buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); +// buttonPane.add(manage_bluetooth_button); +// buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); + buttonPane.add(select_button); + + //Put everything together, using the content pane's BorderLayout. + Container contentPane = getContentPane(); + contentPane.add(listPane, BorderLayout.CENTER); + contentPane.add(buttonPane, BorderLayout.PAGE_END); + + //Initialize values. + if (devices != null && devices.length != 0) + list.setSelectedValue(devices[0], true); + pack(); + setLocationRelativeTo(location); + } + + //Handle clicks on the Set and Cancel buttons. + public void actionPerformed(ActionEvent e) { + if ("select".equals(e.getActionCommand())) + value = (AltosDevice)(list.getSelectedValue()); +// if ("manage".equals(e.getActionCommand())) { +// AltosBTManage.show(frame, AltosBTKnown.bt_known()); +// update_devices(); +// return; +// } + setVisible(false); + } + +} diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java new file mode 100644 index 00000000..2f4e0dc6 --- /dev/null +++ b/altosuilib/AltosUSBDevice.java @@ -0,0 +1,112 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib; + +import java.util.*; +import libaltosJNI.*; + +public class AltosUSBDevice extends altos_device implements AltosDevice { + + public String toString() { + String name = getName(); + if (name == null) + name = "Altus Metrum"; + return String.format("%-20.20s %4d %s", + name, getSerial(), getPath()); + } + + public String toShortString() { + String name = getName(); + if (name == null) + name = "Altus Metrum"; + return String.format("%s %d %s", + name, getSerial(), getPath()); + + } + + public String getErrorString() { + altos_error error = new altos_error(); + + libaltos.altos_get_last_error(error); + return String.format("%s (%d)", error.getString(), error.getCode()); + } + + public SWIGTYPE_p_altos_file open() { + return libaltos.altos_open(this); + } + + private boolean isAltusMetrum() { + if (getVendor() != AltosUILib.vendor_altusmetrum) + return false; + if (getProduct() < AltosUILib.product_altusmetrum_min) + return false; + if (getProduct() > AltosUILib.product_altusmetrum_max) + return false; + return true; + } + + public boolean matchProduct(int want_product) { + + if (!isAltusMetrum()) + return false; + + if (want_product == AltosUILib.product_any) + return true; + + if (want_product == AltosUILib.product_basestation) + return matchProduct(AltosUILib.product_teledongle) || + matchProduct(AltosUILib.product_teleterra) || + matchProduct(AltosUILib.product_telebt) || + matchProduct(AltosUILib.product_megadongle); + + if (want_product == AltosUILib.product_altimeter) + return matchProduct(AltosUILib.product_telemetrum) || + matchProduct(AltosUILib.product_megametrum); + + int have_product = getProduct(); + + if (have_product == AltosUILib.product_altusmetrum) /* old devices match any request */ + return true; + + if (want_product == have_product) + return true; + + return false; + } + + static java.util.List list(int product) { + if (!AltosUILib.load_library()) + return null; + + SWIGTYPE_p_altos_list list = libaltos.altos_list_start(); + + ArrayList device_list = new ArrayList(); + if (list != null) { + for (;;) { + AltosUSBDevice device = new AltosUSBDevice(); + if (libaltos.altos_list_next(list, device) == 0) + break; + if (device.matchProduct(product)) + device_list.add(device); + } + libaltos.altos_list_finish(list); + } + + return device_list; + } +} \ No newline at end of file diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 26aee7c4..e2ff8cb5 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -11,6 +11,9 @@ AltosUILibdir = $(datadir)/java AltosUILib_JAVA = \ AltosConfigureUI.java \ + AltosDevice.java \ + AltosDeviceDialog.java \ + AltosUSBDevice.java \ AltosFontListener.java \ AltosUIDialog.java \ AltosUIFrame.java \ diff --git a/libaltos/libaltos.c b/libaltos/libaltos.c index d7b266cf..6e884c80 100644 --- a/libaltos/libaltos.c +++ b/libaltos/libaltos.c @@ -116,6 +116,7 @@ altos_open(struct altos_device *device) return NULL; } + printf ("open\n"); // altos_set_last_error(12, "yeah yeah, failed again"); // free(file); // return NULL; @@ -148,6 +149,8 @@ altos_open(struct altos_device *device) return NULL; } cfmakeraw(&term); + cfsetospeed(&term, B9600); + cfsetispeed(&term, B9600); #ifdef USE_POLL term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0; @@ -609,6 +612,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) { struct altos_usbdev *dev; if (list->current >= list->ndev) { + printf ("end\n"); return 0; } dev = list->dev[list->current]; diff --git a/micropeak/Makefile.am b/micropeak/Makefile.am index e0de690c..a54b78a5 100644 --- a/micropeak/Makefile.am +++ b/micropeak/Makefile.am @@ -10,12 +10,15 @@ micropeakdir=$(datadir)/java micropeak_JAVA= \ MicroPeak.java \ MicroData.java \ + MicroDownload.java \ MicroFrame.java \ MicroGraph.java \ + MicroSave.java \ MicroSerial.java \ MicroStats.java \ MicroStatsTable.java \ MicroFileChooser.java \ + MicroDeviceDialog.java \ MicroUSB.java JFREECHART_CLASS= \ diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index ec9b83d8..8ccd5fd8 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -110,6 +110,7 @@ public class MicroData { private double time_step; private double ground_altitude; private ArrayList bytes; + String name; class FileEndedException extends Exception { @@ -310,12 +311,18 @@ public class MicroData { public void save (OutputStream f) throws IOException { for (int c : bytes) f.write(c); + f.write('\n'); } - public MicroData (InputStream f) throws IOException { + public void set_name(String name) { + this.name = name; + } + + public MicroData (InputStream f, String name) throws IOException, InterruptedException { + this.name = name; bytes = new ArrayList(); if (!find_header(f)) - throw new IOException(); + throw new IOException("No MicroPeak data header found"); try { file_crc = 0xffff; ground_pressure = get_32(f); @@ -354,9 +361,9 @@ public class MicroData { time_step = 0.192; } catch (FileEndedException fe) { - throw new IOException(); + throw new IOException("File Ended Unexpectedly"); } catch (NonHexcharException ne) { - throw new IOException(); + throw new IOException("Non hexadecimal character found"); } } diff --git a/micropeak/MicroDeviceDialog.java b/micropeak/MicroDeviceDialog.java new file mode 100644 index 00000000..7b8a630c --- /dev/null +++ b/micropeak/MicroDeviceDialog.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.micropeak; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.util.*; +import org.altusmetrum.altosuilib.*; + +public class MicroDeviceDialog extends AltosDeviceDialog { + + public AltosDevice[] devices() { + java.util.List list = MicroUSB.list(); + int num_devices = list.size(); + AltosDevice[] devices = new AltosDevice[num_devices]; + + for (int i = 0; i < num_devices; i++) + devices[i] = list.get(i); + return devices; + } + + public MicroDeviceDialog (Frame in_frame, Component location) { + super(in_frame, location, 0); + } + + public static AltosDevice show (Component frameComp) { + Frame frame = JOptionPane.getFrameForComponent(frameComp); + MicroDeviceDialog dialog; + + dialog = new MicroDeviceDialog (frame, frameComp); + dialog.setVisible(true); + return dialog.getValue(); + } +} diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java new file mode 100644 index 00000000..2e328b4a --- /dev/null +++ b/micropeak/MicroDownload.java @@ -0,0 +1,139 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.micropeak; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.io.*; +import java.util.concurrent.*; +import java.util.*; +import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altosuilib.*; + +public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener { + MicroPeak owner; + Container pane; + AltosDevice device; + JButton cancel; + MicroData data; + MicroSerial serial; + + private void done_internal() { + setVisible(false); + if (data != null) { + owner = owner.SetData(data); + MicroSave save = new MicroSave(owner, data); + if (save.runDialog()) + owner.SetName(data.name); + } + dispose(); + } + + public void done() { + Runnable r = new Runnable() { + public void run() { + try { + done_internal(); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + public void run() { + try { + data = new MicroData(serial, device.toShortString()); + serial.close(); + } catch (FileNotFoundException fe) { + } catch (IOException ioe) { + } catch (InterruptedException ie) { + } + done(); + } + + Thread serial_thread; + + public void start() { + try { + serial = new MicroSerial(device); + } catch (FileNotFoundException fe) { + return; + } + serial_thread = new Thread(this); + serial_thread.start(); + } + + public void actionPerformed(ActionEvent ae) { + System.out.printf ("command %s\n", ae.getActionCommand()); + if (serial_thread != null) { + System.out.printf ("Interrupting serial_thread\n"); + serial.close(); + serial_thread.interrupt(); + } + } + + public MicroDownload(MicroPeak owner, AltosDevice device) { + super (owner, "Download MicroPeak Data", false); + + GridBagConstraints c; + Insets il = new Insets(4,4,4,4); + Insets ir = new Insets(4,4,4,4); + + this.owner = owner; + this.device = device; + + pane = getContentPane(); + pane.setLayout(new GridBagLayout()); + + c = new GridBagConstraints(); + c.gridx = 0; c.gridy = 0; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + JLabel device_label = new JLabel("Device:"); + pane.add(device_label, c); + + c = new GridBagConstraints(); + c.gridx = 1; c.gridy = 0; + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 1; + c.anchor = GridBagConstraints.LINE_START; + c.insets = ir; + JLabel device_value = new JLabel(device.toString()); + pane.add(device_value, c); + + cancel = new JButton("Cancel"); + c = new GridBagConstraints(); + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.CENTER; + c.gridx = 0; c.gridy = 1; + c.gridwidth = GridBagConstraints.REMAINDER; + Insets ic = new Insets(4,4,4,4); + c.insets = ic; + pane.add(cancel, c); + + cancel.addActionListener(this); + + pack(); + setLocationRelativeTo(owner); + setVisible(true); + this.start(); + } +} diff --git a/micropeak/MicroGraph.java b/micropeak/MicroGraph.java index 38f54fe0..b9b084f8 100644 --- a/micropeak/MicroGraph.java +++ b/micropeak/MicroGraph.java @@ -111,8 +111,13 @@ public class MicroGraph implements AltosUnitsListener { } } + public void setName (String name) { + chart.setTitle(name); + } + public void setData (MicroData data) { this.data = data; + chart.setTitle(data.name); resetData(); } diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index c69f7167..5e375057 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -34,13 +34,36 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene MicroData data; Container container; JTabbedPane pane; + static int number_of_windows; - private void RunFile(InputStream input) { + MicroPeak SetData(MicroData data) { + MicroPeak mp = this; + if (this.data != null) { + mp = new MicroPeak(); + return mp.SetData(data); + } + this.data = data; + graph.setData(data); + stats.setData(data); + setTitle(data.name); + return this; + } + + void SetName(String name) { + graph.setName(name); + setTitle(name); + } + + private void RunFile(InputStream input, String name) { try { - data = new MicroData(input); - graph.setData(data); - stats.setData(data); + MicroData data = new MicroData(input, name); + SetData(data); } catch (IOException ioe) { + JOptionPane.showMessageDialog(this, + ioe.getMessage(), + "File Read Error", + JOptionPane.ERROR_MESSAGE); + } catch (InterruptedException ie) { } try { input.close(); @@ -50,8 +73,12 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene private void OpenFile(File filename) { try { - RunFile (new FileInputStream(filename)); + RunFile (new FileInputStream(filename), filename.getName()); } catch (FileNotFoundException fne) { + JOptionPane.showMessageDialog(this, + fne.getMessage(), + "Cannot open file", + JOptionPane.ERROR_MESSAGE); } } @@ -60,30 +87,44 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene InputStream input = chooser.runDialog(); if (input != null) - RunFile(input); + RunFile(input, chooser.filename); } private void Preferences() { new AltosConfigureUI(this); } - + private void DownloadData() { - java.util.List devices = MicroUSB.list(); - for (MicroUSB device : devices) - System.out.printf("device %s\n", device.toString()); + AltosDevice device = MicroDeviceDialog.show(this); + + if (device != null) + new MicroDownload(this, device); } + private void Save() { + if (data == null) { + JOptionPane.showMessageDialog(this, + "No data available", + "No data", + JOptionPane.INFORMATION_MESSAGE); + return; + } + MicroSave save = new MicroSave (this, data); + if (save.runDialog()) + SetName(data.name); + } + public void actionPerformed(ActionEvent ev) { if ("Exit".equals(ev.getActionCommand())) System.exit(0); else if ("Open".equals(ev.getActionCommand())) SelectFile(); - else if ("New".equals(ev.getActionCommand())) - new MicroPeak(); else if ("Download".equals(ev.getActionCommand())) DownloadData(); else if ("Preferences".equals(ev.getActionCommand())) Preferences(); + else if ("Save a Copy".equals(ev.getActionCommand())) + Save(); } public void itemStateChanged(ItemEvent e) { @@ -91,6 +132,8 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene public MicroPeak() { + ++number_of_windows; + AltosUIPreferences.set_component(this); container = getContentPane(); @@ -104,10 +147,6 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); - JMenuItem newAction = new JMenuItem("New"); - fileMenu.add(newAction); - newAction.addActionListener(this); - JMenuItem openAction = new JMenuItem("Open"); fileMenu.add(openAction); openAction.addActionListener(this); @@ -116,6 +155,10 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene fileMenu.add(downloadAction); downloadAction.addActionListener(this); + JMenuItem saveAction = new JMenuItem("Save a Copy"); + fileMenu.add(saveAction); + saveAction.addActionListener(this); + JMenuItem preferencesAction = new JMenuItem("Preferences"); fileMenu.add(preferencesAction); preferencesAction.addActionListener(this); @@ -128,7 +171,11 @@ public class MicroPeak extends MicroFrame implements ActionListener, ItemListene addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - System.exit(0); + setVisible(false); + dispose(); + --number_of_windows; + if (number_of_windows == 0) + System.exit(0); } }); diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java new file mode 100644 index 00000000..cb4b4221 --- /dev/null +++ b/micropeak/MicroSave.java @@ -0,0 +1,102 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.micropeak; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.io.*; +import java.util.concurrent.*; +import java.util.*; +import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altosuilib.*; + +public class MicroSave extends JFileChooser { + + JFrame frame; + MicroData data; + + public boolean runDialog() { + int ret; + + for (;;) { + ret = showSaveDialog(frame); + if (ret != APPROVE_OPTION) + return false; + File file; + String filename; + file = getSelectedFile(); + if (file == null) + continue; + if (!file.getName().contains(".")) { + String fullname = file.getPath(); + file = new File(fullname.concat(".mpd")); + } + filename = file.getName(); + if (file.exists()) { + if (file.isDirectory()) { + JOptionPane.showMessageDialog(frame, + String.format("\"%s\" is a directory", + filename), + "Directory", + JOptionPane.ERROR_MESSAGE); + continue; + } + int r = JOptionPane.showConfirmDialog(frame, + String.format("\"%s\" already exists. Overwrite?", + filename), + "Overwrite file?", + JOptionPane.YES_NO_OPTION); + if (r != JOptionPane.YES_OPTION) + continue; + + if (!file.canWrite()) { + JOptionPane.showMessageDialog(frame, + String.format("\"%s\" is not writable", + filename), + "File not writable", + JOptionPane.ERROR_MESSAGE); + continue; + } + } + try { + FileOutputStream fos = new FileOutputStream(file); + data.save(fos); + fos.close(); + data.set_name(filename); + return true; + } catch (FileNotFoundException fe) { + JOptionPane.showMessageDialog(frame, + fe.getMessage(), + "Cannot create file", + JOptionPane.ERROR_MESSAGE); + } catch (IOException ioe) { + } + } + } + + public MicroSave(JFrame frame, MicroData data) { + this.frame = frame; + this.data = data; + setDialogTitle("Save MicroPeak Data File"); + setFileFilter(new FileNameExtensionFilter("MicroPeak data file", + "mpd")); + setCurrentDirectory(AltosUIPreferences.logdir()); + } +} diff --git a/micropeak/MicroSerial.java b/micropeak/MicroSerial.java index a1a77a1d..15ef8582 100644 --- a/micropeak/MicroSerial.java +++ b/micropeak/MicroSerial.java @@ -27,6 +27,10 @@ public class MicroSerial extends InputStream { public int read() { int c = libaltos.altos_getchar(file, 0); + if (Thread.interrupted()) + return -1; + if (c == -1) + return -1; if (AltosUIPreferences.serial_debug) System.out.printf("%c", c); return c; @@ -39,12 +43,12 @@ public class MicroSerial extends InputStream { } } - public MicroSerial(MicroUSB usb) throws FileNotFoundException { - file = usb.open(); + public MicroSerial(AltosDevice device) throws FileNotFoundException { + file = device.open(); if (file == null) { - final String message = usb.getErrorString(); + final String message = device.getErrorString(); throw new FileNotFoundException(String.format("%s (%s)", - usb.toShortString(), + device.toShortString(), message)); } } diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index d48610fe..244f7bc0 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -16,10 +16,12 @@ */ package org.altusmetrum.micropeak; + import java.util.*; import libaltosJNI.*; +import org.altusmetrum.altosuilib.*; -public class MicroUSB extends altos_device { +public class MicroUSB extends altos_device implements AltosDevice { static boolean initialized = false; static boolean loaded_library = false; @@ -48,16 +50,16 @@ public class MicroUSB extends altos_device { String name = getName(); if (name == null) name = "Altus Metrum"; - return String.format("%-20.20s %4d %s", - name, getSerial(), getPath()); + return String.format("%-20.20s %s", + name, getPath()); } public String toShortString() { String name = getName(); if (name == null) name = "Altus Metrum"; - return String.format("%s %d %s", - name, getSerial(), getPath()); + return String.format("%s %s", + name, getPath()); } @@ -75,11 +77,15 @@ public class MicroUSB extends altos_device { private boolean isMicro() { if (getVendor() != 0x0403) return false; - if (getProduct() != 0x6001) + if (getProduct() != 0x6015) return false; return true; } + public boolean matchProduct(int product) { + return isMicro(); + } + static java.util.List list() { if (!load_library()) return null; @@ -92,6 +98,7 @@ public class MicroUSB extends altos_device { MicroUSB device = new MicroUSB(); if (libaltos.altos_list_next(list, device) == 0) break; + System.out.printf("Device %s\n", device.toString()); if (device.isMicro()) device_list.add(device); } -- cgit v1.2.3 From 0933f2ed5791cfdc28242cd60be3942556f4ed20 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 2 Jan 2013 10:48:56 -0800 Subject: altoslib: Remove unused fake product_micropeak_serial Code cleanups have made this no longer useful Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 1 - 1 file changed, 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 67138450..07516aeb 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -97,7 +97,6 @@ public class AltosLib { public final static int product_any = 0x10000; public final static int product_basestation = 0x10000 + 1; public final static int product_altimeter = 0x10000 + 2; - public final static int product_micropeak_serial = 0x10000 + 3; /* Bluetooth "identifier" (bluetooth sucks) */ public final static String bt_product_telebt = "TeleBT"; -- cgit v1.2.3 From ca284d8bef2f4bd360eaec58048ba9abdafc55bd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 3 Jan 2013 18:14:40 -0800 Subject: micropeak: Use data.export for Raw display. Change to MPH data.export already knows how to format stuff, so use that to construct the raw data presentation for the GUI too. Signed-off-by: Keith Packard --- altoslib/AltosSpeed.java | 6 +++--- micropeak/MicroData.java | 6 +++--- micropeak/MicroRaw.java | 14 ++++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index af63ed17..4e2daf5a 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -21,19 +21,19 @@ public class AltosSpeed extends AltosUnits { public double value(double v) { if (AltosConvert.imperial_units) - return AltosConvert.meters_to_feet(v); + return AltosConvert.meters_to_mph(v); return v; } public String show_units() { if (AltosConvert.imperial_units) - return "ft/s"; + return "mph"; return "m/s"; } public String say_units() { if (AltosConvert.imperial_units) - return "feet per second"; + return "miles per hour"; return "meters per second"; } diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index d3c8c43e..f1204e11 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -265,15 +265,15 @@ public class MicroData { public void export (Writer f) throws IOException { PrintWriter pw = new PrintWriter(f); - pw.printf(" Time, Press(Pa), Height(m), Height(f), Speed(m/s), Speed(ft/s), Speed(mach), Accel(m/s²), Accel(ft/s²), Accel(g)\n"); + pw.printf(" Time, Press(Pa), Height(m), Height(f), Speed(m/s), Speed(mph), Speed(mach), Accel(m/s²), Accel(ft/s²), Accel(g)\n"); for (MicroDataPoint point : points()) { - pw.printf("%6.3f,%10.0f,%10.1f,%10.1f,%11.2f,%12.2f,%12.4f,%12.2f,%13.2f,%10.4f\n", + pw.printf("%6.3f,%10.0f,%10.1f,%10.1f,%11.2f,%11.2f,%12.4f,%12.2f,%13.2f,%10.4f\n", point.time, point.pressure, point.height, AltosConvert.meters_to_feet(point.height), point.speed, - AltosConvert.meters_to_feet(point.speed), + AltosConvert.meters_to_mph(point.speed), AltosConvert.meters_to_mach(point.speed), point.accel, AltosConvert.meters_to_feet(point.accel), diff --git a/micropeak/MicroRaw.java b/micropeak/MicroRaw.java index f5bea76f..dd480bfe 100644 --- a/micropeak/MicroRaw.java +++ b/micropeak/MicroRaw.java @@ -18,6 +18,7 @@ package org.altusmetrum.micropeak; import java.awt.*; +import java.io.*; import javax.swing.*; import org.altusmetrum.AltosLib.*; import org.altusmetrum.altosuilib.*; @@ -25,12 +26,13 @@ import org.altusmetrum.altosuilib.*; public class MicroRaw extends JTextArea { public void setData(MicroData data) { - setRows(data.pressures.length); - setText(" Time, Press, Height, Speed, Accel\n"); - for (MicroDataPoint point : data.points()) { - append(String.format( - "%6.3f,%6.0f,%7.1f,%7.2f,%7.2f\n", - point.time, point.pressure, point.height, point.speed, point.accel)); + StringWriter sw = new StringWriter(); + try { + data.export(sw); + setRows(data.pressures.length + 1); + setText(sw.toString()); + } catch (IOException ie) { + setText(String.format("Error writing data: %s", ie.getMessage())); } } -- cgit v1.2.3 From 42733d2823b1ecf54c03881fc120067868c0ff4c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 9 Jan 2013 15:23:46 -0800 Subject: altoslib: Don't smash existing GPS pad alt after boost Leave the existing GPS pad altitude value in place after boost by checking to see if it was ever computed before resetting it to the barometric pad altitude. This makes GPS height values relative to the pad. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 218c598a..4f59c840 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -200,10 +200,10 @@ public class AltosState { } ngps++; } - } else - pad_alt = ground_altitude; - - data.new_gps = false; + } else { + if (ngps == 0) + pad_alt = ground_altitude; + } gps_waiting = MIN_PAD_SAMPLES - npad; if (gps_waiting < 0) -- cgit v1.2.3 From f715b5da3424adacc5a7f1e001e1dd7fa6f50385 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 9 Jan 2013 15:29:01 -0800 Subject: altoslib: Clean up AltosRecord clone methods Make the AltosRecord version abstract and then implement suitable versions in each subclass by creating copying constructors for each class. Signed-off-by: Keith Packard --- altoslib/AltosRecord.java | 12 ++---------- altoslib/AltosRecordMM.java | 10 +++++++--- altoslib/AltosRecordNone.java | 4 ++++ altoslib/AltosRecordTM.java | 8 +++++--- 4 files changed, 18 insertions(+), 16 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 09169515..2c4b6fa5 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -126,6 +126,8 @@ public abstract class AltosRecord implements Comparable , Cloneable return tick - o.tick; } + abstract public AltosRecord clone(); + public void copy(AltosRecord old) { seen = old.seen; version = old.version; @@ -144,16 +146,6 @@ public abstract class AltosRecord implements Comparable , Cloneable kalman_height = old.kalman_height; } - public AltosRecord clone() { - try { - AltosRecord n = (AltosRecord) super.clone(); - n.copy(this); - return n; - } catch (CloneNotSupportedException e) { - return null; - } - } - public AltosRecord() { seen = 0; version = 0; diff --git a/altoslib/AltosRecordMM.java b/altoslib/AltosRecordMM.java index 9f529234..546f3055 100644 --- a/altoslib/AltosRecordMM.java +++ b/altoslib/AltosRecordMM.java @@ -131,10 +131,10 @@ public class AltosRecordMM extends AltosRecord { mag = old.mag; } + + public AltosRecordMM clone() { - AltosRecordMM n = (AltosRecordMM) super.clone(); - n.copy(this); - return n; + return new AltosRecordMM(this); } void make_missing() { @@ -167,6 +167,10 @@ public class AltosRecordMM extends AltosRecord { make_missing(); } + public AltosRecordMM(AltosRecordMM old) { + copy(old); + } + public AltosRecordMM() { super(); make_missing(); diff --git a/altoslib/AltosRecordNone.java b/altoslib/AltosRecordNone.java index ca0a5fe3..d4ea305f 100644 --- a/altoslib/AltosRecordNone.java +++ b/altoslib/AltosRecordNone.java @@ -28,6 +28,10 @@ public class AltosRecordNone extends AltosRecord { super.copy(old); } + public AltosRecordNone clone() { + return new AltosRecordNone(this); + } + public AltosRecordNone() { super(); } diff --git a/altoslib/AltosRecordTM.java b/altoslib/AltosRecordTM.java index 9530be31..f6ed4966 100644 --- a/altoslib/AltosRecordTM.java +++ b/altoslib/AltosRecordTM.java @@ -149,9 +149,7 @@ public class AltosRecordTM extends AltosRecord { } public AltosRecordTM clone() { - AltosRecordTM n = (AltosRecordTM) super.clone(); - n.copy(this); - return n; + return new AltosRecordTM(this); } void make_missing() { @@ -177,6 +175,10 @@ public class AltosRecordTM extends AltosRecord { make_missing(); } + public AltosRecordTM(AltosRecordTM old) { + copy(old); + } + public AltosRecordTM() { super(); make_missing(); -- cgit v1.2.3 From 5a3c5de6657d1c26e52015a8acec0cd05e294cef Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 29 Jan 2013 14:52:23 +1100 Subject: Change AltosLib to altoslib Follow Java conventions Signed-off-by: Keith Packard --- Makefile.am | 3 +++ altoslib/AltosAccel.java | 2 +- altoslib/AltosCRCException.java | 2 +- altoslib/AltosConfigData.java | 2 +- altoslib/AltosConfigValues.java | 2 +- altoslib/AltosConvert.java | 2 +- altoslib/AltosDistance.java | 2 +- altoslib/AltosEepromChunk.java | 2 +- altoslib/AltosEepromIterable.java | 2 +- altoslib/AltosEepromLog.java | 2 +- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMegaIterable.java | 2 +- altoslib/AltosEepromRecord.java | 2 +- altoslib/AltosEepromTeleScience.java | 2 +- altoslib/AltosFile.java | 2 +- altoslib/AltosFlightReader.java | 2 +- altoslib/AltosFrequency.java | 2 +- altoslib/AltosGPS.java | 2 +- altoslib/AltosGPSQuery.java | 2 +- altoslib/AltosGPSSat.java | 2 +- altoslib/AltosGreatCircle.java | 2 +- altoslib/AltosHeight.java | 2 +- altoslib/AltosIMU.java | 2 +- altoslib/AltosIMUQuery.java | 2 +- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosIdleMonitorListener.java | 2 +- altoslib/AltosIgnite.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLine.java | 2 +- altoslib/AltosLink.java | 2 +- altoslib/AltosLog.java | 2 +- altoslib/AltosMag.java | 2 +- altoslib/AltosMs5607.java | 2 +- altoslib/AltosMs5607Query.java | 2 +- altoslib/AltosOrderedMegaRecord.java | 2 +- altoslib/AltosOrderedRecord.java | 2 +- altoslib/AltosParse.java | 2 +- altoslib/AltosPreferences.java | 2 +- altoslib/AltosPreferencesBackend.java | 2 +- altoslib/AltosPyro.java | 2 +- altoslib/AltosRecord.java | 2 +- altoslib/AltosRecordCompanion.java | 2 +- altoslib/AltosRecordIterable.java | 2 +- altoslib/AltosRecordMM.java | 2 +- altoslib/AltosRecordNone.java | 2 +- altoslib/AltosRecordTM.java | 2 +- altoslib/AltosReplayReader.java | 2 +- altoslib/AltosSensorMM.java | 2 +- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSpeed.java | 2 +- altoslib/AltosState.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryIterable.java | 2 +- altoslib/AltosTelemetryMap.java | 2 +- altoslib/AltosTelemetryReader.java | 2 +- altoslib/AltosTelemetryRecord.java | 2 +- altoslib/AltosTelemetryRecordCompanion.java | 2 +- altoslib/AltosTelemetryRecordConfiguration.java | 2 +- altoslib/AltosTelemetryRecordGeneral.java | 2 +- altoslib/AltosTelemetryRecordLegacy.java | 2 +- altoslib/AltosTelemetryRecordLocation.java | 2 +- altoslib/AltosTelemetryRecordMegaData.java | 2 +- altoslib/AltosTelemetryRecordMegaSensor.java | 2 +- altoslib/AltosTelemetryRecordRaw.java | 2 +- altoslib/AltosTelemetryRecordSatellite.java | 2 +- altoslib/AltosTelemetryRecordSensor.java | 2 +- altoslib/AltosUnits.java | 2 +- altoslib/AltosUnitsListener.java | 2 +- altoslib/Makefile.am | 2 ++ altosui/Altos.java | 2 +- altosui/AltosAscent.java | 2 +- altosui/AltosBTKnown.java | 2 +- altosui/AltosCSV.java | 2 +- altosui/AltosCSVUI.java | 2 +- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfig.java | 2 +- altosui/AltosConfigFreqUI.java | 2 +- altosui/AltosConfigPyroUI.java | 2 +- altosui/AltosConfigTD.java | 2 +- altosui/AltosConfigTDUI.java | 2 +- altosui/AltosConfigUI.java | 2 +- altosui/AltosDataChooser.java | 2 +- altosui/AltosDataPointReader.java | 2 +- altosui/AltosDescent.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromDownload.java | 2 +- altosui/AltosEepromList.java | 2 +- altosui/AltosEepromManage.java | 2 +- altosui/AltosEepromSelect.java | 2 +- altosui/AltosFlightDisplay.java | 2 +- altosui/AltosFlightStats.java | 2 +- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightStatus.java | 2 +- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 2 +- altosui/AltosFreqList.java | 2 +- altosui/AltosGraphUI.java | 2 +- altosui/AltosIdleMonitorUI.java | 2 +- altosui/AltosIgniteUI.java | 2 +- altosui/AltosInfoTable.java | 2 +- altosui/AltosKML.java | 2 +- altosui/AltosLanded.java | 2 +- altosui/AltosPad.java | 2 +- altosui/AltosScanUI.java | 2 +- altosui/AltosSerial.java | 2 +- altosui/AltosSiteMap.java | 2 +- altosui/AltosSiteMapTile.java | 2 +- altosui/AltosUI.java | 2 +- altosui/AltosUIPreferencesBackend.java | 2 +- altosui/AltosWriter.java | 2 +- altosuilib/AltosUILib.java | 2 +- altosuilib/AltosUIPreferences.java | 2 +- altosuilib/AltosUIPreferencesBackend.java | 2 +- configure.ac | 12 ++++++++++++ micropeak/MicroData.java | 2 +- micropeak/MicroDownload.java | 2 +- micropeak/MicroExport.java | 2 +- micropeak/MicroFile.java | 2 +- micropeak/MicroFileChooser.java | 2 +- micropeak/MicroGraph.java | 2 +- micropeak/MicroPeak.java | 2 +- micropeak/MicroRaw.java | 2 +- micropeak/MicroSave.java | 2 +- micropeak/MicroStats.java | 2 +- micropeak/MicroStatsTable.java | 2 +- 127 files changed, 141 insertions(+), 124 deletions(-) (limited to 'altoslib') diff --git a/Makefile.am b/Makefile.am index 59cddb9f..bd7772e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,3 +20,6 @@ fat: cd altosuilib && $(MAKE) all cd altosui && $(MAKE) fat cd micropeak && $(MAKE) fat + +set-java-versions: + $(top_srcdir)/fix-java-versions org.altusmetrum.altoslib=$(ALTOSLIB_VERSION) org.altusmetrum.altosuilib=$(ALTOSUILIB_VERSION) \ No newline at end of file diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index d14764a2..9cb9a14b 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosAccel extends AltosUnits { diff --git a/altoslib/AltosCRCException.java b/altoslib/AltosCRCException.java index 101c5363..1dd33ce9 100644 --- a/altoslib/AltosCRCException.java +++ b/altoslib/AltosCRCException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosCRCException extends Exception { public int rssi; diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 99b8e39d..387d1067 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; +package org.altusmetrum.altoslib; import java.util.*; import java.text.*; diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 40d5217e..2ec4b2a6 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public interface AltosConfigValues { /* set and get all of the dialog values */ diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index acd6c5f4..6345e522 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -18,7 +18,7 @@ /* * Sensor data conversion functions */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosConvert { /* diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index a6026d4a..3e994618 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosDistance extends AltosUnits { diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index 77b22fe2..a1fc7d11 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 986b7a2c..2e8715ba 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index 211fd706..8a631c3c 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index af4f8aca..0c38a915 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index 16809089..05fc1f4a 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromRecord.java b/altoslib/AltosEepromRecord.java index c7ced6a3..0c914aca 100644 --- a/altoslib/AltosEepromRecord.java +++ b/altoslib/AltosEepromRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosEepromTeleScience.java b/altoslib/AltosEepromTeleScience.java index 02ce4553..c983131e 100644 --- a/altoslib/AltosEepromTeleScience.java +++ b/altoslib/AltosEepromTeleScience.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index 1ab00b38..a2ff261a 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index cbd64153..87a53222 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; import java.io.*; diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index e20f03b7..2e55d3b9 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosFrequency { public double frequency; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index ea0949ec..6405579b 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosGPSQuery.java b/altoslib/AltosGPSQuery.java index e93af259..fe453e0d 100644 --- a/altoslib/AltosGPSQuery.java +++ b/altoslib/AltosGPSQuery.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.concurrent.*; diff --git a/altoslib/AltosGPSSat.java b/altoslib/AltosGPSSat.java index faa1ec8d..605c592a 100644 --- a/altoslib/AltosGPSSat.java +++ b/altoslib/AltosGPSSat.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosGPSSat { public int svid; diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index 76b71859..ad7849a3 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.lang.Math; diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index da7ffdae..d7192e0b 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosHeight extends AltosUnits { diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index c0eaf139..cf37eba1 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosIMU { public int accel_x; diff --git a/altoslib/AltosIMUQuery.java b/altoslib/AltosIMUQuery.java index 0965fa39..f2ada8d4 100644 --- a/altoslib/AltosIMUQuery.java +++ b/altoslib/AltosIMUQuery.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 07d8930d..0a80ca6b 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index 9f9ababf..580626dd 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public interface AltosIdleMonitorListener { public void update(AltosState state); diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index a48d0b69..41f1faaf 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 07516aeb..b3fe2968 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.*; import java.io.*; diff --git a/altoslib/AltosLine.java b/altoslib/AltosLine.java index 5627795a..efa7df7a 100644 --- a/altoslib/AltosLine.java +++ b/altoslib/AltosLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosLine { public String line; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 1b722026..02880ec9 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index aa30190c..ab707edd 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.text.ParseException; diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index 0f8399ab..760cc623 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosMag { public int x; diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 318fea4d..da64a0ea 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosMs5607 { public int reserved; diff --git a/altoslib/AltosMs5607Query.java b/altoslib/AltosMs5607Query.java index 1aaec334..08089b07 100644 --- a/altoslib/AltosMs5607Query.java +++ b/altoslib/AltosMs5607Query.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosOrderedMegaRecord.java b/altoslib/AltosOrderedMegaRecord.java index 3aaf7b5b..4db0bcf8 100644 --- a/altoslib/AltosOrderedMegaRecord.java +++ b/altoslib/AltosOrderedMegaRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.ParseException; diff --git a/altoslib/AltosOrderedRecord.java b/altoslib/AltosOrderedRecord.java index b4cfd8f2..73b4d3f8 100644 --- a/altoslib/AltosOrderedRecord.java +++ b/altoslib/AltosOrderedRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.ParseException; diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index e938a177..e4ab662a 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index e50b9b5c..65a46eb6 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.*; diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index a1184c0b..99ca9432 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.File; diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 14051169..0554ff11 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.*; import java.text.*; diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 2c4b6fa5..b519807b 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public abstract class AltosRecord implements Comparable , Cloneable { diff --git a/altoslib/AltosRecordCompanion.java b/altoslib/AltosRecordCompanion.java index c8cc6cac..ffb114ec 100644 --- a/altoslib/AltosRecordCompanion.java +++ b/altoslib/AltosRecordCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosRecordCompanion { public final static int board_id_telescience = 0x0a; diff --git a/altoslib/AltosRecordIterable.java b/altoslib/AltosRecordIterable.java index ed1787ed..17b13c7d 100644 --- a/altoslib/AltosRecordIterable.java +++ b/altoslib/AltosRecordIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.*; diff --git a/altoslib/AltosRecordMM.java b/altoslib/AltosRecordMM.java index 546f3055..f950d170 100644 --- a/altoslib/AltosRecordMM.java +++ b/altoslib/AltosRecordMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosRecordMM extends AltosRecord { diff --git a/altoslib/AltosRecordNone.java b/altoslib/AltosRecordNone.java index d4ea305f..3fab1121 100644 --- a/altoslib/AltosRecordNone.java +++ b/altoslib/AltosRecordNone.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosRecordNone extends AltosRecord { diff --git a/altoslib/AltosRecordTM.java b/altoslib/AltosRecordTM.java index f6ed4966..eb6935d5 100644 --- a/altoslib/AltosRecordTM.java +++ b/altoslib/AltosRecordTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosRecordTM extends AltosRecord { diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 50bef07a..7184206c 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.*; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index b6f21ef0..c29aa3dc 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index 75158cbf..c3cbe7bb 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index 4e2daf5a..230457dd 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosSpeed extends AltosUnits { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 4f59c840..1838f12d 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,7 +19,7 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosState { public AltosRecord data; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 15534158..26d79cd8 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index e95c15e0..092051a1 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index bc1486d8..529176d2 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 94fa560b..7139644e 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; import java.io.*; diff --git a/altoslib/AltosTelemetryRecord.java b/altoslib/AltosTelemetryRecord.java index 6a8cfd35..22da2836 100644 --- a/altoslib/AltosTelemetryRecord.java +++ b/altoslib/AltosTelemetryRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; public abstract class AltosTelemetryRecord { diff --git a/altoslib/AltosTelemetryRecordCompanion.java b/altoslib/AltosTelemetryRecordCompanion.java index 6ad17244..d68120c0 100644 --- a/altoslib/AltosTelemetryRecordCompanion.java +++ b/altoslib/AltosTelemetryRecordCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordCompanion extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordConfiguration.java b/altoslib/AltosTelemetryRecordConfiguration.java index 25242edc..7482ef5b 100644 --- a/altoslib/AltosTelemetryRecordConfiguration.java +++ b/altoslib/AltosTelemetryRecordConfiguration.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordConfiguration extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordGeneral.java b/altoslib/AltosTelemetryRecordGeneral.java index a53280cf..f3985211 100644 --- a/altoslib/AltosTelemetryRecordGeneral.java +++ b/altoslib/AltosTelemetryRecordGeneral.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosTelemetryRecordLegacy.java b/altoslib/AltosTelemetryRecordLegacy.java index 43189794..1202099a 100644 --- a/altoslib/AltosTelemetryRecordLegacy.java +++ b/altoslib/AltosTelemetryRecordLegacy.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; import java.text.*; diff --git a/altoslib/AltosTelemetryRecordLocation.java b/altoslib/AltosTelemetryRecordLocation.java index cddb773d..a0a8ab81 100644 --- a/altoslib/AltosTelemetryRecordLocation.java +++ b/altoslib/AltosTelemetryRecordLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java index 98b9f4c5..72af6a22 100644 --- a/altoslib/AltosTelemetryRecordMegaData.java +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordMegaSensor.java b/altoslib/AltosTelemetryRecordMegaSensor.java index 93c001de..16b88969 100644 --- a/altoslib/AltosTelemetryRecordMegaSensor.java +++ b/altoslib/AltosTelemetryRecordMegaSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index 51dd704d..9749aa5c 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { int[] bytes; diff --git a/altoslib/AltosTelemetryRecordSatellite.java b/altoslib/AltosTelemetryRecordSatellite.java index 2526afb6..b9418f27 100644 --- a/altoslib/AltosTelemetryRecordSatellite.java +++ b/altoslib/AltosTelemetryRecordSatellite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordSatellite extends AltosTelemetryRecordRaw { int channels; diff --git a/altoslib/AltosTelemetryRecordSensor.java b/altoslib/AltosTelemetryRecordSensor.java index f1fc156c..92375fb0 100644 --- a/altoslib/AltosTelemetryRecordSensor.java +++ b/altoslib/AltosTelemetryRecordSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index 47540c61..fcc9a973 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public abstract class AltosUnits { diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java index 50a00cdf..680d5cb4 100644 --- a/altoslib/AltosUnitsListener.java +++ b/altoslib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.AltosLib; +package org.altusmetrum.altoslib; public interface AltosUnitsListener { public void units_changed(boolean imperial_units); diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 1b03c925..bab7d6d3 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -2,6 +2,8 @@ AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation JAVAROOT=bin +VERSION=1 + CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH="bin:$(FREETTS)/*:/usr/share/java/*" SRC=. diff --git a/altosui/Altos.java b/altosui/Altos.java index c21a5300..170201ce 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class Altos extends AltosUILib { diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index a05c4404..29693da1 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index 606c0349..f8efeef7 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -17,7 +17,7 @@ package altosui; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosBTKnown implements Iterable { diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index 1c929a7c..11b64bfc 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -19,7 +19,7 @@ package altosui; import java.io.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosCSV implements AltosWriter { File name; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 83bf16a7..152b4b27 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosCSVUI diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index f2019438..8ccccfac 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosCompanionInfo extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 1cd61a89..c4dba735 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -22,7 +22,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.text.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosConfig implements ActionListener { diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 75101e3d..074f337a 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; class AltosEditFreqUI extends AltosUIDialog implements ActionListener { diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 5cdaf564..13652e81 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosConfigPyroUI diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 794f8103..480139cb 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -21,7 +21,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosConfigTD implements ActionListener { diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index 54073843..d9df9d79 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosConfigTDUI diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 599ed051..08dccd09 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosConfigUI diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index 242af9ad..eddbb120 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -20,7 +20,7 @@ package altosui; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosDataChooser extends JFileChooser { diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index 88df081f..2bdb4d96 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -7,7 +7,7 @@ package altosui; import java.lang.UnsupportedOperationException; import java.util.NoSuchElementException; import java.util.Iterator; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; class AltosDataPointReader implements Iterable { Iterator iter; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 2ea7cbfa..df151086 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index 1ba70c7e..b52a5770 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -21,7 +21,7 @@ import java.awt.*; import javax.swing.*; import java.io.*; import java.text.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosDisplayThread extends Thread { diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index b0459bb6..0161213b 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -21,7 +21,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosEepromDelete implements Runnable { AltosEepromList flights; diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 21b46740..612b8380 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -23,7 +23,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosEepromDownload implements Runnable { diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index f9bd2748..0cddec76 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -21,7 +21,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; /* * Temporary structure to hold the list of stored flights; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index cc9adb0c..c69f1f53 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -21,7 +21,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosEepromManage implements ActionListener { diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index c0886212..b0b08d3b 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -21,7 +21,7 @@ import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; class AltosEepromItem implements ActionListener { diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java index 826f9522..42191122 100644 --- a/altosui/AltosFlightDisplay.java +++ b/altosui/AltosFlightDisplay.java @@ -17,7 +17,7 @@ package altosui; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public interface AltosFlightDisplay { void reset(); diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java index 1653ca57..967f094f 100644 --- a/altosui/AltosFlightStats.java +++ b/altosui/AltosFlightStats.java @@ -18,7 +18,7 @@ package altosui; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosFlightStats { double max_height; diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index 1e0b94fa..7a91d642 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosFlightStatsTable extends JComponent { GridBagLayout layout; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index b97c8dc6..8eaf5db7 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index 56ad7e6f..060ba301 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -27,7 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosFlightStatusTableModel extends AbstractTableModel { private String[] columnNames = { diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index bef39e8d..6b48a2c0 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -18,7 +18,7 @@ package altosui; import java.awt.event.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosFlightStatusUpdate implements ActionListener { diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index e2dc06bd..7860b218 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener { diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index cc1f07ef..98fe27d5 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -18,7 +18,7 @@ package altosui; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosFreqList extends JComboBox { diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index d6891ffa..4b40ba1f 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -9,7 +9,7 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; import org.jfree.chart.ChartPanel; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 1b3dd547..a3b1a49e 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -22,7 +22,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener { diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index c1378eb9..8c2ac242 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosIgniteUI diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 11d1b0c1..579d720b 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import javax.swing.*; import javax.swing.table.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosInfoTable extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java index 281638bf..5fa03fc1 100644 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@ -18,7 +18,7 @@ package altosui; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosKML implements AltosWriter { diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 5e073f7d..d03e5ac5 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { GridBagLayout layout; diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 2d9c8323..0eac0ebc 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 14b52310..9fdec1cf 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -25,7 +25,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; class AltosScanResult { diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 78d862d0..feca8b95 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -25,7 +25,7 @@ import java.io.*; import java.util.*; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; import libaltosJNI.*; diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 144d506d..7c5d406c 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -23,7 +23,7 @@ import java.io.*; import java.lang.Math; import java.awt.geom.Point2D; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java index e9d4a20b..aeb9de80 100644 --- a/altosui/AltosSiteMapTile.java +++ b/altosui/AltosSiteMapTile.java @@ -22,7 +22,7 @@ import java.awt.image.*; import javax.swing.*; import java.awt.geom.Point2D; import java.awt.geom.Line2D; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosSiteMapTile extends JLayeredPane { JLabel mapLabel; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 0efe27a0..d89b3daa 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -22,7 +22,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class AltosUI extends AltosUIFrame { diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index 3131fd32..3e6ff97d 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -19,7 +19,7 @@ package altosui; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java index 6806c50e..31c1807f 100644 --- a/altosui/AltosWriter.java +++ b/altosui/AltosWriter.java @@ -17,7 +17,7 @@ package altosui; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public interface AltosWriter { diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index d0bdc5b6..e9daf821 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -20,7 +20,7 @@ package org.altusmetrum.altosuilib; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosUILib extends AltosLib { diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 50211fce..98f325ce 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -21,7 +21,7 @@ import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; public class AltosUIPreferences extends AltosPreferences { diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index c6c05e55..7a2f91f0 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -19,7 +19,7 @@ package org.altusmetrum.altosuilib; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/configure.ac b/configure.ac index 1ff672fe..354926c8 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,18 @@ AM_MAINTAINER_MODE VERSION_DASH=`echo $VERSION | sed 's/\./-/g'` AC_SUBST(VERSION_DASH) + +dnl ========================================================================== +dnl Java library versions + +ALTOSUILIB_VERSION=1 +ALTOSLIB_VERSION=1 + +AC_SUBST(ALTOSLIB_VERSION) +AC_DEFINE(ALTOSLIB_VERSION,$ALTOSLIB_VERSION,[Version of the AltosLib package]) +AC_SUBST(ALTOSUILIB_VERSION) +AC_DEFINE(ALTOSUILIB_VERSION,$ALTOSUILIB_VERSION,[Version of the AltosUILib package]) + dnl ========================================================================== AM_CONFIG_HEADER(config.h) diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index 71919ddb..a2e30f3c 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; class MicroIterator implements Iterator { int i; diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java index 28a7550d..cc404626 100644 --- a/micropeak/MicroDownload.java +++ b/micropeak/MicroDownload.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener { diff --git a/micropeak/MicroExport.java b/micropeak/MicroExport.java index 4b83bb4d..8163b4ca 100644 --- a/micropeak/MicroExport.java +++ b/micropeak/MicroExport.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroExport extends JFileChooser { diff --git a/micropeak/MicroFile.java b/micropeak/MicroFile.java index 13d48380..ae80134e 100644 --- a/micropeak/MicroFile.java +++ b/micropeak/MicroFile.java @@ -19,7 +19,7 @@ package org.altusmetrum.micropeak; import java.io.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroFile { diff --git a/micropeak/MicroFileChooser.java b/micropeak/MicroFileChooser.java index 21ddb0f8..ea5c3489 100644 --- a/micropeak/MicroFileChooser.java +++ b/micropeak/MicroFileChooser.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroFileChooser extends JFileChooser { diff --git a/micropeak/MicroGraph.java b/micropeak/MicroGraph.java index 5aa127bb..8cb9504b 100644 --- a/micropeak/MicroGraph.java +++ b/micropeak/MicroGraph.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index d370f563..e6aa9ab0 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroPeak extends MicroFrame implements ActionListener, ItemListener { diff --git a/micropeak/MicroRaw.java b/micropeak/MicroRaw.java index 8546cffb..8cd7afd4 100644 --- a/micropeak/MicroRaw.java +++ b/micropeak/MicroRaw.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.awt.*; import java.io.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroRaw extends JTextArea { diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java index 7879ff90..dae72779 100644 --- a/micropeak/MicroSave.java +++ b/micropeak/MicroSave.java @@ -24,7 +24,7 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroSave extends JFileChooser { diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java index 90e9dd1f..151f40da 100644 --- a/micropeak/MicroStats.java +++ b/micropeak/MicroStats.java @@ -18,7 +18,7 @@ package org.altusmetrum.micropeak; import java.io.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroStats { diff --git a/micropeak/MicroStatsTable.java b/micropeak/MicroStatsTable.java index be03b9f5..7387fdd7 100644 --- a/micropeak/MicroStatsTable.java +++ b/micropeak/MicroStatsTable.java @@ -19,7 +19,7 @@ package org.altusmetrum.micropeak; import java.awt.*; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib.*; import org.altusmetrum.altosuilib.*; public class MicroStatsTable extends JComponent implements AltosFontListener { -- cgit v1.2.3 From 8d1d8d2a3c129cdbd55427bcda0f26715b02f1ee Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 29 Jan 2013 17:00:43 +1100 Subject: Add version numbers to java libraries Make our private java library names include a version number so we can ship and install multiple versions at the same time. Signed-off-by: Keith Packard --- altosdroid/Makefile.am | 7 +- altosdroid/libs/.gitignore | 1 - .../org/altusmetrum/AltosDroid/AltosBluetooth.java | 2 +- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 2 +- .../AltosDroid/AltosDroidPreferences.java | 2 +- .../src/org/altusmetrum/AltosDroid/AltosVoice.java | 2 +- .../altusmetrum/AltosDroid/TelemetryLogger.java | 2 +- .../altusmetrum/AltosDroid/TelemetryReader.java | 2 +- .../altusmetrum/AltosDroid/TelemetryService.java | 2 +- altoslib/AltosAccel.java | 2 +- altoslib/AltosCRCException.java | 2 +- altoslib/AltosConfigData.java | 2 +- altoslib/AltosConfigValues.java | 2 +- altoslib/AltosConvert.java | 2 +- altoslib/AltosDistance.java | 2 +- altoslib/AltosEepromChunk.java | 2 +- altoslib/AltosEepromIterable.java | 2 +- altoslib/AltosEepromLog.java | 2 +- altoslib/AltosEepromMega.java | 2 +- altoslib/AltosEepromMegaIterable.java | 2 +- altoslib/AltosEepromRecord.java | 2 +- altoslib/AltosEepromTeleScience.java | 2 +- altoslib/AltosFile.java | 2 +- altoslib/AltosFlightReader.java | 2 +- altoslib/AltosFrequency.java | 2 +- altoslib/AltosGPS.java | 2 +- altoslib/AltosGPSQuery.java | 2 +- altoslib/AltosGPSSat.java | 2 +- altoslib/AltosGreatCircle.java | 2 +- altoslib/AltosHeight.java | 2 +- altoslib/AltosIMU.java | 2 +- altoslib/AltosIMUQuery.java | 2 +- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosIdleMonitorListener.java | 2 +- altoslib/AltosIgnite.java | 2 +- altoslib/AltosLib.java | 2 +- altoslib/AltosLine.java | 2 +- altoslib/AltosLink.java | 2 +- altoslib/AltosLog.java | 2 +- altoslib/AltosMag.java | 2 +- altoslib/AltosMs5607.java | 2 +- altoslib/AltosMs5607Query.java | 2 +- altoslib/AltosOrderedMegaRecord.java | 2 +- altoslib/AltosOrderedRecord.java | 2 +- altoslib/AltosParse.java | 2 +- altoslib/AltosPreferences.java | 2 +- altoslib/AltosPreferencesBackend.java | 2 +- altoslib/AltosPyro.java | 2 +- altoslib/AltosRecord.java | 2 +- altoslib/AltosRecordCompanion.java | 2 +- altoslib/AltosRecordIterable.java | 2 +- altoslib/AltosRecordMM.java | 2 +- altoslib/AltosRecordNone.java | 2 +- altoslib/AltosRecordTM.java | 2 +- altoslib/AltosReplayReader.java | 2 +- altoslib/AltosSensorMM.java | 2 +- altoslib/AltosSensorTM.java | 2 +- altoslib/AltosSpeed.java | 2 +- altoslib/AltosState.java | 2 +- altoslib/AltosTelemetry.java | 2 +- altoslib/AltosTelemetryIterable.java | 2 +- altoslib/AltosTelemetryMap.java | 2 +- altoslib/AltosTelemetryReader.java | 2 +- altoslib/AltosTelemetryRecord.java | 2 +- altoslib/AltosTelemetryRecordCompanion.java | 2 +- altoslib/AltosTelemetryRecordConfiguration.java | 2 +- altoslib/AltosTelemetryRecordGeneral.java | 2 +- altoslib/AltosTelemetryRecordLegacy.java | 2 +- altoslib/AltosTelemetryRecordLocation.java | 2 +- altoslib/AltosTelemetryRecordMegaData.java | 2 +- altoslib/AltosTelemetryRecordMegaSensor.java | 2 +- altoslib/AltosTelemetryRecordRaw.java | 2 +- altoslib/AltosTelemetryRecordSatellite.java | 2 +- altoslib/AltosTelemetryRecordSensor.java | 2 +- altoslib/AltosUnits.java | 2 +- altoslib/AltosUnitsListener.java | 2 +- altoslib/Makefile.am | 147 ++++++++++----------- altosui/Altos.java | 4 +- altosui/AltosAscent.java | 2 +- altosui/AltosBTDevice.java | 2 +- altosui/AltosBTKnown.java | 4 +- altosui/AltosBTManage.java | 2 +- altosui/AltosCSV.java | 2 +- altosui/AltosCSVUI.java | 4 +- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfig.java | 4 +- altosui/AltosConfigFreqUI.java | 4 +- altosui/AltosConfigPyroUI.java | 4 +- altosui/AltosConfigTD.java | 4 +- altosui/AltosConfigTDUI.java | 4 +- altosui/AltosConfigUI.java | 4 +- altosui/AltosConfigureUI.java | 2 +- altosui/AltosDataChooser.java | 4 +- altosui/AltosDataPointReader.java | 2 +- altosui/AltosDebug.java | 2 +- altosui/AltosDescent.java | 2 +- altosui/AltosDeviceUIDialog.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromDownload.java | 2 +- altosui/AltosEepromList.java | 2 +- altosui/AltosEepromManage.java | 4 +- altosui/AltosEepromMonitor.java | 2 +- altosui/AltosEepromSelect.java | 4 +- altosui/AltosFlash.java | 2 +- altosui/AltosFlashUI.java | 2 +- altosui/AltosFlightDisplay.java | 2 +- altosui/AltosFlightStats.java | 2 +- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightStatus.java | 2 +- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 4 +- altosui/AltosFreqList.java | 4 +- altosui/AltosGraphUI.java | 4 +- altosui/AltosIdleMonitorUI.java | 4 +- altosui/AltosIgniteUI.java | 4 +- altosui/AltosInfoTable.java | 2 +- altosui/AltosKML.java | 2 +- altosui/AltosLanded.java | 2 +- altosui/AltosLaunch.java | 2 +- altosui/AltosLaunchUI.java | 2 +- altosui/AltosPad.java | 2 +- altosui/AltosRomconfigUI.java | 2 +- altosui/AltosScanUI.java | 4 +- altosui/AltosSerial.java | 4 +- altosui/AltosSerialInUseException.java | 2 +- altosui/AltosSiteMap.java | 4 +- altosui/AltosSiteMapPreload.java | 2 +- altosui/AltosSiteMapTile.java | 2 +- altosui/AltosUI.java | 4 +- altosui/AltosUIPreferencesBackend.java | 2 +- altosui/AltosVoice.java | 2 +- altosui/AltosWriter.java | 2 +- altosuilib/AltosDevice.java | 2 +- altosuilib/AltosDeviceDialog.java | 2 +- altosuilib/AltosFontListener.java | 2 +- altosuilib/AltosPositionListener.java | 2 +- altosuilib/AltosUIConfigure.java | 2 +- altosuilib/AltosUIDialog.java | 2 +- altosuilib/AltosUIFrame.java | 2 +- altosuilib/AltosUILib.java | 4 +- altosuilib/AltosUIListener.java | 2 +- altosuilib/AltosUIPreferences.java | 4 +- altosuilib/AltosUIPreferencesBackend.java | 4 +- altosuilib/AltosUIVersion.java.in | 2 +- altosuilib/AltosUSBDevice.java | 2 +- altosuilib/AltosUnitsListener.java | 2 +- altosuilib/Makefile.am | 2 +- fix-java-versions | 11 ++ micropeak/MicroData.java | 2 +- micropeak/MicroDeviceDialog.java | 2 +- micropeak/MicroDownload.java | 4 +- micropeak/MicroExport.java | 4 +- micropeak/MicroFile.java | 4 +- micropeak/MicroFileChooser.java | 4 +- micropeak/MicroFrame.java | 2 +- micropeak/MicroGraph.java | 2 +- micropeak/MicroPeak.java | 4 +- micropeak/MicroRaw.java | 4 +- micropeak/MicroSave.java | 4 +- micropeak/MicroSerial.java | 2 +- micropeak/MicroStats.java | 4 +- micropeak/MicroStatsTable.java | 4 +- micropeak/MicroUSB.java | 2 +- 165 files changed, 283 insertions(+), 271 deletions(-) delete mode 100644 altosdroid/libs/.gitignore create mode 100755 fix-java-versions (limited to 'altoslib') diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index 3860e110..cc74b7a8 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -17,7 +17,7 @@ ZIPALIGN=$(SDK)/tools/zipalign SRC_DIR=src/org/altusmetrum/AltosDroid EXT_LIBDIR=libs ALTOSLIB_SRCDIR=../altoslib -ALTOSLIB_JAR=AltosLib.jar +ALTOSLIB_JAR=altoslib_$(ALTOSLIB_VERSION).jar ALTOSLIB=$(EXT_LIBDIR)/$(ALTOSLIB_JAR) @@ -56,7 +56,10 @@ bin/AltosDroid-release.apk: $(SRC) $(ALTOSLIB) ant release endif -clean: +clean: clean-local $(clean_command) +clean-local: + rm -rf $(EXT_LIBDIR) + .PHONY: $(SRC_DIR)/BuildInfo.java diff --git a/altosdroid/libs/.gitignore b/altosdroid/libs/.gitignore deleted file mode 100644 index b4e68f63..00000000 --- a/altosdroid/libs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -AltosLib.jar diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java index 9fcc4eba..0aea06f1 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java @@ -31,7 +31,7 @@ import android.os.Handler; //import android.os.Message; import android.util.Log; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class AltosBluetooth extends AltosLink { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index ab1fb0de..fe4907dd 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -43,7 +43,7 @@ import android.widget.TextView; import android.widget.Toast; import android.app.AlertDialog; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; /** * This is the main Activity that displays the current chat session. diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java index 3b4bdcf8..fd4b0768 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java @@ -23,7 +23,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.Environment; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class AltosDroidPreferences implements AltosPreferencesBackend { public final static String NAME = "org.altusmetrum.AltosDroid"; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java index 264e35c6..7da5c4a9 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java @@ -21,7 +21,7 @@ package org.altusmetrum.AltosDroid; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class AltosVoice { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java index b2dcdb48..3ece04ac 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java @@ -1,6 +1,6 @@ package org.altusmetrum.AltosDroid; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; import android.content.BroadcastReceiver; import android.content.Context; diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java index 66e9c6bd..9460bdbc 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java @@ -25,7 +25,7 @@ import java.util.concurrent.*; import android.util.Log; import android.os.Handler; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class TelemetryReader extends Thread { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java index 3cb498e8..5ff00a68 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java @@ -38,7 +38,7 @@ import android.os.RemoteException; import android.util.Log; import android.widget.Toast; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_1.*; public class TelemetryService extends Service { diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index 9cb9a14b..af8c36b9 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosAccel extends AltosUnits { diff --git a/altoslib/AltosCRCException.java b/altoslib/AltosCRCException.java index 1dd33ce9..76e79add 100644 --- a/altoslib/AltosCRCException.java +++ b/altoslib/AltosCRCException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosCRCException extends Exception { public int rssi; diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 387d1067..24ab2556 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; +package org.altusmetrum.altoslib_1; import java.util.*; import java.text.*; diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 2ec4b2a6..027d10f4 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public interface AltosConfigValues { /* set and get all of the dialog values */ diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 6345e522..8adec068 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -18,7 +18,7 @@ /* * Sensor data conversion functions */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosConvert { /* diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index 3e994618..9d98f6b6 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosDistance extends AltosUnits { diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index a1fc7d11..b1bba3bb 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 2e8715ba..bc698c80 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index 8a631c3c..20026c6d 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index 0c38a915..b077e26c 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index 05fc1f4a..a127f435 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromRecord.java b/altoslib/AltosEepromRecord.java index 0c914aca..70ac1113 100644 --- a/altoslib/AltosEepromRecord.java +++ b/altoslib/AltosEepromRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosEepromTeleScience.java b/altoslib/AltosEepromTeleScience.java index c983131e..2a828cf3 100644 --- a/altoslib/AltosEepromTeleScience.java +++ b/altoslib/AltosEepromTeleScience.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index a2ff261a..90dbc6db 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index 87a53222..3039b4dc 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; import java.io.*; diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index 2e55d3b9..484a2fd9 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosFrequency { public double frequency; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 6405579b..068d8c9c 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosGPSQuery.java b/altoslib/AltosGPSQuery.java index fe453e0d..deb9d201 100644 --- a/altoslib/AltosGPSQuery.java +++ b/altoslib/AltosGPSQuery.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.concurrent.*; diff --git a/altoslib/AltosGPSSat.java b/altoslib/AltosGPSSat.java index 605c592a..8714dd8a 100644 --- a/altoslib/AltosGPSSat.java +++ b/altoslib/AltosGPSSat.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosGPSSat { public int svid; diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index ad7849a3..921356a5 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.lang.Math; diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index d7192e0b..e0fef5f6 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosHeight extends AltosUnits { diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index cf37eba1..8f6731fa 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosIMU { public int accel_x; diff --git a/altoslib/AltosIMUQuery.java b/altoslib/AltosIMUQuery.java index f2ada8d4..4ea5d963 100644 --- a/altoslib/AltosIMUQuery.java +++ b/altoslib/AltosIMUQuery.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 0a80ca6b..6b20b3f1 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index 580626dd..7f58d61c 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public interface AltosIdleMonitorListener { public void update(AltosState state); diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index 41f1faaf..85905900 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index b3fe2968..cb5d467b 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.*; import java.io.*; diff --git a/altoslib/AltosLine.java b/altoslib/AltosLine.java index efa7df7a..b3bd20f9 100644 --- a/altoslib/AltosLine.java +++ b/altoslib/AltosLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosLine { public String line; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 02880ec9..2b5909aa 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.concurrent.*; diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index ab707edd..974c9f0f 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.text.ParseException; diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index 760cc623..b3bbd92f 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosMag { public int x; diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index da64a0ea..606916b7 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosMs5607 { public int reserved; diff --git a/altoslib/AltosMs5607Query.java b/altoslib/AltosMs5607Query.java index 08089b07..d39dbf26 100644 --- a/altoslib/AltosMs5607Query.java +++ b/altoslib/AltosMs5607Query.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosOrderedMegaRecord.java b/altoslib/AltosOrderedMegaRecord.java index 4db0bcf8..b20a5bbd 100644 --- a/altoslib/AltosOrderedMegaRecord.java +++ b/altoslib/AltosOrderedMegaRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.ParseException; diff --git a/altoslib/AltosOrderedRecord.java b/altoslib/AltosOrderedRecord.java index 73b4d3f8..63507d39 100644 --- a/altoslib/AltosOrderedRecord.java +++ b/altoslib/AltosOrderedRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.ParseException; diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index e4ab662a..66bbeed5 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 65a46eb6..392497ef 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.*; diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index 99ca9432..fb8a235a 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.File; diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 0554ff11..4dbb4223 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.*; import java.text.*; diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index b519807b..f8c44cc5 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public abstract class AltosRecord implements Comparable , Cloneable { diff --git a/altoslib/AltosRecordCompanion.java b/altoslib/AltosRecordCompanion.java index ffb114ec..b153fb5b 100644 --- a/altoslib/AltosRecordCompanion.java +++ b/altoslib/AltosRecordCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosRecordCompanion { public final static int board_id_telescience = 0x0a; diff --git a/altoslib/AltosRecordIterable.java b/altoslib/AltosRecordIterable.java index 17b13c7d..62dbdfe3 100644 --- a/altoslib/AltosRecordIterable.java +++ b/altoslib/AltosRecordIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.*; diff --git a/altoslib/AltosRecordMM.java b/altoslib/AltosRecordMM.java index f950d170..bf64192c 100644 --- a/altoslib/AltosRecordMM.java +++ b/altoslib/AltosRecordMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosRecordMM extends AltosRecord { diff --git a/altoslib/AltosRecordNone.java b/altoslib/AltosRecordNone.java index 3fab1121..a95b6a9c 100644 --- a/altoslib/AltosRecordNone.java +++ b/altoslib/AltosRecordNone.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosRecordNone extends AltosRecord { diff --git a/altoslib/AltosRecordTM.java b/altoslib/AltosRecordTM.java index eb6935d5..c6cf3646 100644 --- a/altoslib/AltosRecordTM.java +++ b/altoslib/AltosRecordTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosRecordTM extends AltosRecord { diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 7184206c..a7e30370 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.*; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index c29aa3dc..8372d047 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index c3cbe7bb..f5fa83a5 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index 230457dd..020c1377 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosSpeed extends AltosUnits { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 1838f12d..32d02f21 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,7 +19,7 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosState { public AltosRecord data; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 26d79cd8..e7322349 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index 092051a1..57033638 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index 529176d2..7cca98b0 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 7139644e..f365b821 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; import java.io.*; diff --git a/altoslib/AltosTelemetryRecord.java b/altoslib/AltosTelemetryRecord.java index 22da2836..01215968 100644 --- a/altoslib/AltosTelemetryRecord.java +++ b/altoslib/AltosTelemetryRecord.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; public abstract class AltosTelemetryRecord { diff --git a/altoslib/AltosTelemetryRecordCompanion.java b/altoslib/AltosTelemetryRecordCompanion.java index d68120c0..e016dd01 100644 --- a/altoslib/AltosTelemetryRecordCompanion.java +++ b/altoslib/AltosTelemetryRecordCompanion.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordCompanion extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordConfiguration.java b/altoslib/AltosTelemetryRecordConfiguration.java index 7482ef5b..472a6318 100644 --- a/altoslib/AltosTelemetryRecordConfiguration.java +++ b/altoslib/AltosTelemetryRecordConfiguration.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordConfiguration extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordGeneral.java b/altoslib/AltosTelemetryRecordGeneral.java index f3985211..08cd6065 100644 --- a/altoslib/AltosTelemetryRecordGeneral.java +++ b/altoslib/AltosTelemetryRecordGeneral.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosTelemetryRecordLegacy.java b/altoslib/AltosTelemetryRecordLegacy.java index 1202099a..a734b188 100644 --- a/altoslib/AltosTelemetryRecordLegacy.java +++ b/altoslib/AltosTelemetryRecordLegacy.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; import java.text.*; diff --git a/altoslib/AltosTelemetryRecordLocation.java b/altoslib/AltosTelemetryRecordLocation.java index a0a8ab81..469a5400 100644 --- a/altoslib/AltosTelemetryRecordLocation.java +++ b/altoslib/AltosTelemetryRecordLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java index 72af6a22..08df9ee1 100644 --- a/altoslib/AltosTelemetryRecordMegaData.java +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordMegaSensor.java b/altoslib/AltosTelemetryRecordMegaSensor.java index 16b88969..7548d699 100644 --- a/altoslib/AltosTelemetryRecordMegaSensor.java +++ b/altoslib/AltosTelemetryRecordMegaSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index 9749aa5c..a06348c1 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { int[] bytes; diff --git a/altoslib/AltosTelemetryRecordSatellite.java b/altoslib/AltosTelemetryRecordSatellite.java index b9418f27..3e93b337 100644 --- a/altoslib/AltosTelemetryRecordSatellite.java +++ b/altoslib/AltosTelemetryRecordSatellite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordSatellite extends AltosTelemetryRecordRaw { int channels; diff --git a/altoslib/AltosTelemetryRecordSensor.java b/altoslib/AltosTelemetryRecordSensor.java index 92375fb0..767a464a 100644 --- a/altoslib/AltosTelemetryRecordSensor.java +++ b/altoslib/AltosTelemetryRecordSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index fcc9a973..4351123b 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public abstract class AltosUnits { diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java index 680d5cb4..61a181a4 100644 --- a/altoslib/AltosUnitsListener.java +++ b/altoslib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib; +package org.altusmetrum.altoslib_1; public interface AltosUnitsListener { public void units_changed(boolean imperial_units); diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index bab7d6d3..b3c2673a 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -7,89 +7,88 @@ VERSION=1 CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH="bin:$(FREETTS)/*:/usr/share/java/*" SRC=. -BIN=bin/org/altusmetrum/AltosLib -AltosLibdir = $(datadir)/java +altoslibdir = $(datadir)/java -AltosLib_JAVA = \ - $(SRC)/AltosLib.java \ - $(SRC)/AltosConfigData.java \ - $(SRC)/AltosConfigValues.java \ - $(SRC)/AltosConvert.java \ - $(SRC)/AltosCRCException.java \ - $(SRC)/AltosEepromChunk.java \ - $(SRC)/AltosEepromIterable.java \ - $(SRC)/AltosEepromLog.java \ - $(SRC)/AltosEepromMega.java \ - $(SRC)/AltosEepromMegaIterable.java \ - $(SRC)/AltosEepromRecord.java \ - $(SRC)/AltosEepromTeleScience.java \ - $(SRC)/AltosFile.java \ - $(SRC)/AltosFlightReader.java \ - $(SRC)/AltosFrequency.java \ - $(SRC)/AltosGPS.java \ - $(SRC)/AltosGPSQuery.java \ - $(SRC)/AltosGPSSat.java \ - $(SRC)/AltosGreatCircle.java \ - $(SRC)/AltosIdleMonitor.java \ - $(SRC)/AltosIdleMonitorListener.java \ - $(SRC)/AltosIgnite.java \ - $(SRC)/AltosIMU.java \ - $(SRC)/AltosIMUQuery.java \ - $(SRC)/AltosLine.java \ - $(SRC)/AltosLink.java \ - $(SRC)/AltosLog.java \ - $(SRC)/AltosMs5607.java \ - $(SRC)/AltosMs5607Query.java \ - $(SRC)/AltosOrderedRecord.java \ - $(SRC)/AltosOrderedMegaRecord.java \ - $(SRC)/AltosParse.java \ - $(SRC)/AltosPreferences.java \ - $(SRC)/AltosPreferencesBackend.java \ - $(SRC)/AltosRecordCompanion.java \ - $(SRC)/AltosRecordIterable.java \ - $(SRC)/AltosRecord.java \ - $(SRC)/AltosRecordNone.java \ - $(SRC)/AltosRecordTM.java \ - $(SRC)/AltosRecordMM.java \ - $(SRC)/AltosReplayReader.java \ - $(SRC)/AltosSensorMM.java \ - $(SRC)/AltosSensorTM.java \ - $(SRC)/AltosState.java \ - $(SRC)/AltosTelemetry.java \ - $(SRC)/AltosTelemetryIterable.java \ - $(SRC)/AltosTelemetryMap.java \ - $(SRC)/AltosTelemetryReader.java \ - $(SRC)/AltosTelemetryRecordCompanion.java \ - $(SRC)/AltosTelemetryRecordConfiguration.java \ - $(SRC)/AltosTelemetryRecordGeneral.java \ - $(SRC)/AltosTelemetryRecord.java \ - $(SRC)/AltosTelemetryRecordLegacy.java \ - $(SRC)/AltosTelemetryRecordLocation.java \ - $(SRC)/AltosTelemetryRecordRaw.java \ - $(SRC)/AltosTelemetryRecordSatellite.java \ - $(SRC)/AltosTelemetryRecordSensor.java \ - $(SRC)/AltosTelemetryRecordMegaSensor.java \ - $(SRC)/AltosTelemetryRecordMegaData.java \ - $(SRC)/AltosUnitsListener.java \ - $(SRC)/AltosMs5607.java \ - $(SRC)/AltosIMU.java \ - $(SRC)/AltosMag.java \ - $(SRC)/AltosUnits.java \ - $(SRC)/AltosDistance.java \ - $(SRC)/AltosHeight.java \ - $(SRC)/AltosSpeed.java \ - $(SRC)/AltosAccel.java \ - $(SRC)/AltosPyro.java +altoslib_JAVA = \ + AltosLib.java \ + AltosConfigData.java \ + AltosConfigValues.java \ + AltosConvert.java \ + AltosCRCException.java \ + AltosEepromChunk.java \ + AltosEepromIterable.java \ + AltosEepromLog.java \ + AltosEepromMega.java \ + AltosEepromMegaIterable.java \ + AltosEepromRecord.java \ + AltosEepromTeleScience.java \ + AltosFile.java \ + AltosFlightReader.java \ + AltosFrequency.java \ + AltosGPS.java \ + AltosGPSQuery.java \ + AltosGPSSat.java \ + AltosGreatCircle.java \ + AltosIdleMonitor.java \ + AltosIdleMonitorListener.java \ + AltosIgnite.java \ + AltosIMU.java \ + AltosIMUQuery.java \ + AltosLine.java \ + AltosLink.java \ + AltosLog.java \ + AltosMs5607.java \ + AltosMs5607Query.java \ + AltosOrderedRecord.java \ + AltosOrderedMegaRecord.java \ + AltosParse.java \ + AltosPreferences.java \ + AltosPreferencesBackend.java \ + AltosRecordCompanion.java \ + AltosRecordIterable.java \ + AltosRecord.java \ + AltosRecordNone.java \ + AltosRecordTM.java \ + AltosRecordMM.java \ + AltosReplayReader.java \ + AltosSensorMM.java \ + AltosSensorTM.java \ + AltosState.java \ + AltosTelemetry.java \ + AltosTelemetryIterable.java \ + AltosTelemetryMap.java \ + AltosTelemetryReader.java \ + AltosTelemetryRecordCompanion.java \ + AltosTelemetryRecordConfiguration.java \ + AltosTelemetryRecordGeneral.java \ + AltosTelemetryRecord.java \ + AltosTelemetryRecordLegacy.java \ + AltosTelemetryRecordLocation.java \ + AltosTelemetryRecordRaw.java \ + AltosTelemetryRecordSatellite.java \ + AltosTelemetryRecordSensor.java \ + AltosTelemetryRecordMegaSensor.java \ + AltosTelemetryRecordMegaData.java \ + AltosUnitsListener.java \ + AltosMs5607.java \ + AltosIMU.java \ + AltosMag.java \ + AltosUnits.java \ + AltosDistance.java \ + AltosHeight.java \ + AltosSpeed.java \ + AltosAccel.java \ + AltosPyro.java -JAR=AltosLib.jar +JAR=altoslib_$(ALTOSLIB_VERSION).jar all-local: $(JAR) clean-local: -rm -rf bin $(JAR) -install-AltosLibJAVA: $(JAR) +install-altoslibJAVA: $(JAR) @$(NORMAL_INSTALL) test -z "$(AltosLibdir)" || $(MKDIR_P) "$(DESTDIR)$(AltosLibdir)" echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(AltosLibdir)/$(JAR)"; \ diff --git a/altosui/Altos.java b/altosui/Altos.java index 170201ce..d25736bf 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -20,8 +20,8 @@ package altosui; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class Altos extends AltosUILib { diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 29693da1..e90e0e23 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index 222b3c97..727a9f66 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -17,7 +17,7 @@ package altosui; import libaltosJNI.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosBTDevice extends altos_bt_device implements AltosDevice { diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index f8efeef7..1d42365b 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -17,8 +17,8 @@ package altosui; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosBTKnown implements Iterable { LinkedList devices = new LinkedList(); diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index b7b632a7..4c9b7a6c 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.plaf.basic.*; import java.util.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosBTManage extends AltosUIDialog implements ActionListener, Iterable { LinkedBlockingQueue found_devices; diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index 11b64bfc..0676f99d 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -19,7 +19,7 @@ package altosui; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosCSV implements AltosWriter { File name; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 152b4b27..42508346 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosCSVUI extends AltosUIDialog diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 8ccccfac..7dd36aec 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosCompanionInfo extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index c4dba735..4927d3f8 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -22,8 +22,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.text.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosConfig implements ActionListener { diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 074f337a..c90b168f 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; class AltosEditFreqUI extends AltosUIDialog implements ActionListener { Frame frame; diff --git a/altosui/AltosConfigPyroUI.java b/altosui/AltosConfigPyroUI.java index 13652e81..3cac56c3 100644 --- a/altosui/AltosConfigPyroUI.java +++ b/altosui/AltosConfigPyroUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosConfigPyroUI extends AltosUIDialog diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 480139cb..16c9e357 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosConfigTD implements ActionListener { diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index d9df9d79..125780a9 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosConfigTDUI extends AltosUIDialog diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 08dccd09..4fd0647e 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosConfigUI extends AltosUIDialog diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index fad23f59..5e42f430 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -22,7 +22,7 @@ import java.awt.event.*; import java.beans.*; import javax.swing.*; import javax.swing.event.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosConfigureUI extends AltosUIConfigure diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index eddbb120..7de18afb 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -20,8 +20,8 @@ package altosui; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosDataChooser extends JFileChooser { JFrame frame; diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index 2bdb4d96..0b4bd6c1 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -7,7 +7,7 @@ package altosui; import java.lang.UnsupportedOperationException; import java.util.NoSuchElementException; import java.util.Iterator; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; class AltosDataPointReader implements Iterable { Iterator iter; diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java index 482f4c36..c69369ef 100644 --- a/altosui/AltosDebug.java +++ b/altosui/AltosDebug.java @@ -18,7 +18,7 @@ package altosui; import java.io.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosDebug extends AltosSerial { diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index df151086..821e3963 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosDeviceUIDialog.java b/altosui/AltosDeviceUIDialog.java index 7ed599a3..ceabe843 100644 --- a/altosui/AltosDeviceUIDialog.java +++ b/altosui/AltosDeviceUIDialog.java @@ -20,7 +20,7 @@ package altosui; import javax.swing.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosDeviceUIDialog extends AltosDeviceDialog { diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index b52a5770..6f8aa9ee 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -21,7 +21,7 @@ import java.awt.*; import javax.swing.*; import java.io.*; import java.text.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosDisplayThread extends Thread { diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index 0161213b..e81a35d1 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -21,7 +21,7 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosEepromDelete implements Runnable { AltosEepromList flights; diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 612b8380..8fbd661b 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -23,7 +23,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosEepromDownload implements Runnable { diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index 0cddec76..a63d173d 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -21,7 +21,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; /* * Temporary structure to hold the list of stored flights; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index c69f1f53..dbcc5048 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -21,8 +21,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosEepromManage implements ActionListener { diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 8eae5eb8..5b9e5171 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosEepromMonitor extends AltosUIDialog { diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index b0b08d3b..a451aa3a 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -21,8 +21,8 @@ import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; class AltosEepromItem implements ActionListener { AltosEepromLog log; diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java index 7a98ee14..239d4dd7 100644 --- a/altosui/AltosFlash.java +++ b/altosui/AltosFlash.java @@ -20,7 +20,7 @@ package altosui; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosFlash { File file; diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 921207bc..f26a3916 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosFlashUI extends AltosUIDialog diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java index 42191122..d1ed7d2f 100644 --- a/altosui/AltosFlightDisplay.java +++ b/altosui/AltosFlightDisplay.java @@ -17,7 +17,7 @@ package altosui; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public interface AltosFlightDisplay { void reset(); diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java index 967f094f..0f32ae5e 100644 --- a/altosui/AltosFlightStats.java +++ b/altosui/AltosFlightStats.java @@ -18,7 +18,7 @@ package altosui; import java.io.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosFlightStats { double max_height; diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index 7a91d642..2b3e4d5d 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosFlightStatsTable extends JComponent { GridBagLayout layout; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index 8eaf5db7..20539a9f 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index 060ba301..6a327841 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -27,7 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosFlightStatusTableModel extends AbstractTableModel { private String[] columnNames = { diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index 6b48a2c0..bf679b85 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -18,7 +18,7 @@ package altosui; import java.awt.event.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosFlightStatusUpdate implements ActionListener { diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 7860b218..c8faab90 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -21,8 +21,8 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener { AltosVoice voice; diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index 98fe27d5..7464ac3e 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -18,8 +18,8 @@ package altosui; import javax.swing.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosFreqList extends JComboBox { diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 4b40ba1f..c45c1124 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -9,8 +9,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index a3b1a49e..89a3c122 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDisplay, AltosFontListener, AltosIdleMonitorListener { AltosDevice device; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 8c2ac242..14d4eebc 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosIgniteUI extends AltosUIDialog diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 579d720b..c06f57ec 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import javax.swing.*; import javax.swing.table.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosInfoTable extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java index 5fa03fc1..84f9dc7a 100644 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@ -18,7 +18,7 @@ package altosui; import java.io.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosKML implements AltosWriter { diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index d03e5ac5..3994e5de 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { GridBagLayout layout; diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 0bad80aa..04948ee6 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -20,7 +20,7 @@ package altosui; import java.io.*; import java.util.concurrent.*; import java.awt.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosLaunch { AltosDevice device; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index 7e7ed010..4d9fbda5 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -23,7 +23,7 @@ import javax.swing.*; import java.io.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; class FireButton extends JButton { protected void processMouseEvent(MouseEvent e) { diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 0eac0ebc..d13f6945 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -19,7 +19,7 @@ package altosui; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index 5fc786e2..cf4658af 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -20,7 +20,7 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosRomconfigUI extends AltosUIDialog diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 9fdec1cf..0c903873 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -25,8 +25,8 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; class AltosScanResult { String callsign; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index feca8b95..710aa145 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -25,8 +25,8 @@ import java.io.*; import java.util.*; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; import libaltosJNI.*; diff --git a/altosui/AltosSerialInUseException.java b/altosui/AltosSerialInUseException.java index 932a3684..b45d9157 100644 --- a/altosui/AltosSerialInUseException.java +++ b/altosui/AltosSerialInUseException.java @@ -16,7 +16,7 @@ */ package altosui; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosSerialInUseException extends Exception { public AltosDevice device; diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 7c5d406c..f111e62d 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -23,8 +23,8 @@ import java.io.*; import java.lang.Math; import java.awt.geom.Point2D; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { // preferred vertical step in a tile in naut. miles diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java index f4dcc903..fd648abc 100644 --- a/altosui/AltosSiteMapPreload.java +++ b/altosui/AltosSiteMapPreload.java @@ -26,7 +26,7 @@ import java.text.*; import java.lang.Math; import java.net.URL; import java.net.URLConnection; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; class AltosMapPos extends Box { AltosUI owner; diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java index aeb9de80..10e65bcd 100644 --- a/altosui/AltosSiteMapTile.java +++ b/altosui/AltosSiteMapTile.java @@ -22,7 +22,7 @@ import java.awt.image.*; import javax.swing.*; import java.awt.geom.Point2D; import java.awt.geom.Line2D; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosSiteMapTile extends JLayeredPane { JLabel mapLabel; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index d89b3daa..49e3097e 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -22,8 +22,8 @@ import java.awt.event.*; import javax.swing.*; import java.io.*; import java.util.concurrent.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class AltosUI extends AltosUIFrame { public AltosVoice voice = new AltosVoice(); diff --git a/altosui/AltosUIPreferencesBackend.java b/altosui/AltosUIPreferencesBackend.java index 3e6ff97d..0dac9fc7 100644 --- a/altosui/AltosUIPreferencesBackend.java +++ b/altosui/AltosUIPreferencesBackend.java @@ -19,7 +19,7 @@ package altosui; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosui/AltosVoice.java b/altosui/AltosVoice.java index 775c13d5..2ed6a8c2 100644 --- a/altosui/AltosVoice.java +++ b/altosui/AltosVoice.java @@ -20,7 +20,7 @@ package altosui; import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; import java.util.concurrent.LinkedBlockingQueue; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class AltosVoice implements Runnable { VoiceManager voice_manager; diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java index 31c1807f..2f70b472 100644 --- a/altosui/AltosWriter.java +++ b/altosui/AltosWriter.java @@ -17,7 +17,7 @@ package altosui; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public interface AltosWriter { diff --git a/altosuilib/AltosDevice.java b/altosuilib/AltosDevice.java index 69b025ba..2461df1b 100644 --- a/altosuilib/AltosDevice.java +++ b/altosuilib/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import libaltosJNI.*; diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index cde545a7..73bc0b2f 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import javax.swing.*; import java.awt.*; diff --git a/altosuilib/AltosFontListener.java b/altosuilib/AltosFontListener.java index ef543264..da903352 100644 --- a/altosuilib/AltosFontListener.java +++ b/altosuilib/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altosuilib/AltosPositionListener.java b/altosuilib/AltosPositionListener.java index 4f90446c..e75d2de5 100644 --- a/altosuilib/AltosPositionListener.java +++ b/altosuilib/AltosPositionListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosPositionListener { public void position_changed(int position); diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 90b413d6..9e72e403 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIDialog.java b/altosuilib/AltosUIDialog.java index c0c33ba6..e1e699a7 100644 --- a/altosuilib/AltosUIDialog.java +++ b/altosuilib/AltosUIDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUIFrame.java b/altosuilib/AltosUIFrame.java index b93b2d21..3fc99910 100644 --- a/altosuilib/AltosUIFrame.java +++ b/altosuilib/AltosUIFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import java.awt.event.*; diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index e9daf821..1b121405 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -15,12 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.awt.*; import libaltosJNI.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosUILib extends AltosLib { diff --git a/altosuilib/AltosUIListener.java b/altosuilib/AltosUIListener.java index f4127f58..450dc0bf 100644 --- a/altosuilib/AltosUIListener.java +++ b/altosuilib/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 98f325ce..49321bce 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -15,13 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; public class AltosUIPreferences extends AltosPreferences { diff --git a/altosuilib/AltosUIPreferencesBackend.java b/altosuilib/AltosUIPreferencesBackend.java index 7a2f91f0..8a5386c3 100644 --- a/altosuilib/AltosUIPreferencesBackend.java +++ b/altosuilib/AltosUIPreferencesBackend.java @@ -15,11 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.io.File; import java.util.prefs.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; import javax.swing.filechooser.FileSystemView; public class AltosUIPreferencesBackend implements AltosPreferencesBackend { diff --git a/altosuilib/AltosUIVersion.java.in b/altosuilib/AltosUIVersion.java.in index 6fb3b38b..169cca1b 100644 --- a/altosuilib/AltosUIVersion.java.in +++ b/altosuilib/AltosUIVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public class AltosUIVersion { public final static String version = "@VERSION@"; diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index bab16fb0..a5496597 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; import java.util.*; import libaltosJNI.*; diff --git a/altosuilib/AltosUnitsListener.java b/altosuilib/AltosUnitsListener.java index 22c66cd4..c0a5e8b2 100644 --- a/altosuilib/AltosUnitsListener.java +++ b/altosuilib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_1; public interface AltosUnitsListener { public void units_changed(); diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index 5fb82793..25d5722e 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -24,7 +24,7 @@ altosuilib_JAVA = \ AltosUIVersion.java \ AltosUnitsListener.java -JAR=altosuilib.jar +JAR=altosuilib_$(ALTOSUILIB_VERSION).jar all-local: $(JAR) diff --git a/fix-java-versions b/fix-java-versions new file mode 100755 index 00000000..a417b67c --- /dev/null +++ b/fix-java-versions @@ -0,0 +1,11 @@ +#!/bin/sh -vx + +sed_opts='-i' + +for i in "$@"; do + name=`echo $i | sed 's/=.*$//'` + value=`echo $i | sed 's/.*=//'` + sed_opts="$sed_opts -e s/${name}_*[0-9]*/${name}_${value}/g" +done + +find . -name '*.java*' -print0 | xargs -0 sed $sed_opts diff --git a/micropeak/MicroData.java b/micropeak/MicroData.java index a2e30f3c..473af44b 100644 --- a/micropeak/MicroData.java +++ b/micropeak/MicroData.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.lang.*; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; class MicroIterator implements Iterator { int i; diff --git a/micropeak/MicroDeviceDialog.java b/micropeak/MicroDeviceDialog.java index 23195dac..533605d6 100644 --- a/micropeak/MicroDeviceDialog.java +++ b/micropeak/MicroDeviceDialog.java @@ -21,7 +21,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class MicroDeviceDialog extends AltosDeviceDialog { diff --git a/micropeak/MicroDownload.java b/micropeak/MicroDownload.java index cc404626..6f0ca4f6 100644 --- a/micropeak/MicroDownload.java +++ b/micropeak/MicroDownload.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroDownload extends AltosUIDialog implements Runnable, ActionListener { MicroPeak owner; diff --git a/micropeak/MicroExport.java b/micropeak/MicroExport.java index 8163b4ca..20a6f79a 100644 --- a/micropeak/MicroExport.java +++ b/micropeak/MicroExport.java @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroExport extends JFileChooser { diff --git a/micropeak/MicroFile.java b/micropeak/MicroFile.java index ae80134e..cdd42e66 100644 --- a/micropeak/MicroFile.java +++ b/micropeak/MicroFile.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.io.*; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroFile { diff --git a/micropeak/MicroFileChooser.java b/micropeak/MicroFileChooser.java index ea5c3489..7a3423b4 100644 --- a/micropeak/MicroFileChooser.java +++ b/micropeak/MicroFileChooser.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroFileChooser extends JFileChooser { JFrame frame; diff --git a/micropeak/MicroFrame.java b/micropeak/MicroFrame.java index 03e3af0c..ef8b24cc 100644 --- a/micropeak/MicroFrame.java +++ b/micropeak/MicroFrame.java @@ -21,7 +21,7 @@ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class MicroFrame extends AltosUIFrame { static String[] micro_icon_names = { diff --git a/micropeak/MicroGraph.java b/micropeak/MicroGraph.java index 8cb9504b..e8a6ea16 100644 --- a/micropeak/MicroGraph.java +++ b/micropeak/MicroGraph.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; +import org.altusmetrum.altoslib_1.*; import org.jfree.ui.*; import org.jfree.chart.*; diff --git a/micropeak/MicroPeak.java b/micropeak/MicroPeak.java index e6aa9ab0..63387ed1 100644 --- a/micropeak/MicroPeak.java +++ b/micropeak/MicroPeak.java @@ -23,8 +23,8 @@ import javax.swing.*; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroPeak extends MicroFrame implements ActionListener, ItemListener { diff --git a/micropeak/MicroRaw.java b/micropeak/MicroRaw.java index 8cd7afd4..7337a1de 100644 --- a/micropeak/MicroRaw.java +++ b/micropeak/MicroRaw.java @@ -20,8 +20,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import java.io.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroRaw extends JTextArea { diff --git a/micropeak/MicroSave.java b/micropeak/MicroSave.java index dae72779..5088b7d7 100644 --- a/micropeak/MicroSave.java +++ b/micropeak/MicroSave.java @@ -24,8 +24,8 @@ import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; import java.util.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroSave extends JFileChooser { diff --git a/micropeak/MicroSerial.java b/micropeak/MicroSerial.java index 15ef8582..376223f1 100644 --- a/micropeak/MicroSerial.java +++ b/micropeak/MicroSerial.java @@ -20,7 +20,7 @@ package org.altusmetrum.micropeak; import java.util.*; import java.io.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class MicroSerial extends InputStream { SWIGTYPE_p_altos_file file; diff --git a/micropeak/MicroStats.java b/micropeak/MicroStats.java index 151f40da..abc1296b 100644 --- a/micropeak/MicroStats.java +++ b/micropeak/MicroStats.java @@ -18,8 +18,8 @@ package org.altusmetrum.micropeak; import java.io.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroStats { double coast_height; diff --git a/micropeak/MicroStatsTable.java b/micropeak/MicroStatsTable.java index 7387fdd7..5bdf5cb6 100644 --- a/micropeak/MicroStatsTable.java +++ b/micropeak/MicroStatsTable.java @@ -19,8 +19,8 @@ package org.altusmetrum.micropeak; import java.awt.*; import javax.swing.*; -import org.altusmetrum.altoslib.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; public class MicroStatsTable extends JComponent implements AltosFontListener { GridBagLayout layout; diff --git a/micropeak/MicroUSB.java b/micropeak/MicroUSB.java index f56d81d4..3bd61470 100644 --- a/micropeak/MicroUSB.java +++ b/micropeak/MicroUSB.java @@ -19,7 +19,7 @@ package org.altusmetrum.micropeak; import java.util.*; import libaltosJNI.*; -import org.altusmetrum.altosuilib.*; +import org.altusmetrum.altosuilib_1.*; public class MicroUSB extends altos_device implements AltosDevice { -- cgit v1.2.3 From 7afd76e70c086003a2cd87ce459fda4188c76ad6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 4 Feb 2013 09:49:07 -0800 Subject: altoslib: fix Makefile JAR target Was referencing stale classAltosLib.stamp instead of new classaltoslib.stamp Signed-off-by: Keith Packard --- altoslib/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index b3c2673a..0b09102c 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -97,5 +97,5 @@ install-altoslibJAVA: $(JAR) bin: mkdir -p bin -$(JAR): classAltosLib.stamp +$(JAR): classaltoslib.stamp jar cf $@ -C bin org -- cgit v1.2.3 From 9d3da1530c1007d5d1f28062b3947f4aa981bfa8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 9 Feb 2013 02:00:13 -0800 Subject: altoslib: Add AltosUnits.graph_format This describes the format of numbers used on a graph axis for use with jfreechart Signed-off-by: Keith Packard --- altoslib/AltosUnits.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index 4351123b..4f4278b8 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -43,6 +43,10 @@ public abstract class AltosUnits { return String.format("%%1.%df %s", say_fraction(), say_units()); } + public String graph_format(int width) { + return String.format(String.format("%%%d.%df", width, show_fraction(width)), 0.0); + } + public String show(int width, double v) { return String.format(show_format(width), value(v)); } -- cgit v1.2.3 From 518b16f64f4be096ceff13ab31b96d6909fe3ae2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 9 Feb 2013 19:24:18 -0800 Subject: altoslib: Fix altoslib install Was using AltosLibdir in several places still Signed-off-by: Keith Packard --- altoslib/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 0b09102c..74c642d6 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -90,9 +90,9 @@ clean-local: install-altoslibJAVA: $(JAR) @$(NORMAL_INSTALL) - test -z "$(AltosLibdir)" || $(MKDIR_P) "$(DESTDIR)$(AltosLibdir)" - echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(AltosLibdir)/$(JAR)"; \ - $(INSTALL_DATA) "$<" "$(DESTDIR)$(AltosLibdir)" + test -z "$(altoslibdir)" || $(MKDIR_P) "$(DESTDIR)$(altoslibdir)" + echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(altoslibdir)/$(JAR)"; \ + $(INSTALL_DATA) "$<" "$(DESTDIR)$(altoslibdir)" bin: mkdir -p bin -- cgit v1.2.3 From 2efd3ad80d4fefa8ccc1b80a2e657dbf9ba0c60f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 10 Feb 2013 00:29:29 -0800 Subject: altosui/altoslib/altosuilib: Switch altosui to shared graph code This adds a configuration tab to the graph window to enable/disable various plotted values. Signed-off-by: Keith Packard --- altoslib/AltosConvert.java | 6 + altoslib/AltosHeight.java | 2 +- altoslib/AltosTemperature.java | 43 ++++++ altoslib/AltosUnits.java | 2 +- altoslib/Makefile.am | 1 + altosui/AltosDataPoint.java | 27 ---- altosui/AltosDataPointReader.java | 79 ---------- altosui/AltosGraph.java | 228 +++++++++++++++++++++++++--- altosui/AltosGraphDataPoint.java | 122 +++++++++++++++ altosui/AltosGraphDataSet.java | 96 ++++++++++++ altosui/AltosGraphTime.java | 235 ----------------------------- altosui/AltosGraphUI.java | 294 +++---------------------------------- altosui/Makefile.am | 9 +- altosuilib/AltosUIAxis.java | 92 ++++++++++++ altosuilib/AltosUIDataMissing.java | 25 ++++ altosuilib/AltosUIDataPoint.java | 8 +- altosuilib/AltosUIEnable.java | 28 ++++ altosuilib/AltosUIGraph.java | 38 +++-- altosuilib/AltosUIMarker.java | 31 ++-- altosuilib/AltosUISeries.java | 18 +-- altosuilib/Makefile.am | 1 + 21 files changed, 698 insertions(+), 687 deletions(-) create mode 100644 altoslib/AltosTemperature.java delete mode 100644 altosui/AltosDataPoint.java delete mode 100644 altosui/AltosDataPointReader.java create mode 100644 altosui/AltosGraphDataPoint.java create mode 100644 altosui/AltosGraphDataSet.java delete mode 100644 altosui/AltosGraphTime.java create mode 100644 altosuilib/AltosUIAxis.java create mode 100644 altosuilib/AltosUIDataMissing.java (limited to 'altoslib') diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 8adec068..a42b36c4 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -258,6 +258,10 @@ public class AltosConvert { return meters / 9.80665; } + public static double c_to_f(double c) { + return c * 9/5 + 32; + } + public static boolean imperial_units = false; public static AltosDistance distance = new AltosDistance(); @@ -268,6 +272,8 @@ public class AltosConvert { public static AltosAccel accel = new AltosAccel(); + public static AltosTemperature temperature = new AltosTemperature(); + public static String show_gs(String format, double a) { a = meters_to_g(a); format = format.concat(" g"); diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index e0fef5f6..ed590812 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -37,7 +37,7 @@ public class AltosHeight extends AltosUnits { return "meters"; } - int show_fraction(int width) { + public int show_fraction(int width) { return width / 9; } } \ No newline at end of file diff --git a/altoslib/AltosTemperature.java b/altoslib/AltosTemperature.java new file mode 100644 index 00000000..2749eac0 --- /dev/null +++ b/altoslib/AltosTemperature.java @@ -0,0 +1,43 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +public class AltosTemperature extends AltosUnits { + + public double value(double v) { + if (AltosConvert.imperial_units) + return AltosConvert.c_to_f(v); + return v; + } + + public String show_units() { + if (AltosConvert.imperial_units) + return "°F"; + return "°C"; + } + + public String say_units() { + if (AltosConvert.imperial_units) + return "degrees farenheit"; + return "degrees celsius"; + } + + public int show_fraction(int width) { + return width / 3; + } +} diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index 4f4278b8..b8b3254c 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -25,7 +25,7 @@ public abstract class AltosUnits { public abstract String say_units(); - abstract int show_fraction(int width); + public abstract int show_fraction(int width); int say_fraction() { return 0; diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 74c642d6..8e5701ad 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -78,6 +78,7 @@ altoslib_JAVA = \ AltosDistance.java \ AltosHeight.java \ AltosSpeed.java \ + AltosTemperature.java \ AltosAccel.java \ AltosPyro.java diff --git a/altosui/AltosDataPoint.java b/altosui/AltosDataPoint.java deleted file mode 100644 index 4956e9f3..00000000 --- a/altosui/AltosDataPoint.java +++ /dev/null @@ -1,27 +0,0 @@ - -// Copyright (c) 2010 Anthony Towns -// GPL v2 or later - -package altosui; - -interface AltosDataPoint { - int version(); - int serial(); - int flight(); - String callsign(); - double time(); - double rssi(); - - int state(); - String state_name(); - - double acceleration(); - double height(); - double speed(); - double temperature(); - double battery_voltage(); - double drogue_voltage(); - double main_voltage(); - boolean has_accel(); -} - diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java deleted file mode 100644 index 0b4bd6c1..00000000 --- a/altosui/AltosDataPointReader.java +++ /dev/null @@ -1,79 +0,0 @@ - -// Copyright (c) 2010 Anthony Towns -// GPL v2 or later - -package altosui; - -import java.lang.UnsupportedOperationException; -import java.util.NoSuchElementException; -import java.util.Iterator; -import org.altusmetrum.altoslib_1.*; - -class AltosDataPointReader implements Iterable { - Iterator iter; - AltosState state; - boolean has_gps; - boolean has_accel; - boolean has_ignite; - - final static int MISSING = AltosRecord.MISSING; - - public AltosDataPointReader(AltosRecordIterable reader) { - this.iter = reader.iterator(); - this.state = null; - has_accel = true; - has_gps = reader.has_gps(); - has_ignite = reader.has_ignite(); - } - - private void read_next_record() - throws NoSuchElementException - { - state = new AltosState(iter.next(), state); - } - - private AltosDataPoint current_dp() { - assert this.state != null; - - return new AltosDataPoint() { - public int version() { return state.data.version; } - public int serial() { return state.data.serial; } - public int flight() { return state.data.flight; } - public String callsign() { return state.data.callsign; } - public double time() { return state.data.time; } - public double rssi() { return state.data.rssi; } - - public int state() { return state.state; } - public String state_name() { return state.data.state(); } - - public double acceleration() { return state.acceleration; } - public double height() { return state.height; } - public double speed() { return state.speed(); } - public double temperature() { return state.temperature; } - public double battery_voltage() { return state.battery; } - public double drogue_voltage() { return state.drogue_sense; } - public double main_voltage() { return state.main_sense; } - public boolean has_accel() { return true; } // return state.acceleration != AltosRecord.MISSING; } - }; - } - - public Iterator iterator() { - return new Iterator() { - public void remove() { - throw new UnsupportedOperationException(); - } - public boolean hasNext() { - if (state != null && state.state == Altos.ao_flight_landed) - return false; - return iter.hasNext(); - } - public AltosDataPoint next() { - do { - read_next_record(); - } while (state.data.time < -1.0 && hasNext()); - return current_dp(); - } - }; - } -} - diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index fbcefd61..9383824a 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -1,26 +1,214 @@ - -// Copyright (c) 2010 Anthony Towns -// GPL v2 or later +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ package altosui; import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +class AltosVoltage extends AltosUnits { + + public double value(double v) { + return v; + } + + public String show_units() { + return "V"; + } + + public String say_units() { + return "volts"; + } + + public int show_fraction(int width) { + return width / 9; + } +} + +class AltosNsat extends AltosUnits { + + public double value(double v) { + return v; + } + + public String show_units() { + return "Sats"; + } + + public String say_units() { + return "Satellites"; + } -import org.jfree.chart.JFreeChart; -import org.jfree.chart.ChartUtilities; - -abstract class AltosGraph { - public String filename; - public abstract void addData(AltosDataPoint d); - public abstract JFreeChart createChart(); - public String title; - public void toPNG() throws java.io.IOException { toPNG(300, 500); } - public void toPNG(int width, int height) - throws java.io.IOException - { - File pngout = new File(filename); - JFreeChart chart = createChart(); - ChartUtilities.saveChartAsPNG(pngout, chart, width, height); - System.out.println("Created " + filename); - } + public int show_fraction(int width) { + return 0; + } } + +class AltosDbm extends AltosUnits { + + public double value(double v) { + return v; + } + + public String show_units() { + return "dBm"; + } + + public String say_units() { + return "d b m"; + } + + public int show_fraction(int width) { + return 0; + } +} + +public class AltosGraph extends AltosUIGraph { + + static final private Color height_color = new Color(194,31,31); + static final private Color gps_height_color = new Color(150,31,31); + static final private Color range_color = new Color(100, 31, 31); + static final private Color distance_color = new Color(100, 31, 194); + static final private Color speed_color = new Color(31,194,31); + static final private Color accel_color = new Color(31,31,194); + static final private Color voltage_color = new Color(194, 194, 31); + static final private Color battery_voltage_color = new Color(194, 194, 31); + static final private Color drogue_voltage_color = new Color(150, 150, 31); + static final private Color main_voltage_color = new Color(100, 100, 31); + static final private Color gps_nsat_color = new Color (194, 31, 194); + static final private Color gps_nsat_solution_color = new Color (194, 31, 194); + static final private Color gps_nsat_view_color = new Color (150, 31, 150); + static final private Color temperature_color = new Color (31, 194, 194); + static final private Color dbm_color = new Color(31, 100, 100); + static final private Color state_color = new Color(0,0,0); + + static AltosVoltage voltage_units = new AltosVoltage(); + static AltosNsat nsat_units = new AltosNsat(); + static AltosDbm dbm_units = new AltosDbm(); + + AltosUIAxis height_axis, speed_axis, accel_axis, voltage_axis, temperature_axis, nsat_axis, dbm_axis; + AltosUIAxis distance_axis; + + public AltosGraph(AltosUIEnable enable) { + super(enable); + + height_axis = newAxis("Height", AltosConvert.height, height_color); + speed_axis = newAxis("Speed", AltosConvert.speed, speed_color); + accel_axis = newAxis("Acceleration", AltosConvert.accel, accel_color); + voltage_axis = newAxis("Voltage", voltage_units, voltage_color); + temperature_axis = newAxis("Temperature", AltosConvert.temperature, temperature_color, 0); + nsat_axis = newAxis("Satellites", nsat_units, gps_nsat_color, + AltosUIAxis.axis_include_zero | AltosUIAxis.axis_integer); + dbm_axis = newAxis("Signal Strength", dbm_units, dbm_color, 0); + distance_axis = newAxis("Distance", AltosConvert.distance, range_color); + + addMarker("State", AltosGraphDataPoint.data_state, state_color); + addSeries("Height", + AltosGraphDataPoint.data_height, + AltosConvert.height, + height_color, + true, + height_axis); + addSeries("Speed", + AltosGraphDataPoint.data_speed, + AltosConvert.speed, + speed_color, + true, + speed_axis); + addSeries("Acceleration", + AltosGraphDataPoint.data_accel, + AltosConvert.accel, + accel_color, + true, + accel_axis); + addSeries("Range", + AltosGraphDataPoint.data_range, + AltosConvert.distance, + range_color, + false, + distance_axis); + addSeries("Distance", + AltosGraphDataPoint.data_distance, + AltosConvert.distance, + distance_color, + false, + distance_axis); + addSeries("GPS Height", + AltosGraphDataPoint.data_gps_height, + AltosConvert.height, + gps_height_color, + false, + height_axis); + addSeries("GPS Satellites in Solution", + AltosGraphDataPoint.data_gps_nsat_solution, + nsat_units, + gps_nsat_solution_color, + false, + nsat_axis); + addSeries("GPS Satellites in View", + AltosGraphDataPoint.data_gps_nsat_view, + nsat_units, + gps_nsat_view_color, + false, + nsat_axis); + addSeries("Received Signal Strength", + AltosGraphDataPoint.data_rssi, + dbm_units, + dbm_color, + false, + dbm_axis); + addSeries("Temperature", + AltosGraphDataPoint.data_temperature, + AltosConvert.temperature, + temperature_color, + false, + temperature_axis); + addSeries("Battery Voltage", + AltosGraphDataPoint.data_battery_voltage, + voltage_units, + battery_voltage_color, + false, + voltage_axis); + addSeries("Drogue Voltage", + AltosGraphDataPoint.data_drogue_voltage, + voltage_units, + drogue_voltage_color, + false, + voltage_axis); + addSeries("Main Voltage", + AltosGraphDataPoint.data_main_voltage, + voltage_units, + main_voltage_color, + false, + voltage_axis); + } +} \ No newline at end of file diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java new file mode 100644 index 00000000..8e6d6923 --- /dev/null +++ b/altosui/AltosGraphDataPoint.java @@ -0,0 +1,122 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import org.altusmetrum.altosuilib_1.*; +import org.altusmetrum.altoslib_1.*; + +public class AltosGraphDataPoint implements AltosUIDataPoint { + + AltosState state; + + public static final int data_height = 0; + public static final int data_speed = 1; + public static final int data_accel = 2; + public static final int data_temp = 3; + public static final int data_battery_voltage = 4; + public static final int data_drogue_voltage = 5; + public static final int data_main_voltage = 6; + public static final int data_rssi = 7; + public static final int data_state = 8; + public static final int data_gps_height = 9; + public static final int data_gps_nsat_solution = 10; + public static final int data_gps_nsat_view = 11; + public static final int data_temperature = 12; + public static final int data_range = 13; + public static final int data_distance = 14; + + public double x() throws AltosUIDataMissing { + if (state.data.time < -2) + throw new AltosUIDataMissing(-1); + return state.data.time; + } + + public double y(int index) throws AltosUIDataMissing { + double y = AltosRecord.MISSING; + switch (index) { + case data_height: + y = state.height; + break; + case data_speed: + y = state.speed(); + break; + case data_accel: + y = state.acceleration; + break; + case data_temp: + y = state.temperature; + break; + case data_battery_voltage: + y = state.battery; + break; + case data_drogue_voltage: + y = state.drogue_sense; + break; + case data_main_voltage: + y = state.main_sense; + break; + case data_rssi: + y = state.data.rssi; + break; + case data_gps_height: + y = state.gps_height; + break; + case data_gps_nsat_solution: + if (state.gps != null) + y = state.gps.nsat; + break; + case data_gps_nsat_view: + if (state.gps != null && state.gps.cc_gps_sat != null) + y = state.gps.cc_gps_sat.length; + break; + case data_temperature: + y = state.temperature; + break; + case data_range: + y = state.range; + break; + case data_distance: + if (state.from_pad != null) + y = state.from_pad.distance; + break; + } + if (y == AltosRecord.MISSING) + throw new AltosUIDataMissing(index); + return y; + } + + public int id(int index) { + if (index == data_state) { + int s = state.data.state; + if (s < Altos.ao_flight_boost || s > Altos.ao_flight_landed) + return -1; + return s; + } + return 0; + } + + public String id_name(int index) { + if (index == data_state) + return state.data.state(); + return ""; + } + + public AltosGraphDataPoint (AltosState state) { + this.state = state; + } +} \ No newline at end of file diff --git a/altosui/AltosGraphDataSet.java b/altosui/AltosGraphDataSet.java new file mode 100644 index 00000000..092b7c74 --- /dev/null +++ b/altosui/AltosGraphDataSet.java @@ -0,0 +1,96 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.lang.*; +import java.io.*; +import java.util.*; +import org.altusmetrum.altoslib_1.*; +import org.altusmetrum.altosuilib_1.*; + +class AltosGraphIterator implements Iterator { + AltosGraphDataSet dataSet; + Iterator iterator; + + AltosState state; + + public boolean hasNext() { + return iterator.hasNext(); + } + + public AltosUIDataPoint next() { + state = new AltosState(iterator.next(), state); + + if (dataSet.callsign == null && state.data.callsign != null) + dataSet.callsign = state.data.callsign; + + if (dataSet.serial == 0 && state.data.serial != 0) + dataSet.serial = state.data.serial; + + if (dataSet.flight == 0 && state.data.flight != 0) + dataSet.flight = state.data.flight; + + return new AltosGraphDataPoint(state); + } + + public AltosGraphIterator (Iterator iterator, AltosGraphDataSet dataSet) { + this.iterator = iterator; + this.state = null; + this.dataSet = dataSet; + } + + public void remove() { + } +} + +class AltosGraphIterable implements Iterable { + AltosGraphDataSet dataSet; + + public Iterator iterator() { + return new AltosGraphIterator(dataSet.records.iterator(), dataSet); + } + + public AltosGraphIterable(AltosGraphDataSet dataSet) { + this.dataSet = dataSet; + } +} + +public class AltosGraphDataSet implements AltosUIDataSet { + String callsign; + int serial; + int flight; + AltosRecordIterable records; + + public String name() { + if (callsign != null) + return String.format("%s - %d/%d", callsign, serial, flight); + else + return String.format("%d/%d", serial, flight); + } + + public Iterable dataPoints() { + return new AltosGraphIterable(this); + } + + public AltosGraphDataSet (AltosRecordIterable records) { + this.records = records; + this.callsign = null; + this.serial = 0; + this.flight = 0; + } +} diff --git a/altosui/AltosGraphTime.java b/altosui/AltosGraphTime.java deleted file mode 100644 index 62d516b2..00000000 --- a/altosui/AltosGraphTime.java +++ /dev/null @@ -1,235 +0,0 @@ - -// Copyright (c) 2010 Anthony Towns -// GPL v2 or later - -package altosui; - -import java.util.*; -import java.awt.Color; -import java.util.ArrayList; -import java.util.HashMap; -import org.jfree.chart.ChartUtilities; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.AxisLocation; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.labels.StandardXYToolTipGenerator; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.plot.ValueMarker; -import org.jfree.chart.renderer.xy.StandardXYItemRenderer; -import org.jfree.chart.renderer.xy.XYItemRenderer; -import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; -import org.jfree.data.xy.XYSeries; -import org.jfree.data.xy.XYSeriesCollection; -import org.jfree.ui.RectangleAnchor; -import org.jfree.ui.TextAnchor; - -class AltosGraphTime extends AltosGraph { - static interface Element { - void attachGraph(AltosGraphTime g); - void gotTimeData(double time, AltosDataPoint d); - void addToPlot(AltosGraphTime g, XYPlot plot); - } - - static class TimeAxis implements Element { - private int axis; - private Color color; - private String label; - private AxisLocation locn; - private double min_y = Double.NaN; - - public TimeAxis(int axis, String label, Color color, AxisLocation locn) - { - this.axis = axis; - this.color = color; - this.label = label; - this.locn = locn; - } - - public void setLowerBound(double min_y) { - this.min_y = min_y; - } - - public void attachGraph(AltosGraphTime g) { return; } - public void gotTimeData(double time, AltosDataPoint d) { return; } - - public void addToPlot(AltosGraphTime g, XYPlot plot) { - NumberAxis numAxis = new NumberAxis(label); - if (!Double.isNaN(min_y)) - numAxis.setLowerBound(min_y); - plot.setRangeAxis(axis, numAxis); - plot.setRangeAxisLocation(axis, locn); - numAxis.setLabelPaint(color); - numAxis.setTickLabelPaint(color); - numAxis.setAutoRangeIncludesZero(false); - } - } - - abstract static class TimeSeries implements Element { - protected XYSeries series; - private String axisName; - private String axisUnits; - private Color color; - - public TimeSeries(String axisName, String axisUnits, String label, Color color) { - this.series = new XYSeries(label); - this.axisName = String.format("%s (%s)", axisName, axisUnits); - this.axisUnits = axisUnits; - this.color = color; - } - - public void attachGraph(AltosGraphTime g) { - g.setAxis(this, axisName, color); - } - abstract public void gotTimeData(double time, AltosDataPoint d); - - public void addToPlot(AltosGraphTime g, XYPlot plot) { - XYSeriesCollection dataset = new XYSeriesCollection(); - dataset.addSeries(this.series); - - XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); - renderer.setSeriesPaint(0, color); - StandardXYToolTipGenerator tool_tip; - - tool_tip = new StandardXYToolTipGenerator(String.format("{1}s: {2}%s ({0})", axisUnits), - new java.text.DecimalFormat("0.00"), - new java.text.DecimalFormat("0.00")); - renderer.setBaseToolTipGenerator(tool_tip); - - int dataNum = g.getDataNum(this); - int axisNum = g.getAxisNum(this); - - plot.setDataset(dataNum, dataset); - plot.mapDatasetToRangeAxis(dataNum, axisNum); - plot.setRenderer(dataNum, renderer); - } - } - - static class StateMarker implements Element { - private LinkedList times = new LinkedList(); - private String name; - private int state; - private int prev_state = Altos.ao_flight_startup; - - StateMarker(int state, String name) { - this.state = state; - this.name = name; - } - - public void attachGraph(AltosGraphTime g) { return; } - public void gotTimeData(double time, AltosDataPoint d) { - if (prev_state != state && d.state() == state) - times.add(time); - prev_state = d.state(); - } - - public void addToPlot(AltosGraphTime g, XYPlot plot) { - for (double time : times) { - ValueMarker m = new ValueMarker(time); - m.setLabel(name); - m.setLabelAnchor(RectangleAnchor.TOP_RIGHT); - m.setLabelTextAnchor(TextAnchor.TOP_LEFT); - plot.addDomainMarker(m); - } - } - } - - private String callsign = null; - private Integer serial = null; - private Integer flight = null; - - private ArrayList elements; - private HashMap axes; - private HashMap datasets; - private ArrayList datasetAxis; - - public AltosGraphTime(String title) { - this.filename = title.toLowerCase().replaceAll("[^a-z0-9]","_")+".png"; - this.title = title; - this.elements = new ArrayList(); - this.axes = new HashMap(); - this.datasets = new HashMap(); - this.datasetAxis = new ArrayList(); - } - - public AltosGraphTime addElement(Element e) { - e.attachGraph(this); - elements.add(e); - return this; - } - - public void setAxis(Element ds, String axisName, Color color) { - Integer axisNum = axes.get(axisName); - int dsNum = datasetAxis.size(); - if (axisNum == null) { - axisNum = newAxis(axisName, color); - } - datasets.put(ds, dsNum); - datasetAxis.add(axisNum); - } - - public int getAxisNum(Element ds) { - return datasetAxis.get( datasets.get(ds) ).intValue(); - } - public int getDataNum(Element ds) { - return datasets.get(ds).intValue(); - } - - private Integer newAxis(String name, Color color) { - int cnt = axes.size(); - AxisLocation locn = AxisLocation.BOTTOM_OR_LEFT; - if (cnt > 0) { - locn = AxisLocation.TOP_OR_RIGHT; - } - Integer res = new Integer(cnt); - axes.put(name, res); - this.addElement(new TimeAxis(cnt, name, color, locn)); - return res; - } - - public void addData(AltosDataPoint d) { - double time = d.time(); - for (Element e : elements) { - e.gotTimeData(time, d); - } - if (callsign == null) callsign = d.callsign(); - if (serial == null) serial = new Integer(d.serial()); - if (flight == null) flight = new Integer(d.flight()); - } - - public JFreeChart createChart() { - NumberAxis xAxis = new NumberAxis("Time (s)"); - xAxis.setAutoRangeIncludesZero(false); - XYPlot plot = new XYPlot(); - plot.setDomainAxis(xAxis); - plot.setOrientation(PlotOrientation.VERTICAL); - - if (serial != null && flight != null) { - title = serial + "/" + flight + ": " + title; - } - if (callsign != null) { - title = callsign + " - " + title; - } - - JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, - plot, true); - ChartUtilities.applyCurrentTheme(chart); - - plot.setDomainPannable(true); - plot.setRangePannable(true); - - for (Element e : elements) { - e.addToPlot(this, plot); - } - - return chart; - } - - public void toPNG() throws java.io.IOException { - if (axes.size() > 1) { - toPNG(800, 500); - } else { - toPNG(300, 500); - } - } -} diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index c45c1124..b376f7de 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -18,290 +18,30 @@ import org.jfree.ui.RefineryUtilities; public class AltosGraphUI extends AltosUIFrame { - JTabbedPane pane; + JTabbedPane pane; + AltosGraph graph; + AltosUIEnable enable; - static final private Color red = new Color(194,31,31); - static final private Color green = new Color(31,194,31); - static final private Color blue = new Color(31,31,194); - //static final private Color black = new Color(31,31,31); - static final private Color yellow = new Color(194,194,31); - //static final private Color cyan = new Color(31,194,194); - static final private Color magenta = new Color(194,31,194); + AltosGraphUI(AltosRecordIterable records, String file) throws InterruptedException, IOException { + pane = new JTabbedPane(); - static private class OverallGraphs { - AltosGraphTime.Element height = - new AltosGraphTime.TimeSeries("Height", AltosConvert.height.show_units(), "Height (AGL)", red) { - public void gotTimeData(double time, AltosDataPoint d) { - double height = d.height(); - if (height != AltosRecord.MISSING) - series.add(time, AltosConvert.height.value(height)); - } - }; - - AltosGraphTime.Element speed = - new AltosGraphTime.TimeSeries("Speed", AltosConvert.speed.show_units(), "Vertical Speed", green) { - public void gotTimeData(double time, AltosDataPoint d) { - double speed = d.speed(); - if (speed != AltosRecord.MISSING) - series.add(time, AltosConvert.speed.value(speed)); - } - }; - - AltosGraphTime.Element acceleration = - new AltosGraphTime.TimeSeries("Acceleration", - AltosConvert.accel.show_units(), - "Axial Acceleration", blue) - { - public void gotTimeData(double time, AltosDataPoint d) { - double acceleration = d.acceleration(); - if (acceleration != AltosRecord.MISSING) - series.add(time, AltosConvert.accel.value(acceleration)); - } - }; - - AltosGraphTime.Element temperature = - new AltosGraphTime.TimeSeries("Temperature", "\u00B0C", - "Board temperature", red) - { - public void gotTimeData(double time, AltosDataPoint d) { - double temp = d.temperature(); - if (temp != AltosRecord.MISSING) - series.add(time, d.temperature()); - } - }; - - AltosGraphTime.Element drogue_voltage = - new AltosGraphTime.TimeSeries("Voltage", "(V)", "Drogue Continuity", yellow) - { - public void gotTimeData(double time, AltosDataPoint d) { - double v = d.drogue_voltage(); - if (v != AltosRecord.MISSING) - series.add(time, v); - } - }; - - AltosGraphTime.Element main_voltage = - new AltosGraphTime.TimeSeries("Voltage", "(V)", "Main Continuity", magenta) - { - public void gotTimeData(double time, AltosDataPoint d) { - double v = d.main_voltage(); - if (v != AltosRecord.MISSING) - series.add(time, v); - } - }; - - //AltosGraphTime.Element e_pad = new AltosGraphTime.StateMarker(Altos.ao_flight_pad, "Pad"); - AltosGraphTime.Element e_boost = new AltosGraphTime.StateMarker(Altos.ao_flight_boost, "Boost"); - AltosGraphTime.Element e_fast = new AltosGraphTime.StateMarker(Altos.ao_flight_fast, "Fast"); - AltosGraphTime.Element e_coast = new AltosGraphTime.StateMarker(Altos.ao_flight_coast, "Coast"); - AltosGraphTime.Element e_drogue = new AltosGraphTime.StateMarker(Altos.ao_flight_drogue, "Drogue"); - AltosGraphTime.Element e_main = new AltosGraphTime.StateMarker(Altos.ao_flight_main, "Main"); - AltosGraphTime.Element e_landed = new AltosGraphTime.StateMarker(Altos.ao_flight_landed, "Landed"); - - protected AltosGraphTime myAltosGraphTime(String suffix) { - return (new AltosGraphTime("Overall " + suffix)) - .addElement(e_boost) - .addElement(e_fast) - .addElement(e_coast) - .addElement(e_drogue) - .addElement(e_main) - .addElement(e_landed); - } - - public ArrayList graphs() { - ArrayList graphs = new ArrayList(); - - graphs.add( myAltosGraphTime("Summary") - .addElement(height) - .addElement(speed) - .addElement(acceleration) ); + enable = new AltosUIEnable(); - graphs.add( myAltosGraphTime("Summary") - .addElement(height) - .addElement(speed)); - - graphs.add( myAltosGraphTime("Altitude") - .addElement(height) ); - - graphs.add( myAltosGraphTime("Speed") - .addElement(speed) ); - - graphs.add( myAltosGraphTime("Acceleration") - .addElement(acceleration) ); - - graphs.add( myAltosGraphTime("Temperature") - .addElement(temperature) ); - - graphs.add( myAltosGraphTime("Continuity") - .addElement(drogue_voltage) - .addElement(main_voltage) ); - - return graphs; - } - } + AltosGraph graph = new AltosGraph(enable); - /* - static private class AscentGraphs extends OverallGraphs { - protected AltosGraphTime myAltosGraphTime(String suffix) { - return (new AltosGraphTime("Ascent " + suffix) { - public void addData(AltosDataPoint d) { - int state = d.state(); - if (Altos.ao_flight_boost <= state && state <= Altos.ao_flight_coast) { - super.addData(d); - } - } - }).addElement(e_boost) - .addElement(e_fast) - .addElement(e_coast); - } - } - */ + graph.setDataSet(new AltosGraphDataSet(records)); - /* - static private class DescentGraphs extends OverallGraphs { - protected AltosGraphTime myAltosGraphTime(String suffix) { - return (new AltosGraphTime("Descent " + suffix) { - public void addData(AltosDataPoint d) { - int state = d.state(); - if (Altos.ao_flight_drogue <= state && state <= Altos.ao_flight_main) { - super.addData(d); - } - } - }).addElement(e_drogue) - .addElement(e_main); - // ((XYGraph)graph[8]).ymin = new Double(-50); - } - } - */ + pane.add("Flight Graph", graph.panel); + pane.add("Configure Graph", enable); - public AltosGraphUI(AltosRecordIterable records, String name) throws InterruptedException, IOException { - super(String.format("Altos Graph %s", name)); + AltosFlightStatsTable stats = new AltosFlightStatsTable(new AltosFlightStats(records)); + pane.add("Flight Statistics", stats); - AltosDataPointReader reader = new AltosDataPointReader (records); - - if (reader.has_accel) - init(reader, records, 0); - else - init(reader, records, 1); - } - -// public AltosGraphUI(AltosDataPointReader data, int which) - // { -// super("Altos Graph"); -// init(data, which); -// } - - private void init(AltosDataPointReader data, AltosRecordIterable records, int which) throws InterruptedException, IOException { - pane = new JTabbedPane(); - - AltosGraph graph = createGraph(data, which); - - JFreeChart chart = graph.createChart(); - ChartPanel chartPanel = new ChartPanel(chart); - chartPanel.setMouseWheelEnabled(true); - chartPanel.setPreferredSize(new java.awt.Dimension(800, 500)); - pane.add(graph.title, chartPanel); - - AltosFlightStatsTable stats = new AltosFlightStatsTable(new AltosFlightStats(records)); - pane.add("Flight Statistics", stats); - - setContentPane (pane); - - pack(); - - RefineryUtilities.centerFrameOnScreen(this); - - setDefaultCloseOperation(DISPOSE_ON_CLOSE); - setVisible(true); - } - - private static AltosGraph createGraph(Iterable data, - int which) - { - return createGraphsWhich(data, which).get(0); - } - - /* - private static ArrayList createGraphs( - Iterable data) - { - return createGraphsWhich(data, -1); - } - */ - - private static ArrayList createGraphsWhich( - Iterable data, int which) - { - ArrayList graph = new ArrayList(); - graph.addAll((new OverallGraphs()).graphs()); -// graph.addAll((new AscentGraphs()).graphs()); -// graph.addAll((new DescentGraphs()).graphs()); + setContentPane (pane); - if (which > 0) { - if (which >= graph.size()) { - which = 0; - } - AltosGraph g = graph.get(which); - graph = new ArrayList(); - graph.add(g); - } + pack(); - for (AltosDataPoint dp : data) { - for (AltosGraph g : graph) { - g.addData(dp); - } - } - - return graph; - } + setDefaultCloseOperation(DISPOSE_ON_CLOSE); + setVisible(true); + } } - -/* gnuplot bits... - * -300x400 - --------------------------------------------------------- -TOO HARD! :) - -"ascent-gps-accuracy.png" "Vertical error margin to apogee - GPS v Baro (m)" - 5:($7 < 6 ? $24-$11 : 1/0) -"descent-gps-accuracy.png" "Vertical error margin during descent - GPS v Baro (m)" - 5:($7 < 6 ? 1/0 : $24-$11) - -set output "overall-gps-accuracy.png" -set ylabel "distance above sea level (m)" -plot "telemetry.csv" using 5:11 with lines ti "baro altitude" axis x1y1, \ - "telemetry.csv" using 5:24 with lines ti "gps altitude" axis x1y1 - -set term png tiny size 700,700 enhanced -set xlabel "m" -set ylabel "m" -set polar -set grid polar -set rrange[*:*] -set angles degrees - -set output "overall-gps-path.png" -#:30 with yerrorlines -plot "telemetry.csv" using (90-$33):($7 == 2 ? $31 : 1/0) with lines ti "pad", \ - "telemetry.csv" using (90-$33):($7 == 3 ? $31 : 1/0) with lines ti "boost", \ - "telemetry.csv" using (90-$33):($7 == 4 ? $31 : 1/0) with lines ti "fast", \ - "telemetry.csv" using (90-$33):($7 == 5 ? $31 : 1/0) with lines ti "coast", \ - "telemetry.csv" using (90-$33):($7 == 6 ? $31 : 1/0) with lines ti "drogue", \ - "telemetry.csv" using (90-$33):($7 == 7 ? $31 : 1/0) with lines ti "main", \ - "telemetry.csv" using (90-$33):($7 == 8 ? $31 : 1/0) with lines ti "landed" - -set output "ascent-gps-path.png" -plot "telemetry.csv" using (90-$33):($7 == 2 ? $31 : 1/0):30 with lines ti "pad", \ - "telemetry.csv" using (90-$33):($7 == 3 ? $31 : 1/0):20 with lines ti "boost", \ - "telemetry.csv" using (90-$33):($7 == 4 ? $31 : 1/0):10 with lines ti "fast", \ - "telemetry.csv" using (90-$33):($7 == 5 ? $31 : 1/0):5 with lines ti "coast" - -set output "descent-gps-path.png" -plot "telemetry.csv" using (90-$33):($7 == 6 ? $31 : 1/0) with lines ti "drogue", \ - "telemetry.csv" using (90-$33):($7 == 7 ? $31 : 1/0) with lines ti "main", \ - "telemetry.csv" using (90-$33):($7 == 8 ? $31 : 1/0) with lines ti "landed" - - */ - - diff --git a/altosui/Makefile.am b/altosui/Makefile.am index f5b83ce7..8ae1a72e 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -74,10 +74,9 @@ altosui_JAVA = \ AltosSiteMapTile.java \ AltosUI.java \ AltosWriter.java \ - AltosDataPointReader.java \ - AltosDataPoint.java \ AltosGraph.java \ - AltosGraphTime.java \ + AltosGraphDataPoint.java \ + AltosGraphDataSet.java \ AltosGraphUI.java \ AltosDataChooser.java \ AltosVoice.java \ @@ -99,10 +98,10 @@ FREETTS_CLASS= \ freetts.jar ALTOSLIB_CLASS=\ - AltosLib.jar + altoslib_$(ALTOSLIB_VERSION).jar ALTOSUILIB_CLASS=\ - altosuilib.jar + altosuilib_$(ALTOSUILIB_VERSION).jar LIBALTOS= \ libaltos.so \ diff --git a/altosuilib/AltosUIAxis.java b/altosuilib/AltosUIAxis.java new file mode 100644 index 00000000..70084a00 --- /dev/null +++ b/altosuilib/AltosUIAxis.java @@ -0,0 +1,92 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +import java.io.*; +import java.util.ArrayList; + +import java.awt.*; +import javax.swing.*; +import org.altusmetrum.altoslib_1.*; + +import org.jfree.ui.*; +import org.jfree.chart.*; +import org.jfree.chart.plot.*; +import org.jfree.chart.axis.*; +import org.jfree.chart.renderer.*; +import org.jfree.chart.renderer.xy.*; +import org.jfree.chart.labels.*; +import org.jfree.data.xy.*; +import org.jfree.data.*; + +public class AltosUIAxis extends NumberAxis { + String label; + AltosUnits units; + Color color; + int ref; + int visible; + int index; + + public final static int axis_integer = 1; + public final static int axis_include_zero = 2; + + public final static int axis_default = axis_include_zero; + + public void set_units() { + setLabel(String.format("%s (%s)", label, units.show_units())); + } + + public void set_enable(boolean enable) { + if (enable) { + visible++; + if (visible > ref) + System.out.printf("too many visible\n"); + } else { + visible--; + if (visible < 0) + System.out.printf("too few visible\n"); + } + setVisible(visible > 0); + } + + public void ref(boolean enable) { + ++ref; + if (enable) { + ++visible; + setVisible(visible > 0); + } + } + + public AltosUIAxis(String label, AltosUnits units, Color color, int index, int flags) { + this.label = label; + this.units = units; + this.index = index; + this.visible = 0; + this.ref = 0; + setLabelPaint(color); + setTickLabelPaint(color); + setVisible(false); + if ((flags & axis_integer) != 0) + setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + setAutoRangeIncludesZero((flags & axis_include_zero) != 0); + } + + public AltosUIAxis(String label, AltosUnits units, Color color, int index) { + this(label, units, color, index, axis_default); + } +} diff --git a/altosuilib/AltosUIDataMissing.java b/altosuilib/AltosUIDataMissing.java new file mode 100644 index 00000000..c7b01859 --- /dev/null +++ b/altosuilib/AltosUIDataMissing.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altosuilib_1; + +public class AltosUIDataMissing extends Exception { + public int id; + public AltosUIDataMissing(int id) { + this.id = id; + } +} \ No newline at end of file diff --git a/altosuilib/AltosUIDataPoint.java b/altosuilib/AltosUIDataPoint.java index a98f7cdb..d3020410 100644 --- a/altosuilib/AltosUIDataPoint.java +++ b/altosuilib/AltosUIDataPoint.java @@ -18,8 +18,8 @@ package org.altusmetrum.altosuilib_1; public interface AltosUIDataPoint { - public abstract double x(); - public abstract double y(int index); - public abstract int id(int index); - public abstract String id_name(int index); + public abstract double x() throws AltosUIDataMissing; + public abstract double y(int index) throws AltosUIDataMissing; + public abstract int id(int index) throws AltosUIDataMissing; + public abstract String id_name(int index) throws AltosUIDataMissing; } diff --git a/altosuilib/AltosUIEnable.java b/altosuilib/AltosUIEnable.java index 297cf320..55486dea 100644 --- a/altosuilib/AltosUIEnable.java +++ b/altosuilib/AltosUIEnable.java @@ -84,10 +84,38 @@ public class AltosUIEnable extends Container { y++; } + public void add_units() { + /* Imperial units setting */ + /* Add label */ + GridBagConstraints c = new GridBagConstraints(); + c.gridx = 0; c.gridy = 1000; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + add(new JLabel("Imperial Units"), c); + + JRadioButton imperial_units = new JRadioButton("Enable", AltosUIPreferences.imperial_units()); + imperial_units.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JRadioButton item = (JRadioButton) e.getSource(); + boolean enabled = item.isSelected(); + AltosUIPreferences.set_imperial_units(enabled); + } + }); + imperial_units.setToolTipText("Use Imperial units instead of metric"); + c = new GridBagConstraints(); + c.gridx = 1; c.gridy = 1000; + c.fill = GridBagConstraints.NONE; + c.anchor = GridBagConstraints.LINE_START; + c.insets = il; + add(imperial_units, c); + } + public AltosUIEnable() { il = new Insets(4,4,4,4); ir = new Insets(4,4,4,4); y = 0; setLayout(new GridBagLayout()); + add_units(); } } diff --git a/altosuilib/AltosUIGraph.java b/altosuilib/AltosUIGraph.java index e212093a..5c589c02 100644 --- a/altosuilib/AltosUIGraph.java +++ b/altosuilib/AltosUIGraph.java @@ -43,7 +43,8 @@ public class AltosUIGraph implements AltosUnitsListener { AltosUIEnable enable; ArrayList graphers; AltosUIDataSet dataSet; - int index; + int axis_index; + int series_index; static final private Color gridline_color = new Color(0, 0, 0); static final private Color border_color = new Color(255, 255, 255); @@ -53,19 +54,33 @@ public class AltosUIGraph implements AltosUnitsListener { return panel; } - public void addSeries(String label, int fetch, AltosUnits units, Color color) { - AltosUISeries series = new AltosUISeries(label, fetch, units, color); + public AltosUIAxis newAxis(String label, AltosUnits units, Color color, int flags) { + AltosUIAxis axis = new AltosUIAxis(label, units, color, axis_index++, flags); + plot.setRangeAxis(axis.index, axis); + return axis; + } + + public AltosUIAxis newAxis(String label, AltosUnits units, Color color) { + return newAxis(label, units, color, AltosUIAxis.axis_default); + } + + public void addSeries(String label, int fetch, AltosUnits units, Color color, + boolean enabled, AltosUIAxis axis) { + AltosUISeries series = new AltosUISeries(label, fetch, units, color, enabled, axis); XYSeriesCollection dataset = new XYSeriesCollection(series); series.renderer.setPlot(plot); - plot.setRangeAxis(index, series.axis); - plot.setDataset(index, dataset); - plot.setRenderer(index, series.renderer); - plot.mapDatasetToRangeAxis(index, index); + plot.setDataset(series_index, dataset); + plot.setRenderer(series_index, series.renderer); + plot.mapDatasetToRangeAxis(series_index, axis.index); if (enable != null) - enable.add(label, series, true); + enable.add(label, series, enabled); this.graphers.add(series); - index++; + series_index++; + } + + public void addSeries(String label, int fetch, AltosUnits units, Color color) { + addSeries(label, fetch, units, color, true, newAxis(label, units, color)); } public void addMarker(String label, int fetch, Color color) { @@ -97,16 +112,17 @@ public class AltosUIGraph implements AltosUnitsListener { public void setDataSet (AltosUIDataSet dataSet) { this.dataSet = dataSet; + resetData(); if (dataSet != null) setName(dataSet.name()); - resetData(); } public AltosUIGraph(AltosUIEnable enable) { this.enable = enable; this.graphers = new ArrayList(); - this.index = 0; + this.series_index = 0; + this.axis_index = 0; xAxis = new NumberAxis("Time (s)"); diff --git a/altosuilib/AltosUIMarker.java b/altosuilib/AltosUIMarker.java index 560153f2..e2eb9028 100644 --- a/altosuilib/AltosUIMarker.java +++ b/altosuilib/AltosUIMarker.java @@ -72,20 +72,23 @@ public class AltosUIMarker implements AltosUIGrapher { } public void add(AltosUIDataPoint dataPoint) { - int id = dataPoint.id(fetch); - if (id < 0) - return; - if (id == last_id) - return; - ValueMarker marker = new ValueMarker(dataPoint.x()); - marker.setLabel(dataPoint.id_name(fetch)); - marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); - marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); - marker.setPaint(color); - if (enabled) - plot.addDomainMarker(marker); - markers.add(marker); - last_id = id; + try { + int id = dataPoint.id(fetch); + if (id < 0) + return; + if (id == last_id) + return; + ValueMarker marker = new ValueMarker(dataPoint.x()); + marker.setLabel(dataPoint.id_name(fetch)); + marker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); + marker.setLabelTextAnchor(TextAnchor.TOP_LEFT); + marker.setPaint(color); + if (enabled) + plot.addDomainMarker(marker); + markers.add(marker); + last_id = id; + } catch (AltosUIDataMissing m) { + } } public AltosUIMarker (int fetch, Color color, XYPlot plot, boolean enable) { diff --git a/altosuilib/AltosUISeries.java b/altosuilib/AltosUISeries.java index 26679471..ac09a3cc 100644 --- a/altosuilib/AltosUISeries.java +++ b/altosuilib/AltosUISeries.java @@ -65,7 +65,10 @@ public class AltosUISeries extends XYSeries implements AltosUIGrapher { } public void add(AltosUIDataPoint dataPoint) { - super.add(dataPoint.x(), dataPoint.y(fetch)); + try { + super.add(dataPoint.x(), units.value(dataPoint.y(fetch))); + } catch (AltosUIDataMissing dm) { + } } public AltosUISeries (String label, int fetch, AltosUnits units, Color color, @@ -82,18 +85,7 @@ public class AltosUISeries extends XYSeries implements AltosUIGrapher { renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(0, color); + renderer.setSeriesVisible(0, enable); set_units(); } - - public AltosUISeries (String label, int fetch, AltosUnits units, Color color, boolean enable) { - this(label, fetch, units, color, - enable, - new AltosUIAxis(label, units, color)); - } - - public AltosUISeries (String label, int fetch, AltosUnits units, Color color) { - this(label, fetch, units, color, - true, - new AltosUIAxis(label, units, color)); - } } diff --git a/altosuilib/Makefile.am b/altosuilib/Makefile.am index faf7921f..0cd2aaea 100644 --- a/altosuilib/Makefile.am +++ b/altosuilib/Makefile.am @@ -15,6 +15,7 @@ altosuilib_JAVA = \ AltosPositionListener.java \ AltosUIConfigure.java \ AltosUIAxis.java \ + AltosUIDataMissing.java \ AltosUIDataPoint.java \ AltosUIDataSet.java \ AltosUIGraph.java \ -- cgit v1.2.3 From a5fb03421751b342dcd450caee49a608d8828175 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 10 Feb 2013 00:32:26 -0800 Subject: altoslib: Fix a couple of unit functions to make them public Nice to be able to use these outside of altoslib Signed-off-by: Keith Packard --- altoslib/AltosAccel.java | 2 +- altoslib/AltosDistance.java | 4 ++-- altoslib/AltosSpeed.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index af8c36b9..d02b3238 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -37,7 +37,7 @@ public class AltosAccel extends AltosUnits { return "meters per second squared"; } - int show_fraction(int width) { + public int show_fraction(int width) { return width / 9; } } \ No newline at end of file diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index 9d98f6b6..25028ac7 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -37,13 +37,13 @@ public class AltosDistance extends AltosUnits { return "meters"; } - int show_fraction(int width) { + public int show_fraction(int width) { if (AltosConvert.imperial_units) return width / 3; return width / 9; } - int say_fraction() { + public int say_fraction() { if (AltosConvert.imperial_units) return 1; return 0; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index 020c1377..6fb624fb 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -37,7 +37,7 @@ public class AltosSpeed extends AltosUnits { return "meters per second"; } - int show_fraction(int width) { + public int show_fraction(int width) { return width / 9; } } \ No newline at end of file -- cgit v1.2.3 From c2701ae646124f0668c5f2d1df3fc80f0075a9d7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 10 Feb 2013 14:17:04 -0800 Subject: altosui: Interrupt MonitorIdle when changing frequency/callsign When switching radio parameters, the local device needs to have the parameters switched, so interrupt the current operation and start over, the frequency and callsign will be set the next time through. Signed-off-by: Keith Packard --- altoslib/AltosIdleMonitor.java | 19 +++++++++++++++++++ altoslib/AltosLink.java | 3 +++ altosui/AltosIdleMonitorUI.java | 14 +++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 6b20b3f1..f2f75bbb 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -27,6 +27,7 @@ public class AltosIdleMonitor extends Thread { AltosState state; boolean remote; double frequency; + String callsign; AltosState previous_state; AltosConfigData config_data; AltosGPS gps; @@ -87,6 +88,7 @@ public class AltosIdleMonitor extends Thread { try { if (remote) { link.set_radio_frequency(frequency); + link.set_callsign(callsign); link.start_remote(); } else link.flush_input(); @@ -126,12 +128,29 @@ public class AltosIdleMonitor extends Thread { public void set_frequency(double in_frequency) { frequency = in_frequency; + link.abort_reply(); + } + + public void set_callsign(String in_callsign) { + callsign = in_callsign; + link.abort_reply(); } public void post_state() { listener.update(state); } + public void abort() { + if (isAlive()) { + interrupt(); + link.abort_reply(); + try { + join(); + } catch (InterruptedException ie) { + } + } + } + public void run() { try { for (;;) { diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 2b5909aa..9eb25ce0 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -249,6 +249,7 @@ public abstract class AltosLink implements Runnable { public boolean monitor_mode = false; public int telemetry = AltosLib.ao_telemetry_standard; public double frequency; + public String callsign; AltosConfigData config_data; private int telemetry_len() { @@ -330,6 +331,7 @@ public abstract class AltosLink implements Runnable { } public void set_callsign(String callsign) { + this.callsign = callsign; printf ("c c %s\n", callsign); flush_output(); } @@ -363,5 +365,6 @@ public abstract class AltosLink implements Runnable { } public AltosLink() { + callsign = ""; } } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 462bff18..8c883eeb 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -37,11 +37,8 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl boolean remote; void stop_display() { - if (thread != null && thread.isAlive()) { - thread.interrupt(); - try { - thread.join(); - } catch (InterruptedException ie) {} + if (thread != null) { + thread.abort(); } thread = null; } @@ -92,8 +89,11 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl /* DocumentListener interface methods */ public void changedUpdate(DocumentEvent e) { - if (callsign_value != null) - AltosUIPreferences.set_callsign(callsign_value.getText()); + if (callsign_value != null) { + String callsign = callsign_value.getText(); + thread.set_callsign(callsign); + AltosUIPreferences.set_callsign(callsign); + } } public void insertUpdate(DocumentEvent e) { -- cgit v1.2.3 From a9cf50c9f29f42cc3ca0daff3c69a4087cf9aa1c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 10 Feb 2013 14:40:48 -0800 Subject: altoslib: Fix available flight log storage computation number of flights was off by one as it was initialized to -1 storage erase unit wasn't getting fetched correctly flight_log_max is in kB, not B; need to multiply by 1024 Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 24ab2556..12659d88 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -116,12 +116,22 @@ public class AltosConfigData implements Iterable { default: if (flight_log_max <= 0) return 1; + int log_max = flight_log_max * 1024; int log_space = storage_size - storage_erase_unit; - int log_used = stored_flight * flight_log_max; + int log_used; + + if (stored_flight <= 0) + log_used = 0; + else + log_used = stored_flight * log_max; + int log_avail; if (log_used >= log_space) - return 0; - return (log_space - log_used) / flight_log_max; + log_avail = 0; + else + log_avail = (log_space - log_used) / log_max; + + return log_avail; } } @@ -196,7 +206,7 @@ public class AltosConfigData implements Iterable { storage_size = -1; storage_erase_unit = -1; - stored_flight = -1; + stored_flight = 0; } public void parse_line(String line) { @@ -272,7 +282,7 @@ public class AltosConfigData implements Iterable { /* Storage info replies */ try { storage_size = get_int(line, "Storage size:"); } catch (Exception e) {} - try { storage_erase_unit = get_int(line, "Storage erase unit"); } catch (Exception e) {} + try { storage_erase_unit = get_int(line, "Storage erase unit:"); } catch (Exception e) {} /* Log listing replies */ try { get_int(line, "flight"); stored_flight++; } catch (Exception e) {} @@ -485,7 +495,6 @@ public class AltosConfigData implements Iterable { reset(); link.printf("c s\nf\nv\n"); read_link(link, "software-version"); - System.out.printf("Log format %d\n", log_format); switch (log_format) { case AltosLib.AO_LOG_FORMAT_FULL: case AltosLib.AO_LOG_FORMAT_TINY: -- cgit v1.2.3 From 2a9ca1dcd00da2cfdd0a2ea616308dfb64ee80d4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 11 Feb 2013 10:31:24 -0800 Subject: altosui: Stick file basename in graph window title The title was empty before, this seems more useful than that. Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 4 ++++ altosui/AltosGraphUI.java | 3 ++- altosui/AltosUI.java | 58 +++++++++++++++++++++-------------------------- 3 files changed, 32 insertions(+), 33 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index cb5d467b..192da0a9 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -405,4 +405,8 @@ public class AltosLib { input = input.substring(0,dot); return input.concat(extension); } + + public static File replace_extension(File input, String extension) { + return new File(replace_extension(input.getPath(), extension)); + } } diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index ac20f84b..2dded9a2 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -36,7 +36,8 @@ public class AltosGraphUI extends AltosUIFrame return any_gps; } - AltosGraphUI(AltosRecordIterable records, String file) throws InterruptedException, IOException { + AltosGraphUI(AltosRecordIterable records, File file) throws InterruptedException, IOException { + super(file.getName()); state = null; pane = new JTabbedPane(); diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index a6742f2f..9f8f6dda 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -328,7 +328,7 @@ public class AltosUI extends AltosUIFrame { if (record_reader == null) return; try { - new AltosGraphUI(record_reader, chooser.filename()); + new AltosGraphUI(record_reader, chooser.file()); } catch (InterruptedException ie) { } catch (IOException ie) { } @@ -345,15 +345,14 @@ public class AltosUI extends AltosUIFrame { } } - static AltosRecordIterable open_logfile(String filename) { - File file = new File (filename); + static AltosRecordIterable open_logfile(File file) { try { FileInputStream in; in = new FileInputStream(file); - if (filename.endsWith("eeprom")) + if (file.getName().endsWith("eeprom")) return new AltosEepromIterable(in); - else if (filename.endsWith("mega")) + else if (file.getName().endsWith("mega")) return new AltosEepromMegaIterable(in); else return new AltosTelemetryIterable(in); @@ -363,8 +362,7 @@ public class AltosUI extends AltosUIFrame { } } - static AltosWriter open_csv(String filename) { - File file = new File (filename); + static AltosWriter open_csv(File file) { try { return new AltosCSV(file); } catch (FileNotFoundException fe) { @@ -373,8 +371,7 @@ public class AltosUI extends AltosUIFrame { } } - static AltosWriter open_kml(String filename) { - File file = new File (filename); + static AltosWriter open_kml(File file) { try { return new AltosKML(file); } catch (FileNotFoundException fe) { @@ -390,12 +387,12 @@ public class AltosUI extends AltosUIFrame { static final int process_replay = 4; static final int process_summary = 5; - static boolean process_csv(String input) { + static boolean process_csv(File input) { AltosRecordIterable iterable = open_logfile(input); if (iterable == null) return false; - String output = Altos.replace_extension(input,".csv"); + File output = Altos.replace_extension(input,".csv"); System.out.printf("Processing \"%s\" to \"%s\"\n", input, output); if (input.equals(output)) { System.out.printf("Not processing '%s'\n", input); @@ -410,12 +407,12 @@ public class AltosUI extends AltosUIFrame { return true; } - static boolean process_kml(String input) { + static boolean process_kml(File input) { AltosRecordIterable iterable = open_logfile(input); if (iterable == null) return false; - String output = Altos.replace_extension(input,".kml"); + File output = Altos.replace_extension(input,".kml"); System.out.printf("Processing \"%s\" to \"%s\"\n", input, output); if (input.equals(output)) { System.out.printf("Not processing '%s'\n", input); @@ -450,19 +447,15 @@ public class AltosUI extends AltosUIFrame { return recs; } - static AltosRecordIterable record_iterable_file(String filename) { - return record_iterable (new File(filename)); - } - - static AltosReplayReader replay_file(String filename) { - AltosRecordIterable recs = record_iterable_file(filename); + static AltosReplayReader replay_file(File file) { + AltosRecordIterable recs = record_iterable(file); if (recs == null) return null; - return new AltosReplayReader(recs.iterator(), new File(filename)); + return new AltosReplayReader(recs.iterator(), file); } - static boolean process_replay(String filename) { - AltosReplayReader reader = replay_file(filename); + static boolean process_replay(File file) { + AltosReplayReader reader = replay_file(file); if (reader == null) return false; AltosFlightUI flight_ui = new AltosFlightUI(new AltosVoice(), reader); @@ -470,12 +463,12 @@ public class AltosUI extends AltosUIFrame { return true; } - static boolean process_graph(String filename) { - AltosRecordIterable recs = record_iterable_file(filename); + static boolean process_graph(File file) { + AltosRecordIterable recs = record_iterable(file); if (recs == null) return false; try { - new AltosGraphUI(recs, filename); + new AltosGraphUI(recs, file); return true; } catch (InterruptedException ie) { } catch (IOException ie) { @@ -483,8 +476,8 @@ public class AltosUI extends AltosUIFrame { return false; } - static boolean process_summary(String filename) { - AltosRecordIterable iterable = record_iterable_file(filename); + static boolean process_summary(File file) { + AltosRecordIterable iterable = record_iterable(file); if (iterable == null) return false; try { @@ -580,26 +573,27 @@ public class AltosUI extends AltosUIFrame { else if (args[i].startsWith("--")) help(1); else { + File file = new File(args[i]); switch (process) { case process_none: case process_graph: - if (!process_graph(args[i])) + if (!process_graph(file)) ++errors; break; case process_replay: - if (!process_replay(args[i])) + if (!process_replay(file)) ++errors; break; case process_kml: - if (!process_kml(args[i])) + if (!process_kml(file)) ++errors; break; case process_csv: - if (!process_csv(args[i])) + if (!process_csv(file)) ++errors; break; case process_summary: - if (!process_summary(args[i])) + if (!process_summary(file)) ++errors; break; } -- cgit v1.2.3 From 5e53a485310cc11e6add077fb4bd0b0267734ff0 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Fri, 15 Feb 2013 21:59:08 +1300 Subject: all: clean up .gitignore files and Makefile clean targets Signed-off-by: Mike Beattie --- .gitignore | 1 + altosdroid/.gitignore | 1 + altoslib/.gitignore | 4 ++-- altosui/.gitignore | 1 + altosui/Makefile.am | 2 +- altosuilib/.gitignore | 4 ++++ micropeak/.gitignore | 2 ++ micropeak/Makefile.am | 3 ++- src/test/.gitignore | 4 ++++ src/test/Makefile | 2 +- 10 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 altosuilib/.gitignore (limited to 'altoslib') diff --git a/.gitignore b/.gitignore index 9f33ea3c..b7b8fda1 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ ao-tools/ao-load/ao-load ao-tools/ao-postflight/ao-postflight ao-tools/ao-rawload/ao-rawload ao-tools/ao-send-telem/ao-send-telem +ao-tools/ao-sky-flash/ao-sky-flash ao-tools/ao-view/ao-view ao-view/Makefile ao-view/ao-view diff --git a/altosdroid/.gitignore b/altosdroid/.gitignore index e3acba40..0d2ee6e0 100644 --- a/altosdroid/.gitignore +++ b/altosdroid/.gitignore @@ -1,4 +1,5 @@ local.properties bin gen +libs src/org/altusmetrum/AltosDroid/BuildInfo.java diff --git a/altoslib/.gitignore b/altoslib/.gitignore index a71d076c..ff0fd710 100644 --- a/altoslib/.gitignore +++ b/altoslib/.gitignore @@ -1,3 +1,3 @@ bin -classAltosLib.stamp -AltosLib.jar +classaltoslib.stamp +altoslib*.jar diff --git a/altosui/.gitignore b/altosui/.gitignore index 6d2d8c23..f8554c6a 100644 --- a/altosui/.gitignore +++ b/altosui/.gitignore @@ -12,6 +12,7 @@ altosui altosui-test altosui-jdb classaltosui.stamp +altos-windows.nsi Altos-Linux-*.tar.bz2 Altos-Mac-*.zip Altos-Windows-*.exe diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 8ae1a72e..96cf77f2 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -182,7 +182,7 @@ all-local: classes/altosui $(JAR) altosui altosui-test altosui-jdb clean-local: -rm -rf classes $(JAR) $(FATJAR) \ $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) \ - $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log \ + $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log altos-windows.nsi \ altosui altosui-test altosui-jdb macosx linux if FATINSTALL diff --git a/altosuilib/.gitignore b/altosuilib/.gitignore new file mode 100644 index 00000000..4ad8a77a --- /dev/null +++ b/altosuilib/.gitignore @@ -0,0 +1,4 @@ +AltosUIVersion.java +bin +classaltosuilib.stamp +altosuilib*.jar diff --git a/micropeak/.gitignore b/micropeak/.gitignore index ab80492b..6a6475f0 100644 --- a/micropeak/.gitignore +++ b/micropeak/.gitignore @@ -7,6 +7,7 @@ micropeak micropeak-test micropeak-jdb micropeak-windows.log +micropeak-windows.nsi MicroPeak-Linux-* MicroPeak-Mac-* MicroPeak-Windows-* @@ -17,3 +18,4 @@ linux macosx CDM*.exe FTDI*.dmg +Info.plist diff --git a/micropeak/Makefile.am b/micropeak/Makefile.am index d45ecab9..098a00fb 100644 --- a/micropeak/Makefile.am +++ b/micropeak/Makefile.am @@ -78,7 +78,8 @@ clean-local: $(ALTOSLIB_CLASS) \ $(ALTOSUILIB_CLASS) \ $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt \ - micropeak micropeak-test micropeak-jdb macosx linux windows micropeak-windows.log + micropeak micropeak-test micropeak-jdb macosx linux windows micropeak-windows.log \ + micropeak-windows.nsi LINUX_DIST=MicroPeak-Linux-$(VERSION).tar.bz2 MACOSX_DIST=MicroPeak-Mac-$(VERSION).dmg diff --git a/src/test/.gitignore b/src/test/.gitignore index 5d528ab9..8d79d168 100644 --- a/src/test/.gitignore +++ b/src/test/.gitignore @@ -1,3 +1,5 @@ +ao_aprs_data.wav +ao_aprs_test ao_flight_test ao_flight_test_baro ao_flight_test_accel @@ -6,4 +8,6 @@ ao_gps_test_skytraq ao_convert_test ao_convert_pa_test ao_fec_test +ao_flight_test_mm ao_flight_test_noisy_accel +ao_micropeak_test diff --git a/src/test/Makefile b/src/test/Makefile index 1c2d771e..fccc7937 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -13,7 +13,7 @@ CFLAGS=-I.. -I. -I../core -I../drivers -I../micropeak -O0 -g -Wall all: $(PROGS) ao_aprs_data.wav clean: - rm -f $(PROGS) run-out.baro run-out.full + rm -f $(PROGS) ao_aprs_data.wav run-out.baro run-out.full install: -- cgit v1.2.3 From afd2674261e128a0ecff8fbf5dd6a64196b026f6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 4 Mar 2013 19:44:30 -0800 Subject: altoslib: Invalidate GPS new data bit when updating state Somehow this line got lost when the GPS ground altitude fix was made. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 32d02f21..5598a603 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -205,6 +205,8 @@ public class AltosState { pad_alt = ground_altitude; } + data.new_gps = false; + gps_waiting = MIN_PAD_SAMPLES - npad; if (gps_waiting < 0) gps_waiting = 0; -- cgit v1.2.3 From 6fe32e0fc407522101e805cf2653253cb3cee291 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 Mar 2013 22:11:53 -0700 Subject: altosui: Don't deref null pyros when saving altimeter config The check for no pyro config is to compare npyros against zero rather than check the length of the pyros array as the latter may be null. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 12659d88..45b95646 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -476,7 +476,7 @@ public class AltosConfigData implements Iterable { /* UI doesn't support AES key config */ /* AO_PYRO_NUM */ - if (pyros.length > 0) { + if (npyro > 0) { for (int p = 0; p < pyros.length; p++) { link.printf("c P %s\n", pyros[p].toString()); -- cgit v1.2.3 From 0cd203e418e73a1f11460425985b7575c2f0a76c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Apr 2013 16:43:53 -0700 Subject: Set telegps USB id to 0025 It was accidentally using the same ID as megadongle... Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 3 ++- altosuilib/AltosUSBDevice.java | 3 ++- src/telegps-v0.1/Makefile | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 192da0a9..0b5475f7 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -91,8 +91,9 @@ public class AltosLib { public final static int product_telepyro =0x0012; public final static int product_megametrum = 0x0023; public final static int product_megadongle = 0x0024; + public final static int product_telegps = 0x0025; public final static int product_altusmetrum_min = 0x000a; - public final static int product_altusmetrum_max = 0x0024; + public final static int product_altusmetrum_max = 0x0025; public final static int product_any = 0x10000; public final static int product_basestation = 0x10000 + 1; diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index a5496597..5268927c 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -76,7 +76,8 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { if (want_product == AltosUILib.product_altimeter) return matchProduct(AltosUILib.product_telemetrum) || - matchProduct(AltosUILib.product_megametrum); + matchProduct(AltosUILib.product_megametrum) || + matchProduct(AltosUILib.product_telegps); int have_product = getProduct(); diff --git a/src/telegps-v0.1/Makefile b/src/telegps-v0.1/Makefile index 1e551e15..aae37660 100644 --- a/src/telegps-v0.1/Makefile +++ b/src/telegps-v0.1/Makefile @@ -67,7 +67,7 @@ ALTOS_SRC = \ PRODUCT=TeleGPS-v0.1 PRODUCT_DEF=-DTELEGPS -IDPRODUCT=0x0024 +IDPRODUCT=0x0025 CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g -- cgit v1.2.3 From 997cdef3fe04acdd566d287e70981f7b7934d0c8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Apr 2013 16:44:58 -0700 Subject: altoslib: Make any incoming telem packet update the RSSI value Every packet has RSSI info, so use the latest one available. This makes telegps RSSI available as it never sends sensor packets (having no sensors). Signed-off-by: Keith Packard --- altoslib/AltosTelemetryRecord.java | 12 ++++++------ altoslib/AltosTelemetryRecordCompanion.java | 4 ++-- altoslib/AltosTelemetryRecordConfiguration.java | 4 ++-- altoslib/AltosTelemetryRecordLocation.java | 4 ++-- altoslib/AltosTelemetryRecordMegaData.java | 4 ++-- altoslib/AltosTelemetryRecordMegaSensor.java | 10 ++-------- altoslib/AltosTelemetryRecordRaw.java | 5 ++++- altoslib/AltosTelemetryRecordSatellite.java | 4 ++-- altoslib/AltosTelemetryRecordSensor.java | 10 ++-------- 9 files changed, 24 insertions(+), 33 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosTelemetryRecord.java b/altoslib/AltosTelemetryRecord.java index 01215968..fdc3c88e 100644 --- a/altoslib/AltosTelemetryRecord.java +++ b/altoslib/AltosTelemetryRecord.java @@ -80,25 +80,25 @@ public abstract class AltosTelemetryRecord { r = new AltosTelemetryRecordSensor(bytes, rssi); break; case packet_type_configuration: - r = new AltosTelemetryRecordConfiguration(bytes); + r = new AltosTelemetryRecordConfiguration(bytes, rssi); break; case packet_type_location: - r = new AltosTelemetryRecordLocation(bytes); + r = new AltosTelemetryRecordLocation(bytes, rssi); break; case packet_type_satellite: - r = new AltosTelemetryRecordSatellite(bytes); + r = new AltosTelemetryRecordSatellite(bytes, rssi); break; case packet_type_companion: - r = new AltosTelemetryRecordCompanion(bytes); + r = new AltosTelemetryRecordCompanion(bytes, rssi); break; case packet_type_MM_sensor: r = new AltosTelemetryRecordMegaSensor(bytes, rssi); break; case packet_type_MM_data: - r = new AltosTelemetryRecordMegaData(bytes); + r = new AltosTelemetryRecordMegaData(bytes, rssi); break; default: - r = new AltosTelemetryRecordRaw(bytes); + r = new AltosTelemetryRecordRaw(bytes, rssi); break; } break; diff --git a/altoslib/AltosTelemetryRecordCompanion.java b/altoslib/AltosTelemetryRecordCompanion.java index e016dd01..2231df13 100644 --- a/altoslib/AltosTelemetryRecordCompanion.java +++ b/altoslib/AltosTelemetryRecordCompanion.java @@ -21,8 +21,8 @@ public class AltosTelemetryRecordCompanion extends AltosTelemetryRecordRaw { AltosRecordCompanion companion; - public AltosTelemetryRecordCompanion(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordCompanion(int[] in_bytes, int rssi) { + super(in_bytes, rssi); int off = 0; if (uint8(6) == 0) diff --git a/altoslib/AltosTelemetryRecordConfiguration.java b/altoslib/AltosTelemetryRecordConfiguration.java index 472a6318..47fc3488 100644 --- a/altoslib/AltosTelemetryRecordConfiguration.java +++ b/altoslib/AltosTelemetryRecordConfiguration.java @@ -29,8 +29,8 @@ public class AltosTelemetryRecordConfiguration extends AltosTelemetryRecordRaw { String callsign; String version; - public AltosTelemetryRecordConfiguration(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordConfiguration(int[] in_bytes, int rssi) { + super(in_bytes, rssi); device_type = uint8(5); flight = uint16(6); diff --git a/altoslib/AltosTelemetryRecordLocation.java b/altoslib/AltosTelemetryRecordLocation.java index 469a5400..02999696 100644 --- a/altoslib/AltosTelemetryRecordLocation.java +++ b/altoslib/AltosTelemetryRecordLocation.java @@ -37,8 +37,8 @@ public class AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw { int climb_rate; int course; - public AltosTelemetryRecordLocation(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordLocation(int[] in_bytes, int rssi) { + super(in_bytes, rssi); flags = uint8(5); altitude = int16(6); diff --git a/altoslib/AltosTelemetryRecordMegaData.java b/altoslib/AltosTelemetryRecordMegaData.java index 08df9ee1..a484ef4e 100644 --- a/altoslib/AltosTelemetryRecordMegaData.java +++ b/altoslib/AltosTelemetryRecordMegaData.java @@ -35,8 +35,8 @@ public class AltosTelemetryRecordMegaData extends AltosTelemetryRecordRaw { int speed; int height; - public AltosTelemetryRecordMegaData(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordMegaData(int[] in_bytes, int rssi) { + super(in_bytes, rssi); state = int8(5); diff --git a/altoslib/AltosTelemetryRecordMegaSensor.java b/altoslib/AltosTelemetryRecordMegaSensor.java index 7548d699..2a4b17a4 100644 --- a/altoslib/AltosTelemetryRecordMegaSensor.java +++ b/altoslib/AltosTelemetryRecordMegaSensor.java @@ -35,10 +35,8 @@ public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { int mag_y; int mag_z; - int rssi; - - public AltosTelemetryRecordMegaSensor(int[] in_bytes, int in_rssi) { - super(in_bytes); + public AltosTelemetryRecordMegaSensor(int[] in_bytes, int rssi) { + super(in_bytes, rssi); accel = int16(6); pres = int32(8); @@ -55,8 +53,6 @@ public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { mag_x = int16(26); mag_y = int16(28); mag_z = int16(30); - - rssi = in_rssi; } public AltosRecord update_state(AltosRecord previous) { @@ -85,8 +81,6 @@ public class AltosTelemetryRecordMegaSensor extends AltosTelemetryRecordRaw { next.mag.y = mag_y; next.mag.z = mag_z; - next.rssi = rssi; - next.seen |= AltosRecord.seen_sensor; return next; diff --git a/altoslib/AltosTelemetryRecordRaw.java b/altoslib/AltosTelemetryRecordRaw.java index a06348c1..f94789bb 100644 --- a/altoslib/AltosTelemetryRecordRaw.java +++ b/altoslib/AltosTelemetryRecordRaw.java @@ -22,6 +22,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { int serial; int tick; int type; + int rssi; long received_time; @@ -53,11 +54,12 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { return AltosLib.string(bytes, off + 1, l); } - public AltosTelemetryRecordRaw(int[] in_bytes) { + public AltosTelemetryRecordRaw(int[] in_bytes, int in_rssi) { bytes = in_bytes; serial = uint16(0); tick = uint16(2); type = uint8(4); + rssi = in_rssi; } public AltosRecord update_state(AltosRecord previous) { @@ -69,6 +71,7 @@ public class AltosTelemetryRecordRaw extends AltosTelemetryRecord { next = new AltosRecordNone(); next.serial = serial; next.tick = tick; + next.rssi = rssi; return next; } diff --git a/altoslib/AltosTelemetryRecordSatellite.java b/altoslib/AltosTelemetryRecordSatellite.java index 3e93b337..9835389b 100644 --- a/altoslib/AltosTelemetryRecordSatellite.java +++ b/altoslib/AltosTelemetryRecordSatellite.java @@ -21,8 +21,8 @@ public class AltosTelemetryRecordSatellite extends AltosTelemetryRecordRaw { int channels; AltosGPSSat[] sats; - public AltosTelemetryRecordSatellite(int[] in_bytes) { - super(in_bytes); + public AltosTelemetryRecordSatellite(int[] in_bytes, int rssi) { + super(in_bytes, rssi); channels = uint8(5); if (channels > 12) diff --git a/altoslib/AltosTelemetryRecordSensor.java b/altoslib/AltosTelemetryRecordSensor.java index 767a464a..e0e92c13 100644 --- a/altoslib/AltosTelemetryRecordSensor.java +++ b/altoslib/AltosTelemetryRecordSensor.java @@ -36,10 +36,8 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { int accel_plus_g; int accel_minus_g; - int rssi; - - public AltosTelemetryRecordSensor(int[] in_bytes, int in_rssi) { - super(in_bytes); + public AltosTelemetryRecordSensor(int[] in_bytes, int rssi) { + super(in_bytes, rssi); state = uint8(5); accel = int16(6); @@ -57,8 +55,6 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { ground_accel = int16(26); accel_plus_g = int16(28); accel_minus_g = int16(30); - - rssi = in_rssi; } public AltosRecord update_state(AltosRecord prev) { @@ -101,8 +97,6 @@ public class AltosTelemetryRecordSensor extends AltosTelemetryRecordRaw { next.accel_minus_g = AltosRecord.MISSING; } - next.rssi = rssi; - next.seen |= AltosRecord.seen_sensor | AltosRecord.seen_temp_volt; return next; -- cgit v1.2.3 From e747156d0ea4b62eea30a8f486ee105ee35dcaf5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Apr 2013 16:47:07 -0700 Subject: altosui: Don't display missing sensor data For devices without sensors, don't display temperature, barometric and accelerometer-derived values. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 38 ++++++++++++++++++++++++-------------- altosui/AltosInfoTable.java | 30 ++++++++++++++++++++---------- altosui/AltosPad.java | 13 ++++++++++--- 3 files changed, 54 insertions(+), 27 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 5598a603..f18bf368 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -99,19 +99,27 @@ public class AltosState { altitude = data.altitude(); + height = AltosRecord.MISSING; if (data.kalman_height != AltosRecord.MISSING) height = data.kalman_height; else { - if (prev_state != null) - height = (prev_state.height * 15 + altitude - ground_altitude) / 16.0; + if (prev_state != null && altitude != AltosRecord.MISSING && ground_altitude != AltosRecord.MISSING) { + double cur_height = altitude - ground_altitude; + if (prev_state.height == AltosRecord.MISSING) + height = cur_height; + else + height = (prev_state.height * 15 + cur_height) / 16.0; + } } report_time = System.currentTimeMillis(); if (data.kalman_acceleration != AltosRecord.MISSING) acceleration = data.kalman_acceleration; - else + else { acceleration = data.acceleration(); + System.out.printf ("data acceleration %g\n", acceleration); + } temperature = data.temperature(); drogue_sense = data.drogue_voltage(); main_sense = data.main_voltage(); @@ -169,16 +177,18 @@ public class AltosState { npad = 0; ngps = 0; gps = null; - baro_speed = 0; - accel_speed = 0; + baro_speed = AltosRecord.MISSING; + accel_speed = AltosRecord.MISSING; + max_baro_speed = AltosRecord.MISSING; + max_accel_speed = AltosRecord.MISSING; + max_height = AltosRecord.MISSING; + max_acceleration = AltosRecord.MISSING; time_change = 0; - if (acceleration == AltosRecord.MISSING) - acceleration = 0; } time = tick / 100.0; - if (cur.new_gps && (state == AltosLib.ao_flight_pad || state == AltosLib.ao_flight_idle)) { + if (cur.new_gps && (state < AltosLib.ao_flight_boost)) { /* Track consecutive 'good' gps reports, waiting for 10 of them */ if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) @@ -188,7 +198,7 @@ public class AltosState { /* Average GPS data while on the pad */ if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) { - if (ngps > 1) { + if (ngps > 1 && state == AltosLib.ao_flight_pad) { /* filter pad position */ pad_lat = (pad_lat * 31.0 + data.gps.lat) / 32.0; pad_lon = (pad_lon * 31.0 + data.gps.lon) / 32.0; @@ -201,7 +211,7 @@ public class AltosState { ngps++; } } else { - if (ngps == 0) + if (ngps == 0 && ground_altitude != AltosRecord.MISSING) pad_alt = ground_altitude; } @@ -218,14 +228,14 @@ public class AltosState { boost = (AltosLib.ao_flight_boost == state); /* Only look at accelerometer data under boost */ - if (boost && acceleration > max_acceleration && acceleration != AltosRecord.MISSING) + if (boost && acceleration != AltosRecord.MISSING && (max_acceleration == AltosRecord.MISSING || acceleration > max_acceleration)) max_acceleration = acceleration; - if (boost && accel_speed > max_accel_speed && accel_speed != AltosRecord.MISSING) + if (boost && accel_speed != AltosRecord.MISSING && (max_accel_speed == AltosRecord.MISSING || accel_speed > max_accel_speed)) max_accel_speed = accel_speed; - if (boost && baro_speed > max_baro_speed && baro_speed != AltosRecord.MISSING) + if (boost && baro_speed != AltosRecord.MISSING && (max_baro_speed == AltosRecord.MISSING || baro_speed > max_baro_speed)) max_baro_speed = baro_speed; - if (height > max_height && height != AltosRecord.MISSING) + if (height != AltosRecord.MISSING || (max_height == AltosRecord.MISSING || height > max_height)) max_height = height; if (data.gps != null) { if (gps == null || !gps.locked || data.gps.locked) diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 2facf38a..1dce6daf 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -108,16 +108,26 @@ public class AltosInfoTable extends JTable { if (state == null) return; info_reset(); - info_add_row(0, "Altitude", "%6.0f m", state.altitude); - info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude); - info_add_row(0, "Height", "%6.0f m", state.height); - info_add_row(0, "Max height", "%6.0f m", state.max_height); - info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration); - info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration); - info_add_row(0, "Speed", "%8.1f m/s", state.speed()); - info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed); - info_add_row(0, "Temperature", "%9.2f °C", state.temperature); - info_add_row(0, "Battery", "%9.2f V", state.battery); + if (state.altitude != AltosRecord.MISSING) + info_add_row(0, "Altitude", "%6.0f m", state.altitude); + if (state.ground_altitude != AltosRecord.MISSING) + info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude); + if (state.height != AltosRecord.MISSING) + info_add_row(0, "Height", "%6.0f m", state.height); + if (state.max_height != AltosRecord.MISSING) + info_add_row(0, "Max height", "%6.0f m", state.max_height); + if (state.acceleration != AltosRecord.MISSING) + info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration); + if (state.max_acceleration != AltosRecord.MISSING) + info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration); + if (state.speed() != AltosRecord.MISSING) + info_add_row(0, "Speed", "%8.1f m/s", state.speed()); + if (state.max_speed() != AltosRecord.MISSING) + info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed); + if (state.temperature != AltosRecord.MISSING) + info_add_row(0, "Temperature", "%9.2f °C", state.temperature); + if (state.battery != AltosRecord.MISSING) + info_add_row(0, "Battery", "%9.2f V", state.battery); if (state.drogue_sense != AltosRecord.MISSING) info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense); if (state.main_sense != AltosRecord.MISSING) diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index d13f6945..66cb4cfc 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -168,8 +168,12 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class Battery extends LaunchStatus { void show (AltosState state, int crc_errors) { - show("%4.2f V", state.battery); - lights.set(state.battery > 3.7); + if (state.battery == AltosRecord.MISSING) + hide(); + else { + show("%4.2f V", state.battery); + lights.set(state.battery > 3.7); + } } public Battery (GridBagLayout layout, int y) { super(layout, y, "Battery Voltage"); @@ -285,7 +289,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class PadAlt extends LaunchValue { void show (AltosState state, int crc_errors) { - show("%4.0f m", state.pad_alt); + if (state.pad_alt == AltosRecord.MISSING) + hide(); + else + show("%4.0f m", state.pad_alt); } public PadAlt (GridBagLayout layout, int y) { super (layout, y, "Pad Altitude"); -- cgit v1.2.3 From 67b8bdb4ea8c22688d4f18416593346585595cfa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Apr 2013 17:29:40 -0700 Subject: altosui: Display current GPS in 'pad' tab for 'startup' staten This is the state for telegps, so just display the current GPS info as we don't know where it started at. Signed-off-by: Keith Packard --- altoslib/AltosState.java | 24 ++++++++++++------------ altosui/AltosPad.java | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 18 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index f18bf368..8a3bbd4c 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -98,14 +98,16 @@ public class AltosState { ground_altitude = data.ground_altitude(); altitude = data.altitude(); + if (altitude == AltosRecord.MISSING && data.gps != null) + altitude = data.gps.alt; height = AltosRecord.MISSING; if (data.kalman_height != AltosRecord.MISSING) height = data.kalman_height; else { - if (prev_state != null && altitude != AltosRecord.MISSING && ground_altitude != AltosRecord.MISSING) { + if (altitude != AltosRecord.MISSING && ground_altitude != AltosRecord.MISSING) { double cur_height = altitude - ground_altitude; - if (prev_state.height == AltosRecord.MISSING) + if (prev_state == null || prev_state.height == AltosRecord.MISSING) height = cur_height; else height = (prev_state.height * 15 + cur_height) / 16.0; @@ -116,10 +118,8 @@ public class AltosState { if (data.kalman_acceleration != AltosRecord.MISSING) acceleration = data.kalman_acceleration; - else { + else acceleration = data.acceleration(); - System.out.printf ("data acceleration %g\n", acceleration); - } temperature = data.temperature(); drogue_sense = data.drogue_voltage(); main_sense = data.main_voltage(); @@ -179,10 +179,10 @@ public class AltosState { gps = null; baro_speed = AltosRecord.MISSING; accel_speed = AltosRecord.MISSING; - max_baro_speed = AltosRecord.MISSING; - max_accel_speed = AltosRecord.MISSING; - max_height = AltosRecord.MISSING; - max_acceleration = AltosRecord.MISSING; + max_baro_speed = 0; + max_accel_speed = 0; + max_height = 0; + max_acceleration = 0; time_change = 0; } @@ -230,12 +230,12 @@ public class AltosState { /* Only look at accelerometer data under boost */ if (boost && acceleration != AltosRecord.MISSING && (max_acceleration == AltosRecord.MISSING || acceleration > max_acceleration)) max_acceleration = acceleration; - if (boost && accel_speed != AltosRecord.MISSING && (max_accel_speed == AltosRecord.MISSING || accel_speed > max_accel_speed)) + if (boost && accel_speed != AltosRecord.MISSING && accel_speed > max_accel_speed) max_accel_speed = accel_speed; - if (boost && baro_speed != AltosRecord.MISSING && (max_baro_speed == AltosRecord.MISSING || baro_speed > max_baro_speed)) + if (boost && baro_speed != AltosRecord.MISSING && baro_speed > max_baro_speed) max_baro_speed = baro_speed; - if (height != AltosRecord.MISSING || (max_height == AltosRecord.MISSING || height > max_height)) + if (height != AltosRecord.MISSING && height > max_height) max_height = height; if (data.gps != null) { if (gps == null || !gps.locked || data.gps.locked) diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 66cb4cfc..eb08525c 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -66,6 +66,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { value.setFont(Altos.value_font); } + public void set_label(String text) { + label.setText(text); + } + public LaunchStatus (GridBagLayout layout, int y, String text) { GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; @@ -135,6 +139,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { show(String.format(format, v)); } + public void set_label(String text) { + label.setText(text); + } + void reset() { value.setText(""); } @@ -267,7 +275,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class PadLat extends LaunchValue { void show (AltosState state, int crc_errors) { - show(pos(state.pad_lat,"N", "S")); + if (state.state < AltosLib.ao_flight_pad && state.gps != null) { + show(pos(state.gps.lat,"N", "S")); + set_label("Latitude"); + } else { + show(pos(state.pad_lat,"N", "S")); + set_label("Pad Latitude"); + } } public PadLat (GridBagLayout layout, int y) { super (layout, y, "Pad Latitude"); @@ -278,7 +292,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class PadLon extends LaunchValue { void show (AltosState state, int crc_errors) { - show(pos(state.pad_lon,"E", "W")); + if (state.state < AltosLib.ao_flight_pad && state.gps != null) { + show(pos(state.gps.lon,"E", "W")); + set_label("Longitude"); + } else { + show(pos(state.pad_lon,"E", "W")); + set_label("Pad Longitude"); + } } public PadLon (GridBagLayout layout, int y) { super (layout, y, "Pad Longitude"); @@ -289,10 +309,17 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { class PadAlt extends LaunchValue { void show (AltosState state, int crc_errors) { - if (state.pad_alt == AltosRecord.MISSING) - hide(); - else - show("%4.0f m", state.pad_alt); + if (state.state < AltosLib.ao_flight_pad && state.gps != null) { + show("%4.0f m", state.gps.alt); + set_label("Altitude"); + } else { + if (state.pad_alt == AltosRecord.MISSING) + hide(); + else { + show("%4.0f m", state.pad_alt); + set_label("Pad Altitude"); + } + } } public PadAlt (GridBagLayout layout, int y) { super (layout, y, "Pad Altitude"); -- cgit v1.2.3 From 398c02b945a58634c8932f07df2c2be8438da7d1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 9 Apr 2013 00:28:05 -0700 Subject: altoslib/altosui: Carry receiver status around in AltosListenerState This moves the crc_errors into the new structure and adds a receiver battery voltage value there as well. Now the receiver status can be monitored separately from the flight status. That also means that code receiving state updates should be prepared to accept missing listener or flight state values. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 6 + altoslib/AltosFlightReader.java | 4 + altoslib/AltosGPS.java | 57 +++++----- altoslib/AltosIdleMonitor.java | 6 +- altoslib/AltosLink.java | 57 ++++++++++ altoslib/AltosListenerState.java | 28 +++++ altoslib/AltosRecord.java | 24 ++-- altoslib/AltosSensorMM.java | 122 +++++++++----------- altoslib/AltosSensorTM.java | 80 ++++++------- altoslib/AltosState.java | 21 +++- altoslib/AltosTelemetryReader.java | 8 ++ altoslib/Makefile.am | 1 + altosui/AltosAscent.java | 36 +++--- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosDescent.java | 48 ++++---- altosui/AltosDisplayThread.java | 55 ++++----- altosui/AltosFlightDisplay.java | 2 +- altosui/AltosFlightStatus.java | 38 ++++--- altosui/AltosFlightStatusUpdate.java | 12 +- altosui/AltosFlightUI.java | 31 ++--- altosui/AltosGraphUI.java | 2 +- altosui/AltosIdleMonitorUI.java | 10 +- altosui/AltosInfoTable.java | 213 ++++++++++++++++++----------------- altosui/AltosLanded.java | 32 +++--- altosui/AltosPad.java | 199 +++++++++++++++++++------------- altosui/AltosSiteMap.java | 6 +- altosui/AltosSiteMapTile.java | 2 +- src/core/ao.h | 2 +- src/stm/ao_timer.c | 11 +- 29 files changed, 632 insertions(+), 483 deletions(-) create mode 100644 altoslib/AltosListenerState.java (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 45b95646..57605607 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -135,6 +135,12 @@ public class AltosConfigData implements Iterable { } } + public boolean has_monitor_battery() { + if (product.startsWith("TeleBT")) + return true; + return false; + } + int[] parse_version(String v) { String[] parts = v.split("\\."); int r[] = new int[parts.length]; diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index 3039b4dc..34526658 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -45,4 +45,8 @@ public class AltosFlightReader { public boolean supports_telemetry(int telemetry) { return false; } public File backing_file() { return null; } + + public boolean has_monitor_battery() { return false; } + + public double monitor_battery() { return AltosRecord.MISSING; } } diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 068d8c9c..f23842f3 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -217,33 +217,38 @@ public class AltosGPS { } public AltosGPS(AltosGPS old) { - nsat = old.nsat; - locked = old.locked; - connected = old.connected; - lat = old.lat; /* degrees (+N -S) */ - lon = old.lon; /* degrees (+E -W) */ - alt = old.alt; /* m */ - year = old.year; - month = old.month; - day = old.day; - hour = old.hour; - minute = old.minute; - second = old.second; - - ground_speed = old.ground_speed; /* m/s */ - course = old.course; /* degrees */ - climb_rate = old.climb_rate; /* m/s */ - hdop = old.hdop; /* unitless? */ - h_error = old.h_error; /* m */ - v_error = old.v_error; /* m */ - - if (old.cc_gps_sat != null) { - cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length]; - for (int i = 0; i < old.cc_gps_sat.length; i++) { - cc_gps_sat[i] = new AltosGPSSat(); - cc_gps_sat[i].svid = old.cc_gps_sat[i].svid; - cc_gps_sat[i].c_n0 = old.cc_gps_sat[i].c_n0; + if (old != null) { + nsat = old.nsat; + locked = old.locked; + connected = old.connected; + lat = old.lat; /* degrees (+N -S) */ + lon = old.lon; /* degrees (+E -W) */ + alt = old.alt; /* m */ + year = old.year; + month = old.month; + day = old.day; + hour = old.hour; + minute = old.minute; + second = old.second; + + ground_speed = old.ground_speed; /* m/s */ + course = old.course; /* degrees */ + climb_rate = old.climb_rate; /* m/s */ + hdop = old.hdop; /* unitless? */ + h_error = old.h_error; /* m */ + v_error = old.v_error; /* m */ + + if (old.cc_gps_sat != null) { + cc_gps_sat = new AltosGPSSat[old.cc_gps_sat.length]; + for (int i = 0; i < old.cc_gps_sat.length; i++) { + cc_gps_sat[i] = new AltosGPSSat(); + cc_gps_sat[i].svid = old.cc_gps_sat[i].svid; + cc_gps_sat[i].c_n0 = old.cc_gps_sat[i].c_n0; + } } + } else { + ClearGPSTime(); + cc_gps_sat = null; } } } diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index f2f75bbb..ec51b9c1 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -116,8 +116,10 @@ public class AltosIdleMonitor extends Thread { } finally { if (remote) { link.stop_remote(); - if (record != null) - record.rssi = AltosRSSI(); + if (record != null) { + record.rssi = link.rssi(); + record.monitor_battery = link.monitor_battery(); + } } else { if (record != null) record.rssi = 0; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 9eb25ce0..159ebfe1 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -364,6 +364,63 @@ public abstract class AltosLink implements Runnable { remote = false; } + public int rssi() throws TimeoutException, InterruptedException { + if (remote) + return 0; + printf("s\n"); + String line = get_reply_no_dialog(5000); + if (line == null) + throw new TimeoutException(); + String[] items = line.split("\\s+"); + if (items.length < 2) + return 0; + if (!items[0].equals("RSSI:")) + return 0; + int rssi = Integer.parseInt(items[1]); + return rssi; + } + + public String[] adc() throws TimeoutException, InterruptedException { + printf("a\n"); + for (;;) { + String line = get_reply_no_dialog(5000); + if (line == null) { + throw new TimeoutException(); + } + if (!line.startsWith("tick:")) + continue; + String[] items = line.split("\\s+"); + return items; + } + } + + public boolean has_monitor_battery() { + return config_data.has_monitor_battery(); + } + + public double monitor_battery() { + int monitor_batt = AltosRecord.MISSING; + + if (config_data.has_monitor_battery()) { + try { + String[] items = adc(); + for (int i = 0; i < items.length;) { + if (items[i].equals("batt")) { + monitor_batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + i++; + } + } catch (InterruptedException ie) { + } catch (TimeoutException te) { + } + } + if (monitor_batt == AltosRecord.MISSING) + return AltosRecord.MISSING; + return AltosConvert.cc_battery_to_voltage(monitor_batt); + } + public AltosLink() { callsign = ""; } diff --git a/altoslib/AltosListenerState.java b/altoslib/AltosListenerState.java new file mode 100644 index 00000000..2fb4673e --- /dev/null +++ b/altoslib/AltosListenerState.java @@ -0,0 +1,28 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +public class AltosListenerState { + public int crc_errors; + public double battery; + + public AltosListenerState() { + crc_errors = 0; + battery = AltosRecord.MISSING; + } +} diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index f8c44cc5..7046b9f1 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -17,7 +17,7 @@ package org.altusmetrum.altoslib_1; -public abstract class AltosRecord implements Comparable , Cloneable { +public class AltosRecord implements Comparable , Cloneable { public static final int seen_flight = 1; public static final int seen_sensor = 2; @@ -75,15 +75,17 @@ public abstract class AltosRecord implements Comparable , Cloneable * temperature: °C */ - abstract public double pressure(); - abstract public double ground_pressure(); - abstract public double acceleration(); + public double pressure() { return MISSING; } + public double ground_pressure() { return MISSING; } + public double acceleration() { return MISSING; } public double altitude() { double p = pressure(); - if (p == MISSING) + if (p == MISSING) { + System.out.printf ("altitude missing\n"); return MISSING; + } return AltosConvert.pressure_to_altitude(p); } @@ -126,7 +128,11 @@ public abstract class AltosRecord implements Comparable , Cloneable return tick - o.tick; } - abstract public AltosRecord clone(); + public AltosRecord clone() { + AltosRecord n = new AltosRecord(); + n.copy(this); + return n; + } public void copy(AltosRecord old) { seen = old.seen; @@ -150,13 +156,13 @@ public abstract class AltosRecord implements Comparable , Cloneable seen = 0; version = 0; callsign = "N0CALL"; - serial = 0; - flight = 0; + serial = MISSING; + flight = MISSING; rssi = 0; status = 0; state = AltosLib.ao_flight_startup; tick = 0; - gps = new AltosGPS(); + gps = null; new_gps = false; companion = null; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index 8372d047..6d1b61c0 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -28,75 +28,65 @@ class AltosSensorMM { int accel_ref; public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException { - link.printf("a\n"); - for (;;) { - String line = link.get_reply_no_dialog(5000); - if (line == null) { - throw new TimeoutException(); + String[] items = link.adc(); + sense = new int[6]; + for (int i = 0; i < items.length;) { + if (items[i].equals("tick:")) { + tick = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("0:")) { + sense[0] = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("1:")) { + sense[1] = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("2:")) { + sense[2] = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("3:")) { + sense[3] = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("4:")) { + sense[4] = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("5:")) { + sense[5] = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("6:")) { + v_batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("7:")) { + v_pyro = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("8:")) { + accel = Integer.parseInt(items[i+1]); + i += 2; + continue; } - if (!line.startsWith("tick:")) + if (items[i].equals("9:")) { + accel_ref = Integer.parseInt(items[i+1]); + i += 2; continue; - String[] items = line.split("\\s+"); - sense = new int[6]; - for (int i = 0; i < items.length;) { - if (items[i].equals("tick:")) { - tick = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("0:")) { - sense[0] = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("1:")) { - sense[1] = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("2:")) { - sense[2] = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("3:")) { - sense[3] = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("4:")) { - sense[4] = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("5:")) { - sense[5] = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("6:")) { - v_batt = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("7:")) { - v_pyro = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("8:")) { - accel = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("9:")) { - accel_ref = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - i++; } - break; + i++; } } } diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index f5fa83a5..754dc5bb 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -23,54 +23,44 @@ class AltosSensorTM extends AltosRecordTM { public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException { super(); - link.printf("a\n"); - for (;;) { - String line = link.get_reply_no_dialog(5000); - if (line == null) { - throw new TimeoutException(); + String[] items = link.adc(); + for (int i = 0; i < items.length;) { + if (items[i].equals("tick:")) { + tick = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("accel:")) { + accel = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("pres:")) { + pres = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("temp:")) { + temp = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("batt:")) { + batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("drogue:")) { + drogue = Integer.parseInt(items[i+1]); + i += 2; + continue; } - if (!line.startsWith("tick:")) + if (items[i].equals("main:")) { + main = Integer.parseInt(items[i+1]); + i += 2; continue; - String[] items = line.split("\\s+"); - for (int i = 0; i < items.length;) { - if (items[i].equals("tick:")) { - tick = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("accel:")) { - accel = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("pres:")) { - pres = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("temp:")) { - temp = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("batt:")) { - batt = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("drogue:")) { - drogue = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - if (items[i].equals("main:")) { - main = Integer.parseInt(items[i+1]); - i += 2; - continue; - } - i++; } - break; + i++; } ground_accel = config_data.accel_cal_plus; ground_pres = pres; diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 8a3bbd4c..f1bcb1c1 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -155,30 +155,41 @@ public class AltosState { /* compute barometric speed */ double height_change = height - prev_state.height; + + double prev_baro_speed = prev_state.baro_speed; + if (prev_baro_speed == AltosRecord.MISSING) + prev_baro_speed = 0; + if (time_change > 0) - baro_speed = (prev_state.baro_speed * 3 + (height_change / time_change)) / 4.0; + baro_speed = (prev_baro_speed * 3 + (height_change / time_change)) / 4.0; else baro_speed = prev_state.baro_speed; + double prev_accel_speed = prev_state.accel_speed; + + if (prev_accel_speed == AltosRecord.MISSING) + prev_accel_speed = 0; + if (acceleration == AltosRecord.MISSING) { /* Fill in mising acceleration value */ accel_speed = baro_speed; - if (time_change > 0) - acceleration = (accel_speed - prev_state.accel_speed) / time_change; + + if (time_change > 0 && accel_speed != AltosRecord.MISSING) + acceleration = (accel_speed - prev_accel_speed) / time_change; else acceleration = prev_state.acceleration; } else { /* compute accelerometer speed */ - accel_speed = prev_state.accel_speed + acceleration * time_change; + accel_speed = prev_accel_speed + acceleration * time_change; } } - } else { npad = 0; ngps = 0; gps = null; baro_speed = AltosRecord.MISSING; accel_speed = AltosRecord.MISSING; + pad_alt = AltosRecord.MISSING; max_baro_speed = 0; max_accel_speed = 0; max_height = 0; diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index f365b821..b4293c73 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -107,6 +107,14 @@ public class AltosTelemetryReader extends AltosFlightReader { return log.file(); } + public boolean has_monitor_battery() { + return link.has_monitor_battery(); + } + + public double monitor_battery() { + return link.monitor_battery(); + } + public AltosTelemetryReader (AltosLink in_link) throws IOException, InterruptedException, TimeoutException { link = in_link; diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 8e5701ad..30a9d954 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -37,6 +37,7 @@ altoslib_JAVA = \ AltosIMUQuery.java \ AltosLine.java \ AltosLink.java \ + AltosListenerState.java \ AltosLog.java \ AltosMs5607.java \ AltosMs5607Query.java \ diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 80a5b759..4da4d591 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -42,7 +42,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { label.setVisible(false); } - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void show(String s) { show(); @@ -107,7 +107,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { public class AscentValue { JLabel label; JTextField value; - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void reset() { value.setText(""); @@ -174,7 +174,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { JTextField max_value; double max; - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void reset() { value.setText(""); @@ -239,7 +239,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Height extends AscentValueHold { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.height, state.height); } public Height (GridBagLayout layout, int y) { @@ -250,7 +250,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { Height height; class Speed extends AscentValueHold { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { double speed = state.accel_speed; if (!state.ascent) speed = state.baro_speed; @@ -264,7 +264,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { Speed speed; class Accel extends AscentValueHold { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.accel, state.acceleration); } public Accel (GridBagLayout layout, int y) { @@ -286,7 +286,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { } class Apogee extends AscentStatus { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.drogue_sense); lights.set(state.drogue_sense > 3.2); } @@ -298,7 +298,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { Apogee apogee; class Main extends AscentStatus { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.main_sense); lights.set(state.main_sense > 3.2); } @@ -310,7 +310,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { Main main; class Lat extends AscentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { if (state.gps != null) show(pos(state.gps.lat,"N", "S")); else @@ -324,7 +324,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { Lat lat; class Lon extends AscentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { if (state.gps != null) show(pos(state.gps.lon,"E", "W")); else @@ -359,25 +359,25 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { accel.set_font(); } - public void show(AltosState state, int crc_errors) { + public void show(AltosState state, AltosListenerState listener_state) { if (state.gps != null && state.gps.connected) { - lat.show(state, crc_errors); - lon.show(state, crc_errors); + lat.show(state, listener_state); + lon.show(state, listener_state); } else { lat.hide(); lon.hide(); } - height.show(state, crc_errors); + height.show(state, listener_state); if (state.main_sense != AltosRecord.MISSING) - main.show(state, crc_errors); + main.show(state, listener_state); else main.hide(); if (state.drogue_sense != AltosRecord.MISSING) - apogee.show(state, crc_errors); + apogee.show(state, listener_state); else apogee.hide(); - speed.show(state, crc_errors); - accel.show(state, crc_errors); + speed.show(state, listener_state); + accel.show(state, listener_state); } public void labels(GridBagLayout layout, int y) { diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 7dd36aec..ebe1d1f9 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -83,7 +83,7 @@ public class AltosCompanionInfo extends JTable { } } - public void show(AltosState state, int crc_errors) { + public void show(AltosState state, AltosListenerState listener_state) { if (state == null) return; if (state.data.companion != null) diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 9838f46b..29d33ddc 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -29,7 +29,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { JTextField value; AltosLights lights; - abstract void show(AltosState state, int crc_errors); + abstract void show(AltosState state, AltosListenerState listener_state); void show() { label.setVisible(true); @@ -108,7 +108,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value.setText(""); } - abstract void show(AltosState state, int crc_errors); + abstract void show(AltosState state, AltosListenerState listener_state); void show() { label.setVisible(true); @@ -192,7 +192,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { value2.setFont(Altos.value_font); } - abstract void show(AltosState state, int crc_errors); + abstract void show(AltosState state, AltosListenerState listener_state); void show(String v1, String v2) { show(); @@ -244,7 +244,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { } class Height extends DescentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.height, state.height); } public Height (GridBagLayout layout, int x, int y) { @@ -255,7 +255,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Height height; class Speed extends DescentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { double speed = state.accel_speed; if (!state.ascent) speed = state.baro_speed; @@ -280,7 +280,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { } class Lat extends DescentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { if (state.gps != null && state.gps.connected) show(pos(state.gps.lat,"N", "S")); else @@ -294,7 +294,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Lat lat; class Lon extends DescentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { if (state.gps != null && state.gps.connected) show(pos(state.gps.lon,"W", "E")); else @@ -308,7 +308,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Lon lon; class Distance extends DescentValue { - void show(AltosState state, int crc_errors) { + void show(AltosState state, AltosListenerState listener_state) { if (state.from_pad != null) show(AltosConvert.distance, state.from_pad.distance); else @@ -324,7 +324,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Apogee extends DescentStatus { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.drogue_sense); lights.set(state.drogue_sense > 3.2); } @@ -336,7 +336,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Apogee apogee; class Main extends DescentStatus { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.main_sense); lights.set(state.main_sense > 3.2); } @@ -348,7 +348,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Main main; class Bearing extends DescentDualValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { if (state.from_pad != null) { show( String.format("%3.0f°", state.from_pad.bearing), state.from_pad.bearing_words( @@ -365,7 +365,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Bearing bearing; class Range extends DescentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.distance, state.range); } public Range (GridBagLayout layout, int x, int y) { @@ -376,7 +376,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { Range range; class Elevation extends DescentValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show("%3.0f°", state.elevation); } public Elevation (GridBagLayout layout, int x, int y) { @@ -412,16 +412,16 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { apogee.set_font(); } - public void show(AltosState state, int crc_errors) { - height.show(state, crc_errors); - speed.show(state, crc_errors); + public void show(AltosState state, AltosListenerState listener_state) { + height.show(state, listener_state); + speed.show(state, listener_state); if (state.gps != null && state.gps.connected) { - bearing.show(state, crc_errors); - range.show(state, crc_errors); - distance.show(state, crc_errors); - elevation.show(state, crc_errors); - lat.show(state, crc_errors); - lon.show(state, crc_errors); + bearing.show(state, listener_state); + range.show(state, listener_state); + distance.show(state, listener_state); + elevation.show(state, listener_state); + lat.show(state, listener_state); + lon.show(state, listener_state); } else { bearing.hide(); range.hide(); @@ -431,11 +431,11 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { lon.hide(); } if (state.main_sense != AltosRecord.MISSING) - main.show(state, crc_errors); + main.show(state, listener_state); else main.hide(); if (state.drogue_sense != AltosRecord.MISSING) - apogee.show(state, crc_errors); + apogee.show(state, listener_state); else apogee.hide(); } diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index 6f8aa9ee..095bed99 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -29,21 +29,17 @@ public class AltosDisplayThread extends Thread { IdleThread idle_thread; AltosVoice voice; AltosFlightReader reader; - int crc_errors; + AltosState old_state, state; + AltosListenerState listener_state; AltosFlightDisplay display; - void show_internal(AltosState state, int crc_errors) { - if (state != null) - display.show(state, crc_errors); - } - - void show_safely(AltosState in_state, int in_crc_errors) { - final AltosState state = in_state; - final int crc_errors = in_crc_errors; + synchronized void show_safely() { + final AltosState my_state = state; + final AltosListenerState my_listener_state = listener_state; Runnable r = new Runnable() { public void run() { try { - show_internal(state, crc_errors); + display.show(my_state, my_listener_state); } catch (Exception ex) { } } @@ -73,7 +69,6 @@ public class AltosDisplayThread extends Thread { class IdleThread extends Thread { boolean started; - private AltosState state; int reported_landing; int report_interval; long report_time; @@ -129,7 +124,7 @@ public class AltosDisplayThread extends Thread { ++reported_landing; if (state.state != Altos.ao_flight_landed) { state.state = Altos.ao_flight_landed; - show_safely(state, 0); + show_safely(); } } } @@ -145,6 +140,10 @@ public class AltosDisplayThread extends Thread { public void run () { try { for (;;) { + if (reader.has_monitor_battery()) { + listener_state.battery = reader.monitor_battery(); + show_safely(); + } set_report_time(); for (;;) { voice.drain(); @@ -155,6 +154,7 @@ public class AltosDisplayThread extends Thread { wait(sleep_time); } } + report(false); } } catch (InterruptedException ie) { @@ -164,18 +164,7 @@ public class AltosDisplayThread extends Thread { } } - public synchronized void notice(AltosState new_state, boolean spoken) { - AltosState old_state = state; - state = new_state; - if (!started && state.state > Altos.ao_flight_pad) { - started = true; - start(); - } - - if (state.state < Altos.ao_flight_drogue) - report_interval = 10000; - else - report_interval = 20000; + public synchronized void notice(boolean spoken) { if (old_state != null && old_state.state != state.state) { report_time = now(); this.notify(); @@ -184,13 +173,12 @@ public class AltosDisplayThread extends Thread { } public IdleThread() { - state = null; reported_landing = 0; report_interval = 10000; } } - boolean tell(AltosState state, AltosState old_state) { + synchronized boolean tell() { boolean ret = false; if (old_state == null || old_state.state != state.state) { voice.speak(state.data.state()); @@ -222,12 +210,10 @@ public class AltosDisplayThread extends Thread { public void run() { boolean interrupted = false; - //String line; - AltosState state = null; - AltosState old_state = null; boolean told; idle_thread = new IdleThread(); + idle_thread.start(); try { for (;;) { @@ -238,14 +224,14 @@ public class AltosDisplayThread extends Thread { old_state = state; state = new AltosState(record, state); reader.update(state); - show_safely(state, crc_errors); - told = tell(state, old_state); - idle_thread.notice(state, told); + show_safely(); + told = tell(); + idle_thread.notice(told); } catch (ParseException pp) { System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage()); } catch (AltosCRCException ce) { - ++crc_errors; - show_safely(state, crc_errors); + ++listener_state.crc_errors; + show_safely(); } } } catch (InterruptedException ee) { @@ -264,6 +250,7 @@ public class AltosDisplayThread extends Thread { } public AltosDisplayThread(Frame in_parent, AltosVoice in_voice, AltosFlightDisplay in_display, AltosFlightReader in_reader) { + listener_state = new AltosListenerState(); parent = in_parent; voice = in_voice; display = in_display; diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java index d1ed7d2f..4f4c158e 100644 --- a/altosui/AltosFlightDisplay.java +++ b/altosui/AltosFlightDisplay.java @@ -22,7 +22,7 @@ import org.altusmetrum.altoslib_1.*; public interface AltosFlightDisplay { void reset(); - void show(AltosState state, int crc_errors); + void show(AltosState state, AltosListenerState listener_state); void set_font(); } diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index 20539a9f..d2910414 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -28,7 +28,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay JLabel label; JTextField value; - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void reset() { value.setText(""); @@ -64,7 +64,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay } class Call extends FlightValue { - void show(AltosState state, int crc_errors) { + void show(AltosState state, AltosListenerState listener_state) { value.setText(state.data.callsign); } public Call (GridBagLayout layout, int x) { @@ -75,8 +75,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay Call call; class Serial extends FlightValue { - void show(AltosState state, int crc_errors) { - value.setText(String.format("%d", state.data.serial)); + void show(AltosState state, AltosListenerState listener_state) { + if (state.data.serial == AltosRecord.MISSING) + value.setText("none"); + else + value.setText(String.format("%d", state.data.serial)); } public Serial (GridBagLayout layout, int x) { super (layout, x, "Serial"); @@ -86,8 +89,11 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay Serial serial; class Flight extends FlightValue { - void show(AltosState state, int crc_errors) { - value.setText(String.format("%d", state.data.flight)); + void show(AltosState state, AltosListenerState listener_state) { + if (state.data.flight == AltosRecord.MISSING) + value.setText("none"); + else + value.setText(String.format("%d", state.data.flight)); } public Flight (GridBagLayout layout, int x) { super (layout, x, "Flight"); @@ -97,7 +103,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay Flight flight; class FlightState extends FlightValue { - void show(AltosState state, int crc_errors) { + void show(AltosState state, AltosListenerState listener_state) { value.setText(state.data.state()); } public FlightState (GridBagLayout layout, int x) { @@ -108,7 +114,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay FlightState flight_state; class RSSI extends FlightValue { - void show(AltosState state, int crc_errors) { + void show(AltosState state, AltosListenerState listener_state) { value.setText(String.format("%d", state.data.rssi)); } public RSSI (GridBagLayout layout, int x) { @@ -119,7 +125,7 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay RSSI rssi; class LastPacket extends FlightValue { - void show(AltosState state, int crc_errors) { + void show(AltosState state, AltosListenerState listener_state) { long secs = (System.currentTimeMillis() - state.report_time + 500) / 1000; value.setText(String.format("%d", secs)); } @@ -148,13 +154,13 @@ public class AltosFlightStatus extends JComponent implements AltosFlightDisplay last_packet.set_font(); } - public void show (AltosState state, int crc_errors) { - call.show(state, crc_errors); - serial.show(state, crc_errors); - flight.show(state, crc_errors); - flight_state.show(state, crc_errors); - rssi.show(state, crc_errors); - last_packet.show(state, crc_errors); + public void show (AltosState state, AltosListenerState listener_state) { + call.show(state, listener_state); + serial.show(state, listener_state); + flight.show(state, listener_state); + flight_state.show(state, listener_state); + rssi.show(state, listener_state); + last_packet.show(state, listener_state); } public int height() { diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index bf679b85..962a08f7 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -22,12 +22,16 @@ import org.altusmetrum.altoslib_1.*; public class AltosFlightStatusUpdate implements ActionListener { - public AltosState saved_state; - AltosFlightStatus flightStatus; + public AltosState saved_state; + public AltosListenerState saved_listener_state; + AltosFlightStatus flightStatus; public void actionPerformed (ActionEvent e) { - if (saved_state != null) - flightStatus.show(saved_state, 0); + if (saved_state != null) { + if (saved_listener_state == null) + saved_listener_state = new AltosListenerState(); + flightStatus.show(saved_state, saved_listener_state); + } } public AltosFlightStatusUpdate (AltosFlightStatus in_flightStatus) { diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index c04a4357..6b258f2e 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -98,11 +98,15 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A AltosFlightStatusUpdate status_update; - public void show(AltosState state, int crc_errors) { + public void show(AltosState state, AltosListenerState listener_state) { status_update.saved_state = state; - JComponent tab = which_tab(state); - try { - pad.show(state, crc_errors); + + if (state == null) { + System.out.printf ("no state provided\n"); + state = new AltosState(new AltosRecord()); + } + + pad.show(state, listener_state); if (state.state != Altos.ao_flight_startup) { if (!has_state) { @@ -114,25 +118,26 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A } } - ascent.show(state, crc_errors); - descent.show(state, crc_errors); - landed.show(state, crc_errors); + ascent.show(state, listener_state); + descent.show(state, listener_state); + landed.show(state, listener_state); + JComponent tab = which_tab(state); if (tab != cur_tab) { if (cur_tab == pane.getSelectedComponent()) { pane.setSelectedComponent(tab); } cur_tab = tab; } - flightStatus.show(state, crc_errors); - flightInfo.show(state, crc_errors); + flightStatus.show(state, listener_state); + flightInfo.show(state, listener_state); if (state.data.companion != null) { if (!has_companion) { pane.add("Companion", companion); has_companion= true; } - companion.show(state, crc_errors); + companion.show(state, listener_state); } else { if (has_companion) { pane.remove(companion); @@ -144,17 +149,13 @@ public class AltosFlightUI extends AltosUIFrame implements AltosFlightDisplay, A pane.add("Site Map", sitemap); has_map = true; } - sitemap.show(state, crc_errors); + sitemap.show(state, listener_state); } else { if (has_map) { pane.remove(sitemap); has_map = false; } } - } catch (Exception e) { - System.out.print("Show exception " + e + "\n"); - e.printStackTrace(); - } } public void set_exit_on_close() { diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index f6e57e7e..d8b8f6dd 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -35,7 +35,7 @@ public class AltosGraphUI extends AltosUIFrame if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) { if (map == null) map = new AltosSiteMap(); - map.show(state, 0); + map.show(state, null); has_gps = true; } } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 8c883eeb..1ef30f0a 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -63,12 +63,12 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl AltosFlightStatusUpdate status_update; - public void show(AltosState state, int crc_errors) { + public void show(AltosState state, AltosListenerState listener_state) { status_update.saved_state = state; try { - pad.show(state, crc_errors); - flightStatus.show(state, crc_errors); - flightInfo.show(state, crc_errors); + pad.show(state, listener_state); + flightStatus.show(state, listener_state); + flightInfo.show(state, listener_state); } catch (Exception e) { System.out.print("Show exception" + e); } @@ -77,7 +77,7 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl public void update(final AltosState state) { Runnable r = new Runnable() { public void run() { - show(state, 0); + show(state, null); } }; SwingUtilities.invokeLater(r); diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 1dce6daf..3d16faf2 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -104,111 +104,118 @@ public class AltosInfoTable extends JTable { model.clear(); } - public void show(AltosState state, int crc_errors) { - if (state == null) - return; + public void show(AltosState state, AltosListenerState listener_state) { info_reset(); - if (state.altitude != AltosRecord.MISSING) - info_add_row(0, "Altitude", "%6.0f m", state.altitude); - if (state.ground_altitude != AltosRecord.MISSING) - info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude); - if (state.height != AltosRecord.MISSING) - info_add_row(0, "Height", "%6.0f m", state.height); - if (state.max_height != AltosRecord.MISSING) - info_add_row(0, "Max height", "%6.0f m", state.max_height); - if (state.acceleration != AltosRecord.MISSING) - info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration); - if (state.max_acceleration != AltosRecord.MISSING) - info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration); - if (state.speed() != AltosRecord.MISSING) - info_add_row(0, "Speed", "%8.1f m/s", state.speed()); - if (state.max_speed() != AltosRecord.MISSING) - info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed); - if (state.temperature != AltosRecord.MISSING) - info_add_row(0, "Temperature", "%9.2f °C", state.temperature); - if (state.battery != AltosRecord.MISSING) - info_add_row(0, "Battery", "%9.2f V", state.battery); - if (state.drogue_sense != AltosRecord.MISSING) - info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense); - if (state.main_sense != AltosRecord.MISSING) - info_add_row(0, "Main", "%9.2f V", state.main_sense); - info_add_row(0, "CRC Errors", "%6d", crc_errors); - - if (state.gps == null || !state.gps.connected) { - info_add_row(1, "GPS", "not available"); - } else { - if (state.gps_ready) - info_add_row(1, "GPS state", "%s", "ready"); - else - info_add_row(1, "GPS state", "wait (%d)", - state.gps_waiting); - if (state.data.gps.locked) - info_add_row(1, "GPS", " locked"); - else if (state.data.gps.connected) - info_add_row(1, "GPS", " unlocked"); - else - info_add_row(1, "GPS", " missing"); - info_add_row(1, "Satellites", "%6d", state.data.gps.nsat); - info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S'); - info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W'); - info_add_row(1, "GPS altitude", "%6d", state.gps.alt); - info_add_row(1, "GPS height", "%6.0f", state.gps_height); - - /* The SkyTraq GPS doesn't report these values */ - /* - if (false) { - info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°", - state.gps.ground_speed, - state.gps.course); - info_add_row(1, "GPS climb rate", "%8.1f m/s", - state.gps.climb_rate); - info_add_row(1, "GPS error", "%6d m(h)%3d m(v)", - state.gps.h_error, state.gps.v_error); - } - */ - - info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop); - - if (state.npad > 0) { - if (state.from_pad != null) { - info_add_row(1, "Distance from pad", "%6d m", - (int) (state.from_pad.distance + 0.5)); - info_add_row(1, "Direction from pad", "%6d°", - (int) (state.from_pad.bearing + 0.5)); - info_add_row(1, "Elevation from pad", "%6d°", - (int) (state.elevation + 0.5)); - info_add_row(1, "Range from pad", "%6d m", - (int) (state.range + 0.5)); - } else { - info_add_row(1, "Distance from pad", "unknown"); - info_add_row(1, "Direction from pad", "unknown"); - info_add_row(1, "Elevation from pad", "unknown"); - info_add_row(1, "Range from pad", "unknown"); + if (state != null) { + if (state.altitude != AltosRecord.MISSING) + info_add_row(0, "Altitude", "%6.0f m", state.altitude); + if (state.ground_altitude != AltosRecord.MISSING) + info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude); + if (state.height != AltosRecord.MISSING) + info_add_row(0, "Height", "%6.0f m", state.height); + if (state.height != AltosRecord.MISSING) + info_add_row(0, "Max height", "%6.0f m", state.max_height); + if (state.acceleration != AltosRecord.MISSING) + info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration); + if (state.acceleration != AltosRecord.MISSING) + info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration); + if (state.speed() != AltosRecord.MISSING) + info_add_row(0, "Speed", "%8.1f m/s", state.speed()); + if (state.speed() != AltosRecord.MISSING) + info_add_row(0, "Max Speed", "%8.1f m/s", state.max_accel_speed); + if (state.temperature != AltosRecord.MISSING) + info_add_row(0, "Temperature", "%9.2f °C", state.temperature); + if (state.battery != AltosRecord.MISSING) + info_add_row(0, "Battery", "%9.2f V", state.battery); + if (state.drogue_sense != AltosRecord.MISSING) + info_add_row(0, "Drogue", "%9.2f V", state.drogue_sense); + if (state.main_sense != AltosRecord.MISSING) + info_add_row(0, "Main", "%9.2f V", state.main_sense); + } + if (listener_state != null) { + info_add_row(0, "CRC Errors", "%6d", listener_state.crc_errors); + + if (listener_state.battery != AltosRecord.MISSING) + info_add_row(0, "Receiver Battery", "%9.2f", listener_state.battery); + } + + if (state != null) { + if (state.gps == null || !state.gps.connected) { + info_add_row(1, "GPS", "not available"); + } else { + if (state.gps_ready) + info_add_row(1, "GPS state", "%s", "ready"); + else + info_add_row(1, "GPS state", "wait (%d)", + state.gps_waiting); + if (state.data.gps.locked) + info_add_row(1, "GPS", " locked"); + else if (state.data.gps.connected) + info_add_row(1, "GPS", " unlocked"); + else + info_add_row(1, "GPS", " missing"); + info_add_row(1, "Satellites", "%6d", state.data.gps.nsat); + info_add_deg(1, "Latitude", state.gps.lat, 'N', 'S'); + info_add_deg(1, "Longitude", state.gps.lon, 'E', 'W'); + info_add_row(1, "GPS altitude", "%6d", state.gps.alt); + info_add_row(1, "GPS height", "%6.0f", state.gps_height); + + /* The SkyTraq GPS doesn't report these values */ + /* + if (false) { + info_add_row(1, "GPS ground speed", "%8.1f m/s %3d°", + state.gps.ground_speed, + state.gps.course); + info_add_row(1, "GPS climb rate", "%8.1f m/s", + state.gps.climb_rate); + info_add_row(1, "GPS error", "%6d m(h)%3d m(v)", + state.gps.h_error, state.gps.v_error); + } + */ + + info_add_row(1, "GPS hdop", "%8.1f", state.gps.hdop); + + if (state.npad > 0) { + if (state.from_pad != null) { + info_add_row(1, "Distance from pad", "%6d m", + (int) (state.from_pad.distance + 0.5)); + info_add_row(1, "Direction from pad", "%6d°", + (int) (state.from_pad.bearing + 0.5)); + info_add_row(1, "Elevation from pad", "%6d°", + (int) (state.elevation + 0.5)); + info_add_row(1, "Range from pad", "%6d m", + (int) (state.range + 0.5)); + } else { + info_add_row(1, "Distance from pad", "unknown"); + info_add_row(1, "Direction from pad", "unknown"); + info_add_row(1, "Elevation from pad", "unknown"); + info_add_row(1, "Range from pad", "unknown"); + } + info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S'); + info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W'); + info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt); } - info_add_deg(1, "Pad latitude", state.pad_lat, 'N', 'S'); - info_add_deg(1, "Pad longitude", state.pad_lon, 'E', 'W'); - info_add_row(1, "Pad GPS alt", "%6.0f m", state.pad_alt); - } - info_add_row(1, "GPS date", "%04d-%02d-%02d", - state.gps.year, - state.gps.month, - state.gps.day); - info_add_row(1, "GPS time", " %02d:%02d:%02d", - state.gps.hour, - state.gps.minute, - state.gps.second); - //int nsat_vis = 0; - int c; - - if (state.gps.cc_gps_sat == null) - info_add_row(2, "Satellites Visible", "%4d", 0); - else { - info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length); - for (c = 0; c < state.gps.cc_gps_sat.length; c++) { - info_add_row(2, "Satellite id,C/N0", - "%4d, %4d", - state.gps.cc_gps_sat[c].svid, - state.gps.cc_gps_sat[c].c_n0); + info_add_row(1, "GPS date", "%04d-%02d-%02d", + state.gps.year, + state.gps.month, + state.gps.day); + info_add_row(1, "GPS time", " %02d:%02d:%02d", + state.gps.hour, + state.gps.minute, + state.gps.second); + //int nsat_vis = 0; + int c; + + if (state.gps.cc_gps_sat == null) + info_add_row(2, "Satellites Visible", "%4d", 0); + else { + info_add_row(2, "Satellites Visible", "%4d", state.gps.cc_gps_sat.length); + for (c = 0; c < state.gps.cc_gps_sat.length; c++) { + info_add_row(2, "Satellite id,C/N0", + "%4d, %4d", + state.gps.cc_gps_sat[c].svid, + state.gps.cc_gps_sat[c].c_n0); + } } } } diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index a245dde3..1d209bda 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -29,7 +29,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio public class LandedValue { JLabel label; JTextField value; - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void reset() { value.setText(""); @@ -102,7 +102,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio } class Lat extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { if (state.gps != null && state.gps.connected) show(pos(state.gps.lat,"N", "S")); else @@ -116,7 +116,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio Lat lat; class Lon extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(); if (state.gps != null && state.gps.connected) show(pos(state.gps.lon,"E", "W")); @@ -131,7 +131,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio Lon lon; class Bearing extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(); if (state.from_pad != null) show("%3.0f°", state.from_pad.bearing); @@ -146,7 +146,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio Bearing bearing; class Distance extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(); if (state.from_pad != null) show(AltosConvert.distance, state.from_pad.distance); @@ -161,7 +161,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio Distance distance; class Height extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.height, state.max_height); } public Height (GridBagLayout layout, int y) { @@ -172,7 +172,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio Height height; class Speed extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.speed, state.max_speed()); } public Speed (GridBagLayout layout, int y) { @@ -183,7 +183,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio Speed speed; class Accel extends LandedValue { - void show (AltosState state, int crc_errors) { + void show (AltosState state, AltosListenerState listener_state) { show(AltosConvert.accel, state.max_acceleration); } public Accel (GridBagLayout layout, int y) { @@ -213,21 +213,21 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio accel.set_font(); } - public void show(AltosState state, int crc_errors) { + public void show(AltosState state, AltosListenerState listener_state) { if (state.gps != null && state.gps.connected) { - bearing.show(state, crc_errors); - distance.show(state, crc_errors); - lat.show(state, crc_errors); - lon.show(state, crc_errors); + bearing.show(state, listener_state); + distance.show(state, listener_state); + lat.show(state, listener_state); + lon.show(state, listener_state); } else { bearing.hide(); distance.hide(); lat.hide(); lon.hide(); } - height.show(state, crc_errors); - speed.show(state, crc_errors); - accel.show(state, crc_errors); + height.show(state, listener_state); + speed.show(state, listener_state); + accel.show(state, listener_state); if (reader.backing_file() != null) graph.setEnabled(true); } diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index eb08525c..e2316a13 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -29,7 +29,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { JTextField value; AltosLights lights; - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void reset() { value.setText(""); @@ -109,7 +109,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { public class LaunchValue { JLabel label; JTextField value; - void show(AltosState state, int crc_errors) {} + void show(AltosState state, AltosListenerState listener_state) {} void show() { label.setVisible(true); @@ -175,8 +175,8 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } class Battery extends LaunchStatus { - void show (AltosState state, int crc_errors) { - if (state.battery == AltosRecord.MISSING) + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.battery == AltosRecord.MISSING) hide(); else { show("%4.2f V", state.battery); @@ -191,9 +191,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { Battery battery; class Apogee extends LaunchStatus { - void show (AltosState state, int crc_errors) { - show("%4.2f V", state.drogue_sense); - lights.set(state.drogue_sense > 3.2); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.drogue_sense == AltosRecord.MISSING) + hide(); + else { + show("%4.2f V", state.drogue_sense); + lights.set(state.drogue_sense > 3.2); + } } public Apogee (GridBagLayout layout, int y) { super(layout, y, "Apogee Igniter Voltage"); @@ -203,9 +207,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { Apogee apogee; class Main extends LaunchStatus { - void show (AltosState state, int crc_errors) { - show("%4.2f V", state.main_sense); - lights.set(state.main_sense > 3.2); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.main_sense == AltosRecord.MISSING) + hide(); + else { + show("%4.2f V", state.main_sense); + lights.set(state.main_sense > 3.2); + } } public Main (GridBagLayout layout, int y) { super(layout, y, "Main Igniter Voltage"); @@ -215,18 +223,21 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { Main main; class LoggingReady extends LaunchStatus { - void show (AltosState state, int crc_errors) { - if (state.data.flight != 0) { - if (state.data.state <= Altos.ao_flight_pad) - show("Ready to record"); - else if (state.data.state < Altos.ao_flight_landed) - show("Recording data"); - else - show("Recorded data"); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.data.flight == AltosRecord.MISSING) { + hide(); + } else { + if (state.data.flight != 0) { + if (state.data.state <= Altos.ao_flight_pad) + show("Ready to record"); + else if (state.data.state < Altos.ao_flight_landed) + show("Recording data"); + else + show("Recorded data"); + } else + show("Storage full"); + lights.set(state.data.flight != 0); } - else - show("Storage full"); - lights.set(state.data.flight != 0); } public LoggingReady (GridBagLayout layout, int y) { super(layout, y, "On-board Data Logging"); @@ -236,9 +247,13 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { LoggingReady logging_ready; class GPSLocked extends LaunchStatus { - void show (AltosState state, int crc_errors) { - show("%4d sats", state.gps.nsat); - lights.set(state.gps.locked && state.gps.nsat >= 4); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.gps == null) + hide(); + else { + show("%4d sats", state.gps.nsat); + lights.set(state.gps.locked && state.gps.nsat >= 4); + } } public GPSLocked (GridBagLayout layout, int y) { super (layout, y, "GPS Locked"); @@ -248,12 +263,16 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { GPSLocked gps_locked; class GPSReady extends LaunchStatus { - void show (AltosState state, int crc_errors) { - if (state.gps_ready) - show("Ready"); - else - show("Waiting %d", state.gps_waiting); - lights.set(state.gps_ready); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.gps == null) + hide(); + else { + if (state.gps_ready) + show("Ready"); + else + show("Waiting %d", state.gps_waiting); + lights.set(state.gps_ready); + } } public GPSReady (GridBagLayout layout, int y) { super (layout, y, "GPS Ready"); @@ -262,6 +281,22 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { GPSReady gps_ready; + class ReceiverBattery extends LaunchStatus { + void show (AltosState state, AltosListenerState listener_state) { + if (listener_state == null || listener_state.battery == AltosRecord.MISSING) + hide(); + else { + show("%4.2f V", listener_state.battery); + lights.set(listener_state.battery > 3.7); + } + } + public ReceiverBattery (GridBagLayout layout, int y) { + super(layout, y, "Receiver Battery"); + } + } + + ReceiverBattery receiver_battery; + String pos(double p, String pos, String neg) { String h = pos; if (p < 0) { @@ -274,13 +309,17 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { } class PadLat extends LaunchValue { - void show (AltosState state, int crc_errors) { - if (state.state < AltosLib.ao_flight_pad && state.gps != null) { - show(pos(state.gps.lat,"N", "S")); - set_label("Latitude"); - } else { - show(pos(state.pad_lat,"N", "S")); - set_label("Pad Latitude"); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.gps == null) { + hide(); + } else { + if (state.state < AltosLib.ao_flight_pad) { + show(pos(state.gps.lat,"N", "S")); + set_label("Latitude"); + } else { + show(pos(state.pad_lat,"N", "S")); + set_label("Pad Latitude"); + } } } public PadLat (GridBagLayout layout, int y) { @@ -291,13 +330,17 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { PadLat pad_lat; class PadLon extends LaunchValue { - void show (AltosState state, int crc_errors) { - if (state.state < AltosLib.ao_flight_pad && state.gps != null) { - show(pos(state.gps.lon,"E", "W")); - set_label("Longitude"); - } else { - show(pos(state.pad_lon,"E", "W")); - set_label("Pad Longitude"); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null || state.gps == null) { + hide(); + } else { + if (state.state < AltosLib.ao_flight_pad) { + show(pos(state.gps.lon,"E", "W")); + set_label("Longitude"); + } else { + show(pos(state.pad_lon,"E", "W")); + set_label("Pad Longitude"); + } } } public PadLon (GridBagLayout layout, int y) { @@ -308,16 +351,20 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { PadLon pad_lon; class PadAlt extends LaunchValue { - void show (AltosState state, int crc_errors) { - if (state.state < AltosLib.ao_flight_pad && state.gps != null) { - show("%4.0f m", state.gps.alt); - set_label("Altitude"); - } else { - if (state.pad_alt == AltosRecord.MISSING) - hide(); - else { - show("%4.0f m", state.pad_alt); - set_label("Pad Altitude"); + void show (AltosState state, AltosListenerState listener_state) { + if (state == null) + hide(); + else { + if (state.state < AltosLib.ao_flight_pad && state.gps != null) { + show("%4.0f m", state.gps.alt); + set_label("Altitude"); + } else { + if (state.pad_alt == AltosRecord.MISSING) + hide(); + else { + show("%4.0f m", state.pad_alt); + set_label("Pad Altitude"); + } } } } @@ -335,6 +382,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { logging_ready.reset(); gps_locked.reset(); gps_ready.reset(); + receiver_battery.reset(); pad_lat.reset(); pad_lon.reset(); pad_alt.reset(); @@ -347,34 +395,23 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { logging_ready.set_font(); gps_locked.set_font(); gps_ready.set_font(); + receiver_battery.set_font(); pad_lat.set_font(); pad_lon.set_font(); pad_alt.set_font(); } - public void show(AltosState state, int crc_errors) { - battery.show(state, crc_errors); - if (state.drogue_sense == AltosRecord.MISSING) - apogee.hide(); - else - apogee.show(state, crc_errors); - if (state.main_sense == AltosRecord.MISSING) - main.hide(); - else - main.show(state, crc_errors); - logging_ready.show(state, crc_errors); - pad_alt.show(state, crc_errors); - if (state.gps != null && state.gps.connected) { - gps_locked.show(state, crc_errors); - gps_ready.show(state, crc_errors); - pad_lat.show(state, crc_errors); - pad_lon.show(state, crc_errors); - } else { - gps_locked.hide(); - gps_ready.hide(); - pad_lat.hide(); - pad_lon.hide(); - } + public void show(AltosState state, AltosListenerState listener_state) { + battery.show(state, listener_state); + apogee.show(state, listener_state); + main.show(state, listener_state); + logging_ready.show(state, listener_state); + pad_alt.show(state, listener_state); + receiver_battery.show(state, listener_state); + gps_locked.show(state, listener_state); + gps_ready.show(state, listener_state); + pad_lat.show(state, listener_state); + pad_lon.show(state, listener_state); } public AltosPad() { @@ -398,8 +435,10 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { logging_ready = new LoggingReady(layout, 3); gps_locked = new GPSLocked(layout, 4); gps_ready = new GPSReady(layout, 5); - pad_lat = new PadLat(layout, 6); - pad_lon = new PadLon(layout, 7); - pad_alt = new PadAlt(layout, 8); + receiver_battery = new ReceiverBattery(layout, 6); + pad_lat = new PadLat(layout, 7); + pad_lon = new PadLon(layout, 8); + pad_alt = new PadAlt(layout, 9); + show(null, null); } } diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index f614eae6..5bf02e54 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -264,7 +264,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { initMaps(lat, lon); scrollRocketToVisible(pt(lat, lon)); } - public void show(final AltosState state, final int crc_errors) { + public void show(final AltosState state, final AltosListenerState listener_state) { // if insufficient gps data, nothing to update if (!state.gps.locked && state.gps.nsat < 4) return; @@ -294,7 +294,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { Point2D.Double ref, lref; ref = translatePoint(pt, tileCoordOffset(offset)); lref = translatePoint(last_pt, tileCoordOffset(offset)); - tile.show(state, crc_errors, lref, ref); + tile.show(state, listener_state, lref, ref); if (0 <= ref.x && ref.x < px_size) if (0 <= ref.y && ref.y < px_size) in_any = true; @@ -307,7 +307,7 @@ public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { lref = translatePoint(last_pt, tileCoordOffset(offset)); AltosSiteMapTile tile = createTile(offset); - tile.show(state, crc_errors, lref, ref); + tile.show(state, listener_state, lref, ref); initMap(offset); finishTileLater(tile, offset); } diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java index 10e65bcd..365e4b6c 100644 --- a/altosui/AltosSiteMapTile.java +++ b/altosui/AltosSiteMapTile.java @@ -56,7 +56,7 @@ public class AltosSiteMapTile extends JLayeredPane { private boolean drawn_landed_circle = false; private boolean drawn_boost_circle = false; - public synchronized void show(AltosState state, int crc_errors, + public synchronized void show(AltosState state, AltosListenerState listener_state, Point2D.Double last_pt, Point2D.Double pt) { if (0 <= state.state && state.state < stateColors.length) { diff --git a/src/core/ao.h b/src/core/ao.h index 6c790f69..977e10b8 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -94,7 +94,7 @@ extern volatile __data AO_TICK_TYPE ao_tick_count; #define AO_SEC_TO_TICKS(s) ((s) * AO_HERTZ) /* Returns the current time in ticks */ -uint16_t +AO_TICK_TYPE ao_time(void); /* Suspend the current task until ticks time has passed */ diff --git a/src/stm/ao_timer.c b/src/stm/ao_timer.c index e07625d8..8b7c2327 100644 --- a/src/stm/ao_timer.c +++ b/src/stm/ao_timer.c @@ -18,15 +18,12 @@ #include "ao.h" #include -volatile __data AO_TICK_TYPE ao_tick_count; +volatile AO_TICK_TYPE ao_tick_count; -uint16_t ao_time(void) +AO_TICK_TYPE +ao_time(void) { - uint16_t v; - ao_arch_critical( - v = ao_tick_count; - ); - return v; + return ao_tick_count; } #if AO_DATA_ALL -- cgit v1.2.3 From 07fb6efc54b8575627572a2113bdbc62914bafb5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 9 Apr 2013 00:38:25 -0700 Subject: altoslib/altosui: Adapt monitor idle to new AltosListenerState Move the receiver battery monitoring to the new spot Signed-off-by: Keith Packard --- altoslib/AltosIdleMonitor.java | 6 ++++-- altoslib/AltosIdleMonitorListener.java | 2 +- altosui/AltosIdleMonitorUI.java | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index ec51b9c1..c379547f 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -29,6 +29,7 @@ public class AltosIdleMonitor extends Thread { double frequency; String callsign; AltosState previous_state; + AltosListenerState listener_state; AltosConfigData config_data; AltosGPS gps; @@ -118,7 +119,7 @@ public class AltosIdleMonitor extends Thread { link.stop_remote(); if (record != null) { record.rssi = link.rssi(); - record.monitor_battery = link.monitor_battery(); + listener_state.battery = link.monitor_battery(); } } else { if (record != null) @@ -139,7 +140,7 @@ public class AltosIdleMonitor extends Thread { } public void post_state() { - listener.update(state); + listener.update(state, listener_state); } public void abort() { @@ -174,5 +175,6 @@ public class AltosIdleMonitor extends Thread { link = in_link; remote = in_remote; state = null; + listener_state = new AltosListenerState(); } } diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index 7f58d61c..27e36dea 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -18,5 +18,5 @@ package org.altusmetrum.altoslib_1; public interface AltosIdleMonitorListener { - public void update(AltosState state); + public void update(AltosState state, AltosListenerState listener_state); } \ No newline at end of file diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 1ef30f0a..bbab017f 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -74,10 +74,10 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl } } - public void update(final AltosState state) { + public void update(final AltosState state, final AltosListenerState listener_state) { Runnable r = new Runnable() { public void run() { - show(state, null); + show(state, listener_state); } }; SwingUtilities.invokeLater(r); -- cgit v1.2.3 From f02bb1df132443fc27b69f23f382ea87e610f533 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 11 Apr 2013 23:56:47 -0700 Subject: altoslib: Add range and elevation to AltosGreatCircle Move the computations from AltosState here so they can be re-used elsewhere. Signed-off-by: Keith Packard --- altoslib/AltosGreatCircle.java | 20 ++++++++++++++++---- altoslib/AltosState.java | 22 ++++++++++------------ 2 files changed, 26 insertions(+), 16 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index 921356a5..f1cf0ae9 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -22,6 +22,8 @@ import java.lang.Math; public class AltosGreatCircle { public double distance; public double bearing; + public double range; + public double elevation; double sqr(double a) { return a * a; } @@ -54,9 +56,8 @@ public class AltosGreatCircle { return bearing_string[length][(int)((bearing / 90 * 8 + 1) / 2)%16]; } - public AltosGreatCircle (double start_lat, double start_lon, - double end_lat, double end_lon) - { + public AltosGreatCircle (double start_lat, double start_lon, double start_alt, + double end_lat, double end_lon, double end_alt) { double lat1 = rad * start_lat; double lon1 = rad * -start_lon; double lat2 = rad * end_lat; @@ -88,14 +89,25 @@ public class AltosGreatCircle { } distance = d * earth_radius; bearing = course * 180/Math.PI; + + double height_diff = end_alt - start_alt; + range = Math.sqrt(distance * distance + height_diff * height_diff); + elevation = Math.atan2(height_diff, distance) * 180 / Math.PI; + } + + public AltosGreatCircle (double start_lat, double start_lon, + double end_lat, double end_lon) { + this(start_lat, start_lon, 0, end_lat, end_lon, 0); } public AltosGreatCircle(AltosGPS start, AltosGPS end) { - this(start.lat, start.lon, end.lat, end.lon); + this(start.lat, start.lon, start.alt, end.lat, end.lon, end.alt); } public AltosGreatCircle() { distance = 0; bearing = 0; + range = 0; + elevation = 0; } } diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index f1bcb1c1..a3b9a8c0 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -248,23 +248,21 @@ public class AltosState { if (height != AltosRecord.MISSING && height > max_height) max_height = height; + elevation = 0; + range = -1; + gps_height = 0; if (data.gps != null) { if (gps == null || !gps.locked || data.gps.locked) gps = data.gps; if (ngps > 0 && gps.locked) { - from_pad = new AltosGreatCircle(pad_lat, pad_lon, gps.lat, gps.lon); - } - } - elevation = 0; - range = -1; - if (ngps > 0) { - gps_height = gps.alt - pad_alt; - if (from_pad != null) { - elevation = Math.atan2(height, from_pad.distance) * 180 / Math.PI; - range = Math.sqrt(height * height + from_pad.distance * from_pad.distance); + double h = height; + + if (h == AltosRecord.MISSING) h = 0; + from_pad = new AltosGreatCircle(pad_lat, pad_lon, 0, gps.lat, gps.lon, h); + elevation = from_pad.elevation; + range = from_pad.range; + gps_height = gps.alt - pad_alt; } - } else { - gps_height = 0; } } -- cgit v1.2.3 From 02243463adbdfb860f69580f544da9026dc7cbd4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Apr 2013 00:55:59 -0700 Subject: altoslib: Remove spurious debug message Signed-off-by: Keith Packard --- altoslib/AltosRecord.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 7046b9f1..07e910eb 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -82,10 +82,8 @@ public class AltosRecord implements Comparable , Cloneable { public double altitude() { double p = pressure(); - if (p == MISSING) { - System.out.printf ("altitude missing\n"); + if (p == MISSING) return MISSING; - } return AltosConvert.pressure_to_altitude(p); } -- cgit v1.2.3 From 1430c48cfef1ef21831205f4fadd26ca6c7f5dbe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Apr 2013 00:55:59 -0700 Subject: altoslib: Remove spurious debug message Signed-off-by: Keith Packard --- altoslib/AltosRecord.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 7046b9f1..07e910eb 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -82,10 +82,8 @@ public class AltosRecord implements Comparable , Cloneable { public double altitude() { double p = pressure(); - if (p == MISSING) { - System.out.printf ("altitude missing\n"); + if (p == MISSING) return MISSING; - } return AltosConvert.pressure_to_altitude(p); } -- cgit v1.2.3 From eba3aa949decacd5592472a3cda920aa6a06d96f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 15 Apr 2013 23:14:22 -0700 Subject: altoslib: Check for null state.gps before accessing it in eeprom records Used to be we'd set state.gps to garbage before seeing the first GPS record; now we leave it null, which will cause crashes for code that doesn't expect it. The code for reading and replaying eeprom data was not checking and was nicely crashing as a result. Signed-off-by: Keith Packard --- altoslib/AltosEepromIterable.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index bc698c80..7a8bbdea 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -131,24 +131,34 @@ public class AltosEepromIterable extends AltosRecordIterable { case AltosLib.AO_LOG_GPS_LAT: eeprom.seen |= AltosRecord.seen_gps_lat; int lat32 = record.a | (record.b << 16); + if (state.gps == null) + state.gps = new AltosGPS(); state.gps.lat = (double) lat32 / 1e7; break; case AltosLib.AO_LOG_GPS_LON: eeprom.seen |= AltosRecord.seen_gps_lon; int lon32 = record.a | (record.b << 16); + if (state.gps == null) + state.gps = new AltosGPS(); state.gps.lon = (double) lon32 / 1e7; break; case AltosLib.AO_LOG_GPS_ALT: + if (state.gps == null) + state.gps = new AltosGPS(); state.gps.alt = record.a; break; case AltosLib.AO_LOG_GPS_SAT: if (state.tick == eeprom.gps_tick) { int svid = record.a; int c_n0 = record.b >> 8; + if (state.gps == null) + state.gps = new AltosGPS(); state.gps.add_sat(svid, c_n0); } break; case AltosLib.AO_LOG_GPS_DATE: + if (state.gps == null) + state.gps = new AltosGPS(); state.gps.year = (record.a & 0xff) + 2000; state.gps.month = record.a >> 8; state.gps.day = record.b & 0xff; -- cgit v1.2.3 From aa7eac32adf4c2cdf441991d02411758f2682d1e Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Mon, 22 Apr 2013 13:00:26 -0600 Subject: name change from MegaMetrum to TeleMega --- altoslib/AltosConfigData.java | 2 +- altoslib/AltosIdleMonitor.java | 4 +- altoslib/AltosLib.java | 6 +- altosui/AltosDataChooser.java | 2 +- altosui/AltosEepromDownload.java | 2 +- altosui/Makefile.am | 2 +- altosui/altos-windows.nsi.in | 2 +- altosuilib/AltosUSBDevice.java | 6 +- ao-bringup/megametrum.cfg | 4 - ao-bringup/megametrum.gdb | 2 - ao-bringup/telemega.cfg | 4 + ao-bringup/telemega.gdb | 2 + debian/docs | 2 +- doc/altos.xsl | 2 +- doc/megametrum-outline.pdf | Bin 4349 -> 0 bytes doc/megametrum-outline.svg | 244 ------------------------ doc/release-notes-1.2.xsl | 2 +- src/Makefile | 2 +- src/core/ao_fec_rx.c | 2 +- src/core/ao_log.h | 2 +- src/core/ao_log_mega.c | 2 +- src/core/ao_telemetry.c | 2 +- src/drivers/ao_companion.c | 2 +- src/megametrum-v0.1/.gitignore | 2 - src/megametrum-v0.1/Makefile | 131 ------------- src/megametrum-v0.1/ao_megametrum.c | 100 ---------- src/megametrum-v0.1/ao_pins.h | 359 ------------------------------------ src/megametrum-v0.1/stlink-pins | 57 ------ src/stm/ao_i2c_stm.c | 2 +- src/telelco-v0.1/Makefile | 2 +- src/test/Makefile | 2 +- src/test/ao_flight_test.c | 22 +-- telemetrum.inf | 8 +- 33 files changed, 46 insertions(+), 939 deletions(-) delete mode 100644 ao-bringup/megametrum.cfg delete mode 100644 ao-bringup/megametrum.gdb create mode 100644 ao-bringup/telemega.cfg create mode 100644 ao-bringup/telemega.gdb delete mode 100644 doc/megametrum-outline.pdf delete mode 100644 doc/megametrum-outline.svg delete mode 100644 src/megametrum-v0.1/.gitignore delete mode 100644 src/megametrum-v0.1/Makefile delete mode 100644 src/megametrum-v0.1/ao_megametrum.c delete mode 100644 src/megametrum-v0.1/ao_pins.h delete mode 100644 src/megametrum-v0.1/stlink-pins (limited to 'altoslib') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 57605607..2ca5a7a5 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -504,7 +504,7 @@ public class AltosConfigData implements Iterable { switch (log_format) { case AltosLib.AO_LOG_FORMAT_FULL: case AltosLib.AO_LOG_FORMAT_TINY: - case AltosLib.AO_LOG_FORMAT_MEGAMETRUM: + case AltosLib.AO_LOG_FORMAT_TELEMEGA: link.printf("l\n"); read_link(link, "done"); default: diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index c379547f..2e4ddef2 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -52,11 +52,11 @@ public class AltosIdleMonitor extends Thread { } boolean has_sensor_mm(AltosConfigData config_data) { - return config_data.product.startsWith("MegaMetrum"); + return config_data.product.startsWith("TeleMega"); } boolean has_gps(AltosConfigData config_data) { - return config_data.product.startsWith("TeleMetrum") || config_data.product.startsWith("MegaMetrum"); + return config_data.product.startsWith("TeleMetrum") || config_data.product.startsWith("TeleMega"); } AltosRecord sensor_mm(AltosConfigData config_data) throws InterruptedException, TimeoutException { diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 0b5475f7..25d17e72 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -50,7 +50,7 @@ public class AltosLib { public static final int AO_LOG_SERIAL_NUMBER = 2002; public static final int AO_LOG_LOG_FORMAT = 2003; - /* Added for header fields in megametrum files */ + /* Added for header fields in telemega files */ public static final int AO_LOG_BARO_RESERVED = 3000; public static final int AO_LOG_BARO_SENS = 3001; public static final int AO_LOG_BARO_OFF = 3002; @@ -89,7 +89,7 @@ public class AltosLib { public final static int product_telelco = 0x0010; public final static int product_telescience = 0x0011; public final static int product_telepyro =0x0012; - public final static int product_megametrum = 0x0023; + public final static int product_telemega = 0x0023; public final static int product_megadongle = 0x0024; public final static int product_telegps = 0x0025; public final static int product_altusmetrum_min = 0x000a; @@ -215,7 +215,7 @@ public class AltosLib { public static final int AO_LOG_FORMAT_TINY = 2; public static final int AO_LOG_FORMAT_TELEMETRY = 3; public static final int AO_LOG_FORMAT_TELESCIENCE = 4; - public static final int AO_LOG_FORMAT_MEGAMETRUM = 5; + public static final int AO_LOG_FORMAT_TELEMEGA = 5; public static final int AO_LOG_FORMAT_NONE = 127; public static boolean isspace(int c) { diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index 7de18afb..f914f138 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -75,7 +75,7 @@ public class AltosDataChooser extends JFileChooser { "eeprom")); setFileFilter(new FileNameExtensionFilter("Telemetry file", "telem")); - setFileFilter(new FileNameExtensionFilter("MegaMetrum eeprom file", + setFileFilter(new FileNameExtensionFilter("TeleMega eeprom file", "mega")); setFileFilter(new FileNameExtensionFilter("Flight data file", "telem", "eeprom", "mega")); diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 801d4ec0..a0523b58 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -366,7 +366,7 @@ public class AltosEepromDownload implements Runnable { extension = "science"; CaptureTeleScience(eechunk); break; - case AltosLib.AO_LOG_FORMAT_MEGAMETRUM: + case AltosLib.AO_LOG_FORMAT_TELEMEGA: extension = "mega"; CaptureMega(eechunk); } diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 96cf77f2..4bfef47c 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -157,7 +157,7 @@ FIRMWARE=$(FIRMWARE_TM) $(FIRMWARE_TELEMINI) $(FIRMWARE_TD) ALTUSMETRUM_DOC=$(top_srcdir)/doc/altusmetrum.pdf ALTOS_DOC=$(top_srcdir)/doc/altos.pdf TELEMETRY_DOC=$(top_srcdir)/doc/telemetry.pdf -TEMPLATE_DOC=$(top_srcdir)/doc/telemetrum-outline.pdf $(top_srcdir)/doc/megametrum-outline.pdf +TEMPLATE_DOC=$(top_srcdir)/doc/telemetrum-outline.pdf $(top_srcdir)/doc/telemega-outline.pdf DOC=$(ALTUSMETRUM_DOC) $(ALTOS_DOC) $(TELEMETRY_DOC) $(TEMPLATE_DOC) diff --git a/altosui/altos-windows.nsi.in b/altosui/altos-windows.nsi.in index cde54b41..9886e4a2 100644 --- a/altosui/altos-windows.nsi.in +++ b/altosui/altos-windows.nsi.in @@ -131,7 +131,7 @@ Section "Documentation" File "../doc/altos.pdf" File "../doc/telemetry.pdf" File "../doc/telemetrum-outline.pdf" - File "../doc/megametrum-outline.pdf" + File "../doc/telemega-outline.pdf" SectionEnd Section "Uninstaller" diff --git a/altosuilib/AltosUSBDevice.java b/altosuilib/AltosUSBDevice.java index 5268927c..0f6cbd10 100644 --- a/altosuilib/AltosUSBDevice.java +++ b/altosuilib/AltosUSBDevice.java @@ -72,11 +72,11 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { return matchProduct(AltosUILib.product_teledongle) || matchProduct(AltosUILib.product_teleterra) || matchProduct(AltosUILib.product_telebt) || - matchProduct(AltosUILib.product_megadongle); + matchProduct(AltosUILib.product_telemega); if (want_product == AltosUILib.product_altimeter) return matchProduct(AltosUILib.product_telemetrum) || - matchProduct(AltosUILib.product_megametrum) || + matchProduct(AltosUILib.product_telemega) || matchProduct(AltosUILib.product_telegps); int have_product = getProduct(); @@ -110,4 +110,4 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { return device_list; } -} \ No newline at end of file +} diff --git a/ao-bringup/megametrum.cfg b/ao-bringup/megametrum.cfg deleted file mode 100644 index e95c6f2b..00000000 --- a/ao-bringup/megametrum.cfg +++ /dev/null @@ -1,4 +0,0 @@ -# openocd config for MegaMetrum using the Olimex ARM-USB-OCD dongle - -source /opt/stm32/share/openocd/scripts/interface/olimex-arm-usb-ocd.cfg -source /opt/stm32/share/openocd/scripts/target/stm32l.cfg diff --git a/ao-bringup/megametrum.gdb b/ao-bringup/megametrum.gdb deleted file mode 100644 index 964ae1f3..00000000 --- a/ao-bringup/megametrum.gdb +++ /dev/null @@ -1,2 +0,0 @@ -target remote localhost:3333 -monitor poll diff --git a/ao-bringup/telemega.cfg b/ao-bringup/telemega.cfg new file mode 100644 index 00000000..f6b96c13 --- /dev/null +++ b/ao-bringup/telemega.cfg @@ -0,0 +1,4 @@ +# openocd config for TeleMega using the Olimex ARM-USB-OCD dongle + +source /opt/stm32/share/openocd/scripts/interface/olimex-arm-usb-ocd.cfg +source /opt/stm32/share/openocd/scripts/target/stm32l.cfg diff --git a/ao-bringup/telemega.gdb b/ao-bringup/telemega.gdb new file mode 100644 index 00000000..964ae1f3 --- /dev/null +++ b/ao-bringup/telemega.gdb @@ -0,0 +1,2 @@ +target remote localhost:3333 +monitor poll diff --git a/debian/docs b/debian/docs index 3ac75ad4..dcdb7763 100644 --- a/debian/docs +++ b/debian/docs @@ -7,4 +7,4 @@ doc/telemetry.pdf doc/altos.html doc/altos.pdf doc/telemetrum-outline.pdf -doc/megametrum-outline.pdf +doc/telemega-outline.pdf diff --git a/doc/altos.xsl b/doc/altos.xsl index c301adde..5af94725 100644 --- a/doc/altos.xsl +++ b/doc/altos.xsl @@ -50,7 +50,7 @@ STM32L series from ST Microelectronics. This ARM Cortex-M3 based microcontroller offers low power consumption and a wide variety of built-in peripherals. Altus Metrum uses - this in the MegaMetrum, MegaDongle and TeleLCO projects. + this in the TeleMega, MegaDongle and TeleLCO projects. diff --git a/doc/megametrum-outline.pdf b/doc/megametrum-outline.pdf deleted file mode 100644 index f8fc26e2..00000000 Binary files a/doc/megametrum-outline.pdf and /dev/null differ diff --git a/doc/megametrum-outline.svg b/doc/megametrum-outline.svg deleted file mode 100644 index e8d74d38..00000000 --- a/doc/megametrum-outline.svg +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UP - - diff --git a/doc/release-notes-1.2.xsl b/doc/release-notes-1.2.xsl index 610fa1a2..b254c7b5 100644 --- a/doc/release-notes-1.2.xsl +++ b/doc/release-notes-1.2.xsl @@ -41,7 +41,7 @@ raised, breaking the Descent tab contents. - Add preliminary MegaMetrum support, including configuration, + Add preliminary TeleMega support, including configuration, data download and analysis. diff --git a/src/Makefile b/src/Makefile index d91a235a..e271ddf3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -29,7 +29,7 @@ AVRDIRS=\ telescience-v0.1 telescience-pwm telepyro-v0.1 micropeak ARMDIRS=\ - megametrum-v0.1 megadongle-v0.1 stm-bringup stm-demo telelco-v0.1 \ + telemega-v0.1 megadongle-v0.1 stm-bringup stm-demo telelco-v0.1 \ telescience-v0.2 ifneq ($(shell which sdcc),) diff --git a/src/core/ao_fec_rx.c b/src/core/ao_fec_rx.c index 072a9e90..c4f5559a 100644 --- a/src/core/ao_fec_rx.c +++ b/src/core/ao_fec_rx.c @@ -18,7 +18,7 @@ #include #include -#ifdef MEGAMETRUM +#ifdef TELEMEGA #include #endif diff --git a/src/core/ao_log.h b/src/core/ao_log.h index cac78771..a68a40dd 100644 --- a/src/core/ao_log.h +++ b/src/core/ao_log.h @@ -43,7 +43,7 @@ extern __pdata enum ao_flight_state ao_log_state; #define AO_LOG_FORMAT_TINY 2 /* two byte state/baro records */ #define AO_LOG_FORMAT_TELEMETRY 3 /* 32 byte ao_telemetry records */ #define AO_LOG_FORMAT_TELESCIENCE 4 /* 32 byte typed telescience records */ -#define AO_LOG_FORMAT_MEGAMETRUM 5 /* 32 byte typed megametrum records */ +#define AO_LOG_FORMAT_TELEMEGA 5 /* 32 byte typed telemega records */ #define AO_LOG_FORMAT_NONE 127 /* No log at all */ extern __code uint8_t ao_log_format; diff --git a/src/core/ao_log_mega.c b/src/core/ao_log_mega.c index ba3f7bfc..abf953a6 100644 --- a/src/core/ao_log_mega.c +++ b/src/core/ao_log_mega.c @@ -23,7 +23,7 @@ static __xdata uint8_t ao_log_mutex; static __xdata struct ao_log_mega log; -__code uint8_t ao_log_format = AO_LOG_FORMAT_MEGAMETRUM; +__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEMEGA; static uint8_t ao_log_csum(__xdata uint8_t *b) __reentrant diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index 3aa315c7..03aa48d8 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -29,7 +29,7 @@ static __pdata uint16_t ao_aprs_time; #include #endif -#if defined(MEGAMETRUM) +#if defined(TELEMEGA) #define AO_SEND_MEGA 1 #endif diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c index 0ebe8429..0f405253 100644 --- a/src/drivers/ao_companion.c +++ b/src/drivers/ao_companion.c @@ -18,7 +18,7 @@ #include #include -#ifdef MEGAMETRUM +#ifdef TELEMEGA #define ao_spi_slow(b) #define ao_spi_fast(b) #endif diff --git a/src/megametrum-v0.1/.gitignore b/src/megametrum-v0.1/.gitignore deleted file mode 100644 index b04d3950..00000000 --- a/src/megametrum-v0.1/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -ao_product.h -megametrum-*.elf diff --git a/src/megametrum-v0.1/Makefile b/src/megametrum-v0.1/Makefile deleted file mode 100644 index a5fdcbb2..00000000 --- a/src/megametrum-v0.1/Makefile +++ /dev/null @@ -1,131 +0,0 @@ -# -# AltOS build -# -# - -include ../stm/Makefile.defs - -INC = \ - ao.h \ - ao_arch.h \ - ao_arch_funcs.h \ - ao_companion.h \ - ao_data.h \ - ao_sample.h \ - ao_pins.h \ - altitude-pa.h \ - ao_kalman.h \ - ao_product.h \ - ao_ms5607.h \ - ao_hmc5883.h \ - ao_mpu6000.h \ - ao_mma655x.h \ - ao_cc1120_CC1120.h \ - ao_profile.h \ - ao_task.h \ - ao_whiten.h \ - ao_sample_profile.h \ - ao_mpu.h \ - stm32l.h \ - Makefile - -# -# Common AltOS sources -# -# ao_hmc5883.c - -#PROFILE=ao_profile.c -#PROFILE_DEF=-DAO_PROFILE=1 - -#SAMPLE_PROFILE=ao_sample_profile.c \ -# ao_sample_profile_timer.c -#SAMPLE_PROFILE_DEF=-DHAS_SAMPLE_PROFILE=1 - -#STACK_GUARD=ao_mpu_stm.c -#STACK_GUARD_DEF=-DHAS_STACK_GUARD=1 - -ALTOS_SRC = \ - ao_interrupt.c \ - ao_product.c \ - ao_romconfig.c \ - ao_cmd.c \ - ao_config.c \ - ao_task.c \ - ao_led.c \ - ao_stdio.c \ - ao_panic.c \ - ao_timer.c \ - ao_mutex.c \ - ao_serial_stm.c \ - ao_gps_skytraq.c \ - ao_gps_report_mega.c \ - ao_ignite.c \ - ao_freq.c \ - ao_dma_stm.c \ - ao_spi_stm.c \ - ao_cc1120.c \ - ao_fec_tx.c \ - ao_fec_rx.c \ - ao_data.c \ - ao_ms5607.c \ - ao_mma655x.c \ - ao_hmc5883.c \ - ao_adc_stm.c \ - ao_beep_stm.c \ - ao_storage.c \ - ao_m25.c \ - ao_usb_stm.c \ - ao_exti_stm.c \ - ao_report.c \ - ao_i2c_stm.c \ - ao_mpu6000.c \ - ao_convert_pa.c \ - ao_log.c \ - ao_log_mega.c \ - ao_sample.c \ - ao_kalman.c \ - ao_flight.c \ - ao_telemetry.c \ - ao_packet_slave.c \ - ao_packet.c \ - ao_companion.c \ - ao_pyro.c \ - ao_aprs.c \ - $(PROFILE) \ - $(SAMPLE_PROFILE) \ - $(STACK_GUARD) - -PRODUCT=MegaMetrum-v0.1 -PRODUCT_DEF=-DMEGAMETRUM -IDPRODUCT=0x0023 - -CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) $(SAMPLE_PROFILE_DEF) $(STACK_GUARD_DEF) -Os -g - -PROGNAME=megametrum-v0.1 -PROG=$(PROGNAME)-$(VERSION).elf - -SRC=$(ALTOS_SRC) ao_megametrum.c -OBJ=$(SRC:.c=.o) - -all: $(PROG) - -$(PROG): Makefile $(OBJ) altos.ld - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(SAT_CLIB) -lgcc - -../altitude-pa.h: make-altitude-pa - nickle $< > $@ - -$(OBJ): $(INC) - -ao_product.h: ao-make-product.5c ../Version - $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ - -distclean: clean - -clean: - rm -f *.o $(PROGNAME)-*.elf - rm -f ao_product.h - -install: - -uninstall: diff --git a/src/megametrum-v0.1/ao_megametrum.c b/src/megametrum-v0.1/ao_megametrum.c deleted file mode 100644 index fbdab64a..00000000 --- a/src/megametrum-v0.1/ao_megametrum.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if HAS_SAMPLE_PROFILE -#include -#endif -#include -#if HAS_STACK_GUARD -#include -#endif - -int -main(void) -{ - ao_clock_init(); - -#if HAS_STACK_GUARD - ao_mpu_init(); -#endif - - ao_task_init(); - ao_serial_init(); - ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); - ao_timer_init(); - - ao_i2c_init(); - ao_spi_init(); - ao_dma_init(); - ao_exti_init(); - - ao_adc_init(); -#if HAS_BEEP - ao_beep_init(); -#endif - ao_cmd_init(); - -#if HAS_MS5607 - ao_ms5607_init(); -#endif -#if HAS_HMC5883 - ao_hmc5883_init(); -#endif -#if HAS_MPU6000 - ao_mpu6000_init(); -#endif -#if HAS_MMA655X - ao_mma655x_init(); -#endif - - ao_storage_init(); - - ao_flight_init(); - ao_log_init(); - ao_report_init(); - - ao_usb_init(); - ao_gps_init(); - ao_gps_report_mega_init(); - ao_telemetry_init(); - ao_radio_init(); - ao_packet_slave_init(FALSE); - ao_igniter_init(); - ao_companion_init(); - ao_pyro_init(); - - ao_config_init(); -#if AO_PROFILE - ao_profile_init(); -#endif -#if HAS_SAMPLE_PROFILE - ao_sample_profile_init(); -#endif - - ao_start_scheduler(); - return 0; -} diff --git a/src/megametrum-v0.1/ao_pins.h b/src/megametrum-v0.1/ao_pins.h deleted file mode 100644 index 4c645871..00000000 --- a/src/megametrum-v0.1/ao_pins.h +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright © 2012 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -#ifndef _AO_PINS_H_ -#define _AO_PINS_H_ - -#define HAS_TASK_QUEUE 1 - -/* 8MHz High speed external crystal */ -#define AO_HSE 8000000 - -/* PLLVCO = 96MHz (so that USB will work) */ -#define AO_PLLMUL 12 -#define AO_RCC_CFGR_PLLMUL (STM_RCC_CFGR_PLLMUL_12) - -/* SYSCLK = 32MHz (no need to go faster than CPU) */ -#define AO_PLLDIV 3 -#define AO_RCC_CFGR_PLLDIV (STM_RCC_CFGR_PLLDIV_3) - -/* HCLK = 32MHz (CPU clock) */ -#define AO_AHB_PRESCALER 1 -#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 - -/* Run APB1 at 16MHz (HCLK/2) */ -#define AO_APB1_PRESCALER 2 -#define AO_RCC_CFGR_PPRE1_DIV STM_RCC_CFGR_PPRE2_DIV_2 - -/* Run APB2 at 16MHz (HCLK/2) */ -#define AO_APB2_PRESCALER 2 -#define AO_RCC_CFGR_PPRE2_DIV STM_RCC_CFGR_PPRE2_DIV_2 - -#define HAS_SERIAL_1 1 -#define USE_SERIAL_1_STDIN 0 -#define SERIAL_1_PB6_PB7 0 -#define SERIAL_1_PA9_PA10 1 - -#define HAS_SERIAL_2 0 -#define USE_SERIAL_2_STDIN 0 -#define SERIAL_2_PA2_PA3 0 -#define SERIAL_2_PD5_PD6 0 - -#define HAS_SERIAL_3 1 -#define USE_SERIAL_3_STDIN 0 -#define SERIAL_3_PB10_PB11 0 -#define SERIAL_3_PC10_PC11 1 -#define SERIAL_3_PD8_PD9 0 - -#define ao_gps_getchar ao_serial3_getchar -#define ao_gps_putchar ao_serial3_putchar -#define ao_gps_set_speed ao_serial3_set_speed -#define ao_gps_fifo (ao_stm_usart3.rx_fifo) - -#define HAS_EEPROM 1 -#define USE_INTERNAL_FLASH 0 -#define HAS_USB 1 -#define HAS_BEEP 1 -#define HAS_RADIO 1 -#define HAS_TELEMETRY 1 -#define HAS_APRS 1 - -#define HAS_SPI_1 1 -#define SPI_1_PA5_PA6_PA7 1 /* Barometer */ -#define SPI_1_PB3_PB4_PB5 0 -#define SPI_1_PE13_PE14_PE15 1 /* Accelerometer */ -#define SPI_1_OSPEEDR STM_OSPEEDR_10MHz - -#define HAS_SPI_2 1 -#define SPI_2_PB13_PB14_PB15 1 /* Flash, Companion */ -#define SPI_2_PD1_PD3_PD4 0 -#define SPI_2_OSPEEDR STM_OSPEEDR_10MHz - -#define SPI_2_PORT (&stm_gpiob) -#define SPI_2_SCK_PIN 13 -#define SPI_2_MISO_PIN 14 -#define SPI_2_MOSI_PIN 15 - -#define HAS_I2C_1 1 -#define I2C_1_PB8_PB9 1 - -#define HAS_I2C_2 1 -#define I2C_2_PB10_PB11 1 - -#define PACKET_HAS_SLAVE 1 -#define PACKET_HAS_MASTER 0 - -#define LOW_LEVEL_DEBUG 0 - -#define LED_PORT_ENABLE STM_RCC_AHBENR_GPIOCEN -#define LED_PORT (&stm_gpioc) -#define LED_PIN_RED 8 -#define LED_PIN_GREEN 9 -#define AO_LED_RED (1 << LED_PIN_RED) -#define AO_LED_GREEN (1 << LED_PIN_GREEN) - -#define LEDS_AVAILABLE (AO_LED_RED | AO_LED_GREEN) - -#define HAS_GPS 1 -#define HAS_FLIGHT 1 -#define HAS_ADC 1 -#define HAS_LOG 1 - -/* - * Igniter - */ - -#define HAS_IGNITE 1 -#define HAS_IGNITE_REPORT 1 - -#define AO_SENSE_DROGUE(p) ((p)->adc.sense[0]) -#define AO_SENSE_MAIN(p) ((p)->adc.sense[1]) -#define AO_IGNITER_CLOSED 400 -#define AO_IGNITER_OPEN 60 - -#define AO_IGNITER_DROGUE_PORT (&stm_gpiod) -#define AO_IGNITER_DROGUE_PIN 6 - -#define AO_IGNITER_MAIN_PORT (&stm_gpiod) -#define AO_IGNITER_MAIN_PIN 7 - -#define AO_PYRO_PORT_0 (&stm_gpiob) -#define AO_PYRO_PIN_0 5 - -#define AO_PYRO_PORT_1 (&stm_gpioe) -#define AO_PYRO_PIN_1 4 - -#define AO_PYRO_PORT_2 (&stm_gpioe) -#define AO_PYRO_PIN_2 6 - -#define AO_PYRO_PORT_3 (&stm_gpioe) -#define AO_PYRO_PIN_3 5 - -/* Number of general purpose pyro channels available */ -#define AO_PYRO_NUM 4 - -#define AO_IGNITER_SET_DROGUE(v) stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v) -#define AO_IGNITER_SET_MAIN(v) stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v) - -/* - * ADC - */ -#define AO_DATA_RING 32 -#define AO_ADC_NUM_SENSE 6 - -struct ao_adc { - int16_t sense[AO_ADC_NUM_SENSE]; - int16_t v_batt; - int16_t v_pbatt; - int16_t accel_ref; - int16_t accel; - int16_t temp; -}; - -#define AO_ADC_SENSE_A 0 -#define AO_ADC_SENSE_A_PORT (&stm_gpioa) -#define AO_ADC_SENSE_A_PIN 0 - -#define AO_ADC_SENSE_B 1 -#define AO_ADC_SENSE_B_PORT (&stm_gpioa) -#define AO_ADC_SENSE_B_PIN 1 - -#define AO_ADC_SENSE_C 2 -#define AO_ADC_SENSE_C_PORT (&stm_gpioa) -#define AO_ADC_SENSE_C_PIN 2 - -#define AO_ADC_SENSE_D 3 -#define AO_ADC_SENSE_D_PORT (&stm_gpioa) -#define AO_ADC_SENSE_D_PIN 3 - -#define AO_ADC_SENSE_E 4 -#define AO_ADC_SENSE_E_PORT (&stm_gpioa) -#define AO_ADC_SENSE_E_PIN 4 - -#define AO_ADC_SENSE_F 22 -#define AO_ADC_SENSE_F_PORT (&stm_gpioe) -#define AO_ADC_SENSE_F_PIN 7 - -#define AO_ADC_V_BATT 8 -#define AO_ADC_V_BATT_PORT (&stm_gpiob) -#define AO_ADC_V_BATT_PIN 0 - -#define AO_ADC_V_PBATT 9 -#define AO_ADC_V_PBATT_PORT (&stm_gpiob) -#define AO_ADC_V_PBATT_PIN 1 - -#define AO_ADC_ACCEL_REF 10 -#define AO_ADC_ACCEL_REF_PORT (&stm_gpioc) -#define AO_ADC_ACCEL_REF_PIN 0 - -#define AO_ADC_ACCEL 11 -#define AO_ADC_ACCEL_PORT (&stm_gpioc) -#define AO_ADC_ACCEL_PIN 1 - -#define AO_ADC_TEMP 16 - -#define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_GPIOAEN) | \ - (1 << STM_RCC_AHBENR_GPIOEEN) | \ - (1 << STM_RCC_AHBENR_GPIOBEN) | \ - (1 << STM_RCC_AHBENR_GPIOCEN)) - -#define AO_NUM_ADC_PIN (AO_ADC_NUM_SENSE + 4) - -#define AO_ADC_PIN0_PORT AO_ADC_SENSE_A_PORT -#define AO_ADC_PIN0_PIN AO_ADC_SENSE_A_PIN -#define AO_ADC_PIN1_PORT AO_ADC_SENSE_B_PORT -#define AO_ADC_PIN1_PIN AO_ADC_SENSE_B_PIN -#define AO_ADC_PIN2_PORT AO_ADC_SENSE_C_PORT -#define AO_ADC_PIN2_PIN AO_ADC_SENSE_C_PIN -#define AO_ADC_PIN3_PORT AO_ADC_SENSE_D_PORT -#define AO_ADC_PIN3_PIN AO_ADC_SENSE_D_PIN -#define AO_ADC_PIN4_PORT AO_ADC_SENSE_E_PORT -#define AO_ADC_PIN4_PIN AO_ADC_SENSE_E_PIN -#define AO_ADC_PIN5_PORT AO_ADC_SENSE_F_PORT -#define AO_ADC_PIN5_PIN AO_ADC_SENSE_F_PIN -#define AO_ADC_PIN6_PORT AO_ADC_V_BATT_PORT -#define AO_ADC_PIN6_PIN AO_ADC_V_BATT_PIN -#define AO_ADC_PIN7_PORT AO_ADC_V_PBATT_PORT -#define AO_ADC_PIN7_PIN AO_ADC_V_PBATT_PIN -#define AO_ADC_PIN8_PORT AO_ADC_ACCEL_REF_PORT -#define AO_ADC_PIN8_PIN AO_ADC_ACCEL_REF_PIN -#define AO_ADC_PIN9_PORT AO_ADC_ACCEL_PORT -#define AO_ADC_PIN9_PIN AO_ADC_ACCEL_PIN - -#define AO_NUM_ADC (AO_ADC_NUM_SENSE + 5) - -#define AO_ADC_SQ1 AO_ADC_SENSE_A -#define AO_ADC_SQ2 AO_ADC_SENSE_B -#define AO_ADC_SQ3 AO_ADC_SENSE_C -#define AO_ADC_SQ4 AO_ADC_SENSE_D -#define AO_ADC_SQ5 AO_ADC_SENSE_E -#define AO_ADC_SQ6 AO_ADC_SENSE_F -#define AO_ADC_SQ7 AO_ADC_V_BATT -#define AO_ADC_SQ8 AO_ADC_V_PBATT -#define AO_ADC_SQ9 AO_ADC_ACCEL_REF -#define AO_ADC_SQ10 AO_ADC_ACCEL -#define AO_ADC_SQ11 AO_ADC_TEMP - -/* - * Pressure sensor settings - */ -#define HAS_MS5607 1 -#define HAS_MS5611 0 -#define AO_MS5607_PRIVATE_PINS 1 -#define AO_MS5607_CS_PORT (&stm_gpioc) -#define AO_MS5607_CS_PIN 4 -#define AO_MS5607_CS_MASK (1 << AO_MS5607_CS) -#define AO_MS5607_MISO_PORT (&stm_gpioa) -#define AO_MS5607_MISO_PIN 6 -#define AO_MS5607_MISO_MASK (1 << AO_MS5607_MISO) -#define AO_MS5607_SPI_INDEX AO_SPI_1_PA5_PA6_PA7 - -/* - * SPI Flash memory - */ - -#define M25_MAX_CHIPS 1 -#define AO_M25_SPI_CS_PORT (&stm_gpiod) -#define AO_M25_SPI_CS_MASK (1 << 3) -#define AO_M25_SPI_BUS AO_SPI_2_PB13_PB14_PB15 - -/* - * Radio (cc1120) - */ - -/* gets pretty close to 434.550 */ - -#define AO_RADIO_CAL_DEFAULT 0x6ca333 - -#define AO_FEC_DEBUG 0 -#define AO_CC1120_SPI_CS_PORT (&stm_gpioc) -#define AO_CC1120_SPI_CS_PIN 5 -#define AO_CC1120_SPI_BUS AO_SPI_2_PB13_PB14_PB15 -#define AO_CC1120_SPI stm_spi2 - -#define AO_CC1120_INT_PORT (&stm_gpioc) -#define AO_CC1120_INT_PIN 14 -#define AO_CC1120_MCU_WAKEUP_PORT (&stm_gpioc) -#define AO_CC1120_MCU_WAKEUP_PIN (0) - -#define AO_CC1120_INT_GPIO 2 -#define AO_CC1120_INT_GPIO_IOCFG CC1120_IOCFG2 - -#define AO_CC1120_MARC_GPIO 3 -#define AO_CC1120_MARC_GPIO_IOCFG CC1120_IOCFG3 - - -#define HAS_BOOT_RADIO 0 - -/* - * Mag sensor (hmc5883) - */ - -#define HAS_HMC5883 0 -#define AO_HMC5883_INT_PORT (&stm_gpioc) -#define AO_HMC5883_INT_PIN 12 -#define AO_HMC5883_I2C_INDEX STM_I2C_INDEX(1) - -/* - * mpu6000 - */ - -#define HAS_MPU6000 1 -#define AO_MPU6000_INT_PORT (&stm_gpioc) -#define AO_MPU6000_INT_PIN 13 -#define AO_MPU6000_I2C_INDEX STM_I2C_INDEX(1) - -#define HAS_HIGHG_ACCEL 0 - -/* - * mma655x - */ - -#define HAS_MMA655X 1 -#define AO_MMA655X_SPI_INDEX AO_SPI_1_PE13_PE14_PE15 -#define AO_MMA655X_CS_PORT (&stm_gpiod) -#define AO_MMA655X_CS_PIN 4 - -#define NUM_CMDS 16 - -/* - * Companion - */ - -#define AO_COMPANION_CS_PORT (&stm_gpiod) -#define AO_COMPANION_CS_PIN (0) -#define AO_COMPANION_SPI_BUS AO_SPI_2_PB13_PB14_PB15 - -/* - * Monitor - */ - -#define HAS_MONITOR 0 -#define LEGACY_MONITOR 0 -#define HAS_MONITOR_PUT 1 -#define AO_MONITOR_LED 0 -#define HAS_RSSI 0 - -/* - * Profiling Viterbi decoding - */ - -#ifndef AO_PROFILE -#define AO_PROFILE 0 -#endif - -#endif /* _AO_PINS_H_ */ diff --git a/src/megametrum-v0.1/stlink-pins b/src/megametrum-v0.1/stlink-pins deleted file mode 100644 index 390f8e5d..00000000 --- a/src/megametrum-v0.1/stlink-pins +++ /dev/null @@ -1,57 +0,0 @@ -ST discovery card pins - -1 AIN-1 -2 JTCK -3 GND -4 JTMS -5 NRST -6 SWO - -MegaMetrum v0.1 misc connector - -1 GND -2 reset_n -3 boot0 -4 tx1 -5 rx1 -6 +3.3V -7 GND -8 jtms -9 jtck -10 jtdi -11 jtdo -12 jntrst -13 sda2 -14 scl2 -15 pe1 -16 pe0 - -For debugging: - - ST MM v0.1 -JTCK 2 9 -GND 3 7 -JTMS 4 8 -NRST 5 2 - -Altus Metrum STM32L standard debug connector (4 pin MicoMaTch): - - TL ST -GND 1 3 -NRST 2 5 -SWDIO 3 4 -SWCLK 4 2 - -Altus Metrum standard 4-pin connector to MegaMetrum v0.1 misc connector: - - AMstd MM v0.1 -gnd 1 1 -nrst 2 2 -swdio 3 8 -swclk 4 9 - -MegaAccel: - -Jumpers -PC0 (pin15) (blue) PE0 (pin97) accel_ref (debug 16) -PC1 (pin16) (green) PE1 (pin98) accel (debug 15) diff --git a/src/stm/ao_i2c_stm.c b/src/stm/ao_i2c_stm.c index 779e2275..809b5c6f 100644 --- a/src/stm/ao_i2c_stm.c +++ b/src/stm/ao_i2c_stm.c @@ -36,7 +36,7 @@ static uint16_t ao_i2c_addr[STM_NUM_I2C]; uint8_t ao_i2c_mutex[STM_NUM_I2C]; # define I2C_HIGH_SLOW 5000 /* ns, 100kHz clock */ -#ifdef MEGAMETRUM +#ifdef TELEMEGA # define I2C_HIGH_FAST 2000 /* ns, 167kHz clock */ #else # define I2C_HIGH_FAST 1000 /* ns, 333kHz clock */ diff --git a/src/telelco-v0.1/Makefile b/src/telelco-v0.1/Makefile index d2702dd6..a4a83d02 100644 --- a/src/telelco-v0.1/Makefile +++ b/src/telelco-v0.1/Makefile @@ -61,7 +61,7 @@ ALTOS_SRC = \ ao_radio_cmac_cmd.c PRODUCT=TeleLCO-v0.1 -PRODUCT_DEF=-DMEGAMETRUM +PRODUCT_DEF=-DTELEMEGA IDPRODUCT=0x0023 CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) -Os -g diff --git a/src/test/Makefile b/src/test/Makefile index 991bdbfc..a62b59c5 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -30,7 +30,7 @@ ao_flight_test_accel: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kal cc $(CFLAGS) -o $@ -DFORCE_ACCEL=1 ao_flight_test.c ao_flight_test_mm: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kalman.c $(INCS) - cc -DMEGAMETRUM=1 $(CFLAGS) -o $@ $< -lm + cc -DTELEMEGA=1 $(CFLAGS) -o $@ $< -lm ao_gps_test: ao_gps_test.c ao_gps_sirf.c ao_gps_print.c ao_host.h cc $(CFLAGS) -o $@ $< diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index cdd1f236..99bed7ee 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -35,7 +35,7 @@ #define AO_MS_TO_SPEED(ms) ((int16_t) ((ms) * 16)) #define AO_MSS_TO_ACCEL(mss) ((int16_t) ((mss) * 16)) -#if MEGAMETRUM +#if TELEMEGA #define AO_ADC_NUM_SENSE 6 #define HAS_MS5607 1 #define HAS_MPU6000 1 @@ -195,7 +195,7 @@ struct ao_cmds { #define ao_xmemcmp(d,s,c) memcmp(d,s,c) #define AO_NEED_ALTITUDE_TO_PRES 1 -#if MEGAMETRUM +#if TELEMEGA #include "ao_convert_pa.c" #include struct ao_ms5607_prom ms5607_prom; @@ -333,7 +333,7 @@ ao_insert(void) #else double accel = 0.0; #endif -#if MEGAMETRUM +#if TELEMEGA double height; ao_ms5607_convert(&ao_data_static.ms5607_raw, &ao_data_static.ms5607_cooked); @@ -373,7 +373,7 @@ ao_insert(void) if (!ao_summary) { printf("%7.2f height %8.2f accel %8.3f " -#if MEGAMETRUM +#if TELEMEGA "roll %8.3f angle %8.3f qangle %8.3f " "accel_x %8.3f accel_y %8.3f accel_z %8.3f gyro_x %8.3f gyro_y %8.3f gyro_z %8.3f " #endif @@ -381,7 +381,7 @@ ao_insert(void) time, height, accel, -#if MEGAMETRUM +#if TELEMEGA ao_mpu6000_gyro(ao_sample_roll_angle) / 100.0, ao_mpu6000_gyro(ao_sample_angle) / 100.0, ao_sample_qangle, @@ -555,7 +555,7 @@ int32(uint8_t *bytes, int off) static int log_format; -#if MEGAMETRUM +#if TELEMEGA static double ao_vec_norm(double x, double y, double z) @@ -774,7 +774,7 @@ ao_sleep(void *wchan) for (;;) { if (ao_records_read > 2 && ao_flight_state == ao_flight_startup) { -#if MEGAMETRUM +#if TELEMEGA ao_data_static.mpu6000 = ao_ground_mpu6000; #else ao_data_static.adc.accel = ao_flight_ground_accel; @@ -800,8 +800,8 @@ ao_sleep(void *wchan) if (words[nword] == NULL) break; } -#if MEGAMETRUM - if (log_format == AO_LOG_FORMAT_MEGAMETRUM && nword == 30 && strlen(words[0]) == 1) { +#if TELEMEGA + if (log_format == AO_LOG_FORMAT_TELEMEGA && nword == 30 && strlen(words[0]) == 1) { int i; struct ao_ms5607_value value; @@ -885,7 +885,7 @@ ao_sleep(void *wchan) continue; } #else - if (nword == 4 && log_format != AO_LOG_FORMAT_MEGAMETRUM) { + if (nword == 4 && log_format != AO_LOG_FORMAT_TELEMEGA) { type = words[0][0]; tick = strtoul(words[1], NULL, 16); a = strtoul(words[2], NULL, 16); @@ -1002,7 +1002,7 @@ ao_sleep(void *wchan) if (type != 'F' && !ao_flight_started) continue; -#if MEGAMETRUM +#if TELEMEGA (void) a; (void) b; #else diff --git a/telemetrum.inf b/telemetrum.inf index 91416bca..386dd286 100755 --- a/telemetrum.inf +++ b/telemetrum.inf @@ -30,7 +30,7 @@ DefaultDestDir = 12 %TeleScience% = AltusMetrum.Install, USB\VID_FFFE&PID_0011, AltusMetrumSerial %TelePyro% = AltusMetrum.Install, USB\VID_FFFE&PID_0012, AltusMetrumSerial %TeleShield% = AltusMetrum.Install, USB\VID_FFFE&PID_0013, AltusMetrumSerial -%MegaMetrum% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial +%TeleMega% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial %MegaDongle = AltusMetrum.Install, USB\VID_FFFE&PID_0024, AltusMetrumSerial %TeleGPS% = AltusMetrum.Install, USB\VID_FFFE&PID_0025, AltusMetrumSerial %AltusMetrum26% = AltusMetrum.Install, USB\VID_FFFE&PID_0026, AltusMetrumSerial @@ -52,7 +52,7 @@ DefaultDestDir = 12 %TeleScience% = AltusMetrum.Install, USB\VID_FFFE&PID_0011, AltusMetrumSerial %TelePyro% = AltusMetrum.Install, USB\VID_FFFE&PID_0012, AltusMetrumSerial %TeleShield% = AltusMetrum.Install, USB\VID_FFFE&PID_0013, AltusMetrumSerial -%MegaMetrum% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial +%TeleMega% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial %MegaDongle = AltusMetrum.Install, USB\VID_FFFE&PID_0024, AltusMetrumSerial %TeleGPS% = AltusMetrum.Install, USB\VID_FFFE&PID_0025, AltusMetrumSerial %AltusMetrum26% = AltusMetrum.Install, USB\VID_FFFE&PID_0026, AltusMetrumSerial @@ -74,7 +74,7 @@ DefaultDestDir = 12 %TeleScience% = AltusMetrum.Install, USB\VID_FFFE&PID_0011, AltusMetrumSerial %TelePyro% = AltusMetrum.Install, USB\VID_FFFE&PID_0012, AltusMetrumSerial %TeleShield% = AltusMetrum.Install, USB\VID_FFFE&PID_0013, AltusMetrumSerial -%MegaMetrum% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial +%TeleMega% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial %MegaDongle = AltusMetrum.Install, USB\VID_FFFE&PID_0024, AltusMetrumSerial %TeleGPS% = AltusMetrum.Install, USB\VID_FFFE&PID_0025, AltusMetrumSerial %AltusMetrum26% = AltusMetrum.Install, USB\VID_FFFE&PID_0026, AltusMetrumSerial @@ -96,7 +96,7 @@ DefaultDestDir = 12 %TeleScience% = AltusMetrum.Install, USB\VID_FFFE&PID_0011, AltusMetrumSerial %TelePyro% = AltusMetrum.Install, USB\VID_FFFE&PID_0012, AltusMetrumSerial %TeleShield% = AltusMetrum.Install, USB\VID_FFFE&PID_0013, AltusMetrumSerial -%MegaMetrum% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial +%TeleMega% = AltusMetrum.Install, USB\VID_FFFE&PID_0023, AltusMetrumSerial %MegaDongle = AltusMetrum.Install, USB\VID_FFFE&PID_0024, AltusMetrumSerial %TeleGPS% = AltusMetrum.Install, USB\VID_FFFE&PID_0025, AltusMetrumSerial %AltusMetrum26% = AltusMetrum.Install, USB\VID_FFFE&PID_0026, AltusMetrumSerial -- cgit v1.2.3 From 6a6a5d0afa646564a9277ad3bd80c4225247a27b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 30 Apr 2013 20:25:20 -0700 Subject: altoslib: Update GPS state even if new state is unlocked Otherwise, we can't see fine GPS details while GPS is unlocked, and that's annoying Signed-off-by: Keith Packard --- altoslib/AltosState.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index a3b9a8c0..ccbe498d 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -252,8 +252,7 @@ public class AltosState { range = -1; gps_height = 0; if (data.gps != null) { - if (gps == null || !gps.locked || data.gps.locked) - gps = data.gps; + gps = data.gps; if (ngps > 0 && gps.locked) { double h = height; -- cgit v1.2.3 From 09e0c304b420a12fa1616005db946523c6e5bef1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 24 Mar 2013 16:01:08 -0700 Subject: altosui & altoslib: Move a pile of debug/programming bits to altoslib Prepare to create external Java utilities to flash devices Signed-off-by: Keith Packard --- altoslib/AltosDebug.java | 280 +++++++++++++++++++++++++++++++++++++++ altoslib/AltosHexfile.java | 298 ++++++++++++++++++++++++++++++++++++++++++ altoslib/AltosRomconfig.java | 148 +++++++++++++++++++++ altoslib/Makefile.am | 3 + altosui/AltosDebug.java | 275 -------------------------------------- altosui/AltosFlash.java | 3 +- altosui/AltosFlashUI.java | 1 + altosui/AltosHexfile.java | 298 ------------------------------------------ altosui/AltosRomconfig.java | 147 --------------------- altosui/AltosRomconfigUI.java | 1 + altosui/Makefile.am | 3 - 11 files changed, 733 insertions(+), 724 deletions(-) create mode 100644 altoslib/AltosDebug.java create mode 100644 altoslib/AltosHexfile.java create mode 100644 altoslib/AltosRomconfig.java delete mode 100644 altosui/AltosDebug.java delete mode 100644 altosui/AltosHexfile.java delete mode 100644 altosui/AltosRomconfig.java (limited to 'altoslib') diff --git a/altoslib/AltosDebug.java b/altoslib/AltosDebug.java new file mode 100644 index 00000000..4d8e3ae7 --- /dev/null +++ b/altoslib/AltosDebug.java @@ -0,0 +1,280 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +import java.io.*; + +public class AltosDebug { + + public static final byte WR_CONFIG = 0x1d; + public static final byte RD_CONFIG = 0x24; + public static final byte CONFIG_TIMERS_OFF = (1 << 3); + public static final byte CONFIG_DMA_PAUSE = (1 << 2); + public static final byte CONFIG_TIMER_SUSPEND = (1 << 1); + public static final byte SET_FLASH_INFO_PAGE = (1 << 0); + + public static final byte GET_PC = 0x28; + public static final byte READ_STATUS = 0x34; + public static final byte STATUS_CHIP_ERASE_DONE = (byte) (1 << 7); + public static final byte STATUS_PCON_IDLE = (1 << 6); + public static final byte STATUS_CPU_HALTED = (1 << 5); + public static final byte STATUS_POWER_MODE_0 = (1 << 4); + public static final byte STATUS_HALT_STATUS = (1 << 3); + public static final byte STATUS_DEBUG_LOCKED = (1 << 2); + public static final byte STATUS_OSCILLATOR_STABLE = (1 << 1); + public static final byte STATUS_STACK_OVERFLOW = (1 << 0); + + public static final byte SET_HW_BRKPNT = 0x3b; + public static byte HW_BRKPNT_N(byte n) { return (byte) ((n) << 3); } + public static final byte HW_BRKPNT_N_MASK = (0x3 << 3); + public static final byte HW_BRKPNT_ENABLE = (1 << 2); + + public static final byte HALT = 0x44; + public static final byte RESUME = 0x4c; + public static byte DEBUG_INSTR(byte n) { return (byte) (0x54|(n)); } + public static final byte STEP_INSTR = 0x5c; + public static byte STEP_REPLACE(byte n) { return (byte) (0x64|(n)); } + public static final byte GET_CHIP_ID = 0x68; + + + AltosLink link; + + boolean debug_mode; + + void ensure_debug_mode() { + if (!debug_mode) { + link.printf("D\n"); + try { + link.flush_input(); + } catch (InterruptedException ie) { + } + debug_mode = true; + } + } + + void dump_memory(String header, int address, byte[] bytes, int start, int len) { + System.out.printf("%s\n", header); + for (int j = 0; j < len; j++) { + if ((j & 15) == 0) { + if (j != 0) + System.out.printf("\n"); + System.out.printf ("%04x:", address + j); + } + System.out.printf(" %02x", bytes[start + j]); + } + System.out.printf("\n"); + } + + public void close() { + link.close(); + } + + /* + * Write target memory + */ + public void write_memory(int address, byte[] bytes, int start, int len) { + ensure_debug_mode(); +// dump_memory("write_memory", address, bytes, start, len); + link.printf("O %x %x\n", len, address); + for (int i = 0; i < len; i++) + link.printf("%02x", bytes[start + i]); + } + + public void write_memory(int address, byte[] bytes) { + write_memory(address, bytes, 0, bytes.length); + } + + /* + * Read target memory + */ + public byte[] read_memory(int address, int length) + throws IOException, InterruptedException { + byte[] data = new byte[length]; + + link.flush_input(); + ensure_debug_mode(); + link.printf("I %x %x\n", length, address); + int i = 0; + int start = 0; + while (i < length) { + String line = link.get_reply().trim(); + if (!AltosLib.ishex(line) || line.length() % 2 != 0) + throw new IOException( + String.format + ("Invalid reply \"%s\"", line)); + int this_time = line.length() / 2; + for (int j = 0; j < this_time; j++) + data[start + j] = (byte) ((AltosLib.fromhex(line.charAt(j*2)) << 4) + + AltosLib.fromhex(line.charAt(j*2+1))); + start += this_time; + i += this_time; + } +// dump_memory("read_memory", address, data, 0, length); + + return data; + } + + /* + * Write raw bytes to the debug link using the 'P' command + */ + public void write_bytes(byte[] bytes) throws IOException { + int i = 0; + ensure_debug_mode(); + while (i < bytes.length) { + int this_time = bytes.length - i; + if (this_time > 8) + this_time = 0; + link.printf("P"); + for (int j = 0; j < this_time; j++) + link.printf(" %02x", bytes[i+j]); + link.printf("\n"); + i += this_time; + } + } + + public void write_byte(byte b) throws IOException { + byte[] bytes = { b }; + write_bytes(bytes); + } + + /* + * Read raw bytes from the debug link using the 'G' command + */ + public byte[] read_bytes(int length) + throws IOException, InterruptedException { + + link.flush_input(); + ensure_debug_mode(); + link.printf("G %x\n", length); + int i = 0; + byte[] data = new byte[length]; + while (i < length) { + String line = link.get_reply(); + + if (line == null) + throw new IOException("Timeout in read_bytes"); + line = line.trim(); + String tokens[] = line.split("\\s+"); + for (int j = 0; j < tokens.length; j++) { + if (!AltosLib.ishex(tokens[j]) || + tokens[j].length() != 2) + throw new IOException( + String.format + ("Invalid read_bytes reply \"%s\"", line)); + try { + if (i + j >= length) + throw new IOException( + String.format + ("Invalid read_bytes reply \"%s\"", line)); + else + data[i + j] = (byte) Integer.parseInt(tokens[j], 16); + } catch (NumberFormatException ne) { + throw new IOException( + String.format + ("Invalid read_bytes reply \"%s\"", line)); + } + } + i += tokens.length; + } + return data; + } + + public byte read_byte() throws IOException, InterruptedException { + return read_bytes(1)[0]; + } + + public byte debug_instr(byte[] instruction) throws IOException, InterruptedException { + byte[] command = new byte[1 + instruction.length]; + command[0] = DEBUG_INSTR((byte) instruction.length); + for (int i = 0; i < instruction.length; i++) + command[i+1] = instruction[i]; + write_bytes(command); + return read_byte(); + } + + public byte resume() throws IOException, InterruptedException { + write_byte(RESUME); + return read_byte(); + } + + public int read_uint16() throws IOException, InterruptedException { + byte[] d = read_bytes(2); + return ((int) (d[0] & 0xff) << 8) | (d[1] & 0xff); + } + + public int read_uint8() throws IOException, InterruptedException { + byte[] d = read_bytes(1); + return (int) (d[0] & 0xff); + } + + public int get_chip_id() throws IOException, InterruptedException { + write_byte(GET_CHIP_ID); + return read_uint16(); + } + + public int get_pc() throws IOException, InterruptedException { + write_byte(GET_PC); + return read_uint16(); + } + + public byte read_status() throws IOException, InterruptedException { + write_byte(READ_STATUS); + return read_byte(); + } + + static final byte LJMP = 0x02; + + public void set_pc(int pc) throws IOException, InterruptedException { + byte high = (byte) (pc >> 8); + byte low = (byte) pc; + byte[] jump_mem = { LJMP, high, low }; + debug_instr(jump_mem); + } + + public boolean check_connection() throws IOException, InterruptedException { + byte reply = read_status(); + if ((reply & STATUS_CHIP_ERASE_DONE) == 0) + return false; + if ((reply & STATUS_PCON_IDLE) != 0) + return false; + if ((reply & STATUS_POWER_MODE_0) == 0) + return false; + return true; + } + + public AltosRomconfig romconfig() { + try { + byte[] bytes = read_memory(0xa0, 10); + return new AltosRomconfig(bytes, 0); + } catch (IOException ie) { + } catch (InterruptedException ie) { + } + return new AltosRomconfig(); + } + + /* + * Reset target + */ + public void reset() { + link.printf ("R\n"); + } + + public AltosDebug (AltosLink link) { + this.link = link; + } +} \ No newline at end of file diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java new file mode 100644 index 00000000..68f42f14 --- /dev/null +++ b/altoslib/AltosHexfile.java @@ -0,0 +1,298 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +import java.io.*; +import java.util.LinkedList; +import java.util.Arrays; + +class HexFileInputStream extends PushbackInputStream { + public int line; + + public HexFileInputStream(FileInputStream o) { + super(new BufferedInputStream(o)); + line = 1; + } + + public int read() throws IOException { + int c = super.read(); + if (c == '\n') + line++; + return c; + } + + public void unread(int c) throws IOException { + if (c == '\n') + line--; + if (c != -1) + super.unread(c); + } +} + +class HexRecord implements Comparable { + public int address; + public int type; + public byte checksum; + public byte[] data; + + static final int NORMAL = 0; + static final int EOF = 1; + static final int EXTENDED_ADDRESS = 2; + + enum read_state { + marker, + length, + address, + type, + data, + checksum, + newline, + white, + done, + } + + boolean ishex(int c) { + if ('0' <= c && c <= '9') + return true; + if ('a' <= c && c <= 'f') + return true; + if ('A' <= c && c <= 'F') + return true; + return false; + } + + boolean isspace(int c) { + switch (c) { + case ' ': + case '\t': + return true; + } + return false; + } + + int fromhex(int c) { + if ('0' <= c && c <= '9') + return c - '0'; + if ('a' <= c && c <= 'f') + return c - 'a' + 10; + if ('A' <= c && c <= 'F') + return c - 'A' + 10; + return -1; + } + + public byte checksum() { + byte got = 0; + + got += data.length; + got += (address >> 8) & 0xff; + got += (address ) & 0xff; + got += type; + for (int i = 0; i < data.length; i++) + got += data[i]; + return (byte) (-got); + } + + public int compareTo(Object other) { + HexRecord o = (HexRecord) other; + return address - o.address; + } + + public String toString() { + return String.format("%04x: %02x (%d)", address, type, data.length); + } + + public HexRecord(HexFileInputStream input) throws IOException { + read_state state = read_state.marker; + int nhexbytes = 0; + int hex = 0; + int ndata = 0; + byte got_checksum; + + while (state != read_state.done) { + int c = input.read(); + if (c < 0 && state != read_state.white) + throw new IOException(String.format("%d: Unexpected EOF", input.line)); + if (c == ' ') + continue; + switch (state) { + case marker: + if (c != ':') + throw new IOException("Missing ':'"); + state = read_state.length; + nhexbytes = 2; + hex = 0; + break; + case length: + case address: + case type: + case data: + case checksum: + if(!ishex(c)) + throw new IOException(String.format("Non-hex char '%c'", c)); + hex = hex << 4 | fromhex(c); + --nhexbytes; + if (nhexbytes != 0) + break; + + switch (state) { + case length: + data = new byte[hex]; + state = read_state.address; + nhexbytes = 4; + break; + case address: + address = hex; + state = read_state.type; + nhexbytes = 2; + break; + case type: + type = hex; + if (data.length > 0) + state = read_state.data; + else + state = read_state.checksum; + nhexbytes = 2; + ndata = 0; + break; + case data: + data[ndata] = (byte) hex; + ndata++; + nhexbytes = 2; + if (ndata == data.length) + state = read_state.checksum; + break; + case checksum: + checksum = (byte) hex; + state = read_state.newline; + break; + default: + break; + } + hex = 0; + break; + case newline: + if (c != '\n' && c != '\r') + throw new IOException("Missing newline"); + state = read_state.white; + break; + case white: + if (!isspace(c)) { + input.unread(c); + state = read_state.done; + } + break; + case done: + break; + } + } + got_checksum = checksum(); + if (got_checksum != checksum) + throw new IOException(String.format("Invalid checksum (read 0x%02x computed 0x%02x)\n", + checksum, got_checksum)); + } +} + +public class AltosHexfile { + public int address; + public byte[] data; + + public byte get_byte(int a) { + return data[a - address]; + } + + public AltosHexfile(FileInputStream file) throws IOException { + HexFileInputStream input = new HexFileInputStream(file); + LinkedList record_list = new LinkedList(); + boolean done = false; + + while (!done) { + HexRecord record = new HexRecord(input); + + if (record.type == HexRecord.EOF) + done = true; + else + record_list.add(record); + } + + long extended_addr = 0; + long base = 0xffffffff; + long bound = 0x00000000; + for (HexRecord record : record_list) { + switch (record.type) { + case 0: + long addr = extended_addr + record.address; + long r_bound = addr + record.data.length; + if (addr < base) + base = addr; + if (r_bound > bound) + bound = r_bound; + break; + case 1: + break; + case 2: + if (record.data.length != 2) + throw new IOException("invalid extended segment address record"); + extended_addr = ((record.data[0] << 8) + (record.data[1])) << 4; + break; + case 4: + if (record.data.length != 2) + throw new IOException("invalid extended segment address record"); + extended_addr = ((record.data[0] << 8) + (record.data[1])) << 16; + break; + default: + throw new IOException ("invalid hex record type"); + } + } + + if (base >= bound) + throw new IOException("invalid hex file"); + + if (bound - base > 4 * 1024 * 1024) + throw new IOException("hex file too large"); + + data = new byte[(int) (bound - base)]; + address = (int) base; + Arrays.fill(data, (byte) 0xff); + + /* Paint the records into the new array */ + for (HexRecord record : record_list) { + switch (record.type) { + case 0: + long addr = extended_addr + record.address; + long r_bound = addr + record.data.length; + for (int j = 0; j < record.data.length; j++) + data[(int) (addr - base) + j] = record.data[j]; + break; + case 1: + break; + case 2: + if (record.data.length != 2) + throw new IOException("invalid extended segment address record"); + extended_addr = ((record.data[0] << 8) + (record.data[1])) << 4; + break; + case 4: + if (record.data.length != 2) + throw new IOException("invalid extended segment address record"); + extended_addr = ((record.data[0] << 8) + (record.data[1])) << 16; + break; + default: + throw new IOException ("invalid hex record type"); + } + } + } +} \ No newline at end of file diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java new file mode 100644 index 00000000..0800a2c4 --- /dev/null +++ b/altoslib/AltosRomconfig.java @@ -0,0 +1,148 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +import java.io.*; + +public class AltosRomconfig { + public boolean valid; + public int version; + public int check; + public int serial_number; + public int radio_calibration; + + static int get_int(byte[] bytes, int start, int len) { + int v = 0; + int o = 0; + while (len > 0) { + v = v | ((((int) bytes[start]) & 0xff) << o); + start++; + len--; + o += 8; + } + return v; + } + + static void put_int(int value, byte[] bytes, int start, int len) { + while (len > 0) { + bytes[start] = (byte) (value & 0xff); + start++; + len--; + value >>= 8; + } + } + + static void put_string(String value, byte[] bytes, int start) { + for (int i = 0; i < value.length(); i++) + bytes[start + i] = (byte) value.charAt(i); + } + + static final int AO_USB_DESC_STRING = 3; + + static void put_usb_serial(int value, byte[] bytes, int start) { + int offset = start + 0xa; + int string_num = 0; + + while (offset < bytes.length && bytes[offset] != 0) { + if (bytes[offset + 1] == AO_USB_DESC_STRING) { + ++string_num; + if (string_num == 4) + break; + } + offset += ((int) bytes[offset]) & 0xff; + } + if (offset >= bytes.length || bytes[offset] == 0) + return; + int len = ((((int) bytes[offset]) & 0xff) - 2) / 2; + String fmt = String.format("%%0%dd", len); + + String s = String.format(fmt, value); + if (s.length() != len) { + System.out.printf("weird usb length issue %s isn't %d\n", + s, len); + return; + } + for (int i = 0; i < len; i++) { + bytes[offset + 2 + i*2] = (byte) s.charAt(i); + bytes[offset + 2 + i*2+1] = 0; + } + } + + public AltosRomconfig(byte[] bytes, int offset) { + version = get_int(bytes, offset + 0, 2); + check = get_int(bytes, offset + 2, 2); + if (check == (~version & 0xffff)) { + switch (version) { + case 2: + case 1: + serial_number = get_int(bytes, offset + 4, 2); + radio_calibration = get_int(bytes, offset + 6, 4); + valid = true; + break; + } + } + } + + public AltosRomconfig(AltosHexfile hexfile) { + this(hexfile.data, 0xa0 - hexfile.address); + } + + public void write(byte[] bytes, int offset) throws IOException { + if (!valid) + throw new IOException("rom configuration invalid"); + + if (offset < 0 || bytes.length < offset + 10) + throw new IOException("image cannot contain rom config"); + + AltosRomconfig existing = new AltosRomconfig(bytes, offset); + if (!existing.valid) + throw new IOException("image does not contain existing rom config"); + + switch (existing.version) { + case 2: + put_usb_serial(serial_number, bytes, offset); + case 1: + put_int(serial_number, bytes, offset + 4, 2); + put_int(radio_calibration, bytes, offset + 6, 4); + break; + } + } + + public void write (AltosHexfile hexfile) throws IOException { + write(hexfile.data, 0xa0 - hexfile.address); + AltosRomconfig check = new AltosRomconfig(hexfile); + if (!check.valid()) + throw new IOException("writing new rom config failed\n"); + } + + public AltosRomconfig(int in_serial_number, int in_radio_calibration) { + valid = true; + version = 1; + check = (~version & 0xffff); + serial_number = in_serial_number; + radio_calibration = in_radio_calibration; + } + + public boolean valid() { + return valid && serial_number != 0; + } + + public AltosRomconfig() { + valid = false; + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 30a9d954..db0236a1 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -16,6 +16,7 @@ altoslib_JAVA = \ AltosConfigValues.java \ AltosConvert.java \ AltosCRCException.java \ + AltosDebug.java \ AltosEepromChunk.java \ AltosEepromIterable.java \ AltosEepromLog.java \ @@ -30,6 +31,7 @@ altoslib_JAVA = \ AltosGPSQuery.java \ AltosGPSSat.java \ AltosGreatCircle.java \ + AltosHexfile.java \ AltosIdleMonitor.java \ AltosIdleMonitorListener.java \ AltosIgnite.java \ @@ -53,6 +55,7 @@ altoslib_JAVA = \ AltosRecordTM.java \ AltosRecordMM.java \ AltosReplayReader.java \ + AltosRomconfig.java \ AltosSensorMM.java \ AltosSensorTM.java \ AltosState.java \ diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java deleted file mode 100644 index c69369ef..00000000 --- a/altosui/AltosDebug.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; - -import java.io.*; -import org.altusmetrum.altosuilib_1.*; - -public class AltosDebug extends AltosSerial { - - public static final byte WR_CONFIG = 0x1d; - public static final byte RD_CONFIG = 0x24; - public static final byte CONFIG_TIMERS_OFF = (1 << 3); - public static final byte CONFIG_DMA_PAUSE = (1 << 2); - public static final byte CONFIG_TIMER_SUSPEND = (1 << 1); - public static final byte SET_FLASH_INFO_PAGE = (1 << 0); - - public static final byte GET_PC = 0x28; - public static final byte READ_STATUS = 0x34; - public static final byte STATUS_CHIP_ERASE_DONE = (byte) (1 << 7); - public static final byte STATUS_PCON_IDLE = (1 << 6); - public static final byte STATUS_CPU_HALTED = (1 << 5); - public static final byte STATUS_POWER_MODE_0 = (1 << 4); - public static final byte STATUS_HALT_STATUS = (1 << 3); - public static final byte STATUS_DEBUG_LOCKED = (1 << 2); - public static final byte STATUS_OSCILLATOR_STABLE = (1 << 1); - public static final byte STATUS_STACK_OVERFLOW = (1 << 0); - - public static final byte SET_HW_BRKPNT = 0x3b; - public static byte HW_BRKPNT_N(byte n) { return (byte) ((n) << 3); } - public static final byte HW_BRKPNT_N_MASK = (0x3 << 3); - public static final byte HW_BRKPNT_ENABLE = (1 << 2); - - public static final byte HALT = 0x44; - public static final byte RESUME = 0x4c; - public static byte DEBUG_INSTR(byte n) { return (byte) (0x54|(n)); } - public static final byte STEP_INSTR = 0x5c; - public static byte STEP_REPLACE(byte n) { return (byte) (0x64|(n)); } - public static final byte GET_CHIP_ID = 0x68; - - - boolean debug_mode; - - void ensure_debug_mode() { - if (!debug_mode) { - printf("D\n"); - try { - flush_input(); - } catch (InterruptedException ie) { - } - debug_mode = true; - } - } - - void dump_memory(String header, int address, byte[] bytes, int start, int len) { - System.out.printf("%s\n", header); - for (int j = 0; j < len; j++) { - if ((j & 15) == 0) { - if (j != 0) - System.out.printf("\n"); - System.out.printf ("%04x:", address + j); - } - System.out.printf(" %02x", bytes[start + j]); - } - System.out.printf("\n"); - } - - /* - * Write target memory - */ - public void write_memory(int address, byte[] bytes, int start, int len) { - ensure_debug_mode(); -// dump_memory("write_memory", address, bytes, start, len); - printf("O %x %x\n", len, address); - for (int i = 0; i < len; i++) - printf("%02x", bytes[start + i]); - } - - public void write_memory(int address, byte[] bytes) { - write_memory(address, bytes, 0, bytes.length); - } - - /* - * Read target memory - */ - public byte[] read_memory(int address, int length) - throws IOException, InterruptedException { - byte[] data = new byte[length]; - - flush_input(); - ensure_debug_mode(); - printf("I %x %x\n", length, address); - int i = 0; - int start = 0; - while (i < length) { - String line = get_reply().trim(); - if (!Altos.ishex(line) || line.length() % 2 != 0) - throw new IOException( - String.format - ("Invalid reply \"%s\"", line)); - int this_time = line.length() / 2; - for (int j = 0; j < this_time; j++) - data[start + j] = (byte) ((Altos.fromhex(line.charAt(j*2)) << 4) + - Altos.fromhex(line.charAt(j*2+1))); - start += this_time; - i += this_time; - } -// dump_memory("read_memory", address, data, 0, length); - - return data; - } - - /* - * Write raw bytes to the debug link using the 'P' command - */ - public void write_bytes(byte[] bytes) throws IOException { - int i = 0; - ensure_debug_mode(); - while (i < bytes.length) { - int this_time = bytes.length - i; - if (this_time > 8) - this_time = 0; - printf("P"); - for (int j = 0; j < this_time; j++) - printf(" %02x", bytes[i+j]); - printf("\n"); - i += this_time; - } - } - - public void write_byte(byte b) throws IOException { - byte[] bytes = { b }; - write_bytes(bytes); - } - - /* - * Read raw bytes from the debug link using the 'G' command - */ - public byte[] read_bytes(int length) - throws IOException, InterruptedException { - - flush_input(); - ensure_debug_mode(); - printf("G %x\n", length); - int i = 0; - byte[] data = new byte[length]; - while (i < length) { - String line = get_reply(); - - if (line == null) - throw new IOException("Timeout in read_bytes"); - line = line.trim(); - String tokens[] = line.split("\\s+"); - for (int j = 0; j < tokens.length; j++) { - if (!Altos.ishex(tokens[j]) || - tokens[j].length() != 2) - throw new IOException( - String.format - ("Invalid read_bytes reply \"%s\"", line)); - try { - if (i + j >= length) - throw new IOException( - String.format - ("Invalid read_bytes reply \"%s\"", line)); - else - data[i + j] = (byte) Integer.parseInt(tokens[j], 16); - } catch (NumberFormatException ne) { - throw new IOException( - String.format - ("Invalid read_bytes reply \"%s\"", line)); - } - } - i += tokens.length; - } - return data; - } - - public byte read_byte() throws IOException, InterruptedException { - return read_bytes(1)[0]; - } - - public byte debug_instr(byte[] instruction) throws IOException, InterruptedException { - byte[] command = new byte[1 + instruction.length]; - command[0] = DEBUG_INSTR((byte) instruction.length); - for (int i = 0; i < instruction.length; i++) - command[i+1] = instruction[i]; - write_bytes(command); - return read_byte(); - } - - public byte resume() throws IOException, InterruptedException { - write_byte(RESUME); - return read_byte(); - } - - public int read_uint16() throws IOException, InterruptedException { - byte[] d = read_bytes(2); - return ((int) (d[0] & 0xff) << 8) | (d[1] & 0xff); - } - - public int read_uint8() throws IOException, InterruptedException { - byte[] d = read_bytes(1); - return (int) (d[0] & 0xff); - } - - public int get_chip_id() throws IOException, InterruptedException { - write_byte(GET_CHIP_ID); - return read_uint16(); - } - - public int get_pc() throws IOException, InterruptedException { - write_byte(GET_PC); - return read_uint16(); - } - - public byte read_status() throws IOException, InterruptedException { - write_byte(READ_STATUS); - return read_byte(); - } - - static final byte LJMP = 0x02; - - public void set_pc(int pc) throws IOException, InterruptedException { - byte high = (byte) (pc >> 8); - byte low = (byte) pc; - byte[] jump_mem = { LJMP, high, low }; - debug_instr(jump_mem); - } - - public boolean check_connection() throws IOException, InterruptedException { - byte reply = read_status(); - if ((reply & STATUS_CHIP_ERASE_DONE) == 0) - return false; - if ((reply & STATUS_PCON_IDLE) != 0) - return false; - if ((reply & STATUS_POWER_MODE_0) == 0) - return false; - return true; - } - - public AltosRomconfig romconfig() { - try { - byte[] bytes = read_memory(0xa0, 10); - return new AltosRomconfig(bytes, 0); - } catch (IOException ie) { - } catch (InterruptedException ie) { - } - return new AltosRomconfig(); - } - - /* - * Reset target - */ - public void reset() { - printf ("R\n"); - } - - public AltosDebug (AltosDevice in_device) throws FileNotFoundException, AltosSerialInUseException { - super(in_device); - } -} \ No newline at end of file diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java index 239d4dd7..b409a611 100644 --- a/altosui/AltosFlash.java +++ b/altosui/AltosFlash.java @@ -20,6 +20,7 @@ package altosui; import java.awt.event.*; import javax.swing.*; import java.io.*; +import org.altusmetrum.altoslib_1.*; import org.altusmetrum.altosuilib_1.*; public class AltosFlash { @@ -362,7 +363,7 @@ public class AltosFlash { file = in_file; debug_dongle = in_debug_dongle; if (debug_dongle != null) - debug = new AltosDebug(in_debug_dongle); + debug = new AltosDebug(new AltosSerial(in_debug_dongle)); input = new FileInputStream(file); image = new AltosHexfile(input); if (debug != null && !debug.check_connection()) { diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index f26a3916..e5176278 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -23,6 +23,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.*; import java.util.concurrent.*; +import org.altusmetrum.altoslib_1.*; import org.altusmetrum.altosuilib_1.*; public class AltosFlashUI diff --git a/altosui/AltosHexfile.java b/altosui/AltosHexfile.java deleted file mode 100644 index 625c5ba1..00000000 --- a/altosui/AltosHexfile.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; - -import java.io.*; -import java.util.LinkedList; -import java.util.Arrays; - -class HexFileInputStream extends PushbackInputStream { - public int line; - - public HexFileInputStream(FileInputStream o) { - super(new BufferedInputStream(o)); - line = 1; - } - - public int read() throws IOException { - int c = super.read(); - if (c == '\n') - line++; - return c; - } - - public void unread(int c) throws IOException { - if (c == '\n') - line--; - if (c != -1) - super.unread(c); - } -} - -class HexRecord implements Comparable { - public int address; - public int type; - public byte checksum; - public byte[] data; - - static final int NORMAL = 0; - static final int EOF = 1; - static final int EXTENDED_ADDRESS = 2; - - enum read_state { - marker, - length, - address, - type, - data, - checksum, - newline, - white, - done, - } - - boolean ishex(int c) { - if ('0' <= c && c <= '9') - return true; - if ('a' <= c && c <= 'f') - return true; - if ('A' <= c && c <= 'F') - return true; - return false; - } - - boolean isspace(int c) { - switch (c) { - case ' ': - case '\t': - return true; - } - return false; - } - - int fromhex(int c) { - if ('0' <= c && c <= '9') - return c - '0'; - if ('a' <= c && c <= 'f') - return c - 'a' + 10; - if ('A' <= c && c <= 'F') - return c - 'A' + 10; - return -1; - } - - public byte checksum() { - byte got = 0; - - got += data.length; - got += (address >> 8) & 0xff; - got += (address ) & 0xff; - got += type; - for (int i = 0; i < data.length; i++) - got += data[i]; - return (byte) (-got); - } - - public int compareTo(Object other) { - HexRecord o = (HexRecord) other; - return address - o.address; - } - - public String toString() { - return String.format("%04x: %02x (%d)", address, type, data.length); - } - - public HexRecord(HexFileInputStream input) throws IOException { - read_state state = read_state.marker; - int nhexbytes = 0; - int hex = 0; - int ndata = 0; - byte got_checksum; - - while (state != read_state.done) { - int c = input.read(); - if (c < 0 && state != read_state.white) - throw new IOException(String.format("%d: Unexpected EOF", input.line)); - if (c == ' ') - continue; - switch (state) { - case marker: - if (c != ':') - throw new IOException("Missing ':'"); - state = read_state.length; - nhexbytes = 2; - hex = 0; - break; - case length: - case address: - case type: - case data: - case checksum: - if(!ishex(c)) - throw new IOException(String.format("Non-hex char '%c'", c)); - hex = hex << 4 | fromhex(c); - --nhexbytes; - if (nhexbytes != 0) - break; - - switch (state) { - case length: - data = new byte[hex]; - state = read_state.address; - nhexbytes = 4; - break; - case address: - address = hex; - state = read_state.type; - nhexbytes = 2; - break; - case type: - type = hex; - if (data.length > 0) - state = read_state.data; - else - state = read_state.checksum; - nhexbytes = 2; - ndata = 0; - break; - case data: - data[ndata] = (byte) hex; - ndata++; - nhexbytes = 2; - if (ndata == data.length) - state = read_state.checksum; - break; - case checksum: - checksum = (byte) hex; - state = read_state.newline; - break; - default: - break; - } - hex = 0; - break; - case newline: - if (c != '\n' && c != '\r') - throw new IOException("Missing newline"); - state = read_state.white; - break; - case white: - if (!isspace(c)) { - input.unread(c); - state = read_state.done; - } - break; - case done: - break; - } - } - got_checksum = checksum(); - if (got_checksum != checksum) - throw new IOException(String.format("Invalid checksum (read 0x%02x computed 0x%02x)\n", - checksum, got_checksum)); - } -} - -public class AltosHexfile { - public int address; - public byte[] data; - - public byte get_byte(int a) { - return data[a - address]; - } - - public AltosHexfile(FileInputStream file) throws IOException { - HexFileInputStream input = new HexFileInputStream(file); - LinkedList record_list = new LinkedList(); - boolean done = false; - - while (!done) { - HexRecord record = new HexRecord(input); - - if (record.type == HexRecord.EOF) - done = true; - else - record_list.add(record); - } - - long extended_addr = 0; - long base = 0xffffffff; - long bound = 0x00000000; - for (HexRecord record : record_list) { - switch (record.type) { - case 0: - long addr = extended_addr + record.address; - long r_bound = addr + record.data.length; - if (addr < base) - base = addr; - if (r_bound > bound) - bound = r_bound; - break; - case 1: - break; - case 2: - if (record.data.length != 2) - throw new IOException("invalid extended segment address record"); - extended_addr = ((record.data[0] << 8) + (record.data[1])) << 4; - break; - case 4: - if (record.data.length != 2) - throw new IOException("invalid extended segment address record"); - extended_addr = ((record.data[0] << 8) + (record.data[1])) << 16; - break; - default: - throw new IOException ("invalid hex record type"); - } - } - - if (base >= bound) - throw new IOException("invalid hex file"); - - if (bound - base > 4 * 1024 * 1024) - throw new IOException("hex file too large"); - - data = new byte[(int) (bound - base)]; - address = (int) base; - Arrays.fill(data, (byte) 0xff); - - /* Paint the records into the new array */ - for (HexRecord record : record_list) { - switch (record.type) { - case 0: - long addr = extended_addr + record.address; - long r_bound = addr + record.data.length; - for (int j = 0; j < record.data.length; j++) - data[(int) (addr - base) + j] = record.data[j]; - break; - case 1: - break; - case 2: - if (record.data.length != 2) - throw new IOException("invalid extended segment address record"); - extended_addr = ((record.data[0] << 8) + (record.data[1])) << 4; - break; - case 4: - if (record.data.length != 2) - throw new IOException("invalid extended segment address record"); - extended_addr = ((record.data[0] << 8) + (record.data[1])) << 16; - break; - default: - throw new IOException ("invalid hex record type"); - } - } - } -} \ No newline at end of file diff --git a/altosui/AltosRomconfig.java b/altosui/AltosRomconfig.java deleted file mode 100644 index 55056b5e..00000000 --- a/altosui/AltosRomconfig.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; -import java.io.*; - -public class AltosRomconfig { - public boolean valid; - public int version; - public int check; - public int serial_number; - public int radio_calibration; - - static int get_int(byte[] bytes, int start, int len) { - int v = 0; - int o = 0; - while (len > 0) { - v = v | ((((int) bytes[start]) & 0xff) << o); - start++; - len--; - o += 8; - } - return v; - } - - static void put_int(int value, byte[] bytes, int start, int len) { - while (len > 0) { - bytes[start] = (byte) (value & 0xff); - start++; - len--; - value >>= 8; - } - } - - static void put_string(String value, byte[] bytes, int start) { - for (int i = 0; i < value.length(); i++) - bytes[start + i] = (byte) value.charAt(i); - } - - static final int AO_USB_DESC_STRING = 3; - - static void put_usb_serial(int value, byte[] bytes, int start) { - int offset = start + 0xa; - int string_num = 0; - - while (offset < bytes.length && bytes[offset] != 0) { - if (bytes[offset + 1] == AO_USB_DESC_STRING) { - ++string_num; - if (string_num == 4) - break; - } - offset += ((int) bytes[offset]) & 0xff; - } - if (offset >= bytes.length || bytes[offset] == 0) - return; - int len = ((((int) bytes[offset]) & 0xff) - 2) / 2; - String fmt = String.format("%%0%dd", len); - - String s = String.format(fmt, value); - if (s.length() != len) { - System.out.printf("weird usb length issue %s isn't %d\n", - s, len); - return; - } - for (int i = 0; i < len; i++) { - bytes[offset + 2 + i*2] = (byte) s.charAt(i); - bytes[offset + 2 + i*2+1] = 0; - } - } - - public AltosRomconfig(byte[] bytes, int offset) { - version = get_int(bytes, offset + 0, 2); - check = get_int(bytes, offset + 2, 2); - if (check == (~version & 0xffff)) { - switch (version) { - case 2: - case 1: - serial_number = get_int(bytes, offset + 4, 2); - radio_calibration = get_int(bytes, offset + 6, 4); - valid = true; - break; - } - } - } - - public AltosRomconfig(AltosHexfile hexfile) { - this(hexfile.data, 0xa0 - hexfile.address); - } - - public void write(byte[] bytes, int offset) throws IOException { - if (!valid) - throw new IOException("rom configuration invalid"); - - if (offset < 0 || bytes.length < offset + 10) - throw new IOException("image cannot contain rom config"); - - AltosRomconfig existing = new AltosRomconfig(bytes, offset); - if (!existing.valid) - throw new IOException("image does not contain existing rom config"); - - switch (existing.version) { - case 2: - put_usb_serial(serial_number, bytes, offset); - case 1: - put_int(serial_number, bytes, offset + 4, 2); - put_int(radio_calibration, bytes, offset + 6, 4); - break; - } - } - - public void write (AltosHexfile hexfile) throws IOException { - write(hexfile.data, 0xa0 - hexfile.address); - AltosRomconfig check = new AltosRomconfig(hexfile); - if (!check.valid()) - throw new IOException("writing new rom config failed\n"); - } - - public AltosRomconfig(int in_serial_number, int in_radio_calibration) { - valid = true; - version = 1; - check = (~version & 0xffff); - serial_number = in_serial_number; - radio_calibration = in_radio_calibration; - } - - public boolean valid() { - return valid && serial_number != 0; - } - - public AltosRomconfig() { - valid = false; - } -} diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index cf4658af..909e72a0 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -20,6 +20,7 @@ package altosui; import java.awt.*; import java.awt.event.*; import javax.swing.*; +import org.altusmetrum.altoslib_1.*; import org.altusmetrum.altosuilib_1.*; public class AltosRomconfigUI diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 4bfef47c..56554697 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -30,7 +30,6 @@ altosui_JAVA = \ AltosConfigTDUI.java \ AltosCSV.java \ AltosCSVUI.java \ - AltosDebug.java \ AltosDescent.java \ AltosDeviceUIDialog.java \ AltosDisplayThread.java \ @@ -50,7 +49,6 @@ altosui_JAVA = \ AltosFlightStatusUpdate.java \ AltosFlightUI.java \ AltosFreqList.java \ - AltosHexfile.java \ Altos.java \ AltosIdleMonitorUI.java \ AltosIgniteUI.java \ @@ -63,7 +61,6 @@ altosui_JAVA = \ AltosLights.java \ AltosPad.java \ AltosUIPreferencesBackend.java \ - AltosRomconfig.java \ AltosRomconfigUI.java \ AltosScanUI.java \ AltosSerial.java \ -- cgit v1.2.3 From 9df4e874b2785aec4aecce2f767543ee9f638b4f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 24 Mar 2013 16:15:21 -0700 Subject: altosui/altoslib: Move more flashing code from altosui to altoslib Required a bit of refactoring to eliminate swing types from the flashing code, but nothing major. Signed-off-by: Keith Packard --- altoslib/AltosFlash.java | 353 ++++++++++++++++++++++++++++++++++++ altoslib/AltosFlashListener.java | 22 +++ altoslib/Makefile.am | 2 + altosui/AltosFlash.java | 374 --------------------------------------- altosui/AltosFlashUI.java | 21 ++- altosui/Makefile.am | 1 - 6 files changed, 395 insertions(+), 378 deletions(-) create mode 100644 altoslib/AltosFlash.java create mode 100644 altoslib/AltosFlashListener.java delete mode 100644 altosui/AltosFlash.java (limited to 'altoslib') diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java new file mode 100644 index 00000000..010274b9 --- /dev/null +++ b/altoslib/AltosFlash.java @@ -0,0 +1,353 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +import java.io.*; + +public class AltosFlash { + File file; + FileInputStream input; + AltosHexfile image; + AltosLink link; + AltosDebug debug; + AltosRomconfig rom_config; + boolean aborted; + AltosFlashListener listener; + + static final byte MOV_direct_data = (byte) 0x75; + static final byte MOV_DPTR_data16 = (byte) 0x90; + static final byte MOV_A_data = (byte) 0x74; + static final byte MOVX_atDPTR_A = (byte) 0xf0; + static final byte MOVX_A_atDPTR = (byte) 0xe0; + static final byte INC_DPTR = (byte) 0xa3; + static final byte TRAP = (byte) 0xa5; + + static final byte JB = (byte) 0x20; + + static final byte MOV_A_direct = (byte) 0xe5; + static final byte MOV_direct1_direct2 = (byte) 0x85; + static final byte MOV_direct_A = (byte) 0xf5; + static final byte MOV_R0_data = (byte) (0x78 | 0); + static final byte MOV_R1_data = (byte) (0x78 | 1); + static final byte MOV_R2_data = (byte) (0x78 | 2); + static final byte MOV_R3_data = (byte) (0x78 | 3); + static final byte MOV_R4_data = (byte) (0x78 | 4); + static final byte MOV_R5_data = (byte) (0x78 | 5); + static final byte MOV_R6_data = (byte) (0x78 | 6); + static final byte MOV_R7_data = (byte) (0x78 | 7); + static final byte DJNZ_R0_rel = (byte) (0xd8 | 0); + static final byte DJNZ_R1_rel = (byte) (0xd8 | 1); + static final byte DJNZ_R2_rel = (byte) (0xd8 | 2); + static final byte DJNZ_R3_rel = (byte) (0xd8 | 3); + static final byte DJNZ_R4_rel = (byte) (0xd8 | 4); + static final byte DJNZ_R5_rel = (byte) (0xd8 | 5); + static final byte DJNZ_R6_rel = (byte) (0xd8 | 6); + static final byte DJNZ_R7_rel = (byte) (0xd8 | 7); + + static final byte P1DIR = (byte) 0xFE; + static final byte P1 = (byte) 0x90; + + /* flash controller */ + static final byte FWT = (byte) 0xAB; + static final byte FADDRL = (byte) 0xAC; + static final byte FADDRH = (byte) 0xAD; + static final byte FCTL = (byte) 0xAE; + static final byte FCTL_BUSY = (byte) 0x80; + static final byte FCTL_BUSY_BIT = (byte) 7; + static final byte FCTL_SWBSY = (byte) 0x40; + static final byte FCTL_SWBSY_BIT = (byte) 6; + static final byte FCTL_CONTRD = (byte) 0x10; + static final byte FCTL_WRITE = (byte) 0x02; + static final byte FCTL_ERASE = (byte) 0x01; + static final byte FWDATA = (byte) 0xAF; + + static final byte ACC = (byte) 0xE0; + + /* offsets within the flash_page program */ + static final int FLASH_ADDR_HIGH = 8; + static final int FLASH_ADDR_LOW = 11; + static final int RAM_ADDR_HIGH = 13; + static final int RAM_ADDR_LOW = 14; + static final int FLASH_WORDS_HIGH = 16; + static final int FLASH_WORDS_LOW = 18; + static final int FLASH_TIMING = 21; + + /* sleep mode control */ + static final int SLEEP = (byte) 0xbe; + static final int SLEEP_USB_EN = (byte) 0x80; + static final int SLEEP_XOSC_STB = (byte) 0x40; + static final int SLEEP_HFRC_STB = (byte) 0x20; + static final int SLEEP_RST_MASK = (byte) 0x18; + static final int SLEEP_RST_POWERON = (byte) 0x00; + static final int SLEEP_RST_EXTERNAL = (byte) 0x10; + static final int SLEEP_RST_WATCHDOG = (byte) 0x08; + static final int SLEEP_OSC_PD = (byte) 0x04; + static final int SLEEP_MODE_MASK = (byte) 0x03; + static final int SLEEP_MODE_PM0 = (byte) 0x00; + static final int SLEEP_MODE_PM1 = (byte) 0x01; + static final int SLEEP_MODE_PM2 = (byte) 0x02; + static final int SLEEP_MODE_PM3 = (byte) 0x03; + + /* clock controller */ + static final byte CLKCON = (byte) 0xC6; + static final byte CLKCON_OSC32K = (byte) 0x80; + static final byte CLKCON_OSC = (byte) 0x40; + static final byte CLKCON_TICKSPD = (byte) 0x38; + static final byte CLKCON_CLKSPD = (byte) 0x07; + + static final byte[] flash_page_proto = { + + MOV_direct_data, P1DIR, (byte) 0x02, + MOV_direct_data, P1, (byte) 0xFF, + + MOV_direct_data, FADDRH, 0, /* FLASH_ADDR_HIGH */ + + MOV_direct_data, FADDRL, 0, /* FLASH_ADDR_LOW */ + + MOV_DPTR_data16, 0, 0, /* RAM_ADDR_HIGH, RAM_ADDR_LOW */ + + MOV_R7_data, 0, /* FLASH_WORDS_HIGH */ + + MOV_R6_data, 0, /* FLASH_WORDS_LOW */ + + + MOV_direct_data, FWT, 0x20, /* FLASH_TIMING */ + + MOV_direct_data, FCTL, FCTL_ERASE, +/* eraseWaitLoop: */ + MOV_A_direct, FCTL, + JB, ACC|FCTL_BUSY_BIT, (byte) 0xfb, + + MOV_direct_data, P1, (byte) 0xfd, + + MOV_direct_data, FCTL, FCTL_WRITE, +/* writeLoop: */ + MOV_R5_data, 2, +/* writeWordLoop: */ + MOVX_A_atDPTR, + INC_DPTR, + MOV_direct_A, FWDATA, + DJNZ_R5_rel, (byte) 0xfa, /* writeWordLoop */ +/* writeWaitLoop: */ + MOV_A_direct, FCTL, + JB, ACC|FCTL_SWBSY_BIT, (byte) 0xfb, /* writeWaitLoop */ + DJNZ_R6_rel, (byte) 0xf1, /* writeLoop */ + DJNZ_R7_rel, (byte) 0xef, /* writeLoop */ + + MOV_direct_data, P1DIR, (byte) 0x00, + MOV_direct_data, P1, (byte) 0xFF, + TRAP, + }; + + public byte[] make_flash_page(int flash_addr, int ram_addr, int byte_count) { + int flash_word_addr = flash_addr >> 1; + int flash_word_count = ((byte_count + 1) >> 1); + + byte[] flash_page = new byte[flash_page_proto.length]; + for (int i = 0; i < flash_page.length; i++) + flash_page[i] = flash_page_proto[i]; + + flash_page[FLASH_ADDR_HIGH] = (byte) (flash_word_addr >> 8); + flash_page[FLASH_ADDR_LOW] = (byte) (flash_word_addr); + flash_page[RAM_ADDR_HIGH] = (byte) (ram_addr >> 8); + flash_page[RAM_ADDR_LOW] = (byte) (ram_addr); + + byte flash_words_low = (byte) (flash_word_count); + byte flash_words_high = (byte) (flash_word_count >> 8); + /* the flashing code has a minor 'bug' */ + if (flash_words_low != 0) + flash_words_high++; + + flash_page[FLASH_WORDS_HIGH] = (byte) flash_words_high; + flash_page[FLASH_WORDS_LOW] = (byte) flash_words_low; + return flash_page; + } + + static byte[] set_clkcon_fast = { + MOV_direct_data, CLKCON, 0x00 + }; + + static byte[] get_sleep = { + MOV_A_direct, SLEEP + }; + + public void clock_init() throws IOException, InterruptedException { + if (debug != null) { + debug.debug_instr(set_clkcon_fast); + + byte status; + for (int times = 0; times < 20; times++) { + Thread.sleep(1); + status = debug.debug_instr(get_sleep); + if ((status & SLEEP_XOSC_STB) != 0) + return; + } + throw new IOException("Failed to initialize target clock"); + } + } + + void action(String s, int percent) { + if (listener != null && !aborted) + listener.position(s, percent); + } + + void action(int part, int total) { + int percent = 100 * part / total; + action(String.format("%d/%d (%d%%)", + part, total, percent), + percent); + } + + void altos_run(int pc) throws IOException, InterruptedException { + debug.set_pc(pc); + int set_pc = debug.get_pc(); + if (pc != set_pc) + throw new IOException("Failed to set target program counter"); + debug.resume(); + + for (int times = 0; times < 20; times++) { + byte status = debug.read_status(); + if ((status & AltosDebug.STATUS_CPU_HALTED) != 0) + return; + } + + throw new IOException("Failed to execute program on target"); + } + + public void flash() { + try { + if (!check_rom_config()) + throw new IOException("Invalid rom config settings"); + if (image.address + image.data.length > 0x8000) + throw new IOException(String.format("Flash image too long %d", + image.address + + image.data.length)); + if ((image.address & 0x3ff) != 0) + throw new IOException(String.format("Flash image must start on page boundary (is 0x%x)", + image.address)); + int ram_address = 0xf000; + int flash_prog = 0xf400; + + /* + * Store desired config values into image + */ + rom_config.write(image); + /* + * Bring up the clock + */ + clock_init(); + + int remain = image.data.length; + int flash_addr = image.address; + int image_start = 0; + + action("start", 0); + action(0, image.data.length); + while (remain > 0 && !aborted) { + int this_time = remain; + if (this_time > 0x400) + this_time = 0x400; + + if (debug != null) { + /* write the data */ + debug.write_memory(ram_address, image.data, + image_start, this_time); + + /* write the flash program */ + byte[] flash_page = make_flash_page(flash_addr, + ram_address, + this_time); + debug.write_memory(flash_prog, flash_page); + + altos_run(flash_prog); + byte[] check = debug.read_memory(flash_addr, this_time); + for (int i = 0; i < this_time; i++) + if (check[i] != image.data[image_start + i]) + throw new IOException(String.format("Flash write failed at 0x%x (%02x != %02x)", + image.address + image_start + i, + check[i], image.data[image_start + i])); + } else { + Thread.sleep(100); + } + + remain -= this_time; + flash_addr += this_time; + image_start += this_time; + + action(image.data.length - remain, image.data.length); + } + if (!aborted) { + action("done", 100); + if (debug != null) { + debug.set_pc(image.address); + debug.resume(); + } + } + if (debug != null) + debug.close(); + } catch (IOException ie) { + action(ie.getMessage(), -1); + abort(); + } catch (InterruptedException ie) { + abort(); + } + } + + public void close() { + if (debug != null) + debug.close(); + } + + synchronized public void abort() { + aborted = true; + close(); + } + + public boolean check_rom_config() { + if (debug == null) + return true; + if (rom_config == null) + rom_config = debug.romconfig(); + return rom_config != null && rom_config.valid(); + } + + public void set_romconfig (AltosRomconfig romconfig) { + rom_config = romconfig; + } + + public AltosRomconfig romconfig() { + if (!check_rom_config()) + return null; + return rom_config; + } + + public AltosFlash(File file, AltosLink link, AltosFlashListener listener) + throws IOException, FileNotFoundException, InterruptedException { + this.file = file; + this.link = link; + this.listener = listener; + if (link != null) + debug = new AltosDebug(link); + input = new FileInputStream(file); + image = new AltosHexfile(input); + if (debug != null && !debug.check_connection()) { + debug.close(); + throw new IOException("Debug port not connected"); + } + } +} \ No newline at end of file diff --git a/altoslib/AltosFlashListener.java b/altoslib/AltosFlashListener.java new file mode 100644 index 00000000..ab50b74a --- /dev/null +++ b/altoslib/AltosFlashListener.java @@ -0,0 +1,22 @@ +/* + * Copyright © 2013 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_1; + +public interface AltosFlashListener { + public void position(String label, int percent); +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index db0236a1..18b028d6 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -25,6 +25,8 @@ altoslib_JAVA = \ AltosEepromRecord.java \ AltosEepromTeleScience.java \ AltosFile.java \ + AltosFlash.java \ + AltosFlashListener.java \ AltosFlightReader.java \ AltosFrequency.java \ AltosGPS.java \ diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java deleted file mode 100644 index b409a611..00000000 --- a/altosui/AltosFlash.java +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; - -import java.awt.event.*; -import javax.swing.*; -import java.io.*; -import org.altusmetrum.altoslib_1.*; -import org.altusmetrum.altosuilib_1.*; - -public class AltosFlash { - File file; - FileInputStream input; - AltosHexfile image; - JFrame frame; - AltosDevice debug_dongle; - AltosDebug debug; - AltosRomconfig rom_config; - ActionListener listener; - boolean aborted; - - static final byte MOV_direct_data = (byte) 0x75; - static final byte MOV_DPTR_data16 = (byte) 0x90; - static final byte MOV_A_data = (byte) 0x74; - static final byte MOVX_atDPTR_A = (byte) 0xf0; - static final byte MOVX_A_atDPTR = (byte) 0xe0; - static final byte INC_DPTR = (byte) 0xa3; - static final byte TRAP = (byte) 0xa5; - - static final byte JB = (byte) 0x20; - - static final byte MOV_A_direct = (byte) 0xe5; - static final byte MOV_direct1_direct2 = (byte) 0x85; - static final byte MOV_direct_A = (byte) 0xf5; - static final byte MOV_R0_data = (byte) (0x78 | 0); - static final byte MOV_R1_data = (byte) (0x78 | 1); - static final byte MOV_R2_data = (byte) (0x78 | 2); - static final byte MOV_R3_data = (byte) (0x78 | 3); - static final byte MOV_R4_data = (byte) (0x78 | 4); - static final byte MOV_R5_data = (byte) (0x78 | 5); - static final byte MOV_R6_data = (byte) (0x78 | 6); - static final byte MOV_R7_data = (byte) (0x78 | 7); - static final byte DJNZ_R0_rel = (byte) (0xd8 | 0); - static final byte DJNZ_R1_rel = (byte) (0xd8 | 1); - static final byte DJNZ_R2_rel = (byte) (0xd8 | 2); - static final byte DJNZ_R3_rel = (byte) (0xd8 | 3); - static final byte DJNZ_R4_rel = (byte) (0xd8 | 4); - static final byte DJNZ_R5_rel = (byte) (0xd8 | 5); - static final byte DJNZ_R6_rel = (byte) (0xd8 | 6); - static final byte DJNZ_R7_rel = (byte) (0xd8 | 7); - - static final byte P1DIR = (byte) 0xFE; - static final byte P1 = (byte) 0x90; - - /* flash controller */ - static final byte FWT = (byte) 0xAB; - static final byte FADDRL = (byte) 0xAC; - static final byte FADDRH = (byte) 0xAD; - static final byte FCTL = (byte) 0xAE; - static final byte FCTL_BUSY = (byte) 0x80; - static final byte FCTL_BUSY_BIT = (byte) 7; - static final byte FCTL_SWBSY = (byte) 0x40; - static final byte FCTL_SWBSY_BIT = (byte) 6; - static final byte FCTL_CONTRD = (byte) 0x10; - static final byte FCTL_WRITE = (byte) 0x02; - static final byte FCTL_ERASE = (byte) 0x01; - static final byte FWDATA = (byte) 0xAF; - - static final byte ACC = (byte) 0xE0; - - /* offsets within the flash_page program */ - static final int FLASH_ADDR_HIGH = 8; - static final int FLASH_ADDR_LOW = 11; - static final int RAM_ADDR_HIGH = 13; - static final int RAM_ADDR_LOW = 14; - static final int FLASH_WORDS_HIGH = 16; - static final int FLASH_WORDS_LOW = 18; - static final int FLASH_TIMING = 21; - - /* sleep mode control */ - static final int SLEEP = (byte) 0xbe; - static final int SLEEP_USB_EN = (byte) 0x80; - static final int SLEEP_XOSC_STB = (byte) 0x40; - static final int SLEEP_HFRC_STB = (byte) 0x20; - static final int SLEEP_RST_MASK = (byte) 0x18; - static final int SLEEP_RST_POWERON = (byte) 0x00; - static final int SLEEP_RST_EXTERNAL = (byte) 0x10; - static final int SLEEP_RST_WATCHDOG = (byte) 0x08; - static final int SLEEP_OSC_PD = (byte) 0x04; - static final int SLEEP_MODE_MASK = (byte) 0x03; - static final int SLEEP_MODE_PM0 = (byte) 0x00; - static final int SLEEP_MODE_PM1 = (byte) 0x01; - static final int SLEEP_MODE_PM2 = (byte) 0x02; - static final int SLEEP_MODE_PM3 = (byte) 0x03; - - /* clock controller */ - static final byte CLKCON = (byte) 0xC6; - static final byte CLKCON_OSC32K = (byte) 0x80; - static final byte CLKCON_OSC = (byte) 0x40; - static final byte CLKCON_TICKSPD = (byte) 0x38; - static final byte CLKCON_CLKSPD = (byte) 0x07; - - static final byte[] flash_page_proto = { - - MOV_direct_data, P1DIR, (byte) 0x02, - MOV_direct_data, P1, (byte) 0xFF, - - MOV_direct_data, FADDRH, 0, /* FLASH_ADDR_HIGH */ - - MOV_direct_data, FADDRL, 0, /* FLASH_ADDR_LOW */ - - MOV_DPTR_data16, 0, 0, /* RAM_ADDR_HIGH, RAM_ADDR_LOW */ - - MOV_R7_data, 0, /* FLASH_WORDS_HIGH */ - - MOV_R6_data, 0, /* FLASH_WORDS_LOW */ - - - MOV_direct_data, FWT, 0x20, /* FLASH_TIMING */ - - MOV_direct_data, FCTL, FCTL_ERASE, -/* eraseWaitLoop: */ - MOV_A_direct, FCTL, - JB, ACC|FCTL_BUSY_BIT, (byte) 0xfb, - - MOV_direct_data, P1, (byte) 0xfd, - - MOV_direct_data, FCTL, FCTL_WRITE, -/* writeLoop: */ - MOV_R5_data, 2, -/* writeWordLoop: */ - MOVX_A_atDPTR, - INC_DPTR, - MOV_direct_A, FWDATA, - DJNZ_R5_rel, (byte) 0xfa, /* writeWordLoop */ -/* writeWaitLoop: */ - MOV_A_direct, FCTL, - JB, ACC|FCTL_SWBSY_BIT, (byte) 0xfb, /* writeWaitLoop */ - DJNZ_R6_rel, (byte) 0xf1, /* writeLoop */ - DJNZ_R7_rel, (byte) 0xef, /* writeLoop */ - - MOV_direct_data, P1DIR, (byte) 0x00, - MOV_direct_data, P1, (byte) 0xFF, - TRAP, - }; - - public byte[] make_flash_page(int flash_addr, int ram_addr, int byte_count) { - int flash_word_addr = flash_addr >> 1; - int flash_word_count = ((byte_count + 1) >> 1); - - byte[] flash_page = new byte[flash_page_proto.length]; - for (int i = 0; i < flash_page.length; i++) - flash_page[i] = flash_page_proto[i]; - - flash_page[FLASH_ADDR_HIGH] = (byte) (flash_word_addr >> 8); - flash_page[FLASH_ADDR_LOW] = (byte) (flash_word_addr); - flash_page[RAM_ADDR_HIGH] = (byte) (ram_addr >> 8); - flash_page[RAM_ADDR_LOW] = (byte) (ram_addr); - - byte flash_words_low = (byte) (flash_word_count); - byte flash_words_high = (byte) (flash_word_count >> 8); - /* the flashing code has a minor 'bug' */ - if (flash_words_low != 0) - flash_words_high++; - - flash_page[FLASH_WORDS_HIGH] = (byte) flash_words_high; - flash_page[FLASH_WORDS_LOW] = (byte) flash_words_low; - return flash_page; - } - - static byte[] set_clkcon_fast = { - MOV_direct_data, CLKCON, 0x00 - }; - - static byte[] get_sleep = { - MOV_A_direct, SLEEP - }; - - public void clock_init() throws IOException, InterruptedException { - if (debug != null) { - debug.debug_instr(set_clkcon_fast); - - byte status; - for (int times = 0; times < 20; times++) { - Thread.sleep(1); - status = debug.debug_instr(get_sleep); - if ((status & SLEEP_XOSC_STB) != 0) - return; - } - throw new IOException("Failed to initialize target clock"); - } - } - - void action(String in_s, int in_percent) { - final String s = in_s; - final int percent = in_percent; - if (listener != null && !aborted) { - Runnable r = new Runnable() { - public void run() { - try { - listener.actionPerformed(new ActionEvent(this, - percent, - s)); - } catch (Exception ex) { - } - } - }; - SwingUtilities.invokeLater(r); - } - } - - void action(int part, int total) { - int percent = 100 * part / total; - action(String.format("%d/%d (%d%%)", - part, total, percent), - percent); - } - - void altos_run(int pc) throws IOException, InterruptedException { - debug.set_pc(pc); - int set_pc = debug.get_pc(); - if (pc != set_pc) - throw new IOException("Failed to set target program counter"); - debug.resume(); - - for (int times = 0; times < 20; times++) { - byte status = debug.read_status(); - if ((status & AltosDebug.STATUS_CPU_HALTED) != 0) - return; - } - - throw new IOException("Failed to execute program on target"); - } - - public void flash() { - try { - if (!check_rom_config()) - throw new IOException("Invalid rom config settings"); - if (image.address + image.data.length > 0x8000) - throw new IOException(String.format("Flash image too long %d", - image.address + - image.data.length)); - if ((image.address & 0x3ff) != 0) - throw new IOException(String.format("Flash image must start on page boundary (is 0x%x)", - image.address)); - int ram_address = 0xf000; - int flash_prog = 0xf400; - - /* - * Store desired config values into image - */ - rom_config.write(image); - /* - * Bring up the clock - */ - clock_init(); - - int remain = image.data.length; - int flash_addr = image.address; - int image_start = 0; - - action("start", 0); - action(0, image.data.length); - while (remain > 0 && !aborted) { - int this_time = remain; - if (this_time > 0x400) - this_time = 0x400; - - if (debug != null) { - /* write the data */ - debug.write_memory(ram_address, image.data, - image_start, this_time); - - /* write the flash program */ - byte[] flash_page = make_flash_page(flash_addr, - ram_address, - this_time); - debug.write_memory(flash_prog, flash_page); - - altos_run(flash_prog); - byte[] check = debug.read_memory(flash_addr, this_time); - for (int i = 0; i < this_time; i++) - if (check[i] != image.data[image_start + i]) - throw new IOException(String.format("Flash write failed at 0x%x (%02x != %02x)", - image.address + image_start + i, - check[i], image.data[image_start + i])); - } else { - Thread.sleep(100); - } - - remain -= this_time; - flash_addr += this_time; - image_start += this_time; - - action(image.data.length - remain, image.data.length); - } - if (!aborted) { - action("done", 100); - if (debug != null) { - debug.set_pc(image.address); - debug.resume(); - } - } - if (debug != null) - debug.close(); - } catch (IOException ie) { - action(ie.getMessage(), -1); - abort(); - } catch (InterruptedException ie) { - abort(); - } - } - - public void close() { - if (debug != null) - debug.close(); - } - - synchronized public void abort() { - aborted = true; - close(); - } - - public void addActionListener(ActionListener l) { - listener = l; - } - - public boolean check_rom_config() { - if (debug == null) - return true; - if (rom_config == null) - rom_config = debug.romconfig(); - return rom_config != null && rom_config.valid(); - } - - public void set_romconfig (AltosRomconfig romconfig) { - rom_config = romconfig; - } - - public AltosRomconfig romconfig() { - if (!check_rom_config()) - return null; - return rom_config; - } - - public AltosFlash(File in_file, AltosDevice in_debug_dongle) - throws IOException, FileNotFoundException, AltosSerialInUseException, InterruptedException { - file = in_file; - debug_dongle = in_debug_dongle; - if (debug_dongle != null) - debug = new AltosDebug(new AltosSerial(in_debug_dongle)); - input = new FileInputStream(file); - image = new AltosHexfile(input); - if (debug != null && !debug.check_connection()) { - debug.close(); - throw new IOException("Debug port not connected"); - } - } -} \ No newline at end of file diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index e5176278..f4e52218 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -215,15 +215,30 @@ public class AltosFlashUI } } - class flash_task implements Runnable { + class flash_task implements Runnable, AltosFlashListener { AltosFlashUI ui; Thread t; AltosFlash flash; + public void position(String in_s, int in_percent) { + final String s = in_s; + final int percent = in_percent; + Runnable r = new Runnable() { + public void run() { + try { + ui.actionPerformed(new ActionEvent(this, + percent, + s)); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + public void run () { try { - flash = new AltosFlash(ui.file, ui.debug_dongle); - flash.addActionListener(ui); + flash = new AltosFlash(ui.file, new AltosSerial(ui.debug_dongle), this); final AltosRomconfig current_config = flash.romconfig(); diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 56554697..d59e3082 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -39,7 +39,6 @@ altosui_JAVA = \ AltosEepromManage.java \ AltosEepromMonitor.java \ AltosEepromSelect.java \ - AltosFlash.java \ AltosFlashUI.java \ AltosFlightDisplay.java \ AltosFlightInfoTableModel.java \ -- cgit v1.2.3 From 17eada6e586731defa9fd75316670c2b2b1601ee Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 9 May 2013 21:04:11 -0700 Subject: altoslib: Add non-persistent 'last logdir' preference This is used to record the last directory for reading or writing log files so that the UI can pop back to the same place next time. Signed-off-by: Keith Packard --- altoslib/AltosPreferences.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'altoslib') diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index 392497ef..088ca3d7 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -62,6 +62,9 @@ public class AltosPreferences { /* Log directory */ public static File logdir; + /* Last log directory - use this next time we open or save something */ + public static File last_logdir; + /* Map directory -- hangs of logdir */ public static File mapdir; @@ -198,6 +201,24 @@ public class AltosPreferences { } } + public static File last_logdir() { + synchronized (backend) { + if (last_logdir == null) + last_logdir = logdir; + return last_logdir; + } + } + + public static void set_last_logdir(File file) { + synchronized(backend) { + if (file != null && !file.isDirectory()) + file = file.getParentFile(); + if (file == null) + file = new File("."); + last_logdir = file; + } + } + public static File mapdir() { synchronized (backend) { return mapdir; -- cgit v1.2.3 From 80a6b0ea5c36c307a8edc79ad10ef7a8ff3d480e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 13 May 2013 22:27:00 -0700 Subject: altoslib: Correct hexfile address ranges Stop trying to use sentinal values for addresses and just keep a boolean tracking whether they've been initialized. Avoids precision errors in the variables. Signed-off-by: Keith Packard --- altoslib/AltosHexfile.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 68f42f14..2140228a 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -230,17 +230,19 @@ public class AltosHexfile { } long extended_addr = 0; - long base = 0xffffffff; - long bound = 0x00000000; + long base = 0; + long bound = 0; + boolean set = false; for (HexRecord record : record_list) { switch (record.type) { case 0: long addr = extended_addr + record.address; long r_bound = addr + record.data.length; - if (addr < base) + if (!set || addr < base) base = addr; - if (r_bound > bound) + if (!set || r_bound > bound) bound = r_bound; + set = true; break; case 1: break; @@ -259,7 +261,7 @@ public class AltosHexfile { } } - if (base >= bound) + if (!set || base >= bound) throw new IOException("invalid hex file"); if (bound - base > 4 * 1024 * 1024) -- cgit v1.2.3 From 43f94e923a6a87520edcbb8fb4829e6ddf708908 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 14 May 2013 00:24:53 -0700 Subject: altoslib: Use sequence numbers to track GPS updates to AltosRecord State objects now record what GPS sequence ID they have to know when the GPS data has been updated. Record objects bump the GPS sequence each time new GPS data is recorded. This way, record objects aren't modified as they're iterated over to generate the list of state objects which makes it possible to iterate multiple times and get the same resulting set of states. Signed-off-by: Keith Packard --- altoslib/AltosEepromIterable.java | 2 +- altoslib/AltosEepromMegaIterable.java | 2 +- altoslib/AltosIdleMonitor.java | 2 +- altoslib/AltosRecord.java | 6 +++--- altoslib/AltosState.java | 7 +++++-- altoslib/AltosTelemetryRecordLegacy.java | 6 +++--- altoslib/AltosTelemetryRecordLocation.java | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index 7a8bbdea..b84574ef 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -125,7 +125,7 @@ public class AltosEepromIterable extends AltosRecordIterable { state.gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0; state.gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >> AltosLib.AO_GPS_NUM_SAT_SHIFT; - state.new_gps = true; + state.gps_sequence++; has_gps = true; break; case AltosLib.AO_LOG_GPS_LAT: diff --git a/altoslib/AltosEepromMegaIterable.java b/altoslib/AltosEepromMegaIterable.java index a127f435..5736f937 100644 --- a/altoslib/AltosEepromMegaIterable.java +++ b/altoslib/AltosEepromMegaIterable.java @@ -136,7 +136,7 @@ public class AltosEepromMegaIterable extends AltosRecordIterable { state.gps.locked = (flags & AltosLib.AO_GPS_VALID) != 0; state.gps.nsat = (flags & AltosLib.AO_GPS_NUM_SAT_MASK) >> AltosLib.AO_GPS_NUM_SAT_SHIFT; - state.new_gps = true; + state.gps_sequence++; has_gps = true; eeprom.seen |= seen_gps_time | seen_gps_lat | seen_gps_lon; break; diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 2e4ddef2..b3ce5b20 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -112,7 +112,7 @@ public class AltosIdleMonitor extends Thread { record.status = 0; record.state = AltosLib.ao_flight_idle; record.gps = gps; - record.new_gps = true; + record.gps_sequence++; state = new AltosState (record, state); } finally { if (remote) { diff --git a/altoslib/AltosRecord.java b/altoslib/AltosRecord.java index 07e910eb..5e4ed927 100644 --- a/altoslib/AltosRecord.java +++ b/altoslib/AltosRecord.java @@ -44,7 +44,7 @@ public class AltosRecord implements Comparable , Cloneable { public int tick; public AltosGPS gps; - public boolean new_gps; + public int gps_sequence; public double time; /* seconds since boost */ @@ -143,7 +143,7 @@ public class AltosRecord implements Comparable , Cloneable { state = old.state; tick = old.tick; gps = new AltosGPS(old.gps); - new_gps = old.new_gps; + gps_sequence = old.gps_sequence; companion = old.companion; kalman_acceleration = old.kalman_acceleration; kalman_speed = old.kalman_speed; @@ -161,7 +161,7 @@ public class AltosRecord implements Comparable , Cloneable { state = AltosLib.ao_flight_startup; tick = 0; gps = null; - new_gps = false; + gps_sequence = 0; companion = null; kalman_acceleration = MISSING; diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index ccbe498d..825306be 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -54,6 +54,7 @@ public class AltosState { public double max_baro_speed; public AltosGPS gps; + public int gps_sequence; public AltosIMU imu; public AltosMag mag; @@ -133,6 +134,7 @@ public class AltosState { npad = prev_state.npad; ngps = prev_state.ngps; gps = prev_state.gps; + gps_sequence = prev_state.gps_sequence; pad_lat = prev_state.pad_lat; pad_lon = prev_state.pad_lon; pad_alt = prev_state.pad_alt; @@ -187,6 +189,7 @@ public class AltosState { npad = 0; ngps = 0; gps = null; + gps_sequence = 0; baro_speed = AltosRecord.MISSING; accel_speed = AltosRecord.MISSING; pad_alt = AltosRecord.MISSING; @@ -199,7 +202,7 @@ public class AltosState { time = tick / 100.0; - if (cur.new_gps && (state < AltosLib.ao_flight_boost)) { + if (data.gps != null && data.gps_sequence != gps_sequence && (state < AltosLib.ao_flight_boost)) { /* Track consecutive 'good' gps reports, waiting for 10 of them */ if (data.gps != null && data.gps.locked && data.gps.nsat >= 4) @@ -226,7 +229,7 @@ public class AltosState { pad_alt = ground_altitude; } - data.new_gps = false; + gps_sequence = data.gps_sequence; gps_waiting = MIN_PAD_SAMPLES - npad; if (gps_waiting < 0) diff --git a/altoslib/AltosTelemetryRecordLegacy.java b/altoslib/AltosTelemetryRecordLegacy.java index a734b188..f2d3f868 100644 --- a/altoslib/AltosTelemetryRecordLegacy.java +++ b/altoslib/AltosTelemetryRecordLegacy.java @@ -267,7 +267,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { if (map.has(AO_TELEM_GPS_STATE)) { record.gps = new AltosGPS(map); - record.new_gps = true; + record.gps_sequence++; } else record.gps = null; @@ -357,7 +357,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { } record.gps = new AltosGPS(words, i, record.version); - record.new_gps = true; + record.gps_sequence++; } public AltosTelemetryRecordLegacy(String line) throws ParseException, AltosCRCException { @@ -476,7 +476,7 @@ public class AltosTelemetryRecordLegacy extends AltosTelemetryRecord { if ((gps_flags & (AO_GPS_VALID|AO_GPS_RUNNING)) != 0) { record.gps = new AltosGPS(); - record.new_gps = true; + record.gps_sequence++; record.seen |= AltosRecord.seen_gps_time | AltosRecord.seen_gps_lat | AltosRecord.seen_gps_lon; record.gps.nsat = (gps_flags & AO_GPS_NUM_SAT_MASK); diff --git a/altoslib/AltosTelemetryRecordLocation.java b/altoslib/AltosTelemetryRecordLocation.java index 02999696..0236d291 100644 --- a/altoslib/AltosTelemetryRecordLocation.java +++ b/altoslib/AltosTelemetryRecordLocation.java @@ -85,7 +85,7 @@ public class AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw { next.gps.hdop = hdop; next.gps.vdop = vdop; next.seen |= AltosRecord.seen_gps_time | AltosRecord.seen_gps_lat | AltosRecord.seen_gps_lon; - next.new_gps = true; + next.gps_sequence++; } return next; -- cgit v1.2.3