-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_display_functions.ino
59 lines (52 loc) · 1.14 KB
/
3_display_functions.ino
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
// display functions
// MIDI au Pair
// by Tom Hoffman
void resetDisplay() {
for (int i = 0; i < 2; i++) {
display_buffer[i * 2] = presets[pad_buttons[i].preset].id;
char a[2];
display_buffer[(i * 2) + 1] = oscillators[pad_buttons[i].oscillator];
writeDisplay();
}
}
void flashLEDs(int v) {
for (int i = 0; i < 2; i++) {
digitalWrite(BUTTON_LEDS[i], v);
}
digitalWrite(PULSE_LED, v);
}
void readyDisplay() {
// flash and pause on boot
flashLEDs(HIGH);
delay(1000);
flashLEDs(LOW);
}
void writeDisplay() {
for (int i = 0; i < 4; i++) {
alpha4.writeDigitAscii(i, display_buffer[i]);
}
alpha4.writeDisplay();
}
void displayByte(byte b) {
// for debugging
// displays exact value of a byte in hex, right justified.
char a[2];
itoa(b, a, 16); // converting
if (b <= 15) {
display_buffer[2] = '0';
display_buffer[3] = a[0];
}
else {
display_buffer[2] = a[0];
display_buffer[3] = a[1];
}
writeDisplay();
}
void updatePadButtonActiveLED(byte side) {
if (pad_buttons[side].active) {
digitalWrite(BUTTON_LEDS[side], HIGH);
}
else {
digitalWrite(BUTTON_LEDS[side], LOW);
}
}