1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-11-04 23:19:41 +02:00
iris/source/alarm.ccp

55 lines
1.7 KiB
Plaintext
Raw Normal View History

#pypp 0
#include <iris.hh>
2012-09-26 20:03:36 +03:00
#include <devices.hh>
2012-09-26 20:03:36 +03:00
enum captypes:
CONTROL = 1
KBD
INTERRUPT
Iris::Num start ():
2012-09-26 20:03:36 +03:00
unsigned *screen = (unsigned *)0x40000000
Iris::RTC rtc = Iris::my_parent.get_capability <Iris::RTC> ()
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> ()
display.map_fb ((unsigned)screen)
Iris::Font font = Iris::my_parent.get_capability <Iris::Font> ()
font.set_display (display)
Iris::Keyboard keyboard = Iris::my_parent.get_capability <Iris::Keyboard> ()
Iris::Cap cap = Iris::my_receiver.create_capability (KBD)
keyboard.set_cb (cap.copy ())
Iris::free_cap (cap)
Iris::Buzzer buzzer = Iris::my_parent.get_capability <Iris::Buzzer> ()
Iris::Event self = Iris::my_receiver.create_capability (CONTROL)
Iris::my_parent.provide_capability <Iris::Event> (self)
cap = Iris::my_receiver.create_capability (INTERRUPT)
Iris::my_parent.init_done ()
font.printf ("Press a key to attempt reboot.\n")
while true:
Iris::wait ()
switch Iris::recv.protected_data.l:
2012-09-26 20:03:36 +03:00
case INTERRUPT:
// Interrupt
if Iris::recv.data[0].l == ~0:
// Not a real interrupt, just an abort notification.
continue
font.printf ("alarm: interrupt\n")
break
case CONTROL:
// Store callback
font.printf ("alarm: control event\n")
break
case KBD:
if Iris::recv.data[0].l & Iris::Keyboard::RELEASE:
// Key release.
Iris::poweroff ()
else:
// Key press.
unsigned time = rtc.get_time ()
rtc.set_alarm (time + 5, cap)
unsigned alarm = rtc.get_alarm ()
unsigned enabled = Iris::recv.data[1].l
font.printf ("Debug: %d %d %d\n", time, alarm, enabled)
2012-09-26 20:03:36 +03:00
break
default:
Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")