Split GPS data into a separate column
authorKeith Packard <keithp@keithp.com>
Fri, 17 Jul 2009 23:22:51 +0000 (16:22 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 17 Jul 2009 23:22:51 +0000 (16:22 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
aoview/aoview.glade
aoview/aoview.h
aoview/aoview_state.c
aoview/aoview_table.c
src/ao_gps.c

index a2dc830f00bae6f8f6c9796b658b093ba3c8b538..df08b83cdb472044545b9a3647480b1c126e159f 100644 (file)
           </packing>
         </child>
         <child>
           </packing>
         </child>
         <child>
-          <widget class="GtkTreeView" id="dataview">
+          <widget class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="headers_clickable">False</property>
-            <property name="show_expanders">False</property>
-            <property name="enable_grid_lines">both</property>
+            <child>
+              <widget class="GtkTreeView" id="dataview_0">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="show_expanders">False</property>
+                <property name="enable_grid_lines">both</property>
+              </widget>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkTreeView" id="dataview_1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="show_expanders">False</property>
+                <property name="enable_grid_lines">both</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
           </widget>
           <packing>
             <property name="position">2</property>
           </widget>
           <packing>
             <property name="position">2</property>
index ac64833fb3e301d9ab1f27ec461da39166b207ca..803bd4a538f186a37ac60ce71c3d356bc72d4d21 100644 (file)
@@ -226,7 +226,7 @@ void
 aoview_table_start(void);
 
 void
 aoview_table_start(void);
 
 void
-aoview_table_add_row(char *label, char *format, ...);
+aoview_table_add_row(int column, char *label, char *format, ...);
 
 void
 aoview_table_finish(void);
 
 void
 aoview_table_finish(void);
index d5e978b68833a856651fd0a999f9c7c9506d4997..8b43ec2993c87559c95f786e057b8f702229755f 100644 (file)
@@ -62,7 +62,7 @@ aoview_great_circle (double start_lat, double start_lon,
 }
 
 static void
 }
 
 static void
-aoview_state_add_deg(char *label, double deg, char pos, char neg)
+aoview_state_add_deg(int column, char *label, double deg, char pos, char neg)
 {
        double  int_part;
        double  min;
 {
        double  int_part;
        double  min;
@@ -74,7 +74,7 @@ aoview_state_add_deg(char *label, double deg, char pos, char neg)
        }
        int_part = floor (deg);
        min = (deg - int_part) * 60.0;
        }
        int_part = floor (deg);
        min = (deg - int_part) * 60.0;
-       aoview_table_add_row(label, "%d°%lf'%c",
+       aoview_table_add_row(column, label, "%d°%lf'%c",
                             (int) int_part, min, sign);
 
 }
                             (int) int_part, min, sign);
 
 }
@@ -266,51 +266,51 @@ aoview_state_notify(struct aodata *data)
        aoview_table_start();
 
        if (state->npad >= MIN_PAD_SAMPLES)
        aoview_table_start();
 
        if (state->npad >= MIN_PAD_SAMPLES)
-               aoview_table_add_row("Ground state", "ready");
+               aoview_table_add_row(0, "Ground state", "ready");
        else
        else
-               aoview_table_add_row("Ground state", "waiting for gps (%d)",
+               aoview_table_add_row(0, "Ground state", "waiting for gps (%d)",
                                     MIN_PAD_SAMPLES - state->npad);
                                     MIN_PAD_SAMPLES - state->npad);
