X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FTabPad.java;h=92bb9013375b47ce18cf86a087ead4c2e2e192af;hp=7a256963c27c460929cee19d2126d7aff6c47cd2;hb=9af72a2e629779833ff1787bbfc2ddc8b9d88bba;hpb=c813c2c8f71017a686128e06b5178fc99ece251c diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java index 7a256963..92bb9013 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java @@ -30,64 +30,78 @@ import android.widget.TextView; import android.location.Location; public class TabPad extends AltosDroidTab { - private TextView mBatteryVoltageView; - private TextView mBatteryVoltageLabel; - private GoNoGoLights mBatteryLights; - private TextView mApogeeVoltageView; - private TextView mApogeeVoltageLabel; - private GoNoGoLights mApogeeLights; - private TextView mMainVoltageView; - private TextView mMainVoltageLabel; - private GoNoGoLights mMainLights; - private TextView mDataLoggingView; - private GoNoGoLights mDataLoggingLights; - private TextView mGPSLockedView; - private GoNoGoLights mGPSLockedLights; - private TextView mGPSReadyView; - private GoNoGoLights mGPSReadyLights; - private TextView mPadLatitudeView; - private TextView mPadLongitudeView; - private TextView mPadAltitudeView; + private TextView battery_voltage_view; + private GoNoGoLights battery_lights; + + private TextView receiver_voltage_view; + private TextView receiver_voltage_label; + private GoNoGoLights receiver_voltage_lights; + + private TextView apogee_voltage_view; + private TextView apogee_voltage_label; + private GoNoGoLights apogee_lights; + + private TextView main_voltage_view; + private TextView main_voltage_label; + private GoNoGoLights main_lights; + + private TextView data_logging_view; + private GoNoGoLights data_logging_lights; + + private TextView gps_locked_view; + private GoNoGoLights gps_locked_lights; + + private TextView gps_ready_view; + private GoNoGoLights gps_ready_lights; + + private TextView pad_latitude_view; + private TextView pad_longitude_view; + private TextView pad_altitude_view; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.tab_pad, container, false); - mBatteryVoltageView = (TextView) v.findViewById(R.id.battery_voltage_value); - mBatteryVoltageLabel = (TextView) v.findViewById(R.id.battery_voltage_label); - mBatteryLights = new GoNoGoLights((ImageView) v.findViewById(R.id.battery_redled), + battery_voltage_view = (TextView) v.findViewById(R.id.battery_voltage_value); + battery_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.battery_redled), (ImageView) v.findViewById(R.id.battery_greenled), getResources()); - mApogeeVoltageView = (TextView) v.findViewById(R.id.apogee_voltage_value); - mApogeeVoltageLabel = (TextView) v.findViewById(R.id.apogee_voltage_label); - mApogeeLights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled), + receiver_voltage_view = (TextView) v.findViewById(R.id.receiver_voltage_value); + receiver_voltage_label = (TextView) v.findViewById(R.id.receiver_voltage_label); + receiver_voltage_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.receiver_redled), + (ImageView) v.findViewById(R.id.receiver_greenled), + getResources()); + + apogee_voltage_view = (TextView) v.findViewById(R.id.apogee_voltage_value); + apogee_voltage_label = (TextView) v.findViewById(R.id.apogee_voltage_label); + apogee_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled), (ImageView) v.findViewById(R.id.apogee_greenled), getResources()); - mMainVoltageView = (TextView) v.findViewById(R.id.main_voltage_value); - mMainVoltageLabel = (TextView) v.findViewById(R.id.main_voltage_label); - mMainLights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled), + main_voltage_view = (TextView) v.findViewById(R.id.main_voltage_value); + main_voltage_label = (TextView) v.findViewById(R.id.main_voltage_label); + main_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled), (ImageView) v.findViewById(R.id.main_greenled), getResources()); - mDataLoggingView = (TextView) v.findViewById(R.id.logging_value); - mDataLoggingLights = new GoNoGoLights((ImageView) v.findViewById(R.id.logging_redled), + data_logging_view = (TextView) v.findViewById(R.id.logging_value); + data_logging_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.logging_redled), (ImageView) v.findViewById(R.id.logging_greenled), getResources()); - mGPSLockedView = (TextView) v.findViewById(R.id.gps_locked_value); - mGPSLockedLights = new GoNoGoLights((ImageView) v.findViewById(R.id.gps_locked_redled), + gps_locked_view = (TextView) v.findViewById(R.id.gps_locked_value); + gps_locked_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.gps_locked_redled), (ImageView) v.findViewById(R.id.gps_locked_greenled), getResources()); - mGPSReadyView = (TextView) v.findViewById(R.id.gps_ready_value); - mGPSReadyLights = new GoNoGoLights((ImageView) v.findViewById(R.id.gps_ready_redled), + gps_ready_view = (TextView) v.findViewById(R.id.gps_ready_value); + gps_ready_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.gps_ready_redled), (ImageView) v.findViewById(R.id.gps_ready_greenled), getResources()); - mPadLatitudeView = (TextView) v.findViewById(R.id.pad_lat_value); - mPadLongitudeView = (TextView) v.findViewById(R.id.pad_lon_value); - mPadAltitudeView = (TextView) v.findViewById(R.id.pad_alt_value); + pad_latitude_view = (TextView) v.findViewById(R.id.pad_lat_value); + pad_longitude_view = (TextView) v.findViewById(R.id.pad_lon_value); + pad_altitude_view = (TextView) v.findViewById(R.id.pad_alt_value); return v; } @@ -95,60 +109,72 @@ public class TabPad extends AltosDroidTab { public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { if (state != null) { - mBatteryVoltageView.setText(AltosDroid.number("%4.2f V", state.battery_voltage)); - mBatteryLights.set(state.battery_voltage >= AltosLib.ao_battery_good, state.battery_voltage == AltosLib.MISSING); + battery_voltage_view.setText(AltosDroid.number("%4.2f V", state.battery_voltage)); + battery_lights.set(state.battery_voltage >= AltosLib.ao_battery_good, state.battery_voltage == AltosLib.MISSING); if (state.apogee_voltage == AltosLib.MISSING) { - mApogeeVoltageView.setVisibility(View.GONE); - mApogeeVoltageLabel.setVisibility(View.GONE); + apogee_voltage_view.setVisibility(View.GONE); + apogee_voltage_label.setVisibility(View.GONE); } else { - mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage)); - mApogeeVoltageView.setVisibility(View.VISIBLE); - mApogeeVoltageLabel.setVisibility(View.VISIBLE); + apogee_voltage_view.setText(AltosDroid.number("%4.2f V", state.apogee_voltage)); + apogee_voltage_view.setVisibility(View.VISIBLE); + apogee_voltage_label.setVisibility(View.VISIBLE); } - mApogeeLights.set(state.apogee_voltage >= AltosLib.ao_igniter_good, state.apogee_voltage == AltosLib.MISSING); + apogee_lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good, state.apogee_voltage == AltosLib.MISSING); if (state.main_voltage == AltosLib.MISSING) { - mMainVoltageView.setVisibility(View.GONE); - mMainVoltageLabel.setVisibility(View.GONE); + main_voltage_view.setVisibility(View.GONE); + main_voltage_label.setVisibility(View.GONE); } else { - mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage)); - mMainVoltageView.setVisibility(View.VISIBLE); - mMainVoltageLabel.setVisibility(View.VISIBLE); + main_voltage_view.setText(AltosDroid.number("%4.2f V", state.main_voltage)); + main_voltage_view.setVisibility(View.VISIBLE); + main_voltage_label.setVisibility(View.VISIBLE); } - mMainLights.set(state.main_voltage >= AltosLib.ao_igniter_good, state.main_voltage == AltosLib.MISSING); + main_lights.set(state.main_voltage >= AltosLib.ao_igniter_good, state.main_voltage == AltosLib.MISSING); if (state.flight != 0) { if (state.state <= AltosLib.ao_flight_pad) - mDataLoggingView.setText("Ready to record"); + data_logging_view.setText("Ready to record"); else if (state.state < AltosLib.ao_flight_landed) - mDataLoggingView.setText("Recording data"); + data_logging_view.setText("Recording data"); else - mDataLoggingView.setText("Recorded data"); + data_logging_view.setText("Recorded data"); } else { - mDataLoggingView.setText("Storage full"); + data_logging_view.setText("Storage full"); } - mDataLoggingLights.set(state.flight != 0, state.flight == AltosLib.MISSING); + data_logging_lights.set(state.flight != 0, state.flight == AltosLib.MISSING); if (state.gps != null) { int soln = state.gps.nsat; int nsat = state.gps.cc_gps_sat != null ? state.gps.cc_gps_sat.length : 0; - mGPSLockedView.setText(String.format("%4d in soln, %4d in view", soln, nsat)); - mGPSLockedLights.set(state.gps.locked && state.gps.nsat >= 4, false); + gps_locked_view.setText(String.format("%4d in soln, %4d in view", soln, nsat)); + gps_locked_lights.set(state.gps.locked && state.gps.nsat >= 4, false); if (state.gps_ready) - mGPSReadyView.setText("Ready"); + gps_ready_view.setText("Ready"); else - mGPSReadyView.setText(AltosDroid.integer("Waiting %d", state.gps_waiting)); + gps_ready_view.setText(AltosDroid.integer("Waiting %d", state.gps_waiting)); } else - mGPSLockedLights.set(false, true); - mGPSReadyLights.set(state.gps_ready, state.gps == null); + gps_locked_lights.set(false, true); + gps_ready_lights.set(state.gps_ready, state.gps == null); + } + + if (telem_state != null) { + if (telem_state.receiver_battery == AltosLib.MISSING) { + receiver_voltage_view.setVisibility(View.GONE); + receiver_voltage_label.setVisibility(View.GONE); + } else { + receiver_voltage_view.setText(AltosDroid.number("%4.2f V", telem_state.receiver_battery)); + receiver_voltage_view.setVisibility(View.VISIBLE); + receiver_voltage_label.setVisibility(View.VISIBLE); + } + receiver_voltage_lights.set(telem_state.receiver_battery >= AltosLib.ao_battery_good, telem_state.receiver_battery == AltosLib.MISSING); } if (receiver != null) { double altitude = AltosLib.MISSING; if (receiver.hasAltitude()) altitude = receiver.getAltitude(); - mPadLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S")); - mPadLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W")); - set_value(mPadAltitudeView, AltosConvert.height, 6, altitude); + pad_latitude_view.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S")); + pad_longitude_view.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W")); + set_value(pad_altitude_view, AltosConvert.height, 6, altitude); } }