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_6.*;
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 TabAscent extends AltosDroidTab {
33 AltosDroid mAltosDroid;
35 private TextView mHeightView;
36 private TextView mMaxHeightView;
37 private TextView mSpeedView;
38 private TextView mMaxSpeedView;
39 private TextView mAccelView;
40 private TextView mMaxAccelView;
41 private TextView mLatitudeView;
42 private TextView mLongitudeView;
43 private TextView mApogeeVoltageView;
44 private GoNoGoLights mApogeeLights;
45 private TextView mMainVoltageView;
46 private GoNoGoLights mMainLights;
49 public void onAttach(Activity activity) {
50 super.onAttach(activity);
51 mAltosDroid = (AltosDroid) activity;
52 mAltosDroid.registerTab(this);
56 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
57 View v = inflater.inflate(R.layout.tab_ascent, container, false);
59 mHeightView = (TextView) v.findViewById(R.id.height_value);
60 mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value);
61 mSpeedView = (TextView) v.findViewById(R.id.speed_value);
62 mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value);
63 mAccelView = (TextView) v.findViewById(R.id.accel_value);
64 mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value);
65 mLatitudeView = (TextView) v.findViewById(R.id.lat_value);
66 mLongitudeView = (TextView) v.findViewById(R.id.lon_value);
68 mApogeeVoltageView = (TextView) v.findViewById(R.id.apogee_voltage_value);
69 mApogeeLights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled),
70 (ImageView) v.findViewById(R.id.apogee_greenled),
73 mMainVoltageView = (TextView) v.findViewById(R.id.main_voltage_value);
74 mMainLights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled),
75 (ImageView) v.findViewById(R.id.main_greenled),
82 public void onDestroy() {
84 mAltosDroid.unregisterTab(this);
88 public String tab_name() {
92 public void show(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
94 set_value(mHeightView, AltosConvert.height, 6, state.height());
95 set_value(mHeightView, AltosConvert.height, 6, state.height());
96 set_value(mMaxHeightView, AltosConvert.height, 6, state.max_height());
97 set_value(mSpeedView, AltosConvert.speed, 6, state.speed());
98 set_value(mMaxSpeedView, AltosConvert.speed, 6, state.max_speed());
99 set_value(mAccelView, AltosConvert.accel, 6, state.acceleration());
100 set_value(mMaxAccelView, AltosConvert.accel, 6, state.max_acceleration());
102 if (state.gps != null) {
103 mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
104 mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W"));
106 mLatitudeView.setText("");
107 mLongitudeView.setText("");
110 mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage));
111 mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING);
113 mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage));
114 mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING);