summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-13 12:13:18 -0700
committerKeith Packard <keithp@keithp.com>2013-04-13 12:13:18 -0700
commit3cd8ff18a7546c1e251747ba26240cb130003ef1 (patch)
treec02d8b775d91ca828c7cb3092bed363f62c00f99
parent192bc28fbe2a8613d0b42e4fb3f7674a1a50abc7 (diff)
altosdroid: Update UI even if no telem has been received. Center map.
This allows the receiver location to be displayed even when telemetry is not. Center the map on the first valid location, either receiver or rocket. Update center if a significantly more precise location is received. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosdroid/res/layout/tab_landed.xml58
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java23
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java34
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java50
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java32
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java62
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java60
7 files changed, 199 insertions, 120 deletions
diff --git a/altosdroid/res/layout/tab_landed.xml b/altosdroid/res/layout/tab_landed.xml
index 9008700f..f27baa9e 100644
--- a/altosdroid/res/layout/tab_landed.xml
+++ b/altosdroid/res/layout/tab_landed.xml
@@ -67,17 +67,17 @@
android:paddingTop="5dp" >
<TextView
- android:id="@+id/lat_label"
+ android:id="@+id/target_lat_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/latitude_label" />
+ android:text="@string/target_latitude_label" />
<TextView
- android:id="@+id/lat_value"
+ android:id="@+id/target_lat_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
- android:layout_below="@id/lat_label"
+ android:layout_below="@id/target_lat_label"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
@@ -88,17 +88,59 @@
android:paddingTop="5dp" >
<TextView
- android:id="@+id/lon_label"
+ android:id="@+id/target_lon_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/longitude_label" />
+ android:text="@string/target_longitude_label" />
<TextView
- android:id="@+id/lon_value"
+ android:id="@+id/target_lon_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
- android:layout_below="@id/lon_label"
+ android:layout_below="@id/target_lon_label"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="5dp" >
+
+ <TextView
+ android:id="@+id/receiver_lat_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/receiver_latitude_label" />
+
+ <TextView
+ android:id="@+id/receiver_lat_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_below="@id/receiver_lat_label"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingTop="5dp" >
+
+ <TextView
+ android:id="@+id/receiver_lon_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/receiver_longitude_label" />
+
+ <TextView
+ android:id="@+id/receiver_lon_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_below="@id/receiver_lon_label"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
index 93af2fdc..5ce6f810 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
@@ -205,13 +205,11 @@ public class AltosDroid extends FragmentActivity {
void set_location(Location location) {
saved_location = location;
- if (saved_state != null) {
- update_ui(saved_state);
- }
+ update_ui(saved_state);
}
void update_ui(AltosState state) {
- if (saved_state != null) {
+ if (state != null && saved_state != null) {
if (saved_state.state != state.state) {
String currentTab = mTabHost.getCurrentTabTag();
switch (state.state) {
@@ -231,7 +229,7 @@ public class AltosDroid extends FragmentActivity {
AltosGreatCircle from_receiver = null;
- if (saved_location != null && state.gps != null && state.gps.locked) {
+ if (state != null && saved_location != null && state.gps != null && state.gps.locked) {
double altitude = 0;
if (saved_location.hasAltitude())
altitude = saved_location.getAltitude();
@@ -243,16 +241,19 @@ public class AltosDroid extends FragmentActivity {
state.gps.alt);
}
- mCallsignView.setText(state.data.callsign);
- mSerialView.setText(String.format("%d", state.data.serial));
- mFlightView.setText(String.format("%d", state.data.flight));
- mStateView.setText(state.data.state());
- mRSSIView.setText(String.format("%d", state.data.rssi));
+ if (state != null) {
+ mCallsignView.setText(state.data.callsign);
+ mSerialView.setText(String.format("%d", state.data.serial));
+ mFlightView.setText(String.format("%d", state.data.flight));
+ mStateView.setText(state.data.state());
+ mRSSIView.setText(String.format("%d", state.data.rssi));
+ }
for (AltosDroidTab mTab : mTabs)
mTab.update_ui(state, from_receiver, saved_location);
- mAltosVoice.tell(state);
+ if (state != null)
+ mAltosVoice.tell(state);
}
private void onTimerTick() {
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
index de3bc3d2..23d2e97c 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
@@ -86,22 +86,24 @@ public class TabAscent extends Fragment implements AltosDroidTab {
}
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
- mHeightView.setText(String.format("%6.0f m", state.height));
- mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
- mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
- mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
- mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
- mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
-
- if (state.gps != null) {
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ if (state != null) {
+ mHeightView.setText(String.format("%6.0f m", state.height));
+ mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
+ mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
+ mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
+ mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
+ mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
+
+ if (state.gps != null) {
+ mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ }
+
+ mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
+ mApogeeLights.set(state.drogue_sense > 3.2);
+
+ mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
+ mMainLights.set(state.main_sense > 3.2);
}
-
- mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2);
-
- mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2);
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
index 698e89fc..49774a30 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
@@ -90,31 +90,33 @@ public class TabDescent extends Fragment implements AltosDroidTab {
}
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
- mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
- mHeightView.setText(String.format("%6.0f m", state.height));
- if (from_receiver != null) {
- mElevationView.setText(String.format("%3.0f°", from_receiver.elevation));
- mRangeView.setText(String.format("%6.0f m", from_receiver.range));
- mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
- mCompassView.setText(from_receiver.bearing_words(AltosGreatCircle.BEARING_LONG));
- mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
- } else {
- mElevationView.setText("<unknown>");
- mRangeView.setText("<unknown>");
- mBearingView.setText("<unknown>");
- mCompassView.setText("<unknown>");
- mDistanceView.setText("<unknown>");
+ if (state != null) {
+ mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
+ mHeightView.setText(String.format("%6.0f m", state.height));
+ if (from_receiver != null) {
+ mElevationView.setText(String.format("%3.0f°", from_receiver.elevation));
+ mRangeView.setText(String.format("%6.0f m", from_receiver.range));
+ mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
+ mCompassView.setText(from_receiver.bearing_words(AltosGreatCircle.BEARING_LONG));
+ mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
+ } else {
+ mElevationView.setText("<unknown>");
+ mRangeView.setText("<unknown>");
+ mBearingView.setText("<unknown>");
+ mCompassView.setText("<unknown>");
+ mDistanceView.setText("<unknown>");
+ }
+ if (state.gps != null) {
+ mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ }
+
+ mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
+ mApogeeLights.set(state.drogue_sense > 3.2);
+
+ mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
+ mMainLights.set(state.main_sense > 3.2);
}
- if (state.gps != null) {
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
- }
-
- mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2);
-
- mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2);
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java
index c346dc99..f42b46b5 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java
@@ -33,8 +33,10 @@ public class TabLanded extends Fragment implements AltosDroidTab {
private TextView mBearingView;
private TextView mDistanceView;
- private TextView mLatitudeView;
- private TextView mLongitudeView;
+ private TextView mTargetLatitudeView;
+ private TextView mTargetLongitudeView;
+ private TextView mReceiverLatitudeView;
+ private TextView mReceiverLongitudeView;
private TextView mMaxHeightView;
private TextView mMaxSpeedView;
private TextView mMaxAccelView;
@@ -53,8 +55,10 @@ public class TabLanded extends Fragment implements AltosDroidTab {
mBearingView = (TextView) v.findViewById(R.id.bearing_value);
mDistanceView = (TextView) v.findViewById(R.id.distance_value);
- mLatitudeView = (TextView) v.findViewById(R.id.lat_value);
- mLongitudeView = (TextView) v.findViewById(R.id.lon_value);
+ mTargetLatitudeView = (TextView) v.findViewById(R.id.target_lat_value);
+ mTargetLongitudeView = (TextView) v.findViewById(R.id.target_lon_value);
+ mReceiverLatitudeView = (TextView) v.findViewById(R.id.receiver_lat_value);
+ mReceiverLongitudeView = (TextView) v.findViewById(R.id.receiver_lon_value);
mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value);
mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value);
mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value);
@@ -74,13 +78,21 @@ public class TabLanded extends Fragment implements AltosDroidTab {
mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
}
- if (state.gps != null) {
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ if (state != null && state.gps != null) {
+ mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ }
+
+ if (receiver != null) {
+ mReceiverLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
+ mReceiverLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "W", "E"));
+ }
+
+ if (state != null) {
+ mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
+ mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
+ mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
}
- mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
- mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
- mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
index 29696dbf..66669ad0 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
@@ -60,6 +60,8 @@ public class TabMap extends Fragment implements AltosDroidTab {
private TextView mReceiverLatitudeView;
private TextView mReceiverLongitudeView;
+ private double mapAccuracy = -1;
+
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
@@ -118,7 +120,6 @@ public class TabMap extends Fragment implements AltosDroidTab {
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setTiltGesturesEnabled(false);
mMap.getUiSettings().setZoomControlsEnabled(false);
- mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40.8,-104.7),8));
mRocketMarker = mMap.addMarker(
// From: http://mapicons.nicolasmollet.com/markers/industry/military/missile-2/
@@ -144,35 +145,52 @@ public class TabMap extends Fragment implements AltosDroidTab {
}
}
- public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
- if (state.from_pad != null) {
- mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance));
- mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
+ private void center(double lat, double lon, double accuracy) {
+ if (mapAccuracy < 0 || accuracy < mapAccuracy/10) {
+ mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon),14));
+ mapAccuracy = accuracy;
}
- if (state.gps != null) {
- mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ }
+ public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
+ if (state != null) {
+ if (state.from_pad != null) {
+ mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance));
+ mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
+ }
+ if (mapLoaded) {
+ if (state.gps != null) {
+ mRocketMarker.setPosition(new LatLng(state.gps.lat, state.gps.lon));
+ mRocketMarker.setVisible(true);
+
+ mPolyline.setPoints(Arrays.asList(new LatLng(state.pad_lat, state.pad_lon), new LatLng(state.gps.lat, state.gps.lon)));
+ mPolyline.setVisible(true);
+ }
+
+ if (state.state == AltosLib.ao_flight_pad) {
+ mPadMarker.setPosition(new LatLng(state.pad_lat, state.pad_lon));
+ mPadMarker.setVisible(true);
+ }
+ }
+ if (state.gps != null) {
+ mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ if (state.gps.locked && state.gps.nsat >= 4)
+ center (state.gps.lat, state.gps.lon, 10);
+ }
}
if (receiver != null) {
+ double accuracy;
+
+ if (receiver.hasAccuracy())
+ accuracy = receiver.getAccuracy();
+ else
+ accuracy = 1000;
mReceiverLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
mReceiverLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "W", "E"));
+ center (receiver.getLatitude(), receiver.getLongitude(), accuracy);
}
- if (mapLoaded) {
- if (state.gps != null) {
- mRocketMarker.setPosition(new LatLng(state.gps.lat, state.gps.lon));
- mRocketMarker.setVisible(true);
-
- mPolyline.setPoints(Arrays.asList(new LatLng(state.pad_lat, state.pad_lon), new LatLng(state.gps.lat, state.gps.lon)));
- mPolyline.setVisible(true);
- }
-
- if (state.state == AltosLib.ao_flight_pad) {
- mPadMarker.setPosition(new LatLng(state.pad_lat, state.pad_lon));
- mPadMarker.setVisible(true);
- }
- }
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
index 5070ec0b..3c168e37 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
@@ -102,35 +102,37 @@ public class TabPad extends Fragment implements AltosDroidTab {
}
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
- mBatteryVoltageView.setText(String.format("%4.2f V", state.battery));
- mBatteryLights.set(state.battery > 3.7);
-
- mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2);
-
- mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2);
-
- if (state.data.flight != 0) {
- if (state.data.state <= AltosLib.ao_flight_pad)
- mDataLoggingView.setText("Ready to record");
- else if (state.data.state < AltosLib.ao_flight_landed)
- mDataLoggingView.setText("Recording data");
- else
- mDataLoggingView.setText("Recorded data");
- } else {
- mDataLoggingView.setText("Storage full");
- }
- mDataLoggingLights.set(state.data.flight != 0);
-
- if (state.gps != null) {
- mGPSLockedView.setText(String.format("%4d sats", state.gps.nsat));
- mGPSLockedLights.set(state.gps.locked && state.gps.nsat >= 4);
- if (state.gps_ready)
- mGPSReadyView.setText("Ready");
- else
- mGPSReadyView.setText(String.format("Waiting %d", state.gps_waiting));
- mGPSReadyLights.set(state.gps_ready);
+ if (state != null) {
+ mBatteryVoltageView.setText(String.format("%4.2f V", state.battery));
+ mBatteryLights.set(state.battery > 3.7);
+
+ mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
+ mApogeeLights.set(state.drogue_sense > 3.2);
+
+ mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
+ mMainLights.set(state.main_sense > 3.2);
+
+ if (state.data.flight != 0) {
+ if (state.data.state <= AltosLib.ao_flight_pad)
+ mDataLoggingView.setText("Ready to record");
+ else if (state.data.state < AltosLib.ao_flight_landed)
+ mDataLoggingView.setText("Recording data");
+ else
+ mDataLoggingView.setText("Recorded data");
+ } else {
+ mDataLoggingView.setText("Storage full");
+ }
+ mDataLoggingLights.set(state.data.flight != 0);
+
+ if (state.gps != null) {
+ mGPSLockedView.setText(String.format("%4d sats", state.gps.nsat));
+ mGPSLockedLights.set(state.gps.locked && state.gps.nsat >= 4);
+ if (state.gps_ready)
+ mGPSReadyView.setText("Ready");
+ else
+ mGPSReadyView.setText(String.format("Waiting %d", state.gps_waiting));
+ mGPSReadyLights.set(state.gps_ready);
+ }
}
if (receiver != null) {