summaryrefslogtreecommitdiff
path: root/altoslib/AltosLib.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-07-10 16:15:52 -0700
committerKeith Packard <keithp@keithp.com>2014-07-10 16:15:52 -0700
commitb8fa4e9a077e8e04b922d0c434c139ad0a57ee66 (patch)
tree55cd8c16ba9cf9419cbc09a078f1652529004559 /altoslib/AltosLib.java
parent6f2a4c610dfacbf500650db0eeeca6623bb49c5c (diff)
altoslib: Clean up GPS DOP support in AltosState
Parse out hdop/pdop/vdop from telem and eeprom. Deal with legacy eeprom files that have dop/100 instead of dop/10 values. Clear state DOP values to MISSING at startup Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosLib.java')
-rw-r--r--altoslib/AltosLib.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java
index c2ec0e3b..eb188d6b 100644
--- a/altoslib/AltosLib.java
+++ b/altoslib/AltosLib.java
@@ -215,6 +215,31 @@ public class AltosLib {
telemetry));
}
+ private static int[] split_version(String version) {
+ String[] tokens = version.split("\\.");
+ int[] ret = new int[tokens.length];
+ for (int i = 0; i < tokens.length; i++)
+ ret[i] = Integer.parseInt(tokens[i]);
+ return ret;
+ }
+
+ public static int compare_version(String version_a, String version_b) {
+ int[] a = split_version(version_a);
+ int[] b = split_version(version_b);
+
+ for (int i = 0; i < Math.min(a.length, b.length); i++) {
+ if (a[i] < b[i])
+ return -1;
+ if (a[i] > b[i])
+ return 1;
+ }
+ if (a.length < b.length)
+ return -1;
+ if (a.length > b.length)
+ return 1;
+ return 0;
+ }
+
private static String[] state_to_string = {
"startup",
"idle",