android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/apogee_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/apogee_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/main_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/main_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/apogee_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/apogee_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/main_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/main_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/battery_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/battery_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/apogee_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/apogee_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/main_voltage_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/main_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/logging_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/logging_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/gps_locked_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/gps_locked_greenled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/gps_ready_label"
- android:src="@drawable/redled" />
+ android:src="@drawable/grayled" />
<ImageView
android:id="@+id/gps_ready_greenled"
static String pos(double p, String pos, String neg) {
String h = pos;
+ if (p == AltosRecord.MISSING)
+ return "";
if (p < 0) {
h = neg;
p = -p;
return String.format("%d°%9.4f\" %s", deg, min, h);
}
+ static String number(String format, double value) {
+ if (value == AltosRecord.MISSING)
+ return "";
+ return String.format(format, value);
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
public class GoNoGoLights {
private Boolean state;
+ private Boolean missing;
+ private Boolean set;
private ImageView red;
private ImageView green;
red = in_red;
green = in_green;
state = false;
+ missing = true;
+ set = false;
dRed = r.getDrawable(R.drawable.redled);
dGreen = r.getDrawable(R.drawable.greenled);
dGray = r.getDrawable(R.drawable.grayled);
}
- public void set(Boolean s) {
- if (s == state) return;
+ public void set(Boolean s, Boolean m) {
+ if (set && s == state && m == missing) return;
state = s;
- if (state) {
+ missing = m;
+ set = true;
+ if (missing) {
+ red.setImageDrawable(dGray);
+ green.setImageDrawable(dGray);
+ } else if (state) {
red.setImageDrawable(dGray);
green.setImageDrawable(dGreen);
} else {
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (state != null) {
- mHeightView.setText(String.format("%6.0f m", state.height));
- mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
- mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
- mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
- mAccelView.setText(String.format("%6.0f m/s²", state.acceleration));
- mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
+ mHeightView.setText(AltosDroid.number("%6.0f m", state.height));
+ mMaxHeightView.setText(AltosDroid.number("%6.0f m", state.max_height));
+ mSpeedView.setText(AltosDroid.number("%6.0f m/s", state.speed()));
+ mMaxSpeedView.setText(AltosDroid.number("%6.0f m/s", state.max_speed()));
+ mAccelView.setText(AltosDroid.number("%6.0f m/s²", state.acceleration));
+ mMaxAccelView.setText(AltosDroid.number("%6.0f m/s²", state.max_acceleration));
if (state.gps != null) {
mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+ } else {
+ mLatitudeView.setText("");
+ mLongitudeView.setText("");
}
- mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2);
+ mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
+ mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosRecord.MISSING);
- mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2);
+ mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
+ mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosRecord.MISSING);
}
}
}
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (state != null) {
- mSpeedView.setText(String.format("%6.0f m/s", state.speed()));
- mHeightView.setText(String.format("%6.0f m", state.height));
+ mSpeedView.setText(AltosDroid.number("%6.0f m/s", state.speed()));
+ mHeightView.setText(AltosDroid.number("%6.0f m", state.height));
if (from_receiver != null) {
- mElevationView.setText(String.format("%3.0f°", from_receiver.elevation));
- mRangeView.setText(String.format("%6.0f m", from_receiver.range));
- mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
+ mElevationView.setText(AltosDroid.number("%3.0f°", from_receiver.elevation));
+ mRangeView.setText(AltosDroid.number("%6.0f m", from_receiver.range));
+ mBearingView.setText(AltosDroid.number("%3.0f°", from_receiver.bearing));
mCompassView.setText(from_receiver.bearing_words(AltosGreatCircle.BEARING_LONG));
- mDistanceView.setText(String.format("%6.0f m", from_receiver.distance));
+ mDistanceView.setText(AltosDroid.number("%6.0f m", from_receiver.distance));
} else {
mElevationView.setText("<unknown>");
mRangeView.setText("<unknown>");
mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
}
- mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2);
+ mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
+ mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosRecord.MISSING);
- mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2);
+ mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
+ mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosRecord.MISSING);
}
}
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (state != null) {
- mBatteryVoltageView.setText(String.format("%4.2f V", state.battery));
- mBatteryLights.set(state.battery > 3.7);
+ mBatteryVoltageView.setText(AltosDroid.number("%4.2f V", state.battery));
+ mBatteryLights.set(state.battery > 3.7, state.battery == AltosRecord.MISSING);
- mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2);
+ mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
+ mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosRecord.MISSING);
- mMainVoltageView.setText(String.format("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2);
+ mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
+ mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosRecord.MISSING);
if (state.data.flight != 0) {
if (state.data.state <= AltosLib.ao_flight_pad)
} else {
mDataLoggingView.setText("Storage full");
}
- mDataLoggingLights.set(state.data.flight != 0);
+ mDataLoggingLights.set(state.data.flight != 0, state.data.flight != AltosRecord.MISSING);
if (state.gps != null) {
- mGPSLockedView.setText(String.format("%4d sats", state.gps.nsat));
- mGPSLockedLights.set(state.gps.locked && state.gps.nsat >= 4);
+ mGPSLockedView.setText(AltosDroid.number("%4d sats", state.gps.nsat));
+ mGPSLockedLights.set(state.gps.locked && state.gps.nsat >= 4, false);
if (state.gps_ready)
mGPSReadyView.setText("Ready");
else
- mGPSReadyView.setText(String.format("Waiting %d", state.gps_waiting));
- mGPSReadyLights.set(state.gps_ready);
- }
+ mGPSReadyView.setText(AltosDroid.number("Waiting %d", state.gps_waiting));
+ } else
+ mGPSLockedLights.set(false, true);
+ mGPSReadyLights.set(state.gps_ready, state.gps == null);
}
if (receiver != null) {
altitude = receiver.getAltitude();
mPadLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
mPadLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "W", "E"));
- mPadAltitudeView.setText(String.format("%4.0f m", altitude));
+ mPadAltitudeView.setText(AltosDroid.number("%4.0f m", altitude));
}
}