+void interpret_and_set_speed(gdouble speed) {
+ g_assert(!isnan(speed));
+
+ /* speed is in m/s so let's convert
+ * it to the unit that we are using
+ */
+ speed *= conversion[unit];
+
+ /* we need to limit the speed down to
+ * less than 1000 whatever or else hell
+ * breaks loose in the form of assert
+ */
+ if(!(fabs(speed) < 1000)) {
+ g_print("Ahem, may I suggest to limit the speed (%f) a bit, Sir.\n", speed);
+ speed = 0;
+ }
+
+ /* Convert float to a 6 digits (including dot) wide
+ * string with leading zeros. After conversion
+ * the speed looks like:
+ *
+ * 009.20 (9,20 km/h) or
+ * 010.90 (10,90 km/h) or
+ * 120.10 (120,10 km/h)
+ *
+ * Now, regardless of speed we know the position
+ * of the digits and can access the array directly.
+ */
+ gchar* charspeed = g_malloc(10); // alloc
+ g_sprintf(charspeed, "%0*.2f", 6, speed);
+
+ g_print("Speed is %s km/h\n", charspeed);
+
+ // these three lines will set the big digits
+ set_nth_digit(0, g_ascii_digit_value(charspeed[0]));
+ set_nth_digit(1, g_ascii_digit_value(charspeed[1]));
+ set_nth_digit(2, g_ascii_digit_value(charspeed[2]));
+
+ // these two lines will set the small digits
+ set_nth_digit(3, g_ascii_digit_value(charspeed[4]));
+ set_nth_digit(4, g_ascii_digit_value(charspeed[5]));
+
+ repaint_all_digits();
+
+ g_free(charspeed);
+}
+
+static void show_dialog() {
+ GtkWidget *dialog = gtk_message_dialog_new(
+ NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ "This program is licensed under GNU General Public License, "
+ "which means (among other things) that you don't have to pay "
+ "a dime for it. "
+ "PS. Long-tapping on the screen will quit the program.");
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+}
+
+void show_cardware_dialog() {
+ GConfClient* client = gconf_client_get_default();
+ g_assert(GCONF_IS_CLIENT(client));
+
+ GConfValue* gcvalue = NULL;
+ gcvalue = gconf_client_get_without_default(client, GCONF_KEY, NULL);
+
+ if(gcvalue == NULL) {
+ g_print("GConf key not found so show dialog.\n");
+ show_dialog();
+ gconf_client_set_bool(client, GCONF_KEY, TRUE, NULL);
+ }
+ g_object_unref(client);