-       aoview_table_add_row("Rocket state", "%s", state->data.state);
-       aoview_table_add_row("Callsign", "%s", state->data.callsign);
-       aoview_table_add_row("Rocket serial", "%d", state->data.serial);
-
-       aoview_table_add_row("RSSI", "%6ddBm", state->data.rssi);
-       aoview_table_add_row("Height", "%6dm", state->height);
-       aoview_table_add_row("Max height", "%6dm", state->max_height);
-       aoview_table_add_row("Acceleration", "%7.1fm/s²", state->acceleration);
-       aoview_table_add_row("Max acceleration", "%7.1fm/s²", state->max_acceleration);
-       aoview_table_add_row("Speed", "%7.1fm/s", state->ascent ? state->speed : state->baro_speed);
-       aoview_table_add_row("Max Speed", "%7.1fm/s", state->max_speed);
-       aoview_table_add_row("Temperature", "%6.2f°C", state->temperature);
-       aoview_table_add_row("Battery", "%5.2fV", state->battery);
-       aoview_table_add_row("Drogue", "%5.2fV", state->drogue_sense);
-       aoview_table_add_row("Main", "%5.2fV", state->main_sense);
-       aoview_table_add_row("Pad altitude", "%dm", state->ground_altitude);
-       aoview_table_add_row("Satellites", "%d", state->data.nsat);
+       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->data.nsat);
        if (state->data.locked) {
        if (state->data.locked) {
-               aoview_state_add_deg("Latitude", state->data.lat, 'N', 'S');
-               aoview_state_add_deg("Longitude", state->data.lon, 'E', 'W');
-               aoview_table_add_row("GPS height", "%d", state->gps_height);
-               aoview_table_add_row("GPS time", "%02d:%02d:%02d",
+               aoview_state_add_deg(1, "Latitude", state->data.lat, 'N', 'S');
+               aoview_state_add_deg(1, "Longitude", state->data.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->data.gps_time.hour,
                                     state->data.gps_time.minute,
                                     state->data.gps_time.second);
                                     state->data.gps_time.hour,
                                     state->data.gps_time.minute,
                                     state->data.gps_time.second);
-               aoview_table_add_row("GPS ground speed", "%7.1fm/s %d°",
+               aoview_table_add_row(1, "GPS ground speed", "%7.1fm/s %d°",
                                     state->data.ground_speed,
                                     state->data.course);
                                     state->data.ground_speed,
                                     state->data.course);
-               aoview_table_add_row("GPS climb rate", "%7.1fm/s",
+               aoview_table_add_row(1, "GPS climb rate", "%7.1fm/s",
                                     state->data.climb_rate);
                                     state->data.climb_rate);
-               aoview_table_add_row("GPS precision", "%f(hdop) %dm(h) %dm(v)\n",
+               aoview_table_add_row(1, "GPS precision", "%f(hdop) %dm(h) %dm(v)\n",
                                     state->data.hdop, state->data.h_error, state->data.v_error);
                                     state->data.hdop, state->data.h_error, state->data.v_error);
-               aoview_table_add_row("Distance from pad", "%5.0fm", state->distance);
-               aoview_table_add_row("Direction from pad", "%4.0f°", state->bearing);
+               aoview_table_add_row(1, "Distance from pad", "%5.0fm", state->distance);
+               aoview_table_add_row(1, "Direction from pad", "%4.0f°", state->bearing);
        } else {
        } else {
-               aoview_table_add_row("GPS", "unlocked");
+               aoview_table_add_row(1, "GPS", "unlocked");
        }
        if (state->npad) {
        }
        if (state->npad) {
-               aoview_state_add_deg("Pad latitude", state->pad_lat, 'N', 'S');
-               aoview_state_add_deg("Pad longitude", state->pad_lon, 'E', 'W');
-               aoview_table_add_row("Pad GPS alt", "%gm", state->pad_alt);
+               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);
        }
        aoview_table_finish();
        aoview_label_show(state);
        }
        aoview_table_finish();
        aoview_label_show(state);
index b3fc6a47c133925d181fbd0e19ff95e343f91d2f..931430096590a8d9f8337af717da980a11b5199a 100644 (file)
 
 #include "aoview.h"
 
 
 #include "aoview.h"
 
