summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-04-19 02:12:03 +0200
committerneoraider <devnull@localhost>2007-04-19 02:12:03 +0200
commit625226774309d4efef855fef759f1da4bc07c0db (patch)
treed93d0e7e4a90d67d0ff3734508967546b03d9188
parente7eeeb0d4e825a175c67cd1c0256c91362517ebb (diff)
downloadrc2007-rescue-master.tar
rc2007-rescue-master.zip
LED eingebaut.HEADmaster
-rw-r--r--avr.cpp20
-rw-r--r--avr.h3
-rw-r--r--hardware.cpp2
-rw-r--r--main.cpp8
4 files changed, 29 insertions, 4 deletions
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;
}
diff --git a/avr.h b/avr.h
index 851f1ff..2925bec 100644
--- a/avr.h
+++ b/avr.h
@@ -10,4 +10,7 @@ void waitForButton(int i);
void beep(unsigned long freq);
void beepOff();
+void ledOn();
+void ledOff();
+
#endif
diff --git a/hardware.cpp b/hardware.cpp
index e652dda..8e25854 100644
--- a/hardware.cpp
+++ b/hardware.cpp
@@ -8,7 +8,7 @@
void initHardware() {
- DDRA = 0x00;
+ DDRA = 0x20;
PORTA = 0xFF;
DDRB = 0xFF;
diff --git a/main.cpp b/main.cpp
index 8fc011b..cc71d55 100644
--- a/main.cpp
+++ b/main.cpp
@@ -48,10 +48,16 @@ int main() {
Srf10 *srf10Last = srf10Left;
- do {
+ do {
lineSensorArray->update();
} while(!lineSensorArray->calibrate());
+ ledOn();
+ waitForButton(0);
+ ledOff();
+
+ sleep(4000);
+
navigation->setSpeed(DEFAULT_SPEED);
while(true) {