Control Surface stm32
MIDI Control Surface library for Arduino
Abstract/MIDIFilteredAnalog.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <Def/Def.hpp>
6
8
16template <class Sender>
18 protected:
31 const Sender &sender)
32 : filteredAnalog(analogPin), address(address), sender(sender) {}
33
34 public:
35 void begin() final override { filteredAnalog.resetToCurrentValue(); }
36
37 void update() final override {
40 }
41
45
59
62
68
74
76 MIDIAddress getAddress() const { return this->address; }
78 void setAddress(MIDIAddress address) { this->address = address; }
79
80 private:
81 AH::FilteredAnalog<Sender::precision()> filteredAnalog;
83
84 public:
85 Sender sender;
86};
87
analog_t(*)(analog_t) MappingFunction
Definition: Def.hpp:21
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class that reads and filters an analog input.
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.
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:173
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
A class for potentiometers and faders that send MIDI events.
void setAddress(MIDIAddress address)
Set the MIDI address.
void forcedUpdate()
Send the value of the analog input over MIDI, even if the value didn't change.
analog_t getValue() const
Get the value of the analog input (this is the value after first applying the mapping function).
void map(MappingFunction fn)
Specify a mapping function that is applied to the raw analog value before sending.
void invert()
Invert the analog value.
MIDIFilteredAnalog(pin_t analogPin, MIDIAddress address, const Sender &sender)
Construct a new MIDIFilteredAnalog.
MIDIAddress getAddress() const
Get the MIDI address.
void begin() final override
Initialize this updatable.
AH::FilteredAnalog< Sender::precision()> filteredAnalog
analog_t getRawValue() const
Get the raw value of the analog input (this is the value without applying the filter or the mapping f...
void update() final override
Update this updatable.
uint16_t analog_t
The type returned from analogRead and similar functions.
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).