Line data Source code
1 : #pragma once
2 :
3 : #include <Banks/BankAddresses.hpp>
4 : #include <MIDI_Outputs/Bankable/Abstract/MIDIButtons.hpp>
5 : #include <MIDI_Senders/DigitalCCSender.hpp>
6 :
7 : BEGIN_CS_NAMESPACE
8 :
9 : namespace Bankable {
10 :
11 : /**
12 : * @brief A class of MIDIOutputElement%s that read the input of **a collection
13 : * of momentary push buttons or switches**, and send out MIDI **Control
14 : * Change** events.
15 : *
16 : * A value of 0x7F is sent when a button is pressed, and a value of 0x00 is sent
17 : * when a button is released.
18 : * The buttons are debounced in software.
19 : * This version can be banked.
20 : *
21 : * @tparam NumButtons
22 : * The number of buttons in the collection.
23 : *
24 : * @ingroup BankableMIDIOutputElements
25 : */
26 : template <uint8_t NumButtons>
27 : class CCButtons
28 : : public MIDIButtons<SingleAddress, DigitalCCSender, NumButtons> {
29 : public:
30 : /**
31 : * @brief Create a new Bankable CCButtons object with the given pins,
32 : * the given controller number and channel.
33 : *
34 : * @param config
35 : * The bank configuration to use: the bank to add this element to,
36 : * and whether to change the address, channel or cable number.
37 : * @param buttons
38 : * A list of digital input pins with the buttons connected.
39 : * The internal pull-up resistors will be enabled.
40 : * @param baseAddress
41 : * The MIDI address of the first button, containing the controller
42 : * number [0, 119], channel [Channel_1, Channel_16], and optional
43 : * cable number [Cable_1, Cable_16].
44 : * @param incrementAddress
45 : * The number of addresses to increment for each next button.
46 : * E.g. if `baseAddress` is 8, and `incrementAddress` is 2,
47 : * then the first button will send on address 8, the second
48 : * button will send on address 10, button three on address 12, etc.
49 : * @param sender
50 : * The MIDI sender to use.
51 : */
52 3 : CCButtons(OutputBankConfig<> config,
53 : const Array<AH::Button, NumButtons> &buttons,
54 : MIDIAddress baseAddress, RelativeMIDIAddress incrementAddress,
55 : const DigitalCCSender &sender = {})
56 : : MIDIButtons<SingleAddress, DigitalCCSender, NumButtons>(
57 3 : {config, baseAddress}, buttons, incrementAddress, sender) {}
58 : };
59 :
60 : } // namespace Bankable
61 :
62 : END_CS_NAMESPACE
|