diff options
author | Keith Packard <keithp@keithp.com> | 2011-07-16 17:38:00 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-07-16 17:48:51 -0700 |
commit | 941b90a4905e34936d24a25ca90ac04eb6f5a792 (patch) | |
tree | 7a0e7000b813db31ab607fec4b781e4609839788 /altosui/Altos.java | |
parent | 7ef786276b5d5c7d17c3fe4f36aa41db61a9742f (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/Altos.java')
-rw-r--r-- | altosui/Altos.java | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/altosui/Altos.java b/altosui/Altos.java index 96263797..8d5916ad 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -70,11 +70,23 @@ public class Altos { /* Telemetry modes */ static final int ao_telemetry_off = 0; - static final int ao_telemetry_legacy = 1; - static final int ao_telemetry_split = 2; + static final int ao_telemetry_min = 1; + static final int ao_telemetry_standard = 1; + static final int ao_telemetry_0_9 = 2; + static final int ao_telemetry_0_8 = 3; + static final int ao_telemetry_max = 3; + + static final String[] ao_telemetry_name = { + "Off", "Standard Telemetry", "TeleMetrum v0.9", "TeleMetrum v0.8" + }; + + static final int ao_telemetry_standard_len = 32; + static final int ao_telemetry_0_9_len = 95; + static final int ao_telemetry_0_8_len = 94; - static final int ao_telemetry_split_len = 32; - static final int ao_telemetry_legacy_len = 95; + static final int[] ao_telemetry_len = { + 0, 32, 95, 94 + }; static HashMap<String,Integer> string_to_state = new HashMap<String,Integer>(); @@ -103,6 +115,20 @@ public class Altos { map_initialized = true; } + static int telemetry_len(int telemetry) { + if (telemetry <= ao_telemetry_max) + return ao_telemetry_len[telemetry]; + throw new IllegalArgumentException(String.format("Invalid telemetry %d", + telemetry)); + } + + static String telemetry_name(int telemetry) { + if (telemetry <= ao_telemetry_max) + return ao_telemetry_name[telemetry]; + throw new IllegalArgumentException(String.format("Invalid telemetry %d", + telemetry)); + } + static String[] state_to_string = { "startup", "idle", |