From d77a4ea206d627635159f35c76c744687d4e633b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 27 Mar 2012 11:58:39 -0700 Subject: 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 --- altosui/AltosConfigData.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'altosui/AltosConfigData.java') 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 { } } + 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(); -- cgit v1.2.3