-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudio_control.ino
87 lines (77 loc) · 1.99 KB
/
audio_control.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
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
/*
* Audio control
*/
void setupAudioControl() {
// None
}
void volumeDown(ESPRotary& volume_knob) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Volume Down");
bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN);
setFrequencyLED(GREEN);
}
}
void volumeUp(ESPRotary& volume_knob) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Volume Up");
bleKeyboard.write(KEY_MEDIA_VOLUME_UP);
setFrequencyLED(RED);
}
}
void volumeClick(Button2& volume_button) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Mute");
bleKeyboard.write(KEY_MEDIA_MUTE);
if (muted) {
frequency_led.setPixelColor(0, frequency_led.Color(0, 0, 0));
} else {
frequency_led.setPixelColor(0, frequency_led.Color(0, 0, 255));
muted = true;
}
frequency_led.show();
}
}
void volumeLongClick(Button2& volume_button) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Long press!");
}
}
void button1Click(Button2& button_1) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Button 1 pressed");
bleKeyboard.write(KEY_MEDIA_PREVIOUS_TRACK);
setFrequencyLED(YELLOW);
}
}
void button2Click(Button2& button_2) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Button 2 pressed");
bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
setFrequencyLED(PURPLE);
}
}
void button3Click(Button2& button_3) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Button 3 pressed");
bleKeyboard.write(KEY_MEDIA_NEXT_TRACK);
setFrequencyLED(CHARTREUSE);
}
}
void button4Click(Button2& button_4) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Button 4 pressed");
bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
setFrequencyLED(CYAN);
}
}
void button5Click(Button2& button_5) {
if(bleKeyboard.isConnected()) {
DEBUG_PRINTLN("Button 5 pressed");
DEBUG_PRINTLN("Going to sleep");
bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
setFrequencyLED(YELLOW);
frequency_led.setPixelColor(0, OFF);
frequency_led.show();
esp_deep_sleep_start();
}
}