Line data Source code
1 : #pragma once 2 : 3 : #include <AH/Settings/Warnings.hpp> 4 : 5 : #include <Banks/BankAddresses.hpp> 6 : #include <MIDI_Outputs/Bankable/Abstract/MIDIAbsoluteEncoder.hpp> 7 : #include <MIDI_Senders/PitchBendSender.hpp> 8 : 9 : AH_DIAGNOSTIC_WERROR() 10 : 11 : BEGIN_CS_NAMESPACE 12 : 13 : namespace Bankable { 14 : 15 : /** 16 : * @brief A class of MIDIOutputElement%s that read the input of a **quadrature 17 : * (rotary) encoder** and send out absolute MIDI **Pitch Bend** 18 : * events. 19 : * 20 : * This version can be banked. 21 : * 22 : * @tparam NumBanks 23 : * The number of banks. 24 : * 25 : * @ingroup BankableMIDIOutputElements 26 : */ 27 : template <size_t NumBanks> 28 : class PBAbsoluteEncoder 29 : : public MIDIAbsoluteEncoder<NumBanks, SingleAddress, PitchBendSender<14>> { 30 : public: 31 : /** 32 : * @brief Construct a new Bankable PBAbsoluteEncoder object with the given 33 : * pins, channel, speed factor, and number of pulses per step. 34 : * 35 : * @param config 36 : * The bank configuration to use: the bank to add this element to, 37 : * and whether to change the address, channel or cable number. 38 : * @param encoder 39 : * The Encoder object to use. 40 : * Usually passed as a list of the two pins connected to the 41 : * A and B outputs of the encoder, e.g. `{2, 3}`. 42 : * The internal pull-up resistors will be enabled by the Encoder 43 : * library. 44 : * @param address 45 : * The MIDI channel [CHANNEL_1, CHANNEL_16], and optional cable 46 : * number [0, 15]. 47 : * @param speedMultiply 48 : * A constant factor to increase the speed of the rotary encoder. 49 : * The difference in position will just be multiplied by this 50 : * factor. 51 : * @param pulsesPerStep 52 : * The number of pulses per physical click of the encoder. 53 : * For a normal encoder, this is 4. If you want to increase the 54 : * resolution, for the use of Jog wheels, for example, you can go 55 : * as 1. 56 : * Whereas a greater speedMultiply factor will increase the 57 : * speed, increasing the number of pulsesPerStep will result in a 58 : * lower speed. 59 : */ 60 1 : PBAbsoluteEncoder(const BankConfig<NumBanks> &config, AHEncoder &&encoder, 61 : MIDIChannelCable address, int16_t speedMultiply = 1, 62 : uint8_t pulsesPerStep = 4) 63 : : MIDIAbsoluteEncoder<NumBanks, SingleAddress, PitchBendSender<14>>( 64 1 : {config, address}, std::move(encoder), speedMultiply, 65 2 : pulsesPerStep, {}) {} 66 : }; 67 : 68 : } // namespace Bankable 69 : 70 : END_CS_NAMESPACE 71 : 72 : AH_DIAGNOSTIC_POP()