]> ToastFreeware Gitweb - gregoa/zavai.git/commitdiff
Started manager of aux button
authorEnrico Zini <enrico@enricozini.org>
Sun, 7 Mar 2010 19:12:09 +0000 (20:12 +0100)
committerEnrico Zini <enrico@enricozini.org>
Sun, 7 Mar 2010 19:12:09 +0000 (20:12 +0100)
README
src/app_aux.vala [new file with mode: 0644]
src/audio.vala
src/zavai.vala

diff --git a/README b/README
index 5587a981bb1da4312bbc6ba0ec5215fdbabe464a..c57b5950e6cdca1828e5fe40ea01947c8cccccbe 100644 (file)
--- a/README
+++ b/README
@@ -202,16 +202,14 @@ TODO list / wish list
        - cancel(id)
        - signals: triggered(info), acked(info), canceled(info)
     + vibrate at alarm trigger
+    - Aux interface widget
+       - blink and input
+       - do alarm notification
     - play sound at alarm trigger
-    - acknowledge alarms with AUX button
-       - then, vibrate and play sound for longer
-    - popup that tells that an alarm is ringing
     - leave expired alarm on screen until acknowledged
       (alarm status icon that also brings to alarm menu)
     - remember alarm names (on request, maybe with an add feature) and how
       often they are triggered, and show them most frequent first
-    - remember unexpired alarms persistently (again, a table in sqlite?) so
-      that they can be reinstated if zavai is restarted
     - show active alarms and allow to delete them
  - work without ogpsd
     + power on/off the gps and start/stop gpsd
diff --git a/src/app_aux.vala b/src/app_aux.vala
new file mode 100644 (file)
index 0000000..5b91fbe
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * app_aux - AUX button interaction
+ *
+ * Copyright (C) 2010  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 ui {
+namespace aux {
+
+public class AUX: zavai.Service
+{
+    protected Omhacks.Led auxled;
+    protected bool has_aux;
+
+    public AUX()
+    {
+        Object(name: "ui.aux");
+
+        has_aux = (auxled.init("gta02-aux:red") == 0);
+
+        if (has_aux)
+        {
+            zavai.log.warning("aux: can notify alarm triggers");
+            clock.alarm_trigger_queue.triggered += on_alarm_trigger;
+            clock.alarm_trigger_queue.acked += on_alarm_done;
+            clock.alarm_trigger_queue.canceled += on_alarm_done;
+        } else {
+            zavai.log.warning("aux: no way to notify alarm triggers");
+        }
+    }
+
+    public void on_alarm_trigger(clock.AlarmTriggerInfo info)
+    {
+        zavai.log.debug("Start blinking");
+        auxled.brightness = 256;
+        // FIXME: is there a better way? I hope there is a better way. Please
+        // tell me there is a better way.
+        var trig = "timer";
+        for (int i = 0; ; ++i)
+        {
+            auxled.trigger[i] = (char)trig[i];
+            if (trig[i] == 0) break;
+        }
+        auxled.delay_on = 200;
+        auxled.delay_off = 300;
+        auxled.set();
+    }
+
+    public void on_alarm_done(clock.AlarmTriggerInfo info)
+    {
+        zavai.log.debug("Stop blinking");
+        var trig = "none";
+        for (int i = 0; ; ++i)
+        {
+            auxled.trigger[i] = (char)trig[i];
+            if (trig[i] == 0) break;
+        }
+        auxled.brightness = 0;
+        auxled.set();
+    }
+}
+
+public AUX aux = null;
+
+public void init()
+{
+    aux = new AUX();
+}
+
+}
+}
+}
index c09739a4e2a61ac0aed94a283ac8fc4f1fca3a3e..fb607fc784758432165c2e0fe484625c2b24a30e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * audio - audio resource for zavai
  *
- * Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
+ * Copyright (C) 2009--2010  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
index 396fb7aed947da74c9d063346a4d569ffaa82c4d..0a33c9442fec189ed1f2adbbacbb84f09523513a 100644 (file)
@@ -114,6 +114,7 @@ static int main (string[] args) {
        zavai.ui.gsm.init();
        zavai.app.run_script(zavai.config.homedir + "/display init");
        zavai.ui.power.init();
+       zavai.ui.aux.init();
        zavai.ui.kbd.init();
        zavai.ui.wm.init();
        zavai.ui.calendar.init();