summaryrefslogtreecommitdiff
path: root/altosui/AltosAscent.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-09-14 11:13:02 -0700
committerKeith Packard <keithp@keithp.com>2012-09-14 11:13:02 -0700
commit97ab77d548964115e4b41ad5952194fcd1455c96 (patch)
tree7bb8d0020050082eb8bf875cc1775d1bc7fcef6c /altosui/AltosAscent.java
parent43e646657502f6162fa02f37fd2bd5aa3e29a1a8 (diff)
altosui: Fix Landed tab units
And clean up the whole flight value reporting code base. It would be nice to create a separate class to make this easier; at present there's a bunch of customization embedded in how values are presented in each tab. Reported by: Bdale Garbee <bdale@gag.com> Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosAscent.java')
-rw-r--r--altosui/AltosAscent.java43
1 files changed, 33 insertions, 10 deletions
diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java
index a158eb21..3fe517aa 100644
--- a/altosui/AltosAscent.java
+++ b/altosui/AltosAscent.java
@@ -51,6 +51,20 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
}
void show(AltosState state, int crc_errors) {}
+
+ void show(String s) {
+ show();
+ value.setText(s);
+ }
+
+ void show(AltosUnits units, double v) {
+ show(units.show(8, v));
+ }
+
+ void show(String format, double v) {
+ show(String.format(format, v));
+ }
+
void reset() {
value.setText("");
lights.set(false);
@@ -112,6 +126,19 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
value.setVisible(true);
}
+ void show(String s) {
+ show();
+ value.setText(s);
+ }
+
+ void show(AltosUnits units, double v) {
+ show(units.show(8, v));
+ }
+
+ void show(String format, double v) {
+ show(String.format(format, v));
+ }
+
void hide() {
label.setVisible(false);
value.setVisible(false);
@@ -268,8 +295,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Apogee extends AscentStatus {
void show (AltosState state, int crc_errors) {
- show();
- value.setText(String.format("%4.2f V", state.drogue_sense));
+ show("%4.2f V", state.drogue_sense);
lights.set(state.drogue_sense > 3.2);
}
public Apogee (GridBagLayout layout, int y) {
@@ -281,8 +307,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Main extends AscentStatus {
void show (AltosState state, int crc_errors) {
- show();
- value.setText(String.format("%4.2f V", state.main_sense));
+ show("%4.2f V", state.main_sense);
lights.set(state.main_sense > 3.2);
}
public Main (GridBagLayout layout, int y) {
@@ -294,11 +319,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Lat extends AscentValue {
void show (AltosState state, int crc_errors) {
- show();
if (state.gps != null)
- value.setText(pos(state.gps.lat,"N", "S"));
+ show(pos(state.gps.lat,"N", "S"));
else
- value.setText("???");
+ show("???");
}
public Lat (GridBagLayout layout, int y) {
super (layout, y, "Latitude");
@@ -309,11 +333,10 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Lon extends AscentValue {
void show (AltosState state, int crc_errors) {
- show();
if (state.gps != null)
- value.setText(pos(state.gps.lon,"E", "W"));
+ show(pos(state.gps.lon,"E", "W"));
else
- value.setText("???");
+ show("???");
}
public Lon (GridBagLayout layout, int y) {
super (layout, y, "Longitude");