2 * Copyright © 2013 Mike Beattie <mike@ethernal.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosDroid;
20 import org.altusmetrum.altoslib_7.*;
22 import android.app.Activity;
23 import android.os.Bundle;
24 import android.support.v4.app.Fragment;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.widget.ImageView;
29 import android.widget.TextView;
30 import android.location.Location;
32 public class TabDescent extends AltosDroidTab {
33 private TextView mSpeedView;
34 private TextView mHeightView;
35 private TextView mElevationView;
36 private TextView mRangeView;
37 private TextView mBearingView;
38 private TextView mCompassView;
39 private TextView mDistanceView;
40 private TextView mLatitudeView;
41 private TextView mLongitudeView;
42 private TextView mApogeeVoltageView;
43 private GoNoGoLights mApogeeLights;
44 private TextView mMainVoltageView;
45 private GoNoGoLights mMainLights;
48 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
49 View v = inflater.inflate(R.layout.tab_descent, container, false);
51 mSpeedView = (TextView) v.findViewById(R.id.speed_value);
52 mHeightView = (TextView) v.findViewById(R.id.height_value);
53 mElevationView = (TextView) v.findViewById(R.id.elevation_value);
54 mRangeView = (TextView) v.findViewById(R.id.range_value);
55 mBearingView = (TextView) v.findViewById(R.id.bearing_value);
56 mCompassView = (TextView) v.findViewById(R.id.compass_value);
57 mDistanceView = (TextView) v.findViewById(R.id.distance_value);
58 mLatitudeView = (TextView) v.findViewById(R.id.lat_value);
59 mLongitudeView = (TextView) v.findViewById(R.id.lon_value);
61 mApogeeVoltageView = (TextView) v.findViewById(R.id.apogee_voltage_value);
62 mApogeeLights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled),
63 (ImageView) v.findViewById(R.id.apogee_greenled),
66 mMainVoltageView = (TextView) v.findViewById(R.id.main_voltage_value);
67 mMainLights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled),
68 (ImageView) v.findViewById(R.id.main_greenled),
74 public String tab_name() { return "descent"; }
76 public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
78 set_value(mSpeedView, AltosConvert.speed, 6, state.speed());
79 set_value(mHeightView, AltosConvert.height, 6, state.height());
80 if (from_receiver != null) {
81 mElevationView.setText(AltosDroid.number("%3.0f°", from_receiver.elevation));
82 set_value(mRangeView, AltosConvert.distance, 6, from_receiver.range);
83 mBearingView.setText(AltosDroid.number("%3.0f°", from_receiver.bearing));
84 mCompassView.setText(from_receiver.bearing_words(AltosGreatCircle.BEARING_LONG));
85 set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance);
87 mElevationView.setText("<unknown>");
88 mRangeView.setText("<unknown>");
89 mBearingView.setText("<unknown>");
90 mCompassView.setText("<unknown>");
91 mDistanceView.setText("<unknown>");
93 if (state.gps != null) {
94 mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
95 mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W"));
98 mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage));
99 mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING);
101 mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage));
102 mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING);