]> err.no Git - mapper/commitdiff
Speek a simple "distance to destination xy" thingy
authorKaj-Michael Lang <milang@angel.tal.org>
Fri, 19 Oct 2007 11:01:01 +0000 (14:01 +0300)
committerKaj-Michael Lang <milang@angel.tal.org>
Fri, 19 Oct 2007 11:01:01 +0000 (14:01 +0300)
src/map.c

index 1ea1b5c3e43e361c54703cd93be07f2ee2fb5459..35d4cc1a4dd626345a77c91cfb12b32b85c7ae34 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -1012,19 +1012,31 @@ if (!s && !mp && !sp) {
 gtk_label_set_label(GTK_LABEL(info_banner.location), buffer);
 }
 
+#define KM10KNOTS 5.39956803
+
 static void
 map_update_destination(gdouble lat, gdouble lon)
 {
 gdouble dh=0.0;
 gdouble dt;
-gchar buffer[32];
+static gdouble prev_dt=99999.0;
+gchar buffer[64];
 
 if (_dest.valid) {
        dt=calculate_distance(lat, lon, _dest.lat, _dest.lon);
        dh=calculate_course(lat, lon, _dest.lat, _dest.lon);
        snprintf(buffer, sizeof(buffer), "%.02f %s (%0.02f)", dt * UNITS_CONVERT[_units], UNITS_TEXT[_units], dh);
        gtk_label_set_label(GTK_LABEL(info_banner.distance), buffer);
+       if (dt<prev_dt-KM10KNOTS) {
+               snprintf(buffer, sizeof(buffer), "Distance to destination: %.02f %s", dt * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
+               speak_text(buffer);
+               prev_dt=dt;
+       } else if (dt>prev_dt+KM10KNOTS) {
+               prev_dt=dt;
+       }
+       g_printf("%f (Prev:%f)\n", prev_dt, dt);
 } else {
+       prev_dt=99999.0;
        gtk_label_set_label(GTK_LABEL(info_banner.distance), "");
 }
 gtk_compass_set_dest_heading(_gps_compass, _dest.valid, (gfloat)dh);