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);