Line data Source code
1 : #pragma once 2 : 3 : #include <MIDI_Outputs/Bankable/Abstract/MIDIRotaryEncoder.hpp> 4 : #include <MIDI_Senders/RelativeCCSender.hpp> 5 : 6 : BEGIN_CS_NAMESPACE 7 : 8 : namespace Bankable { 9 : 10 : /** 11 : * @brief A class of MIDIOutputElement%s that read the input of a **quadrature 12 : * (rotary) encoder** and send out relative MIDI **Control Change** 13 : * events. 14 : * 15 : * This version can be banked. 16 : * 17 : * @note To use this class, include the [PJRC Encoder library] 18 : * (https://github.com/PaulStoffregen/Encoder) before the 19 : * Control-Surface library. 20 : * 21 : * @ingroup BankableMIDIOutputElements 22 : */ 23 2 : class CCRotaryEncoder : public MIDIRotaryEncoder<RelativeCCSender> { 24 : public: 25 : /** 26 : * @brief Construct a new Bankable CCRotaryEncoder object with the given 27 : * pins, controller, channel, speed factor, and number of pulses 28 : * per step. 29 : * 30 : * @param config 31 : * The bank configuration to use: the bank to add this element to, 32 : * and whether to change the address, channel or cable number. 33 : * @param pins 34 : * A list of the two pins connected to the A and B outputs of the 35 : * encoder. 36 : * The internal pull-up resistors will be enabled by the Encoder 37 : * library. 38 : * @param address 39 : * The MIDI address containing the controller number [0, 119], 40 : * channel [CHANNEL_1, CHANNEL_16], and optional cable number 41 : * [0, 15]. 42 : * @param speedMultiplier 43 : * A constant factor to increase the speed of the rotary encoder. 44 : * The difference in position will just be multiplied by this 45 : * factor. 46 : * @param pulsesPerStep 47 : * The number of pulses per physical click of the encoder. 48 : * For a normal encoder, this is 4. If you want to increase the 49 : * resolution, for the use of Jog wheels, for example, you can go 50 : * as 1. 51 : * Whereas a greater speedMultiplier factor will increase the 52 : * speed, increasing the number of pulsesPerStep will result in a 53 : * lower speed. 54 : * @param sender 55 : * The MIDI sender to use. 56 : */ 57 1 : CCRotaryEncoder(const OutputBankConfig &config, const EncoderPinList &pins, 58 : const MIDICNChannelAddress &address, 59 : uint8_t speedMultiplier, uint8_t pulsesPerStep, 60 : const RelativeCCSender &sender = {}) 61 2 : : MIDIRotaryEncoder(config, pins, address, speedMultiplier, 62 3 : pulsesPerStep, sender) {} 63 : 64 : // For tests only (PJRC Encoder library's copy constructor doesn't work) 65 : #ifndef ARDUINO 66 1 : CCRotaryEncoder(const OutputBankConfig &config, const Encoder &encoder, 67 : const MIDICNChannelAddress &address, 68 : uint8_t speedMultiplier = 1, uint8_t pulsesPerStep = 4, 69 : const RelativeCCSender &sender = {}) 70 2 : : MIDIRotaryEncoder(config, encoder, address, speedMultiplier, 71 3 : pulsesPerStep, sender) {} 72 : #endif 73 : }; 74 : 75 : } // namespace Bankable 76 : 77 : END_CS_NAMESPACE