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 TabAscent extends AltosDroidTab {
33 private TextView mHeightView;
34 private TextView mMaxHeightView;
35 private TextView mSpeedView;
36 private TextView mMaxSpeedView;
37 private TextView mAccelView;
38 private TextView mMaxAccelView;
39 private TextView mLatitudeView;
40 private TextView mLongitudeView;
41 private TextView mApogeeVoltageView;
42 private GoNoGoLights mApogeeLights;
43 private TextView mMainVoltageView;
44 private GoNoGoLights mMainLights;
47 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
48 View v = inflater.inflate(R.layout.tab_ascent, container, false);
50 mHeightView = (TextView) v.findViewById(R.id.height_value);
51 mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value);
52 mSpeedView = (TextView) v.findViewById(R.id.speed_value);
53 mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value);
54 mAccelView = (TextView) v.findViewById(R.id.accel_value);
55 mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value);
56 mLatitudeView = (TextView) v.findViewById(R.id.lat_value);
57 mLongitudeView = (TextView) v.findViewById(R.id.lon_value);
59 mApogeeVoltageView = (TextView) v.findViewById(R.id.apogee_voltage_value);
60 mApogeeLights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled),
61 (ImageView) v.findViewById(R.id.apogee_greenled),
64 mMainVoltageView = (TextView) v.findViewById(R.id.main_voltage_value);
65 mMainLights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled),
66 (ImageView) v.findViewById(R.id.main_greenled),
72 public String tab_name() {
76 public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
78 set_value(mHeightView, AltosConvert.height, 6, state.height());
79 set_value(mHeightView, AltosConvert.height, 6, state.height());
80 set_value(mMaxHeightView, AltosConvert.height, 6, state.max_height());
81 set_value(mSpeedView, AltosConvert.speed, 6, state.speed());
82 set_value(mMaxSpeedView, AltosConvert.speed, 6, state.max_speed());
83 set_value(mAccelView, AltosConvert.accel, 6, state.acceleration());
84 set_value(mMaxAccelView, AltosConvert.accel, 6, state.max_acceleration());
86 if (state.gps != null) {
87 mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
88 mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W"));
90 mLatitudeView.setText("");
91 mLongitudeView.setText("");
94 mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage));
95 mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING);
97 mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage));
98 mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING);