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