From: Keith Packard Date: Tue, 9 Nov 2010 22:40:58 +0000 (-0800) Subject: altosui: Add tab UI with 'pad' mode. X-Git-Tag: debian/0.7.1+70+g9ffc2eb~22 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=22d00785188a880700cd372528189a7a15278da9;hp=eb77e806ded99532dc7eaa39c1893f075b028af6 altosui: Add tab UI with 'pad' mode. This creates a multi-tab interface for flight monitoring and includes a special tab for 'pad' mode. Signed-off-by: Keith Packard --- diff --git a/ao-tools/altosui/AltosFlightUI.java b/ao-tools/altosui/AltosFlightUI.java index 11fc2442..a7caf7e9 100644 --- a/ao-tools/altosui/AltosFlightUI.java +++ b/ao-tools/altosui/AltosFlightUI.java @@ -37,6 +37,11 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { AltosDisplayThread thread; private Box vbox; + + JTabbedPane pane; + + AltosPad pad; + private AltosStatusTable flightStatus; private AltosInfoTable flightInfo; @@ -63,10 +68,12 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { } public void reset() { + pad.reset(); flightInfo.clear(); } public void show(AltosState state, int crc_errors) { + pad.show(state, crc_errors); flightStatus.set(state); flightInfo.show(state, crc_errors); } @@ -86,8 +93,15 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { vbox = new Box (BoxLayout.Y_AXIS); vbox.add(flightStatus); + pane = new JTabbedPane(); + + pad = new AltosPad(); + pane.add("Launch Pad", pad); + flightInfo = new AltosInfoTable(); - vbox.add(flightInfo.box()); + pane.add("Table", flightInfo.box()); + + vbox.add(pane); this.add(vbox); diff --git a/ao-tools/altosui/AltosLed.java b/ao-tools/altosui/AltosLed.java new file mode 100644 index 00000000..e08e9960 --- /dev/null +++ b/ao-tools/altosui/AltosLed.java @@ -0,0 +1,54 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosLed extends JLabel { + ImageIcon on, off; + + ImageIcon create_icon(String path) { + java.net.URL imgURL = AltosUI.class.getResource(path); + if (imgURL != null) + return new ImageIcon(imgURL); + System.err.printf("Cannot find icon \"%s\"\n", path); + return null; + } + + public void set(boolean set) { + if (set) + setIcon(on); + else + setIcon(off); + } + + public AltosLed(String on_path, String off_path) { + on = create_icon(on_path); + off = create_icon(off_path); + setIcon(off); + } +} diff --git a/ao-tools/altosui/AltosLights.java b/ao-tools/altosui/AltosLights.java new file mode 100644 index 00000000..2d2a1938 --- /dev/null +++ b/ao-tools/altosui/AltosLights.java @@ -0,0 +1,72 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosLights extends JComponent { + + GridBagLayout gridbag; + + AltosLed red, green; + + ImageIcon create_icon(String path, String description) { + java.net.URL imgURL = AltosUI.class.getResource(path); + if (imgURL != null) + return new ImageIcon(imgURL, description); + System.err.printf("Cannot find icon \"%s\"\n", path); + return null; + } + + public void set (boolean on) { + if (on) { + red.set(false); + green.set(true); + } else { + red.set(true); + green.set(false); + } + } + + public AltosLights() { + GridBagConstraints c; + gridbag = new GridBagLayout(); + setLayout(gridbag); + + c = new GridBagConstraints(); + red = new AltosLed("/redled.png", "/redoff.png"); + c.gridx = 0; c.gridy = 0; + gridbag.setConstraints(red, c); + add(red); + red.set(true); + green = new AltosLed("/greenled.png", "/greenoff.png"); + c.gridx = 1; c.gridy = 0; + gridbag.setConstraints(green, c); + add(green); + green.set(false); + } +} \ No newline at end of file diff --git a/ao-tools/altosui/AltosPad.java b/ao-tools/altosui/AltosPad.java new file mode 100644 index 00000000..133dbed3 --- /dev/null +++ b/ao-tools/altosui/AltosPad.java @@ -0,0 +1,249 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosPad extends JComponent implements AltosFlightDisplay { + GridBagLayout layout; + Font label_font; + Font value_font; + + public class LaunchStatus { + JLabel label; + JLabel value; + AltosLights lights; + + void show(AltosState state, int crc_errors) {} + void reset() { + value.setText("0"); + lights.set(false); + } + + public LaunchStatus (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + + lights = new AltosLights(); + c.gridx = 0; c.gridy = y; + c.anchor = GridBagConstraints.CENTER; + c.fill = GridBagConstraints.CENTER; + layout.setConstraints(lights, c); + add(lights); + + label = new JLabel(text); + label.setFont(label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(10, 10, 10, 10); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.WEST; + layout.setConstraints(label, c); + add(label); + + value = new JLabel("4.00"); + value.setFont(label_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.EAST; + layout.setConstraints(value, c); + add(value); + + } + } + + public class LaunchValue { + JLabel label; + JLabel value; + void show(AltosState state, int crc_errors) {} + + void reset() { + value.setText("0"); + } + public LaunchValue (GridBagLayout layout, int y, String text) { + GridBagConstraints c = new GridBagConstraints(); + + label = new JLabel(text); + label.setFont(label_font); + label.setHorizontalAlignment(SwingConstants.LEFT); + c.gridx = 1; c.gridy = y; + c.insets = new Insets(10, 10, 10, 10); + c.anchor = GridBagConstraints.WEST; + c.fill = GridBagConstraints.WEST; + layout.setConstraints(label, c); + add(label); + + value = new JLabel("4.00"); + value.setFont(label_font); + value.setHorizontalAlignment(SwingConstants.RIGHT); + c.gridx = 2; c.gridy = y; + c.anchor = GridBagConstraints.EAST; + c.fill = GridBagConstraints.EAST; + layout.setConstraints(value, c); + add(value); + } + } + + class Battery extends LaunchStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4.2f V", state.battery)); + lights.set(state.battery > 3.7); + } + public Battery (GridBagLayout layout, int y) { + super(layout, y, "Battery Voltage"); + } + } + + Battery battery; + + class Apogee extends LaunchStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%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"); + } + } + + Apogee apogee; + + class Main extends LaunchStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%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"); + } + } + + Main main; + + class GPS extends LaunchStatus { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4d sats", state.gps.nsat)); + lights.set(state.gps_ready); + } + public GPS (GridBagLayout layout, int y) { + super (layout, y, "GPS Status"); + } + } + + GPS gps; + + String pos(double p, String pos, String neg) { + String h = pos; + if (p < 0) { + h = neg; + p = -p; + } + int deg = (int) Math.floor(p); + double min = (p - Math.floor(p)) * 60.0; + return String.format("%s %4d° %9.6f", h, deg, min); + } + + class PadLat extends LaunchValue { + void show (AltosState state, int crc_errors) { + value.setText(pos(state.pad_lat,"N", "S")); + } + public PadLat (GridBagLayout layout, int y) { + super (layout, y, "Pad Latitude"); + } + } + + PadLat pad_lat; + + class PadLon extends LaunchValue { + void show (AltosState state, int crc_errors) { + value.setText(pos(state.pad_lon,"E", "W")); + } + public PadLon (GridBagLayout layout, int y) { + super (layout, y, "Pad Longitude"); + } + } + + PadLon pad_lon; + + class PadAlt extends LaunchValue { + void show (AltosState state, int crc_errors) { + value.setText(String.format("%4.0f m", state.pad_alt)); + } + public PadAlt (GridBagLayout layout, int y) { + super (layout, y, "Pad Altitude"); + } + } + + PadAlt pad_alt; + + public void reset() { + battery.reset(); + apogee.reset(); + main.reset(); + gps.reset(); + pad_lat.reset(); + pad_lon.reset(); + pad_alt.reset(); + } + + public void show(AltosState state, int crc_errors) { + battery.show(state, crc_errors); + apogee.show(state, crc_errors); + main.show(state, crc_errors); + gps.show(state, crc_errors); + pad_lat.show(state, crc_errors); + pad_lon.show(state, crc_errors); + pad_alt.show(state, crc_errors); + } + + public AltosPad() { + layout = new GridBagLayout(); + + GridBagConstraints c; + + label_font = new Font("Dialog", Font.PLAIN, 24); + value_font = new Font("Monospaced", Font.PLAIN, 24); + setLayout(layout); + + c = new GridBagConstraints(); + /* Elements in pad display: + * + * Battery voltage + * Igniter continuity + * GPS lock status and location + * Pad altitude + * RSSI + */ + battery = new Battery(layout, 0); + apogee = new Apogee(layout, 1); + main = new Main(layout, 2); + gps = new GPS(layout, 3); + pad_lat = new PadLat(layout, 4); + pad_lon = new PadLon(layout, 5); + pad_alt = new PadAlt(layout, 6); + } +} diff --git a/ao-tools/altosui/Makefile.am b/ao-tools/altosui/Makefile.am index ccb88ed1..ab9cf201 100644 --- a/ao-tools/altosui/Makefile.am +++ b/ao-tools/altosui/Makefile.am @@ -39,9 +39,12 @@ altosui_JAVA = \ Altos.java \ AltosInfoTable.java \ AltosKML.java \ + AltosLed.java \ + AltosLights.java \ AltosLine.java \ AltosLogfileChooser.java \ AltosLog.java \ + AltosPad.java \ AltosParse.java \ AltosPreferences.java \ AltosReader.java \ @@ -92,8 +95,21 @@ JAR=altosui.jar FATJAR=altosui-fat.jar # Icons -JAVA_ICON=$(top_srcdir)/icon/altus-metrum-16x16.jpg -WINDOWS_ICON=$(top_srcdir)/icon/altus-metrum.ico +ICONDIR=$(top_srcdir)/icon + +JAVA_ICON=$(ICONDIR)/altus-metrum-16x16.jpg + +ICONS= $(ICONDIR)/redled.png $(ICONDIR)/redoff.png \ + $(ICONDIR)/greenled.png $(ICONDIR)/greenoff.png \ + $(ICONDIR)/grayled.png $(ICONDIR)/grayoff.png + +# icon base names for jar +ICONJAR= -C $(ICONDIR) altus-metrum-16x16.jpg \ + -C $(ICONDIR) redled.png -C $(ICONDIR) redoff.png \ + -C $(ICONDIR) greenled.png -C $(ICONDIR) greenoff.png \ + -C $(ICONDIR) grayon.png -C $(ICONDIR) grayled.png + +WINDOWS_ICON=$(ICONDIR)/altus-metrum.ico # Firmware FIRMWARE_TD=$(top_srcdir)/src/teledongle-v0.2-$(VERSION).ihx @@ -163,13 +179,13 @@ classes/altosui: $(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON) jar cfm $@ Manifest.txt \ - -C $(top_srcdir)/icon altus-metrum-16x16.jpg \ + $(ICONJAR) \ -C classes altosui \ -C ../libaltos libaltosJNI $(FATJAR): classaltosui.stamp Manifest-fat.txt $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON) jar cfm $@ Manifest-fat.txt \ - -C $(top_srcdir)/icon altus-metrum-16x16.jpg \ + $(ICONJAR) \ -C classes altosui \ -C ../libaltos libaltosJNI diff --git a/icon/grayled.png b/icon/grayled.png new file mode 100644 index 00000000..bb6005c6 Binary files /dev/null and b/icon/grayled.png differ diff --git a/icon/grayon.png b/icon/grayon.png new file mode 100644 index 00000000..c99b376e Binary files /dev/null and b/icon/grayon.png differ diff --git a/icon/greenled.png b/icon/greenled.png new file mode 100644 index 00000000..d7663961 Binary files /dev/null and b/icon/greenled.png differ diff --git a/icon/greenoff.png b/icon/greenoff.png new file mode 100644 index 00000000..c3cf8491 Binary files /dev/null and b/icon/greenoff.png differ diff --git a/icon/redled.png b/icon/redled.png new file mode 100644 index 00000000..230afae0 Binary files /dev/null and b/icon/redled.png differ diff --git a/icon/redoff.png b/icon/redoff.png new file mode 100644 index 00000000..a251402f Binary files /dev/null and b/icon/redoff.png differ