Add IR stuff to buggy app

This commit is contained in:
Thammi 2013-09-06 00:35:59 +02:00
parent 9c827808ff
commit 39552d8598

View File

@ -5,6 +5,7 @@
#include <pentabug/photons.h>
#include <pentabug/pentatonic.h>
#include <pentabug/music.h>
#include <pentabug/helper.h>
inline uint16_t biased_random(uint8_t value) {
return value / 8 * (rand() & 7);
@ -16,6 +17,64 @@ static void init(void) {
}
static void run(void) {
if(ir_recv()) {
// receive a ir signal, react
motor_on();
led_on(RIGHT);
set_note(NOTE_B, 5);
wait_ms(200);
set_note(NOTE_F, 5);
wait_ms(100);
led_off(RIGHT);
led_on(LEFT);
set_note(NOTE_G, 5);
wait_ms(100);
set_note(NOTE_Ab, 5);
wait_ms(100);
set_note(NOTE_A, 5);
wait_ms(100);
led_off(LEFT);
motor_off();
} else if(button_clicked(RIGHT)) {
// button clicked, send ir signal and do some stuff
led_on(RIGHT);
set_note(NOTE_A, 5);
wait_ms(100);
set_note(NOTE_Ab, 5);
wait_ms(100);
set_note(NOTE_G, 5);
wait_ms(100);
led_off(RIGHT);
led_on(LEFT);
set_note(NOTE_F, 5);
wait_ms(100);
set_note(NOTE_B, 5);
wait_ms(200);
stop_note();
led_off(LEFT);
ir_on();
wait_ms(400);
ir_off();
wait_ms(10);
} else {
// regular bug behaviour
uint8_t light = photons_measure();
pentatonic_all_led_set(light >> 3);
@ -34,5 +93,6 @@ static void run(void) {
wait_ms(200);
}
}
REGISTER(run, init, NULL);