From 6dc58c63d202e918f16d5fbe9b188d422edcdd9c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jul 2014 17:26:19 -0700 Subject: altosui: Fix the 'Graph' button on the landed tab It hasn't been getting enabled since the state tabs were rewritten. Signed-off-by: Keith Packard --- altosui/AltosLanded.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'altosui') diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 50c1ea31..7c50adac 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -151,6 +151,12 @@ public class AltosLanded extends AltosUIFlightTab implements ActionListener { return "Landed"; } + public void show(AltosState state, AltosListenerState listener_state) { + super.show(state, listener_state); + if (reader.backing_file() != null) + graph.setEnabled(true); + } + public AltosLanded(AltosFlightReader in_reader) { reader = in_reader; -- cgit v1.2.3 From 59702e5ff8d0522b0aa9dcca863309eaafbcda09 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jul 2014 17:27:43 -0700 Subject: altoslib: Extend telemetry heights from 16 to 32 bits Uses the GPS data and/or previous kalman data to compute the upper 16 bits of the truncated telemetry altitude value. Signed-off-by: Keith Packard --- altoslib/AltosConfigData.java | 3 +++ altoslib/AltosConfigValues.java | 2 ++ altoslib/AltosState.java | 28 ++++++++++++++++++++++++---- altoslib/AltosTelemetry.java | 29 +++++++++++++++++++++++++++++ altoslib/AltosTelemetryMegaData.java | 13 ++++++++++--- altoslib/AltosTelemetryMetrumSensor.java | 7 ++++--- altosui/AltosConfigUI.java | 3 +++ 7 files changed, 75 insertions(+), 10 deletions(-) (limited to 'altosui') diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index 847436cd..134a0ed2 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -31,6 +31,7 @@ public class AltosConfigData implements Iterable { public int log_format; public int log_space; public String version; + public int altitude_32; /* Strings returned */ public LinkedList lines; @@ -274,6 +275,7 @@ public class AltosConfigData implements Iterable { try { flight = get_int(line, "current-flight"); } catch (Exception e) {} try { log_format = get_int(line, "log-format"); } catch (Exception e) {} try { log_space = get_int(line, "log-space"); } catch (Exception e) {} + try { altitude_32 = get_int(line, "altitude-32"); } catch (Exception e) {} try { version = get_string(line, "software-version"); } catch (Exception e) {} /* Version also contains MS5607 info, which we ignore here */ @@ -484,6 +486,7 @@ public class AltosConfigData implements Iterable { dest.set_serial(serial); dest.set_product(product); dest.set_version(version); + dest.set_altitude_32(altitude_32); dest.set_main_deploy(main_deploy); dest.set_apogee_delay(apogee_delay); dest.set_apogee_lockout(apogee_lockout); diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 987da53b..3f0a7075 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -25,6 +25,8 @@ public interface AltosConfigValues { public abstract void set_serial(int serial); + public abstract void set_altitude_32(int altitude_32); + public abstract void set_main_deploy(int new_main_deploy); public abstract int main_deploy() throws AltosConfigDataException; diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 2fc13b44..5fce15c4 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -271,6 +271,7 @@ public class AltosState implements Cloneable { public int state; public int flight; public int serial; + public int altitude_32; public int receiver_serial; public boolean landed; public boolean ascent; /* going up? */ @@ -472,15 +473,23 @@ public class AltosState implements Cloneable { pressure.set(p, time); } + public double baro_height() { + double a = altitude(); + double g = ground_altitude(); + if (a != AltosLib.MISSING && g != AltosLib.MISSING) + return a - g; + return AltosLib.MISSING; + } + public double height() { double k = kalman_height.value(); if (k != AltosLib.MISSING) return k; - double a = altitude(); - double g = ground_altitude(); - if (a != AltosLib.MISSING && g != AltosLib.MISSING) - return a - g; + double b = baro_height(); + if (b != AltosLib.MISSING) + return b; + return gps_height(); } @@ -762,6 +771,7 @@ public class AltosState implements Cloneable { product = null; serial = AltosLib.MISSING; receiver_serial = AltosLib.MISSING; + altitude_32 = AltosLib.MISSING; baro = null; companion = null; @@ -899,6 +909,7 @@ public class AltosState implements Cloneable { product = old.product; serial = old.serial; receiver_serial = old.receiver_serial; + altitude_32 = old.altitude_32; baro = old.baro; companion = old.companion; @@ -1066,6 +1077,15 @@ public class AltosState implements Cloneable { receiver_serial = serial; } + public boolean altitude_32() { + return altitude_32 == 1; + } + + public void set_altitude_32(int altitude_32) { + if (altitude_32 != AltosLib.MISSING) + this.altitude_32 = altitude_32; + } + public int rssi() { if (rssi == AltosLib.MISSING) return 0; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 4d50a059..2f15cd89 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -114,6 +114,35 @@ public abstract class AltosTelemetry implements AltosStateUpdate { return telem; } + public static int extend_height(AltosState state, int height_16) { + double compare_height; + int height = height_16; + + System.out.printf("state kalman height %g altitude %g ground_altitude %g gps_height %g\n", + state.kalman_height.value(), state.altitude(), state.ground_altitude(), state.gps_height()); + if (state.gps != null && state.gps.alt != AltosLib.MISSING) { + compare_height = state.gps_height(); + } else { + compare_height = state.height(); + } + + if (compare_height != AltosLib.MISSING) { + int high_bits = (int) Math.floor (compare_height / 65536.0); + + height = (high_bits << 16) | (height_16 & 0xffff); + + if (Math.abs(height + 65536 - compare_height) < Math.abs(height - compare_height)) + height += 65536; + else if (Math.abs(height - 65536 - compare_height) < Math.abs(height - compare_height)) + height -= 65536; + if (height != height_16) { + System.out.printf("Height adjusted from %d to %d with %g\n", + height_16, height, compare_height); + } + } + return height; + } + public static AltosTelemetry parse(String line) throws ParseException, AltosCRCException { String[] word = line.split("\\s+"); int i =0; diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index 93610118..8b1869bb 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -31,7 +31,7 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { int acceleration; int speed; - int height; + int height_16; public AltosTelemetryMegaData(int[] bytes) { super(bytes); @@ -55,7 +55,8 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { acceleration = int16(26); speed = int16(28); - height = int16(30); + + height_16 = int16(30); } public void update_state(AltosState state) { @@ -79,7 +80,13 @@ public class AltosTelemetryMegaData extends AltosTelemetryStandard { state.set_ground_pressure(ground_pres); state.set_accel_g(accel_plus_g, accel_minus_g); - state.set_kalman(height, speed/16.0, acceleration / 16.0); + /* Fill in the high bits of height from recent GPS + * data if available, otherwise guess using the + * previous kalman height + */ + + state.set_kalman(extend_height(state, height_16), + speed/16.0, acceleration / 16.0); } } diff --git a/altoslib/AltosTelemetryMetrumSensor.java b/altoslib/AltosTelemetryMetrumSensor.java index 3e0abedc..beab6da9 100644 --- a/altoslib/AltosTelemetryMetrumSensor.java +++ b/altoslib/AltosTelemetryMetrumSensor.java @@ -27,7 +27,7 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { int acceleration; int speed; - int height; + int height_16; int v_batt; int sense_a; @@ -43,7 +43,7 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { acceleration = int16(14); speed = int16(16); - height = int16(18); + height_16 = int16(18); v_batt = int16(20); sense_a = int16(22); @@ -59,7 +59,8 @@ public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { state.set_pressure(pres); state.set_temperature(temp/100.0); - state.set_kalman(height, speed/16.0, acceleration/16.0); + state.set_kalman(extend_height(state, height_16), + speed/16.0, acceleration/16.0); state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt)); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 043cb876..9fcace61 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -926,6 +926,9 @@ public class AltosConfigUI serial_value.setText(String.format("%d", serial)); } + public void set_altitude_32(int altitude_32) { + } + public void set_main_deploy(int new_main_deploy) { main_deploy_value.setSelectedItem(AltosConvert.height.say(new_main_deploy)); main_deploy_value.setEnabled(new_main_deploy >= 0); -- cgit v1.2.3 From 5f5b03879d9daa68a56498b45ae87a804cb1926b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jul 2014 18:43:31 -0700 Subject: altosui: Don't show bluetooth UI bits on mac/windows This just confuses people into thinking that bluetooth is supported on those machines. Signed-off-by: Keith Packard --- altosui/AltosConfigureUI.java | 8 +++++++- altosuilib/AltosDeviceDialog.java | 3 ++- altosuilib/AltosUIConfigure.java | 3 ++- altosuilib/AltosUILib.java | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) (limited to 'altosui') diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 80d6d341..85a3f6c0 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -89,6 +89,8 @@ public class AltosConfigureUI row++; } + boolean has_bluetooth; + public void add_bluetooth() { JButton manage_bluetooth = new JButton("Manage Bluetooth"); manage_bluetooth.addActionListener(new ActionListener() { @@ -98,6 +100,7 @@ public class AltosConfigureUI }); pane.add(manage_bluetooth, constraints(0, 2)); /* in the same row as add_frequencies, so don't bump row */ + has_bluetooth = true; } public void add_frequencies() { @@ -108,7 +111,10 @@ public class AltosConfigureUI } }); manage_frequencies.setToolTipText("Configure which values are shown in frequency menus"); - pane.add(manage_frequencies, constraints(2, 1)); + if (has_bluetooth) + pane.add(manage_frequencies, constraints(2, 1)); + else + pane.add(manage_frequencies, constraints(0, 3)); row++; } diff --git a/altosuilib/AltosDeviceDialog.java b/altosuilib/AltosDeviceDialog.java index 0875bea7..d2ccd5e7 100644 --- a/altosuilib/AltosDeviceDialog.java +++ b/altosuilib/AltosDeviceDialog.java @@ -131,7 +131,8 @@ public abstract class AltosDeviceDialog extends AltosUIDialog implements ActionL buttonPane.add(cancel_button); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); - add_bluetooth(); + if (AltosUILib.has_bluetooth) + add_bluetooth(); buttonPane.add(select_button); diff --git a/altosuilib/AltosUIConfigure.java b/altosuilib/AltosUIConfigure.java index 5648d1df..9c0f3bc7 100644 --- a/altosuilib/AltosUIConfigure.java +++ b/altosuilib/AltosUIConfigure.java @@ -283,7 +283,8 @@ public class AltosUIConfigure add_look_and_feel(); add_position(); add_map_cache(); - add_bluetooth(); + if (AltosUILib.has_bluetooth) + add_bluetooth(); add_frequencies(); /* And a close button at the bottom */ diff --git a/altosuilib/AltosUILib.java b/altosuilib/AltosUILib.java index 0050f12c..8fa7dfe6 100644 --- a/altosuilib/AltosUILib.java +++ b/altosuilib/AltosUILib.java @@ -80,6 +80,7 @@ public class AltosUILib extends AltosLib { static public boolean initialized = false; static public boolean loaded_library = false; + static public boolean has_bluetooth = false; static final String[] library_names = { "altos", "altos32", "altos64" }; @@ -96,6 +97,13 @@ public class AltosUILib extends AltosLib { loaded_library = false; } } + + String OS = System.getProperty("os.name"); + + if (OS.startsWith("Linux")) { + has_bluetooth = true; + } + initialized = true; } return loaded_library; -- cgit v1.2.3 From ec7ceb607f5ba7e1ed5cfd32b7a452a5f364b095 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 15 Jul 2014 00:44:14 -0700 Subject: linux-fat: Fix up fat linux install icons, mime types and .desktop files use the standard xdg utilities to install mime type and .desktop files. The standard xdg icon installer doesn't handle svg icons, so we have to do those manually. With this patch, xfce, gnome3 and kde4 all place the applications in user-visible menus, display correct file icons and launch correct applications for our file types. Signed-off-by: Keith Packard --- altosui/Makefile.am | 10 +++++- altosui/linux-install.sh | 79 +++++++++++++++++++++++++----------------------- micropeak/Makefile.am | 9 +++++- telegps/Makefile.am | 10 +++++- 4 files changed, 68 insertions(+), 40 deletions(-) (limited to 'altosui') diff --git a/altosui/Makefile.am b/altosui/Makefile.am index c79e27c0..44258fd2 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -104,6 +104,14 @@ MACOSX_ICONS =\ $(ICONDIR)/application-vnd.altusmetrum.eeprom.icns \ $(ICONDIR)/application-vnd.altusmetrum.telemetry.icns +LINUX_ICONS =\ + $(ICONDIR)/altusmetrum-altosui.svg \ + $(ICONDIR)/application-vnd.altusmetrum.eeprom.svg \ + $(ICONDIR)/application-vnd.altusmetrum.telemetry.svg + +LINUX_MIMETYPE =\ + $(ICONDIR)/org-altusmetrum-mimetypes.xml + # Firmware FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx FIRMWARE_TD=$(FIRMWARE_TD_0_2) @@ -152,7 +160,7 @@ FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFR LINUX_LIBS=libaltos32.so libaltos64.so -LINUX_FILES=$(FAT_FILES) $(LINUX_LIBS) $(FIRMWARE) $(DOC) $(desktop_file).in $(ICONDIR)/altusmetrum-altosui.svg +LINUX_FILES=$(FAT_FILES) $(LINUX_LIBS) $(FIRMWARE) $(DOC) $(desktop_file).in $(LINUX_ICONS) $(LINUX_MIMETYPE) LINUX_EXTRA=altosui-fat MACOSX_INFO_PLIST=Info.plist diff --git a/altosui/linux-install.sh b/altosui/linux-install.sh index 957b1aad..2e44c2aa 100644 --- a/altosui/linux-install.sh +++ b/altosui/linux-install.sh @@ -130,6 +130,7 @@ esac # # Create the .desktop file by editing the paths # + case "$target" in /*) target_abs="$target" @@ -149,43 +150,46 @@ for infile in "$target"/AltOS/*.desktop.in; do done # -# Figure out where to install the .desktop files. If we can, write it -# to the public /usr/share/applications, otherwise, write it to the -# per-user ~/.local/share/applications +# Install the .desktop file # -public=/usr/share/applications -private=$HOME/.local/share/applications -apps="" +for desktop in "$target"/AltOS/*.desktop; do + case `id -u` in + 0) + xdg-desktop-menu install --mode system "$desktop" + ;; + *) + xdg-desktop-menu install --mode user "$desktop" + ;; + esac +done -if [ -d "$public" -a -w "$public" ]; then - apps="$public" -else - mkdir -p "$private" >/dev/null 2>&1 - if [ -d "$private" -a -w "$private" ]; then - apps="$private" - fi -fi - -case "$apps" in -"") - echo "Cannot install application icon" - finish 1 - ;; -esac +# +# Install mime type file +# + +for mimetype in "$target"/AltOS/*-mimetypes.xml; do + case `id -u` in + 0) + xdg-mime install --mode system "$mimetype" + ;; + *) + xdg-mime install --mode user "$mimetype" + ;; + esac +done -echo -n "Installing .desktop files to $apps..." +# +# Install icons +# -cp "$target"/AltOS/*.desktop "$apps" +for icon_dir in /usr/share/icons/hicolor/scalable/mimetypes "$HOME/.icons" "$HOME/.kde/share/icons"; do + if [ -w "$icon_dir" ]; then + cp "$target"/AltOS/*.svg "$icon_dir" + update-icon-caches "$icon_dir" + fi +done -case "$?" in -0) - echo " done." - ;; -*) - echo " failed." - ;; -esac # # Install icon to desktop if desired @@ -222,13 +226,14 @@ if [ -d $HOME/Desktop ]; then esac done - echo -n "Installing desktop icons..." case "$do_desktop" in - [yY]*) - for d in "$target"/AltOS/*.desktop; do - ln -f -s "$d" "$HOME/Desktop/" - done - ;; + [yY]*) + echo -n "Installing desktop icons..." + for d in "$target"/AltOS/*.desktop; do + base=`basename $d` + cp --remove-destination "$d" "$HOME/Desktop/" + done + ;; esac echo " done." diff --git a/micropeak/Makefile.am b/micropeak/Makefile.am index e3b77c8a..15865606 100644 --- a/micropeak/Makefile.am +++ b/micropeak/Makefile.am @@ -82,6 +82,13 @@ MACOSX_ICONS =\ ../icon/altusmetrum-micropeak.icns \ ../icon/application-vnd.altusmetrum.micropeak.icns +LINUX_ICONS =\ + $(ICONDIR)/altusmetrum-micropeak.svg \ + $(ICONDIR)/application-vnd.altusmetrum.micropeak.svg + +LINUX_MIMETYPE =\ + $(ICONDIR)/org-altusmetrum-mimetypes.xml + desktopdir = $(datadir)/applications desktop_file = altusmetrum-micropeak.desktop desktop_SCRIPTS = $(desktop_file) @@ -114,7 +121,7 @@ DOC=$(MICROPEAK_DOC) FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) -LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in ../icon/altusmetrum-micropeak.svg +LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in $(LINUX_ICONS) $(LINUX_MIMETYPE) LINUX_EXTRA=micropeak-fat $(desktop_file).in MACOSX_DRIVER_URL=http://www.ftdichip.com/Drivers/VCP/MacOSX/FTDIUSBSerialDriver_v2_2_18.dmg diff --git a/telegps/Makefile.am b/telegps/Makefile.am index 6138b004..3b33428e 100644 --- a/telegps/Makefile.am +++ b/telegps/Makefile.am @@ -87,6 +87,14 @@ MACOSX_ICONS =\ ../icon/application-vnd.altusmetrum.eeprom.icns \ ../icon/application-vnd.altusmetrum.telemetry.icns +LINUX_ICONS =\ + $(ICONDIR)/altusmetrum-altosui.svg \ + $(ICONDIR)/application-vnd.altusmetrum.eeprom.svg \ + $(ICONDIR)/application-vnd.altusmetrum.telemetry.svg + +LINUX_MIMETYPE =\ + $(ICONDIR)/org-altusmetrum-mimetypes.xml + # Firmware FIRMWARE_TD_0_2=$(top_srcdir)/src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx FIRMWARE_TD=$(FIRMWARE_TD_0_2) @@ -131,7 +139,7 @@ DOC=$(TELEGPS_DOC) FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(ALTOSUILIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) -LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in ../icon/altusmetrum-telegps.svg +LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) $(desktop_file).in $(LINUX_ICONS) $(LINUX_MIMETYPE) LINUX_EXTRA=telegps-fat $(desktop_file).in MACOSX_INFO_PLIST=Info.plist -- cgit v1.2.3