summaryrefslogtreecommitdiff
path: root/altosui/AltosScanUI.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-07-16 17:38:00 -0700
committerKeith Packard <keithp@keithp.com>2011-07-16 17:48:51 -0700
commit941b90a4905e34936d24a25ca90ac04eb6f5a792 (patch)
tree7a0e7000b813db31ab607fec4b781e4609839788 /altosui/AltosScanUI.java
parent7ef786276b5d5c7d17c3fe4f36aa41db61a9742f (diff)
altosui: Generalize and centralize telemetry constants, parse v0.8 telemetry
Move telemetry constants to Altos class, adding functions to compute names and lengths. Generalize users of these values to use all of the known values. Add support for v0.8 TeleMetrum telemetry Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosScanUI.java')
-rw-r--r--altosui/AltosScanUI.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java
index d94ac3ae..54be4f52 100644
--- a/altosui/AltosScanUI.java
+++ b/altosui/AltosScanUI.java
@@ -35,13 +35,12 @@ class AltosScanResult {
int flight;
int channel;
int telemetry;
- static final String[] short_monitor_names = { "Standard", "Original" };
boolean interrupted = false;
public String toString() {
- return String.format("%-9.9s serial %-4d flight %-4d (channel %-2d telemetry %s)",
- callsign, serial, flight, channel, short_monitor_names[telemetry]);
+ return String.format("%-9.9s serial %-4d flight %-4d (channel %-2d %s)",
+ callsign, serial, flight, channel, Altos.telemetry_name(telemetry));
}
public String toShortString() {
@@ -116,9 +115,7 @@ public class AltosScanUI
javax.swing.Timer timer;
AltosScanResults results = new AltosScanResults();
- static final String[] monitor_names = { "Standard AltOS Telemetry", "Original TeleMetrum Telemetry" };
- static final int[] monitors = { 2, 1 };
- int monitor;
+ int telemetry;
int channel;
final static int timeout = 1200;
@@ -171,7 +168,7 @@ public class AltosScanUI
record.serial,
record.flight,
channel,
- monitor);
+ telemetry);
Runnable r = new Runnable() {
public void run() {
results.add(result);
@@ -195,7 +192,7 @@ public class AltosScanUI
void set_label() {
scanning_label.setText(String.format("Scanning: channel %d %s",
channel,
- monitor_names[monitor]));
+ Altos.telemetry_name(telemetry)));
}
void next() {
@@ -207,10 +204,10 @@ public class AltosScanUI
++channel;
if (channel > 9) {
channel = 0;
- ++monitor;
- if (monitor == monitors.length)
- monitor = 0;
- reader.serial.set_telemetry(monitors[monitor]);
+ ++telemetry;
+ if (telemetry > Altos.ao_telemetry_max)
+ telemetry = Altos.ao_telemetry_min;
+ reader.serial.set_telemetry(telemetry);
}
reader.serial.set_channel(channel);
set_label();
@@ -251,7 +248,7 @@ public class AltosScanUI
if (r != null) {
if (device != null) {
if (reader != null) {
- reader.set_telemetry(monitors[r.telemetry]);
+ reader.set_telemetry(r.telemetry);
reader.set_channel(r.channel);
owner.telemetry_window(device);
}
@@ -282,7 +279,7 @@ public class AltosScanUI
try {
reader = new AltosTelemetryReader(device);
reader.serial.set_channel(channel);
- reader.serial.set_telemetry(monitors[monitor]);
+ reader.serial.set_telemetry(telemetry);
handler = new TelemetryHandler();
thread = new Thread(handler);
thread.start();
@@ -329,6 +326,9 @@ public class AltosScanUI
pane.setLayout(new GridBagLayout());
+ channel = 0;
+ telemetry = Altos.ao_telemetry_min;
+
scanning_label = new JLabel("Scanning:");
set_label();