From 483763d5ea9b73667b8cc64f1f3db513dde5c9ef Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Tue, 9 Mar 2010 01:37:51 +0100 Subject: [PATCH] Show gps time when available --- README | 2 ++ debian/control | 2 +- src/clock.vala | 12 +++--------- src/gps.vala | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README b/README index 6b418da..e276e7c 100644 --- a/README +++ b/README @@ -161,7 +161,9 @@ TODO list / wish list + power on/off the gps and start/stop gpsd + set to keep the GPS on during suspend + use the gpsd protocol to know if there is a fix or not + + time from the GPS in main clock - suspend/resume hooks to put the GPS into low power mode + - GPS FixNow mode for sleeping - log - timestamp, coordinates - message (structured) (json?) diff --git a/debian/control b/debian/control index e28616b..d8b1bcd 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: zavai Section: unknown Priority: extra Maintainer: Enrico Zini -Build-Depends: debhelper (>= 7), cmake (>= 2.6), valac, libglib2.0-dev, libdbus-glib-1-dev, libgtk2.0-dev, libwnck-dev, libomhacks-dev (>= 0.5), liblua5.1-dev +Build-Depends: debhelper (>= 7), cmake (>= 2.6), valac, libglib2.0-dev, libdbus-glib-1-dev, libgtk2.0-dev, libwnck-dev, libomhacks-dev (>= 0.5), liblua5.1-dev, libgps-dev Standards-Version: 3.8.4 Homepage: http://git.debian.org/?p=users/enrico/zavai.git diff --git a/src/clock.vala b/src/clock.vala index f01da08..374e9d8 100644 --- a/src/clock.vala +++ b/src/clock.vala @@ -214,7 +214,6 @@ public class Clock: zavai.Service protected time_t last_gps_time; protected time_t last_gps_time_system_time; protected time_t last_system_time; - protected dynamic DBus.Object gps_time; protected uint system_time_timeout; protected time_t last_minute; protected time_t chosen_time; @@ -240,11 +239,6 @@ public class Clock: zavai.Service last_system_time = time_t(); chosen_time = last_system_time; - gps_time = zavai.registry.sbus.get_object( - "org.freesmartphone.ogpsd", - "/org/freedesktop/Gypsy", - "org.freedesktop.Gypsy.Time"); - // FSO alarm system otimed_alarm = zavai.registry.sbus.get_object( "org.freesmartphone.otimed", @@ -286,7 +280,7 @@ public class Clock: zavai.Service schedule_changed(next_alarm()); } - private void on_gps_time(dynamic DBus.Object pos, int t) + private void on_gps_time(uint t) { if (t == 0) { @@ -331,7 +325,7 @@ public class Clock: zavai.Service if (started) return; system_time_timeout = Timeout.add(5000, on_system_time); - gps_time.TimeChanged += on_gps_time; + zavai.gps.gps.time_changed += on_gps_time; last_system_time = time_t(); update_time(); @@ -343,7 +337,7 @@ public class Clock: zavai.Service if (!started) return; Source.remove(system_time_timeout); - gps_time.TimeChanged -= on_gps_time; + zavai.gps.gps.time_changed -= on_gps_time; base.stop(); } diff --git a/src/gps.vala b/src/gps.vala index b8c2f99..50c722f 100644 --- a/src/gps.vala +++ b/src/gps.vala @@ -31,8 +31,10 @@ public class GPS: zavai.Service protected uint gpsfd_watch = 0; protected int old_fix_status = libgps.STATUS_NO_FIX; + protected uint old_time = 0; public signal void fix_status_changed(int status); + public signal void time_changed(uint time); public GPS() { @@ -41,6 +43,7 @@ public class GPS: zavai.Service } public int fix_status() { return old_fix_status; } + public double time() { return old_time; } protected bool on_input_data(IOChannel source, IOCondition condition) { @@ -55,6 +58,14 @@ public class GPS: zavai.Service fix_status_changed(data.status); old_fix_status = data.status; } + + uint cur_time = (uint)data.fix.time; + if (data.status != libgps.STATUS_NO_FIX && old_time != cur_time) + { + time_changed(cur_time); + old_time = cur_time; + } + /* stderr.printf("GPSMSG %d %d\n", (int)data.set, data.status); stderr.printf("SATUSED %d\n", data.satellites_used); @@ -137,6 +148,12 @@ public class GPS: zavai.Service fix_status_changed(old_fix_status); } + if (old_time != 0) + { + old_time = 0; + time_changed(old_time); + } + base.stop(); } } -- 2.39.5