-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontrols.h
110 lines (101 loc) · 2.5 KB
/
controls.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
/* ======================================================================
Read a potentiometer. Returns an integer reading.
*/
int readPot(int pot) {
return mozziAnalogRead(pot);
}
/* ======================================================================
Update buttons and switches
*/
void updateButtonsSwitches() {
playmode_switch.update();
ribmode_switch.update();
custom_switch.update();
presetA_switch.update();
presetB_switch.update();
button.update();
}
/* ======================================================================
Gate button (S5; tactile switch with red LED)
Returns true or false
*/
bool gateButton()
{
if (button.isPressed())
{
return true;
}
else
{
return false;
}
}
/* ======================================================================
Tempo control knob (POT1; label: TIME)
Remapped to min and max_tempo
*/
unsigned int tempoKnob() {
int pot1 = readPot(POT1_PIN);
return map(pot1, 0, 1023, min_tempo, max_tempo);
}
/* ======================================================================
Octave control knob (POT2; label: PITCH)
Returns 0.5, 1, or 2
*/
float pitchKnob() {
int pot2 = readPot(POT2_PIN);
if (pot2 >= 0 && pot2 < 250) return 0.5;
else if (pot2 >= 251 && pot2 < 450) return 1;
else return 2;
}
/* ======================================================================
Custom knob (POT3; label: CUSTOM)
Customize to your liking!
*/
unsigned int customKnob() {
int pot3 = readPot(POT3_PIN);
return pot3;
}
/* ======================================================================
Play mode switch (S1; label: PLAY MODE)
Returns true or false
*/
bool playmodeSwitch() {
if (playmode_switch.isPressed()) return true;
else return false;
}
/* ======================================================================
Ribbon mode switch (S2; label: RIBBON MODE)
Returns true or false
*/
bool ribbonmodeSwitch() {
if (ribmode_switch.isPressed()) return true;
else return false;
}
/* ======================================================================
Custom switch (S3; label: CUSTOM)
Returns true or false
*/
bool customSwitch() {
if (custom_switch.isPressed()) return true;
else return false;
}
/* ======================================================================
Preset switch (S4; label: PRESET)
Returns a value of 1, 2, or 3
*/
byte presetSwitch()
{
if (presetA_switch.isPressed())
{
return 1;
}
else if (presetB_switch.isPressed())
{
return 3;
}
else
{
return 2;
}
}