Vibrate on alarm
authorEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 21:56:51 +0000 (22:56 +0100)
committerEnrico Zini <enrico@enricozini.org>
Mon, 17 Aug 2009 21:58:10 +0000 (22:58 +0100)
src/Makefile.am
src/app_main.vala
src/audio.vala [new file with mode: 0644]
src/clock.vala
src/zavai.vala

index 8bfe364886c72bc337554fc027b69f69d6c80206..e141d951765e6df6ef283c845a350e4c48e38444 100644 (file)
@@ -35,6 +35,7 @@ zavai_VALASOURCES = \
        input.vala \
        gps.vala \
        clock.vala \
+       audio.vala \
        app.vala \
        app_keyboard.vala \
        app_power.vala \
index 43a4b77dc0be2f71b957352a3ace389e8c70a365..b293cab1bb0ef45ac0cd67269be06f71af6be86d 100644 (file)
@@ -228,7 +228,9 @@ public abstract class AddDeadline : Applet
     {
         string label = ((Gtk.Entry)dl_label.get_child()).get_text();
         zavai.log.info("Scheduling deadline " + label);
-        zavai.clock.clock.schedule(new zavai.clock.Alarm(get_deadline(), label));
+        zavai.clock.Alarm a = new zavai.clock.Alarm(get_deadline(), label);
+        a.trigger += zavai.audio.audio.notify_alarm;
+        zavai.clock.clock.schedule(a);
         back();
     }
 }
@@ -249,6 +251,7 @@ public class AddAbsoluteDeadline : AddDeadline
         dl_time = 0;
 
         dl_day = new Gtk.Label("");
+        dl_day.set_justify(Gtk.Justification.RIGHT);
         dl_day_tweak = new IncDec();
         dl_day_tweak.tweaked += on_tweak;
         var hbox = new Gtk.HBox(false, 0);
@@ -258,6 +261,7 @@ public class AddAbsoluteDeadline : AddDeadline
         pack_start(hbox, false, false, 0);
 
         dl_hour = new Gtk.Label("");
+        dl_hour.set_justify(Gtk.Justification.RIGHT);
         dl_hour_tweak = new IncDec();
         dl_hour_tweak.tweaked += on_tweak;
         hbox = new Gtk.HBox(false, 0);
@@ -267,6 +271,7 @@ public class AddAbsoluteDeadline : AddDeadline
         pack_start(hbox, false, false, 0);
 
         dl_min = new Gtk.Label("");
+        dl_min.set_justify(Gtk.Justification.RIGHT);
         dl_min_tweak = new IncDec();
         dl_min_tweak.tweaked += on_tweak;
         hbox = new Gtk.HBox(false, 0);
@@ -326,6 +331,7 @@ public class AddRelativeDeadline : AddDeadline
         dl_time = 0;
 
         dl_hour = new Gtk.Label("");
+        dl_hour.set_justify(Gtk.Justification.RIGHT);
         dl_hour_tweak = new IncDec();
         dl_hour_tweak.tweaked += on_tweak;
         var hbox = new Gtk.HBox(false, 0);
@@ -335,6 +341,7 @@ public class AddRelativeDeadline : AddDeadline
         pack_start(hbox, false, false, 0);
 
         dl_min = new Gtk.Label("");
+        dl_min.set_justify(Gtk.Justification.RIGHT);
         dl_min_tweak = new IncDec();
         dl_min_tweak.tweaked += on_tweak;
         hbox = new Gtk.HBox(false, 0);
diff --git a/src/audio.vala b/src/audio.vala
new file mode 100644 (file)
index 0000000..b8cd35d
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * audio - audio resource for zavai
+ *
+ * Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+using GLib;
+
+namespace zavai {
+namespace audio {
+
+public class Audio: zavai.Service
+{
+       protected dynamic DBus.Object audiodev;
+       protected dynamic DBus.Object vibdev;
+
+       public Audio()
+       {
+               name = "audio";
+               audiodev = zavai.registry.sbus.get_object(
+                       "org.freesmartphone.odeviced",
+                       "/org/freesmartphone/Device/Audio",
+                       "org.freesmartphone.Device.Audio");
+        vibdev = zavai.registry.sbus.get_object(
+                       "org.freesmartphone.odeviced",
+                       "/org/freesmartphone/Device/LED/neo1973_vibrator",
+                       "org.freesmartphone.Device.LED");
+       }
+
+    public void notify_alarm(zavai.clock.Alarm a)
+    {
+        try {
+            vibdev.BlinkSeconds(2, 500, 200);
+        } catch (Error e) {
+            zavai.log.error("Cannot blink vibrator: " + e.message);
+        }
+    }
+}
+
+public Audio audio = null;
+
+public void init()
+{
+    audio = new Audio();
+
+       zavai.registry.register_service(audio);
+}
+
+}
+}
index 8b129c82f2cd4b6a3f531988b68a10f18ee70d3d..b140c6189e74d38510472f2c620bdc5bd016ee5d 100644 (file)
@@ -31,7 +31,7 @@ public enum SourceType
 
 public class Alarm : Object
 {
-    public signal void trigger();
+    public signal void trigger(Alarm a);
 
     public time_t deadline;
     public string label;
@@ -151,7 +151,7 @@ public class Clock: zavai.Service
             Alarm a = alarms.data;
             alarms.remove(a);
             zavai.log.info("Triggering " + a.label);
-            a.trigger();
+            a.trigger(a);
         }
 
         otimed_reschedule();
index 23da334b19a927d03b43b516f561bd4c445073aa..96fa9ec69fbb43677a220bf233c22a117f94f129 100644 (file)
@@ -51,6 +51,7 @@ static int main (string[] args) {
     // Additional infrastructure
        zavai.input.init();
        zavai.gps.init();
+       zavai.audio.init();
        zavai.clock.init();
 
        /*