+ aostate_timeout = 0;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+aoview_state_reset(void)
+{
+ memset(&aostate, '\0', sizeof (aostate));
+}
+
+void
+aoview_state_notify(struct aodata *data)
+{
+ struct aostate *state = &aostate;
+ aoview_state_derive(data, state);
+ aoview_table_start();
+
+ if (state->npad >= MIN_PAD_SAMPLES)
+ aoview_table_add_row(0, "Ground state", "ready");
+ else
+ aoview_table_add_row(0, "Ground state", "waiting for gps (%d)",
+ MIN_PAD_SAMPLES - state->npad);
+ aoview_table_add_row(0, "Rocket state", "%s", state->data.state);
+ aoview_table_add_row(0, "Callsign", "%s", state->data.callsign);
+ aoview_table_add_row(0, "Rocket serial", "%d", state->data.serial);
+
+ aoview_table_add_row(0, "RSSI", "%6ddBm", state->data.rssi);
+ aoview_table_add_row(0, "Height", "%6dm", state->height);
+ aoview_table_add_row(0, "Max height", "%6dm", state->max_height);
+ aoview_table_add_row(0, "Acceleration", "%7.1fm/s²", state->acceleration);
+ aoview_table_add_row(0, "Max acceleration", "%7.1fm/s²", state->max_acceleration);
+ aoview_table_add_row(0, "Speed", "%7.1fm/s", state->ascent ? state->speed : state->baro_speed);
+ aoview_table_add_row(0, "Max Speed", "%7.1fm/s", state->max_speed);
+ aoview_table_add_row(0, "Temperature", "%6.2f°C", state->temperature);
+ aoview_table_add_row(0, "Battery", "%5.2fV", state->battery);
+ aoview_table_add_row(0, "Drogue", "%5.2fV", state->drogue_sense);
+ aoview_table_add_row(0, "Main", "%5.2fV", state->main_sense);
+ aoview_table_add_row(0, "Pad altitude", "%dm", state->ground_altitude);
+ aoview_table_add_row(1, "Satellites", "%d", state->gps.nsat);
+ if (state->gps.gps_locked) {
+ aoview_table_add_row(1, "GPS", "locked");
+ } else if (state->gps.gps_connected) {
+ aoview_table_add_row(1, "GPS", "unlocked");
+ } else {
+ aoview_table_add_row(1, "GPS", "not available");
+ }
+ if (state->gps_valid) {
+ aoview_state_add_deg(1, "Latitude", state->gps.lat, 'N', 'S');
+ aoview_state_add_deg(1, "Longitude", state->gps.lon, 'E', 'W');
+ aoview_table_add_row(1, "GPS height", "%d", state->gps_height);
+ aoview_table_add_row(1, "GPS time", "%02d:%02d:%02d",
+ state->gps.gps_time.hour,
+ state->gps.gps_time.minute,
+ state->gps.gps_time.second);
+ }
+ if (state->gps.gps_extended) {
+ aoview_table_add_row(1, "GPS ground speed", "%7.1fm/s %d°",
+ state->gps.ground_speed,
+ state->gps.course);
+ aoview_table_add_row(1, "GPS climb rate", "%7.1fm/s",
+ state->gps.climb_rate);
+ aoview_table_add_row(1, "GPS precision", "%4.1f(hdop) %3dm(h) %3dm(v)",
+ state->gps.hdop, state->gps.h_error, state->gps.v_error);
+ }
+ if (state->npad) {
+ aoview_table_add_row(1, "Distance from pad", "%5.0fm", state->distance);
+ aoview_table_add_row(1, "Direction from pad", "%4.0f°", state->bearing);
+ aoview_state_add_deg(1, "Pad latitude", state->pad_lat, 'N', 'S');
+ aoview_state_add_deg(1, "Pad longitude", state->pad_lon, 'E', 'W');
+ aoview_table_add_row(1, "Pad GPS alt", "%gm", state->pad_alt);