GString *wp_marker_str;
gboolean tracking_is_on;
FILE *outf_p;
+ guint points_recorded_in_current_segment;
+ LocationGPSDeviceStatus last_device_status;
gchar *working_dir;
gchar *intermediate_gpx_data_filename;
} AppData;
data->tracking_is_on = !data->tracking_is_on;
if(data->tracking_is_on) { /* START pressed */
data->outf_p = fopen(data->intermediate_gpx_data_filename, "w");
+ data->points_recorded_in_current_segment = 0;
+ data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
write_gpx_header(data->outf_p);
//hildon_banner_show_information(GTK_WIDGET(data->window), NULL, "Tracking started");
gtk_button_set_label (data->start_stop_button, "Stop");
gtk_widget_set_sensitive(GTK_WIDGET(data->wp_set_btn), TRUE);
}
else { /* STOP pressed */
+ data->points_recorded_in_current_segment = 0;
+ data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
if(data->outf_p) {
write_gpx_footer(data->outf_p);
fclose(data->outf_p);
if (!device)
return;
- if (device->fix && device->status) {
+ if (device->fix) {
+ //g_print("mode=%d stat=%d\n", device->fix->mode, device->status);
if (device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET) {
//g_print ("lat = %f, long = %f\n", device->fix->latitude, device->fix->longitude);
CHANGE_LABEL(app_data->lat_val_label, "% 9.6f", device->fix->latitude);
CHANGE_LABEL(app_data->lon_val_label, "% 9.6f", device->fix->longitude);
if(fp) {
+ if(app_data->last_device_status != device->status) {
+ if(app_data->points_recorded_in_current_segment)
+ g_fprintf(fp, "\n</trkseg>\n<trkseg>\n");
+ app_data->last_device_status = device->status;
+ }
g_fprintf(fp, "\n<trkpt lat=\"%s\" lon=\"%s\">\n",
- g_ascii_formatd(sbuf1, sizeof(sbuf1), "%f", device->fix->latitude),
- g_ascii_formatd(sbuf2, sizeof(sbuf2), "%f", device->fix->longitude));
+ g_ascii_formatd(sbuf1, sizeof(sbuf1), "%f", device->fix->latitude),
+ g_ascii_formatd(sbuf2, sizeof(sbuf2), "%f", device->fix->longitude));
if(app_data->wp_marker_str->len) {
g_fprintf(fp, "<name>%s</name>\n", app_data->wp_marker_str->str);
hildon_banner_show_information(GTK_WIDGET(app_data->window), NULL, app_data->wp_marker_str->str);
}
}
+ app_data->points_recorded_in_current_segment++;
+
if (device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) {
//g_print ("time = %f\n", device->fix->time);
if(fp) {
g_fprintf(fp, "<ele>%s</ele>\n", g_ascii_formatd(sbuf1, sizeof(sbuf1), "%.1f", device->fix->altitude));
}
+ else
+ CHANGE_LABEL(app_data->alt_val_label, " ?", NULL);
if (device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET) {
//g_print ("speed = %f\n", device->fix->speed);
if(fp)
g_fprintf(fp, "<speed>%s</speed>\n", g_ascii_formatd(sbuf1, sizeof(sbuf1), "%.1f", device->fix->speed));
}
+ else
+ CHANGE_LABEL(app_data->speed_val_label, " ?", NULL);
if (device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET) {
//g_print ("track = %f\n", device->fix->track);
if(fp)
g_fprintf(fp, "<course>%s</course>\n", g_ascii_formatd(sbuf1, sizeof(sbuf1), "%.1f", device->fix->track));
}
+ else
+ CHANGE_LABEL(app_data->track_val_label, " ?", NULL);
if (device->fix->fields & LOCATION_GPS_DEVICE_CLIMB_SET) {
//g_print ("climb = %f\n", device->fix->climb);
CHANGE_LABEL(app_data->climb_val_label, "%+4.0fm/s", device->fix->climb);
}
+ else
+ CHANGE_LABEL(app_data->climb_val_label, " ?", NULL);
//g_print ("Accuracy values:\n");
//g_print ("\tept = %e, eph = %e, epv = %e, epd = %e, "
}
}
}
+ else
+ g_print("device->fix=%p\n", device->fix);
//g_print ("Satellites in view: %d\n", device->satellites_in_view);
//g_print ("Satellites in use: %d\n", device->satellites_in_use);
CHANGE_LABEL2(app_data->sat_val_label, "%3d/%2d", device->satellites_in_use, device->satellites_in_view);
//g_print ("GPS status: %d\n", device->status);
- hildon_gtk_window_set_progress_indicator(GTK_WINDOW(app_data->window), device->status == LOCATION_GPS_DEVICE_STATUS_NO_FIX);
-
-
//if (device->cell_info) {
// if (device->cell_info->flags & LOCATION_CELL_INFO_GSM_CELL_INFO_SET)
// g_print ("Mobile Coutry Code GSM: %d\n", device->cell_info->gsm_cell_info.mcc);
// g_print ("Mobile Coutry Code WCDMA: %d\n", device->cell_info->wcdma_cell_info.mcc);
//}
- if(device->status != LOCATION_GPS_DEVICE_STATUS_NO_FIX)
+ if(device->status == LOCATION_GPS_DEVICE_STATUS_NO_FIX) {
+ hildon_gtk_window_set_progress_indicator(GTK_WINDOW(app_data->window), 1);
+ CHANGE_LABEL(app_data->lat_val_label, " ?", NULL);
+ CHANGE_LABEL(app_data->lon_val_label, " ?", NULL);
+ CHANGE_LABEL(app_data->alt_val_label, " ?", NULL);
+ CHANGE_LABEL(app_data->speed_val_label, " ?", NULL);
+ CHANGE_LABEL(app_data->track_val_label, " ?", NULL);
+ }
+ else {
+ hildon_gtk_window_set_progress_indicator(GTK_WINDOW(app_data->window), 0);
gtk_widget_set_sensitive(GTK_WIDGET(app_data->start_stop_button), TRUE);
+ }
}
static void
{
GtkWidget *alignment_track = gtk_alignment_new (0.5, 0.5, 1, 1);
GtkWidget *speed_label = gtk_label_new("Speed:");
- GtkWidget *track_label = gtk_label_new("Heading:");
+ GtkWidget *track_label = gtk_label_new("Orientation:");
GtkWidget *climb_label = gtk_label_new("Climb:");
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_track), 0,0,0,0);
gtk_misc_set_alignment (GTK_MISC (speed_label), 1, 0.5);