Package: speedometer
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Speedometer shows current speed on the screen.
- Speedometer shows your current speed in various units
- on the device screen. Speed is taken from GPS connection.
-
+Description: Shows your current speed on the screen using GPS.
+ Speedometer is an application that shows your current
+ speed on the screen in different units. Supported units are
+ km/h, mph, m/s and f/s. Application is using the whole screen
+ area available to maximize the size of the units. Mount it to
+ your car, boat or bicycle and you'll get as accurate speed
+ as possible.
+XB-Maemo-Icon-26:
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c
+ 6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0
+ SU1FB9gKCA4kFSsWLOsAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJ
+ TVBXgQ4XAAABjElEQVRIx+2WvarCMBiGX+WgdhYHoeDP0MUbcEsoXXRyELyc
+ 0MFN/NlcvIDiJYgmuQJ3XRQ6agsKrt8ZxMI5WukBKxzwhQzJk+Qh5IdkpJTk
+ ui4AgDGGV0ZrDQAQQgCcc+Kck5SSXh0pJd3mR1qS37IsYwycc6QVzjkYY8ji
+ TfmIPqJ40Xw+R6PRQD6fR7PZxHq9jlgQBHAcB4VCAY7jIAzDRCxW5HkewjBE
+ t9tFr9eLmBAClmUhCAJYlnV9WhKwW4fYW306ncgwjKheq9Vou90SEdFms6F6
+ vZ6ICSHo6R6Nx2N0Op2o7vs+KpUKAKBarcL3/UQMAL7iJLPZDJ7nQUqZ3qmb
+ TCYYDAZYLBYolUpRu2ma2O/3AIDdbgfTNBOxh6J+v4/pdIrVaoVyufyDtdtt
+ DIdDXC4XjEYjtFqtROzhYQBwV87nMxERHQ4Hsm2bcrkc2bZNx+MxGveMCSHo
+ bo+urscpFotYLpd/Zp+37p+ItNZQSqUmUEpBa31dkeu6qciUUrj9GTPv+kB+
+ A/Cv7s/4BhwSAAAAAElFTkSuQmCC
* Base unit is m/s thus the first multiplier is
* one. Units are in following order:
*
- * m/s, km/h, mph
+ * m/s, km/h, mph, f/s, knot
*/
-gdouble conversion[] = { 1, 3.6, 2.237 };
+gdouble conversion[] = { 1, 3.6, 2.237, 3.281, 1.944 };
+guint unit = 1;
+#define UNIT_COUNT 4
+// TODO: wrap this mess up somewhere
+// TODO: knot graphics are missing
-static GdkPixbuf* big_graphics[10]; // contains all the big graphics
-static GdkPixbuf* small_graphics[10]; // contains small graphics
-static GtkWidget* digits[5]; //
+static GdkPixbuf* big_graphics[14];
+static GdkPixbuf* small_graphics[14];
+static GtkWidget* digits[5];
+static GtkWidget* unit_graphic;
#define IMAGE_PATH "/usr/share/speedometer/%d.png"
* and store the pixbufs to the array. Pixbufs are
* correct size to be used in the big digits.
*/
- while(i < 10) {
+ while(i < 14) {
char* path = g_malloc(30);
g_sprintf(path, IMAGE_PATH, i);
g_print(path);
small_graphics[i] = gdk_pixbuf_scale_simple(
big_graphics[i],
- 60,
- 60,
+ 150,
+ 150,
GDK_INTERP_BILINEAR);
i++;
digits[2] = gtk_image_new_from_pixbuf(big_graphics[0]);
digits[3] = gtk_image_new_from_pixbuf(small_graphics[0]);
digits[4] = gtk_image_new_from_pixbuf(small_graphics[0]);
+ // TODO: load this from GConf
+ unit_graphic = gtk_image_new_from_pixbuf(small_graphics[11]);
}
static void set_nth_digit(guint n, guint value) {
gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(digits[2]), FALSE, FALSE, 0);
// add small digits to another hbox
+ gtk_box_pack_start(GTK_BOX(bhbox), GTK_WIDGET(unit_graphic), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(bhbox), GTK_WIDGET(digits[3]), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(bhbox), GTK_WIDGET(digits[4]), FALSE, FALSE, 0);
gtk_widget_show_all(GTK_WIDGET(appdata->window));
}
+void change_unit() {
+ unit++;
+
+ if(unit >= UNIT_COUNT) {
+ unit = 0;
+ }
+ g_print("Unit used in conversion: %f\n", conversion[unit]);
+
+ GdkPixbuf* buf = small_graphics[10 + unit];
+ gtk_image_set_from_pixbuf(GTK_IMAGE(unit_graphic), buf);
+}
+
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[1];
+ speed *= conversion[unit];
/* Convert float to a 6 digits (including dot) wide
* string with leading zeros. After conversion
- * the speed might look like:
+ * the speed looks like:
*
* 009.20 (9,20 km/h) or
* 010.90 (10,90 km/h) or