- mCallsignView.setText(state.data.callsign);
- mStateView.setText(state.data.state());
- double speed = state.speed;
- if (!state.ascent)
- speed = state.baro_speed;
- mSpeedView.setText(String.format("%6.0f m/s", speed));
- mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
- mRangeView.setText(String.format("%6.0f m", state.range));
- mAltitudeView.setText(String.format("%6.0f m", state.height));
- mAzimuthView.setText(String.format("%3.0f°", state.elevation));
- if (state.from_pad != null)
- mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
- mLatitudeView.setText(pos(state.gps.lat, "N", "S"));
- mLongitudeView.setText(pos(state.gps.lon, "W", "E"));
+ if (state != null && saved_state != null) {
+ if (saved_state.state != state.state) {
+ String currentTab = mTabHost.getCurrentTabTag();
+ switch (state.state) {
+ case AltosLib.ao_flight_boost:
+ if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("ascent");
+ break;
+ case AltosLib.ao_flight_drogue:
+ if (currentTab.equals("ascent")) mTabHost.setCurrentTabByTag("descent");
+ break;
+ case AltosLib.ao_flight_landed:
+ if (currentTab.equals("descent")) mTabHost.setCurrentTabByTag("landed");
+ break;
+ }
+ }
+ }
+ saved_state = state;
+
+ AltosGreatCircle from_receiver = null;
+
+ if (state != null && 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(),
+ altitude,
+ state.gps.lat,
+ state.gps.lon,
+ state.gps.alt);
+ }
+
+ 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);
+
+ if (state != null)
+ mAltosVoice.tell(state);