altosui: Standard text field in flight UI needs more width (now 20)
[fw/altos] / altosui / Altos.java
index 37a4f67bfdb278188b7a78c42dcd6091f2edd098..1acce9492a4c96b08bdbef5f8de6719f514be35e 100644 (file)
@@ -70,11 +70,23 @@ public class Altos {
 
        /* Telemetry modes */
        static final int ao_telemetry_off = 0;
 
        /* 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>();
 
 
        static HashMap<String,Integer>  string_to_state = new HashMap<String,Integer>();
 
@@ -86,7 +98,7 @@ public class Altos {
        static final Font value_font = new Font("Monospaced", Font.PLAIN, 22);
        static final Font status_font = new Font("SansSerif", Font.BOLD, 24);
 
        static final Font value_font = new Font("Monospaced", Font.PLAIN, 22);
        static final Font status_font = new Font("SansSerif", Font.BOLD, 24);
 
-       static final int text_width = 16;
+       static final int text_width = 20;
 
        static void initialize_map()
        {
 
        static void initialize_map()
        {
@@ -103,6 +115,20 @@ public class Altos {
                map_initialized = true;
        }
 
                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",
        static String[] state_to_string = {
                "startup",
                "idle",
@@ -240,9 +266,15 @@ public class Altos {
                        }
                }
 
                        }
                }
 
+               int i;
+               for (i = l - 1; i >= 0; i--)
+                       if (bytes[s+i] != 0)
+                               break;
+
+               l = i + 1;
                byte[]  b = new byte[l];
 
                byte[]  b = new byte[l];
 
-               for (int i = 0; i < l; i++)
+               for (i = 0; i < l; i++)
                        b[i] = (byte) bytes[s+i];
                String n = new String(b, unicode_set);
                return n;
                        b[i] = (byte) bytes[s+i];
                String n = new String(b, unicode_set);
                return n;
@@ -318,50 +350,42 @@ public class Altos {
        }
 
        static int usb_vendor_altusmetrum() {
        }
 
        static int usb_vendor_altusmetrum() {
-               if (load_library())
-                       return libaltosConstants.USB_VENDOR_ALTUSMETRUM;
-               return 0x000a;
+               load_library();
+               return 0xfffe;
        }
 
        static int usb_product_altusmetrum() {
        }
 
        static int usb_product_altusmetrum() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_ALTUSMETRUM;
+               load_library();
                return 0x000a;
        }
 
        static int usb_product_altusmetrum_min() {
                return 0x000a;
        }
 
        static int usb_product_altusmetrum_min() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_ALTUSMETRUM_MIN;
+               load_library();
                return 0x000a;
        }
 
        static int usb_product_altusmetrum_max() {
                return 0x000a;
        }
 
        static int usb_product_altusmetrum_max() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_ALTUSMETRUM_MAX;
-               return 0x000d;
+               load_library();
+               return 0x0013;
        }
 
        static int usb_product_telemetrum() {
        }
 
        static int usb_product_telemetrum() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_TELEMETRUM;
+               load_library();
                return 0x000b;
        }
 
        static int usb_product_teledongle() {
                return 0x000b;
        }
 
        static int usb_product_teledongle() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_TELEDONGLE;
+               load_library();
                return 0x000c;
        }
 
        static int usb_product_teleterra() {
                return 0x000c;
        }
 
        static int usb_product_teleterra() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_TELETERRA;
+               load_library();
                return 0x000d;
        }
 
        static int usb_product_telebt() {
                return 0x000d;
        }
 
        static int usb_product_telebt() {
-               if (load_library())
-                       return libaltosConstants.USB_PRODUCT_TELEBT;
+               load_library();
                return 0x000e;
        }
 
                return 0x000e;
        }
 
@@ -378,8 +402,7 @@ public class Altos {
        public final static int product_basestation = 0x10000 + 1;
 
        static String bt_product_telebt() {
        public final static int product_basestation = 0x10000 + 1;
 
        static String bt_product_telebt() {
-               if (load_library())
-                       return libaltosConstants.BLUETOOTH_PRODUCT_TELEBT;
+               load_library();
                return "TeleBT";
        }
 
                return "TeleBT";
        }