-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.c
More file actions
80 lines (69 loc) · 1.49 KB
/
Copy pathutil.c
File metadata and controls
80 lines (69 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "include/mcu.h"
#include "include/game.h"
#include "include/util.h"
#include <util/delay.h>
#include <avr/pgmspace.h>
#include "peripherals/include/speaker.h"
#include "peripherals/include/led.h"
#include "peripherals/include/button.h"
/*
* Play frequency durations out from speaker
*/
void util_music_play(const int music[][2], int len)
{
for (int i = 0; i < len; i++) {
int freq = pgm_read_word(&(music[i][FREQUENCY]));
int dur = pgm_read_word(&(music[i][DURATION]));
if (freq > 0) {
_delay_ms(15);
speaker_generate_tone(freq, dur);
} else {
for (int j = 0; j < (dur / 10); j++)
_delay_ms(10);
}
}
}
/*
* Convert button to it's blinker
*/
int util_button_to_blinker(int button)
{
switch (button) {
case BUTTON_GREEN:
return BLINKER_GREEN;
case BUTTON_ORANGE:
return BLINKER_ORANGE;
case BUTTON_YELLOW:
return BLINKER_YELLOW;
case BUTTON_RED:
return BLINKER_RED;
}
return 0;
}
/*
* Blink all score LEDs three times
*/
void util_led_intro()
{
for (int i = 0; i < 3; i++) {
led_counter_set(15);
_delay_ms(600);
led_counter_set(0);
_delay_ms(600);
}
}
/*
* Blink all blinker LEDs
*/
void util_led_sequence_end()
{
led_blinker_turn_on(BLINKER_GREEN);
led_blinker_turn_on(BLINKER_RED);
led_blinker_turn_on(BLINKER_YELLOW);
led_blinker_turn_on(BLINKER_ORANGE);
_delay_ms(300);
led_blinker_turn_off(BLINKER_GREEN);
led_blinker_turn_off(BLINKER_RED);
led_blinker_turn_off(BLINKER_YELLOW);
led_blinker_turn_off(BLINKER_ORANGE);
}