-
Notifications
You must be signed in to change notification settings - Fork 0
/
VolumeButton.ino
70 lines (56 loc) · 1.16 KB
/
VolumeButton.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
#include <RotaryEncoder.h>
#include "OneButton.h"
#include <HID-Project.h>
RotaryEncoder encoder(7, 8);
OneButton button(4, false);
OneButton muteButton(5, false);
int encoderPos = 0;
void setup()
{
button.setClickTicks(250);
button.attachClick(click);
button.attachDoubleClick(doubleClick);
button.attachLongPressStart(click);
muteButton.setClickTicks(250);
muteButton.attachClick(click);
muteButton.attachLongPressStart(click);
//Serial.begin(9600);
Keyboard.begin();
Consumer.begin();
}
void loop()
{
button.tick();
muteButton.tick();
encoder.tick();
int newPos = encoder.getPosition();
if (encoderPos != newPos)
{
if(encoderPos > newPos)
{
Consumer.write(MEDIA_VOLUME_UP);
}
else
{
Consumer.write(MEDIA_VOLUME_DOWN);
}
//Serial.print(newPos);
//Serial.println();
encoderPos = newPos;
}
}
void click()
{
//Serial.print("click");
//Serial.println();
//teams toggle mute
// Keyboard.press(KEY_LEFT_CTRL);
// Keyboard.press(KEY_LEFT_SHIFT);
// Keyboard.press('m');
Keyboard.press(KEY_F13);
delay(100);
Keyboard.releaseAll();
}
void doubleClick()
{
}