diff options
author | Keith Packard <keithp@keithp.com> | 2012-03-27 11:58:39 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-03-27 11:58:39 -0700 |
commit | d77a4ea206d627635159f35c76c744687d4e633b (patch) | |
tree | b8dbf66c2cfeb7817c6ff0e443b6f1a63f910975 /altosui/AltosConfigData.java | |
parent | d8ebb83e64d66fa159e75aa560d39d80bb6d9d04 (diff) |
altosui: Show only supported telemetry version
Make it clear in the UI which telemetry versions are supported,
providing the combobox only for new firmware which supports all versions.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosConfigData.java')
-rw-r--r-- | altosui/AltosConfigData.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java index e5c3566b..0608b4d3 100644 --- a/altosui/AltosConfigData.java +++ b/altosui/AltosConfigData.java @@ -104,6 +104,39 @@ public class AltosConfigData implements Iterable<String> { } } + int[] parse_version(String v) { + String[] parts = v.split("\\."); + int r[] = new int[parts.length]; + + for (int i = 0; i < parts.length; i++) { + try { + r[i] = Altos.fromdec(parts[i]); + } catch (NumberFormatException n) { + r[i] = 0; + } + } + + return r; + } + + public int compare_version(String other) { + int[] me = parse_version(version); + int[] them = parse_version(other); + + int l = Math.min(me.length, them.length); + + for (int i = 0; i < l; i++) { + int d = me[i] - them[i]; + if (d != 0) + return d; + } + if (me.length > l) + return 1; + if (them.length > l) + return -1; + return 0; + } + public AltosConfigData(AltosSerial serial_line) throws InterruptedException, TimeoutException { serial_line.printf("c s\nf\nl\nv\n"); lines = new LinkedList<String>(); |