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/AltosConfigData.java') 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 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/AltosConfigData.java') 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 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/AltosConfigData.java') 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