-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.h
140 lines (130 loc) · 3.38 KB
/
main.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
Last Updated: 30 Mar. 2018
By Anton Grimpelhuber ([email protected])
*/
// The TV-B-Gone for Arduino can use either the EU (European Union) or the NA (North America) database of POWER CODES
// EU is for Europe, Middle East, Australia, New Zealand, and some countries in Africa and South America
// NA is for North America, Asia, and the rest of the world not covered by EU
// Two regions!
#define NA 0 //set by a HIGH on REGIONSWITCH pin
#define EU 1 //set by a LOW on REGIONSWITCH pin
// What pins do what
#define LED 10 //LED indicator pin (built-in LED)
#define IRLED 9 //the IR sender LED / D5 on wemos D1 mini
#define TRIGGER 37 //the button pin / D6 on wemos D1 mini
#define REGIONSWITCH 39 //HIGH (1) = NA, LOW (0) = EU; Pin 5 / D1 (REGIONSWITCH) is HIGH (via in input pullup resistor) for North America, or you (the user) must wire it to ground to set the codes for Europe.
// Lets us calculate the size of the NA/EU databases
#define NUM_ELEM(x) (sizeof (x) / sizeof (*(x)));
// set define to 0 to turn off debug output
#define DEBUG 0
#define DEBUGP(x) if (DEBUG == 1) { x ; }
// Shortcut to insert single, non-optimized-out nop
#define NOP __asm__ __volatile__ ("nop")
// Not used any more on esp8266, so don't bother
// Tweak this if neccessary to change timing
// -for 8MHz Arduinos, a good starting value is 11
// -for 16MHz Arduinos, a good starting value is 25
#define DELAY_CNT 25
// Makes the codes more readable. the OCRA is actually
// programmed in terms of 'periods' not 'freqs' - that
// is, the inverse!
// #define freq_to_timerval(x) (F_CPU / 8 / x - 1)
#define freq_to_timerval(x) (x / 1000)
// The structure of compressed code entries
struct IrCode {
uint8_t timer_val;
uint8_t numpairs;
uint8_t bitcompression;
uint16_t const *times;
uint8_t const *codes;
};
// MEGALOVAINIA
#define N_B0 31
#define N_C1 33
#define N_CS1 35
#define N_D1 37
#define N_DS1 39
#define N_E1 41
#define N_F1 44
#define N_FS1 46
#define N_G1 49
#define N_GS1 52
#define N_A1 55
#define N_AS1 58
#define N_B1 62
#define N_C2 65
#define N_CS2 69
#define N_D2 73
#define N_DS2 78
#define N_E2 82
#define N_F2 87
#define N_FS2 93
#define N_G2 98
#define N_GS2 104
#define N_A2 110
#define N_AS2 117
#define N_B2 123
#define N_C3 131
#define N_CS3 139
#define N_D3 147
#define N_DS3 156
#define N_E3 165
#define N_F3 175
#define N_FS3 185
#define N_G3 196
#define N_GS3 208
#define N_A3 220
#define N_AS3 233
#define N_B3 247
#define N_C4 262
#define N_CS4 277
#define N_D4 294
#define N_DS4 311
#define N_E4 330
#define N_F4 349
#define N_FS4 370
#define N_G4 392
#define N_GS4 415
#define N_A4 440
#define N_AS4 466
#define N_B4 494
#define N_C5 523
#define N_CS5 554
#define N_D5 587
#define N_DS5 622
#define N_E5 659
#define N_F5 698
#define N_FS5 740
#define N_G5 784
#define N_GS5 831
#define N_A5 880
#define N_AS5 932
#define N_B5 988
#define N_C6 1047
#define N_CS6 1109
#define N_D6 1175
#define N_DS6 1245
#define N_E6 1319
#define N_F6 1397
#define N_FS6 1480
#define N_G6 1568
#define N_GS6 1661
#define N_A6 1760
#define N_AS6 1865
#define N_B6 1976
#define N_C7 2093
#define N_CS7 2217
#define N_D7 2349
#define N_DS7 2489
#define N_E7 2637
#define N_F7 2794
#define N_FS7 2960
#define N_G7 3136
#define N_GS7 3322
#define N_A7 3520
#define N_AS7 3729
#define N_B7 3951
#define N_C8 4186
#define N_CS8 4435
#define N_D8 4699
#define N_DS8 4978