-static GtkTreeView     *dataview;
-static GtkListStore    *datalist;
+#define NCOL   2
+
+static GtkTreeView     *dataview[NCOL];
+static GtkListStore    *datalist[NCOL];
 
 void
 aoview_table_start(void)
 {
 
 void
 aoview_table_start(void)
 {
-       datalist = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
+       int col;
+       for (col = 0; col < NCOL; col++)
+               datalist[col] = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
 }
 
 void
 }
 
 void
-aoview_table_add_row(char *label, char *format, ...)
+aoview_table_add_row(int col, char *label, char *format, ...)
 {
        char            buf[1024];
        va_list         ap;
 {
        char            buf[1024];
        va_list         ap;
@@ -36,8 +40,8 @@ aoview_table_add_row(char *label, char *format, ...)
        va_start(ap, format);
        vsnprintf(buf, sizeof (buf), format, ap);
        va_end(ap);
        va_start(ap, format);
        vsnprintf(buf, sizeof (buf), format, ap);
        va_end(ap);
-       gtk_list_store_append(datalist, &iter);
-       gtk_list_store_set(datalist, &iter,
+       gtk_list_store_append(datalist[col], &iter);
+       gtk_list_store_set(datalist[col], &iter,
                           0, label,
                           1, buf,
                           -1);
                           0, label,
                           1, buf,
                           -1);
@@ -46,23 +50,34 @@ aoview_table_add_row(char *label, char *format, ...)
 void
 aoview_table_finish(void)
 {
 void
 aoview_table_finish(void)
 {
-       gtk_tree_view_set_model(dataview, GTK_TREE_MODEL(datalist));
-       g_object_unref(G_OBJECT(datalist));
-       gtk_tree_view_columns_autosize(dataview);
+       int     col;
+       for (col = 0; col < NCOL; col++) {
+               gtk_tree_view_set_model(dataview[col], GTK_TREE_MODEL(datalist[col]));
+               g_object_unref(G_OBJECT(datalist[col]));
+               gtk_tree_view_columns_autosize(dataview[col]);
+       }
 }
 
 void
 aoview_table_clear(void)
 {
 }
 
 void
 aoview_table_clear(void)
 {
-       gtk_tree_view_set_model(dataview, NULL);
+       int     col;
+       for (col = 0; col < NCOL; col++)
+               gtk_tree_view_set_model(dataview[col], NULL);
 }
 
 void
 aoview_table_init(GladeXML *xml)
 {
 }
 
 void
 aoview_table_init(GladeXML *xml)
 {
-       dataview = GTK_TREE_VIEW(glade_xml_get_widget(xml, "dataview"));
-       assert(dataview);
+       int     col;
+
+       for (col = 0; col < NCOL; col++) {
+               char    name[32];
+               sprintf(name, "dataview_%d", col);
+               dataview[col] = GTK_TREE_VIEW(glade_xml_get_widget(xml, name));
+               assert(dataview[col]);
 
 
-       aoview_add_plain_text_column(dataview, "Field", 0, 20);
-       aoview_add_plain_text_column(dataview, "Value", 1, 32);
+               aoview_add_plain_text_column(dataview[col], "Field", 0, 20);
+               aoview_add_plain_text_column(dataview[col], "Value", 1, 32);
+       }
 }
 }
index b6d7182d8558a69f7b58a8559d914ed4f6937359..562899cd030c2a24405ea9b0ac00e34bad82747b 100644 (file)
@@ -27,6 +27,11 @@ const char ao_gps_set_binary[] = {
        '9', '6', '0', '0', ',', '8', ',', '1', ',', '0', '*',
        '0', 'C', '\r','\n',
 
        '9', '6', '0', '0', ',', '8', ',', '1', ',', '0', '*',
        '0', 'C', '\r','\n',
 
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
        0xa0, 0xa2, 0x00, 0x09, /* length 9 bytes */
        134,                    /* Set binary serial port */
        0, 0, 0x25, 0x80,       /* 9600 baud */
        0xa0, 0xa2, 0x00, 0x09, /* length 9 bytes */
        134,                    /* Set binary serial port */
        0, 0, 0x25, 0x80,       /* 9600 baud */