5#include <AH/STL/algorithm>
25template <u
int8_t NumBanks,
class BankAddress,
class Sender>
67 auto activeBank =
address.getSelection();
72 if (value <= previousValue)
75 if (value >= previousValue)
78 if (value == previousValue || previousValue ==
initial)
80 else if (value > previousValue)
160 Sender::precision() <= 14,
161 "Sender precision must be 14 or less, because larger values are "
uint8_t setting_t
The type used for Selectors.
analog_t(*)(analog_t) MappingFunction
#define BEGIN_CS_NAMESPACE
void invert()
Invert the analog value.
void resetToCurrentValue()
Reset the filtered value to the value that's currently being measured at the analog input.
void map(MappingFunction fn)
Specify a mapping function/functor that is applied to the analog value after filtering and before app...
AnalogType getRawValue() const
Read the raw value of the analog input without any filtering or mapping applied, but with its bit dep...
AnalogType getValue() const
Get the filtered value of the analog input (with the mapping function applied).
bool update()
Read the analog input value, apply the mapping function, and update the average.
static constexpr AnalogType getMaxRawValue()
Get the maximum value that can be returned from getRawValue.
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
A super class for object that have to be updated regularly.
A class for potentiometers and faders that send MIDI events.
analog_t getValue() const
Get the value of the analog input (this is the value after first applying the mapping function).
void update() override
Update this updatable.
static constexpr analog_t getMaxRawValue()
Get the maximum value that can be returned from getRawValue.
void map(MappingFunction fn)
Specify a mapping function that is applied to the raw analog value before sending.
static constexpr analog_t initial
State
State of the smart potentiometer.
@ Active
The potentiometer is active, the position changes will be sent over MIDI.
@ Higher
The value of the potentiometer is higher than the previously recorded value for the current bank.
@ Lower
The value of the potentiometer is lower than the previously recorded value for the current bank.
AH::Array< analog_t, NumBanks > previousValues
void begin() override
Initialize this updatable.
void invert()
Invert the analog value.
void activate()
Activate the potentiometer in the current bank, regardless of its current and previous position.
State getState() const
Get the state of the smart potentiometer, to know whether the position has to be lower or higher in o...
analog_t getRawValue() const
Get the raw value of the analog input (this is the value without applying the filter or the mapping f...
analog_t getPreviousValue(setting_t bank) const
Get the previous value of the analog input of the given bank.
FilteredAnalog filteredAnalog
SmartMIDIFilteredAnalog(BankAddress bankAddress, pin_t analogPin, const Sender &sender)
Construct a new SmartMIDIFilteredAnalog.
analog_t getPreviousValue() const
Get the previous value of the analog input of the active bank.
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Type for storing pin numbers of Extended Input/Output elements.