From 625226774309d4efef855fef759f1da4bc07c0db Mon Sep 17 00:00:00 2001 From: neoraider Date: Thu, 19 Apr 2007 00:12:03 +0000 Subject: LED eingebaut. --- avr.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'avr.cpp') diff --git a/avr.cpp b/avr.cpp index cd528ba..585dc7d 100644 --- a/avr.cpp +++ b/avr.cpp @@ -19,13 +19,21 @@ int getButton() { } void waitForButton(int i) { - while(getButton() != CLAMP(0, i, 5)); + if(i <= 0) while(getButton() == 0); + else while(getButton() != CLAMP(1, i, 5)); + while(getButton() != 0); } void beep(unsigned long freq) { const int prescalers[7] = {1, 8, 32, 64, 128, 256, 1024}; + if(freq == 0) { + beepOff(); + return; + } + + for(int i = 0; i < 7; i++) { if(F_CPU/freq/2/prescalers[i] <= 256) { TCCR2 = (TCCR2&~0x07)|(i+1); @@ -39,5 +47,13 @@ void beep(unsigned long freq) { } void beepOff() { - TCCR2 &= ~0x07; + TCCR2 &= ~0x07; +} + +void ledOn() { + PORTA &= ~0x20; +} + +void ledOff() { + PORTA |= 0x20; } -- cgit v1.2.3