mirror of
git://projects.qi-hardware.com/iris.git
synced 2024-11-05 06:43:44 +02:00
71 lines
2.0 KiB
COBOL
71 lines
2.0 KiB
COBOL
#pypp 0
|
|
// Iris: micro-kernel for a capability-based operating system.
|
|
// boot-programs/metronome.ccp: Userspace program.
|
|
// Copyright 2009 Bas Wijnen <wijnen@debian.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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
#include "devices.hh"
|
|
#include "keys.hh"
|
|
|
|
Kernel::Num start ():
|
|
kdebug ("metronome started\n")
|
|
Buzzer buzzer = Kernel::my_parent.get_device <Buzzer> ()
|
|
Keyboard kbd = Kernel::my_parent.get_device <Keyboard> ()
|
|
Kernel::Cap key = Kernel::my_receiver.create_capability (0)
|
|
kbd.set_cb (key)
|
|
unsigned mHz = 1000
|
|
unsigned freq = 1000
|
|
Kernel::my_receiver.set_alarm (1)
|
|
bool running (true)
|
|
while true:
|
|
Kernel::wait ()
|
|
switch Kernel::recv.protected_data.l:
|
|
case ~0:
|
|
if running:
|
|
buzzer.beep (freq, 10, ~0)
|
|
Kernel::my_receiver.set_alarm (HZ * 1000 / mHz)
|
|
break
|
|
case 0:
|
|
if Kernel::recv.data[0].l & Keyboard::RELEASE:
|
|
break
|
|
switch Kernel::recv.data[0].l:
|
|
case Key::VOLUME_UP:
|
|
freq = freq * 11 / 10
|
|
break
|
|
case Key::VOLUME_DOWN:
|
|
freq = freq * 9 / 10
|
|
break
|
|
case Key::LEFT:
|
|
mHz = mHz * 101 / 100
|
|
break
|
|
case Key::RIGHT:
|
|
mHz = mHz * 99 / 100
|
|
break
|
|
case Key::UP:
|
|
mHz = mHz * 11 / 10
|
|
break
|
|
case Key::DOWN:
|
|
mHz = mHz * 9 / 10
|
|
break
|
|
case Key::P:
|
|
running = !running
|
|
if running:
|
|
Kernel::my_receiver.set_alarm (1)
|
|
break
|
|
break
|
|
default:
|
|
kdebug ("huh?\n")
|
|
break
|