altosui: More changes to migrate code to altoslib
authorKeith Packard <keithp@keithp.com>
Tue, 5 Jun 2012 03:56:25 +0000 (20:56 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 5 Jun 2012 03:56:25 +0000 (20:56 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosLib.java
altosui/Altos.java
altosui/AltosEepromDownload.java

index 27d720792739e1af68eb6c265d92c2b414877214..e74eaf99fcde1578fa9e2bd120a40c3a69aaaa5d 100644 (file)
@@ -185,6 +185,7 @@ public class AltosLib {
        public static final int AO_LOG_FORMAT_TINY = 2;
        public static final int AO_LOG_FORMAT_TELEMETRY = 3;
        public static final int AO_LOG_FORMAT_TELESCIENCE = 4;
+       public static final int AO_LOG_FORMAT_MEGAMETRUM = 5;
        public static final int AO_LOG_FORMAT_NONE = 127;
 
        public static boolean isspace(int c) {
index 351927ee39b3fabbac3df8d61fbcfe15830e6471..78e56970d7702669175f011baa79cc1a70f07ec1 100644 (file)
@@ -86,190 +86,6 @@ public class Altos extends AltosLib {
                return state_to_string[state];
        }
 
-       static final int AO_GPS_VALID = (1 << 4);
-       static final int AO_GPS_RUNNING = (1 << 5);
-       static final int AO_GPS_DATE_VALID = (1 << 6);
-       static final int AO_GPS_NUM_SAT_SHIFT = 0;
-       static final int AO_GPS_NUM_SAT_MASK = 0xf;
-
-       static final int AO_LOG_FORMAT_UNKNOWN = 0;
-       static final int AO_LOG_FORMAT_FULL = 1;
-       static final int AO_LOG_FORMAT_TINY = 2;
-       static final int AO_LOG_FORMAT_TELEMETRY = 3;
-       static final int AO_LOG_FORMAT_TELESCIENCE = 4;
-       static final int AO_LOG_FORMAT_MEGAMETRUM = 5;
-       static final int AO_LOG_FORMAT_NONE = 127;
-
-       static boolean isspace(int c) {
-               switch (c) {
-               case ' ':
-               case '\t':
-                       return true;
-               }
-               return false;
-       }
-
-       static boolean ishex(int c) {
-               if ('0' <= c && c <= '9')
-                       return true;
-               if ('a' <= c && c <= 'f')
-                       return true;
-               if ('A' <= c && c <= 'F')
-                       return true;
-               return false;
-       }
-
-       static boolean ishex(String s) {
-               for (int i = 0; i < s.length(); i++)
-                       if (!ishex(s.charAt(i)))
-                               return false;
-               return true;
-       }
-
-       static int fromhex(int c) {
-               if ('0' <= c && c <= '9')
-                       return c - '0';
-               if ('a' <= c && c <= 'f')
-                       return c - 'a' + 10;
-               if ('A' <= c && c <= 'F')
-                       return c - 'A' + 10;
-               return -1;
-       }
-
-       static int fromhex(String s) throws NumberFormatException {
-               int c, v = 0;
-               for (int i = 0; i < s.length(); i++) {
-                       c = s.charAt(i);
-                       if (!ishex(c)) {
-                               if (i == 0)
-                                       throw new NumberFormatException(String.format("invalid hex \"%s\"", s));
-                               return v;
-                       }
-                       v = v * 16 + fromhex(c);
-               }
-               return v;
-       }
-
-       static boolean isdec(int c) {
-               if ('0' <= c && c <= '9')
-                       return true;
-               return false;
-       }
-
-       static boolean isdec(String s) {
-               for (int i = 0; i < s.length(); i++)
-                       if (!isdec(s.charAt(i)))
-                               return false;
-               return true;
-       }
-
-       static int fromdec(int c) {
-               if ('0' <= c && c <= '9')
-                       return c - '0';
-               return -1;
-       }
-
-       static int int8(int[] bytes, int i) {
-               return (int) (byte) bytes[i];
-       }
-
-       static int uint8(int[] bytes, int i) {
-               return bytes[i];
-       }
-
-       static int int16(int[] bytes, int i) {
-               return (int) (short) (bytes[i] + (bytes[i+1] << 8));
-       }
-
-       static int uint16(int[] bytes, int i) {
-               return bytes[i] + (bytes[i+1] << 8);
-       }
-
-       static int uint32(int[] bytes, int i) {
-               return bytes[i] +
-                       (bytes[i+1] << 8) +
-                       (bytes[i+2] << 16) +
-                       (bytes[i+3] << 24);
-       }
-
-       static final Charset    unicode_set = Charset.forName("UTF-8");
-
-       static String string(int[] bytes, int s, int l) {
-               if (s + l > bytes.length) {
-                       if (s > bytes.length) {
-                               s = bytes.length;
-                               l = 0;
-                       } else {
-                               l = bytes.length - s;
-                       }
-               }
-
-               int i;
-               for (i = l - 1; i >= 0; i--)
-                       if (bytes[s+i] != 0)
-                               break;
-
-               l = i + 1;
-               byte[]  b = new byte[l];
-
-               for (i = 0; i < l; i++)
-                       b[i] = (byte) bytes[s+i];
-               String n = new String(b, unicode_set);
-               return n;
-       }
-
-       static int hexbyte(String s, int i) {
-               int c0, c1;
-
-               if (s.length() < i + 2)
-                       throw new NumberFormatException(String.format("invalid hex \"%s\"", s));
-               c0 = s.charAt(i);
-               if (!Altos.ishex(c0))
-                       throw new NumberFormatException(String.format("invalid hex \"%c\"", c0));
-               c1 = s.charAt(i+1);
-               if (!Altos.ishex(c1))
-                       throw new NumberFormatException(String.format("invalid hex \"%c\"", c1));
-               return Altos.fromhex(c0) * 16 + Altos.fromhex(c1);
-       }
-
-       static int[] hexbytes(String s) {
-               int     n;
-               int[]   r;
-               int     i;
-
-               if ((s.length() & 1) != 0)
-                       throw new NumberFormatException(String.format("invalid line \"%s\"", s));
-               n = s.length() / 2;
-               r = new int[n];
-               for (i = 0; i < n; i++)
-                       r[i] = Altos.hexbyte(s, i * 2);
-               return r;
-       }
-
-       static int fromdec(String s) throws NumberFormatException {
-               int c, v = 0;
-               int sign = 1;
-               for (int i = 0; i < s.length(); i++) {
-                       c = s.charAt(i);
-                       if (i == 0 && c == '-') {
-                               sign = -1;
-                       } else if (!isdec(c)) {
-                               if (i == 0)
-                                       throw new NumberFormatException(String.format("invalid number \"%s\"", s));
-                               return v;
-                       } else
-                               v = v * 10 + fromdec(c);
-               }
-               return v * sign;
-       }
-
-       static String replace_extension(String input, String extension) {
-               int dot = input.lastIndexOf(".");
-               if (dot > 0)
-                       input = input.substring(0,dot);
-               return input.concat(extension);
-       }
-
        static public boolean initialized = false;
        static public boolean loaded_library = false;
 
index 080bfc99cfa94c4e248e5c18e86c7b55751a6f95..d1e5fdf0484cd2d51c3a70ef10f9e56761e81a46 100644 (file)
@@ -357,23 +357,23 @@ public class AltosEepromDownload implements Runnable {
                        }
 
                        switch (log_format) {
-                       case Altos.AO_LOG_FORMAT_FULL:
+                       case AltosLib.AO_LOG_FORMAT_FULL:
                                extension = "eeprom";
                                CaptureFull(eechunk);
                                break;
-                       case Altos.AO_LOG_FORMAT_TINY:
+                       case AltosLib.AO_LOG_FORMAT_TINY:
                                extension = "eeprom";
                                CaptureTiny(eechunk);
                                break;
-                       case Altos.AO_LOG_FORMAT_TELEMETRY:
+                       case AltosLib.AO_LOG_FORMAT_TELEMETRY:
                                extension = "telem";
                                CaptureTelemetry(eechunk);
                                break;
-                       case Altos.AO_LOG_FORMAT_TELESCIENCE:
+                       case AltosLib.AO_LOG_FORMAT_TELESCIENCE:
                                extension = "science";
                                CaptureTeleScience(eechunk);
                                break;
-                       case Altos.AO_LOG_FORMAT_MEGAMETRUM:
+                       case AltosLib.AO_LOG_FORMAT_MEGAMETRUM:
                                extension = "mega";
                                CaptureMega(eechunk);
                        }