Control Surface  1.1.0
MIDI Control Surface library for Arduino
CCRotaryEncoder.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 
7 
8 /**
9  * @brief A class of MIDIOutputElement%s that read the input of a **quadrature
10  * (rotary) encoder** and send out relative MIDI **Control Change**
11  * events.
12  *
13  * This version cannot be banked.
14  *
15  * @note To use this class, include the [PJRC Encoder library]
16  * (https://github.com/PaulStoffregen/Encoder) before the
17  * Control-Surface library.
18  *
19  * @ingroup MIDIOutputElements
20  */
21 class CCRotaryEncoder : public MIDIRotaryEncoder<RelativeCCSender> {
22  public:
23  /**
24  * @brief Construct a new CCRotaryEncoder object with the given pins,
25  * address, channel, speed factor, and number of pulses per step.
26  *
27  * @param pins
28  * A list of the two pins connected to the A and B outputs of the
29  * encoder.
30  * The internal pull-up resistors will be enabled by the Encoder
31  * library.
32  * @param address
33  * The MIDI address containing the controller number [0, 119],
34  * channel [CHANNEL_1, CHANNEL_16], and optional cable number
35  * [0, 15].
36  * @param speedMultiply
37  * A constant factor to increase the speed of the rotary encoder.
38  * The difference in position will just be multiplied by this
39  * factor.
40  * @param pulsesPerStep
41  * The number of pulses per physical click of the encoder.
42  * For a normal encoder, this is 4. If you want to increase the
43  * resolution, for the use of Jog wheels, for example, you can go
44  * as 1.
45  * Whereas a greater speedMultiplier factor will increase the
46  * speed, increasing the number of pulsesPerStep will result in a
47  * lower speed.
48  * @param sender
49  * The MIDI sender to use.
50  */
53  uint8_t speedMultiply = 1, uint8_t pulsesPerStep = 4,
54  const RelativeCCSender &sender = {})
56  sender) {}
57 
58 // For tests only (PJRC Encoder library's copy constructor doesn't work)
59 #ifndef ARDUINO
60  CCRotaryEncoder(const Encoder &encoder, const MIDICNChannelAddress &address,
61  uint8_t speedMultiply, uint8_t pulsesPerStep,
62  const RelativeCCSender &sender = {})
64  sender) {}
65 #endif
66 };
67 
MIDIRotaryEncoder.hpp
MIDIRotaryEncoder
An abstract class for rotary encoders that send MIDI events.
Definition: Abstract/MIDIRotaryEncoder.hpp:19
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
MIDIRotaryEncoder< RelativeCCSender >::speedMultiply
const uint8_t speedMultiply
Definition: Abstract/MIDIRotaryEncoder.hpp:58
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
MIDIRotaryEncoder< RelativeCCSender >::sender
RelativeCCSender sender
Definition: Abstract/MIDIRotaryEncoder.hpp:63
MIDIRotaryEncoder< RelativeCCSender >::encoder
Encoder encoder
Definition: Abstract/MIDIRotaryEncoder.hpp:56
MIDIRotaryEncoder< RelativeCCSender >::pulsesPerStep
const uint8_t pulsesPerStep
Definition: Abstract/MIDIRotaryEncoder.hpp:59
CCRotaryEncoder
A class of MIDIOutputElements that read the input of a quadrature (rotary) encoder and send out relat...
Definition: CCRotaryEncoder.hpp:21
RelativeCCSender.hpp
CCRotaryEncoder::CCRotaryEncoder
CCRotaryEncoder(const EncoderPinList &pins, const MIDICNChannelAddress &address, uint8_t speedMultiply=1, uint8_t pulsesPerStep=4, const RelativeCCSender &sender={})
Construct a new CCRotaryEncoder object with the given pins, address, channel, speed factor,...
Definition: CCRotaryEncoder.hpp:51
EncoderPinList
A struct for the pins of a rotary (quadrature) encoder without a switch.
Definition: Def.hpp:44
RelativeCCSender
Definition: RelativeCCSender.hpp:65
MIDIRotaryEncoder< RelativeCCSender >::MIDIRotaryEncoder
MIDIRotaryEncoder(const EncoderPinList &pins, const MIDICNChannelAddress &address, uint8_t speedMultiply, uint8_t pulsesPerStep, const RelativeCCSender &sender)
Construct a new MIDIRotaryEncoder.
Definition: Abstract/MIDIRotaryEncoder.hpp:26
MIDIRotaryEncoder< RelativeCCSender >::address
const MIDICNChannelAddress address
Definition: Abstract/MIDIRotaryEncoder.hpp:57