diff --git a/firmware/apps/buggy.c b/firmware/apps/buggy.c index d4edfcd..5a939df 100644 --- a/firmware/apps/buggy.c +++ b/firmware/apps/buggy.c @@ -5,6 +5,10 @@ #include #include +inline uint16_t biased_random(uint8_t value) { + return value / 4 * (rand() & 7); +} + static void init(void) { pentatonic_direction(ALL_OUT); photons_init(); @@ -13,14 +17,23 @@ static void init(void) { } static void run(void) { - uint8_t light = photons_measure(); + uint16_t light = photons_measure(); pentatonic_all_led_set(light >> 3); - led_inv(LEFT); - led_inv(RIGHT); + motor_set(biased_random(light) > 0x50 ? ON : OFF); - wait_ms(100); + led_set(RIGHT, biased_random(light) > 0x20); + led_set(LEFT, biased_random(light) > 0x20); + + if(biased_random(light) > 0x90) { + uint16_t tone = (biased_random(light) * 2) + 500; + set_note(tone, 0); + } else { + stop_note(); + } + + wait_ms(200); } REGISTER(run, init, NULL); diff --git a/firmware/main.c b/firmware/main.c index 2ceac37..f788641 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -69,5 +69,4 @@ int main(void) { } } } - }