altosdroid: Add tilt angle to pad and flight tabs
authorKeith Packard <keithp@keithp.com>
Mon, 20 Sep 2021 02:01:34 +0000 (19:01 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 20 Sep 2021 02:13:07 +0000 (19:13 -0700)
Useful for monitoring attitude

Signed-off-by: Keith Packard <keithp@keithp.com>
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TabFlight.java
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TabPad.java
altosdroid/app/src/main/res/layout/tab_flight.xml
altosdroid/app/src/main/res/layout/tab_pad.xml
altosdroid/app/src/main/res/values/strings.xml

index 8230757c2b4237c12680cd83627f7f81b6ca1bde..0346f71c42ad99b073a1af457ba5269fe60ff574 100644 (file)
@@ -29,6 +29,8 @@ public class TabFlight extends AltosDroidTab {
        private TextView speed_view;
        private TextView height_view;
        private TextView altitude_view;
        private TextView speed_view;
        private TextView height_view;
        private TextView altitude_view;
+       private View tilt_view;
+       private TextView tilt_value;
        private TextView max_speed_view;
        private TextView max_height_view;
        private TextView max_altitude_view;
        private TextView max_speed_view;
        private TextView max_height_view;
        private TextView max_altitude_view;
@@ -52,11 +54,13 @@ public class TabFlight extends AltosDroidTab {
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                View v = inflater.inflate(R.layout.tab_flight, container, false);
 
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                View v = inflater.inflate(R.layout.tab_flight, container, false);
 
-               speed_view     = (TextView) v.findViewById(R.id.speed_value);
-               height_view    = (TextView) v.findViewById(R.id.height_value);
-               altitude_view    = (TextView) v.findViewById(R.id.altitude_value);
-               max_speed_view = (TextView) v.findViewById(R.id.max_speed_value);
-               max_height_view= (TextView) v.findViewById(R.id.max_height_value);
+               speed_view      = (TextView) v.findViewById(R.id.speed_value);
+               height_view     = (TextView) v.findViewById(R.id.height_value);
+               altitude_view   = (TextView) v.findViewById(R.id.altitude_value);
+               tilt_view       = (View) v.findViewById(R.id.tilt_view);
+               tilt_value      = (TextView) v.findViewById(R.id.tilt_value);
+               max_speed_view  = (TextView) v.findViewById(R.id.max_speed_value);
+               max_height_view = (TextView) v.findViewById(R.id.max_height_value);
                max_altitude_view= (TextView) v.findViewById(R.id.max_altitude_value);
                elevation_view = (TextView) v.findViewById(R.id.elevation_value);
                range_view     = (TextView) v.findViewById(R.id.range_value);
                max_altitude_view= (TextView) v.findViewById(R.id.max_altitude_value);
                elevation_view = (TextView) v.findViewById(R.id.elevation_value);
                range_view     = (TextView) v.findViewById(R.id.range_value);
@@ -90,6 +94,13 @@ public class TabFlight extends AltosDroidTab {
                        set_value(speed_view, AltosConvert.speed, 1, state.speed());
                        set_value(height_view, AltosConvert.height, 1, state.height());
                        set_value(altitude_view, AltosConvert.height, 1, state.altitude());
                        set_value(speed_view, AltosConvert.speed, 1, state.speed());
                        set_value(height_view, AltosConvert.height, 1, state.height());
                        set_value(altitude_view, AltosConvert.height, 1, state.altitude());
+                       double orient = state.orient();
+                       if (orient == AltosLib.MISSING) {
+                               tilt_view.setVisibility(View.GONE);
+                       } else {
+                               tilt_value.setText(AltosDroid.number("%1.0f°", orient));
+                               tilt_view.setVisibility(View.VISIBLE);
+                       }
                        set_value(max_speed_view, AltosConvert.speed, 1, state.max_speed());
                        set_value(max_height_view, AltosConvert.height, 1, state.max_height());
                        set_value(max_altitude_view, AltosConvert.height, 1, state.max_altitude());
                        set_value(max_speed_view, AltosConvert.speed, 1, state.max_speed());
                        set_value(max_height_view, AltosConvert.height, 1, state.max_height());
                        set_value(max_altitude_view, AltosConvert.height, 1, state.max_altitude());
index f526857f00ccedb3a67011dc9b606309dc2394f1..4a8b3f862b9bbeed9077133fc6e8a5b1b1f84f69 100644 (file)
@@ -62,6 +62,8 @@ public class TabPad extends AltosDroidTab {
        private TextView[] ignite_voltage_label = new TextView[4];
        private GoNoGoLights[] ignite_lights = new GoNoGoLights[4];
 
        private TextView[] ignite_voltage_label = new TextView[4];
        private GoNoGoLights[] ignite_lights = new GoNoGoLights[4];
 
+       private View tilt_view;
+       private TextView tilt_value;
 
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@@ -107,6 +109,9 @@ public class TabPad extends AltosDroidTab {
                                                   (ImageView) v.findViewById(R.id.gps_ready_greenled),
                                                   getResources());
 
                                                   (ImageView) v.findViewById(R.id.gps_ready_greenled),
                                                   getResources());
 
+               tilt_view       = (View) v.findViewById(R.id.tilt_view);
+               tilt_value      = (TextView) v.findViewById(R.id.tilt_value);
+
                for (int i = 0; i < 4; i++) {
                        int row_id, view_id, label_id, lights_id;
                        int red_id, green_id;
                for (int i = 0; i < 4; i++) {
                        int row_id, view_id, label_id, lights_id;
                        int red_id, green_id;
@@ -213,8 +218,18 @@ public class TabPad extends AltosDroidTab {
                        } else
                                gps_locked_lights.set(false, true);
                        gps_ready_lights.set(state.gps_ready, state.gps == null);
                        } else
                                gps_locked_lights.set(false, true);
                        gps_ready_lights.set(state.gps_ready, state.gps == null);
+
+                       double orient = state.orient();
+
+                       if (orient == AltosLib.MISSING) {
+                               tilt_view.setVisibility(View.GONE);
+                       } else {
+                               tilt_value.setText(AltosDroid.number("%1.0f°", orient));
+                               tilt_view.setVisibility(View.VISIBLE);
+                       }
                }
 
                }
 
+
                if (telem_state != null) {
                        if (telem_state.receiver_battery == AltosLib.MISSING) {
                                receiver_row.setVisibility(View.GONE);
                if (telem_state != null) {
                        if (telem_state.receiver_battery == AltosLib.MISSING) {
                                receiver_row.setVisibility(View.GONE);
index db65527060206374193476c3a24860da36a38e6f..c588de16b5b32556787d0aebda62a910f363ef9e 100644 (file)
              android:textAppearance="?android:attr/textAppearanceSmall" />
       </TableRow>
 
              android:textAppearance="?android:attr/textAppearanceSmall" />
       </TableRow>
 
+      <TableRow
+         android:id="@+id/tilt_view"
+         android:visibility="gone"
+         android:layout_gravity="center"
+         android:layout_weight="1"
+         android:padding="2dip"
+         android:layout_width="wrap_content"
+         android:layout_height="wrap_content"
+         >
+
+         <TextView
+             android:id="@+id/tilt_label"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:layout_column="2"
+             android:text="@string/tilt_label" />
+
+         <TextView
+             android:id="@+id/tilt_value"
+             android:layout_width="wrap_content"
+             android:layout_height="wrap_content"
+             android:text=""
+             android:textAppearance="?android:attr/textAppearanceSmall" />
+      </TableRow>
+
       <TableRow
          android:layout_gravity="center"
          android:layout_weight="1"
       <TableRow
          android:layout_gravity="center"
          android:layout_weight="1"
index 981f45a880bc7901868618054b07f4aa4e35d365..0eaea9a4e82136160af98584dc294529fedf3c8a 100644 (file)
          android:textAppearance="?android:attr/textAppearanceSmall" />
     </TableRow>
 
          android:textAppearance="?android:attr/textAppearanceSmall" />
     </TableRow>
 
+    <TableRow
+       android:id="@+id/tilt_view"
+       android:visibility="gone"
+       android:layout_gravity="center"
+       android:layout_weight="1"
+       android:padding="2dip"
+       android:layout_width="wrap_content"
+       android:layout_height="wrap_content"
+       >
+
+       <TextView
+           android:id="@+id/tilt_label"
+           android:layout_width="wrap_content"
+           android:layout_height="wrap_content"
+           android:layout_column="2"
+           android:text="@string/tilt_label" />
+
+       <TextView
+           android:id="@+id/tilt_value"
+           android:layout_width="wrap_content"
+           android:layout_height="wrap_content"
+           android:text=""
+           android:textAppearance="?android:attr/textAppearanceSmall" />
+    </TableRow>
+
     <TableRow
        android:padding="2dip"
        android:layout_width="wrap_content"
     <TableRow
        android:padding="2dip"
        android:layout_width="wrap_content"
index 86267fd9529334bd00ff75ea45504f0ec986c9f6..efcfeb22a9413ecf80efff9c6e27ffbaf3e7f902 100644 (file)
@@ -74,6 +74,7 @@
        <string name="altitude_label">Altitude</string>
        <string name="speed_label">Speed</string>
        <string name="accel_label">Acceleration</string>
        <string name="altitude_label">Altitude</string>
        <string name="speed_label">Speed</string>
        <string name="accel_label">Acceleration</string>
+       <string name="tilt_label">Tilt</string>
        <string name="bearing_label">Bearing</string>
        <string name="direction_label">Direction</string>
        <string name="elevation_label">Elevation</string>
        <string name="bearing_label">Bearing</string>
        <string name="direction_label">Direction</string>
        <string name="elevation_label">Elevation</string>