summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0224346)
Avoid crashing.
Signed-off-by: Keith Packard <keithp@keithp.com>
AltosGreatCircle from_receiver = null;
if (saved_location != null && state.gps != null && state.gps.locked) {
AltosGreatCircle from_receiver = null;
if (saved_location != null && state.gps != null && state.gps.locked) {
+ double altitude = 0;
+ if (saved_location.hasAltitude())
+ altitude = saved_location.getAltitude();
from_receiver = new AltosGreatCircle(saved_location.getLatitude(),
saved_location.getLongitude(),
from_receiver = new AltosGreatCircle(saved_location.getLatitude(),
saved_location.getLongitude(),
- saved_location.getAltitude(),
state.gps.lat,
state.gps.lon,
state.gps.alt);
state.gps.lat,
state.gps.lon,
state.gps.alt);
mRSSIView.setText(String.format("%d", state.data.rssi));
for (AltosDroidTab mTab : mTabs)
mRSSIView.setText(String.format("%d", state.data.rssi));
for (AltosDroidTab mTab : mTabs)
- mTab.update_ui(state, from_receiver);
+ mTab.update_ui(state, from_receiver, saved_location);
mAltosVoice.tell(state);
}
mAltosVoice.tell(state);
}
package org.altusmetrum.AltosDroid;
import org.altusmetrum.altoslib_1.*;
package org.altusmetrum.AltosDroid;
import org.altusmetrum.altoslib_1.*;
+import android.location.Location;
public interface AltosDroidTab {
public interface AltosDroidTab {
- public void update_ui(AltosState state, AltosGreatCircle from_receiver);
+ public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver);
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import android.location.Location;
public class TabAscent extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
public class TabAscent extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
- public void update_ui(AltosState state, AltosGreatCircle from_receiver) {
+ 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()));
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()));
mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ 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);
mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
mApogeeLights.set(state.drogue_sense > 3.2);
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import android.location.Location;
public class TabDescent extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
public class TabDescent extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
- public void update_ui(AltosState state, AltosGreatCircle from_receiver) {
+ 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) {
mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
mHeightView.setText(String.format("%6.0f m", state.height));
if (from_receiver != null) {
mCompassView.setText("<unknown>");
mDistanceView.setText("<unknown>");
}
mCompassView.setText("<unknown>");
mDistanceView.setText("<unknown>");
}
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ 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);
mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
mApogeeLights.set(state.drogue_sense > 3.2);
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import android.location.Location;
public class TabLanded extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
public class TabLanded extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
- public void update_ui(AltosState state, AltosGreatCircle from_receiver) {
+ public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (from_receiver != null) {
mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
}
if (from_receiver != null) {
mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
}
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ if (state.gps != null) {
+ mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ }
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()));
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import android.location.Location;
public class TabMap extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
public class TabMap extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
private Marker mRocketMarker;
private Marker mPadMarker;
private Marker mRocketMarker;
private Marker mPadMarker;
+ private Marker mReceiverMarker;
private Polyline mPolyline;
private TextView mDistanceView;
private Polyline mPolyline;
private TextView mDistanceView;
+ mReceiverMarker = mMap.addMarker(
+ new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.pad))
+ .position(new LatLng(0,0))
+ .visible(false)
+ );
+
mPolyline = mMap.addPolyline(
new PolylineOptions().add(new LatLng(0,0), new LatLng(0,0))
.width(3)
mPolyline = mMap.addPolyline(
new PolylineOptions().add(new LatLng(0,0), new LatLng(0,0))
.width(3)
- public void update_ui(AltosState state, AltosGreatCircle from_receiver) {
+ 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));
}
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));
}
- mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ if (state.gps != null) {
+ mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+ mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ }
- mRocketMarker.setPosition(new LatLng(state.gps.lat, state.gps.lon));
- mRocketMarker.setVisible(true);
+ 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);
+ 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.state == AltosLib.ao_flight_pad) {
mPadMarker.setPosition(new LatLng(state.pad_lat, state.pad_lon));
mPadMarker.setVisible(true);
}
+
+ if (receiver != null) {
+ mReceiverMarker.setPosition(new LatLng(receiver.getLatitude(), receiver.getLongitude()));
+ mReceiverMarker.setVisible(true);
+ }
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import android.location.Location;
public class TabPad extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
public class TabPad extends Fragment implements AltosDroidTab {
AltosDroid mAltosDroid;
- public void update_ui(AltosState state, AltosGreatCircle from_receiver) {
+ 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);
mBatteryVoltageView.setText(String.format("%4.2f V", state.battery));
mBatteryLights.set(state.battery > 3.7);
}
mDataLoggingLights.set(state.data.flight != 0);
}
mDataLoggingLights.set(state.data.flight != 0);
- 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.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);
+ }
- mPadLatitudeView.setText(AltosDroid.pos(state.pad_lat, "N", "S"));
- mPadLongitudeView.setText(AltosDroid.pos(state.pad_lon, "W", "E"));
- mPadAltitudeView.setText(String.format("%4.0f m", state.pad_alt));
+ if (receiver != null) {
+ double altitude = 0;
+ if (receiver.hasAltitude())
+ altitude = receiver.getAltitude();
+ mPadLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
+ mPadLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "W", "E"));
+ mPadAltitudeView.setText(String.format("%4.0f m", altitude));
+ }