-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonLatch.cpp
More file actions
31 lines (25 loc) · 884 Bytes
/
ButtonLatch.cpp
File metadata and controls
31 lines (25 loc) · 884 Bytes
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
#include "ButtonLatch.h"
#include "Debug.h"
ButtonLatch::ButtonLatch(byte pin, byte channel, byte ccNumber)
: ButtonBase(pin), _channel(channel), _ccNumber(ccNumber) {
}
void ButtonLatch::init() {
Debug::printNameValuePair("Latch Button Startup", _pin);
midiEventPacket_t msg;
if (_lastState == LOW) {
msg = {0x0B, uint8_t(0xB0 | _channel), _ccNumber, 127};
} else {
msg = {0x0B, uint8_t(0xB0 | _channel), _ccNumber, 0};
}
sendMidiMsg(msg);
}
void ButtonLatch::onPress() {
Debug::printNameValuePair("Latch Button Pressed", _pin);
midiEventPacket_t msg = {0x0B, uint8_t(0xB0 | _channel), _ccNumber, 127};
sendMidiMsg(msg);
}
void ButtonLatch::onRelease() {
Debug::printNameValuePair("Latch Button Released", _pin);
midiEventPacket_t msg = {0x0B, uint8_t(0xB0 | _channel), _ccNumber, 0};
sendMidiMsg(msg);
}