-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpokey.h
65 lines (54 loc) · 1.39 KB
/
pokey.h
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
// name, port, ddr, number
#define LED_TABLE(_) _(targetled1, PORTF, DDRF, PF0)\
_(targetled2, PORTF, DDRF, PF1)\
_(targetled3, PORTF, DDRF, PF4)\
_(targetled4, PORTF, DDRF, PF5)\
_(targetled5, PORTF, DDRF, PF6)\
_(targetled6, PORTF, DDRF, PF7)\
_(targetled7, PORTE, DDRE, PE2)\
_(targetled8, PORTE, DDRE, PE6)\
_(targetled9, PORTC, DDRC, PC6)\
_(targetled10, PORTC, DDRC, PC7)
#define AS_LED_ON_DECL(name, port, ddr, num) void name ## _on(void);
#define AS_LED_OFF_DECL(name, port, ddr, num) void name ## _off(void);
#define AS_LED_ON_FUN(name, port, ddr, num) void name ## _on(void) \
{port |= (1<<num);}
#define AS_LED_OFF_FUN(name, port, ddr, num) void name ## _off(void) \
{port &= ~(1<<num);}
#define AS_ENABLE_OUTPUT(name, port, ddr, num) ddr |= (1<<num);
#define LED_COUNT 10
#define TARGET_COUNT 10
#define MAX_LEDS_ON_AT_ONCE 5
LED_TABLE(AS_LED_OFF_DECL);
LED_TABLE(AS_LED_ON_DECL);
struct target {
struct led *led;
int button_ix;
int loc;
};
uint8_t shuffle_order;
uint8_t target_order[10];
struct int_buffer {
int buf[MAX_LEDS_ON_AT_ONCE];
int first_empty;
unsigned int occupancy;
int first_real;
};
void
led_on(int led);
void
pokey_init(void);
void
pokey_loop(void);
#define BUTTON_COUNT 10
uint8_t button_values[BUTTON_COUNT];
void
set_muxer(uint8_t val);
void
muxer_init(void);
void
read_buttons(void);
void
pokey_flash_handler(void);
void
pokey_test_leds(void);