Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Outputs
Abstract
Abstract/MIDIFilteredAnalog.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
AH/Hardware/FilteredAnalog.hpp
>
4
#include <
Def/Def.hpp
>
5
#include <
MIDI_Outputs/Abstract/MIDIOutputElement.hpp
>
6
7
BEGIN_CS_NAMESPACE
8
16
template
<
class
Sender>
17
class
MIDIFilteredAnalog
:
public
MIDIOutputElement
{
18
protected
:
30
MIDIFilteredAnalog
(
pin_t
analogPin,
MIDIAddress
address
,
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
{
38
if
(
filteredAnalog
.update())
39
forcedUpdate
();
40
}
41
44
void
forcedUpdate
() {
sender
.send(
filteredAnalog
.getValue(),
address
); }
45
58
void
map
(
MappingFunction
fn) {
filteredAnalog
.map(fn); }
59
61
void
invert
() {
filteredAnalog
.invert(); }
62
67
analog_t
getRawValue
()
const
{
return
filteredAnalog
.getRawValue(); }
68
72
static
constexpr
analog_t
getMaxRawValue
() {
73
return
FilteredAnalog::getMaxRawValue
();
74
}
75
80
analog_t
getValue
()
const
{
return
filteredAnalog
.getValue(); }
81
83
MIDIAddress
getAddress
()
const
{
return
this->
address
; }
85
void
setAddress
(
MIDIAddress
address
) { this->address =
address
; }
86
87
private
:
88
using
FilteredAnalog
=
AH::FilteredAnalog
<Sender::precision()>;
89
FilteredAnalog
filteredAnalog
;
90
MIDIAddress
address
;
91
92
public
:
93
Sender
sender
;
94
};
95
96
END_CS_NAMESPACE
Def.hpp
MappingFunction
analog_t(*)(analog_t) MappingFunction
Definition
Def.hpp:23
FilteredAnalog.hpp
MIDIOutputElement.hpp
MIDIOutputElement
AH::Updatable<> MIDIOutputElement
Definition
MIDIOutputElement.hpp:9
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
AH::FilteredAnalog
A class that reads and filters an analog input.
Definition
FilteredAnalog.hpp:275
AH::FilteredAnalog< Sender::precision()>::getMaxRawValue
static constexpr analog_t getMaxRawValue()
Definition
FilteredAnalog.hpp:172
MIDIAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition
MIDIAddress.hpp:145
MIDIFilteredAnalog::address
MIDIAddress address
Definition
Abstract/MIDIFilteredAnalog.hpp:90
MIDIFilteredAnalog::setAddress
void setAddress(MIDIAddress address)
Set the MIDI address.
Definition
Abstract/MIDIFilteredAnalog.hpp:85
MIDIFilteredAnalog::forcedUpdate
void forcedUpdate()
Send the value of the analog input over MIDI, even if the value didn't change.
Definition
Abstract/MIDIFilteredAnalog.hpp:44
MIDIFilteredAnalog::sender
Sender sender
Definition
Abstract/MIDIFilteredAnalog.hpp:93
MIDIFilteredAnalog::getValue
analog_t getValue() const
Get the value of the analog input (this is the value after first applying the mapping function).
Definition
Abstract/MIDIFilteredAnalog.hpp:80
MIDIFilteredAnalog::getMaxRawValue
static constexpr analog_t getMaxRawValue()
Get the maximum value that can be returned from getRawValue.
Definition
Abstract/MIDIFilteredAnalog.hpp:72
MIDIFilteredAnalog::map
void map(MappingFunction fn)
Specify a mapping function that is applied to the raw analog value before sending.
Definition
Abstract/MIDIFilteredAnalog.hpp:58
MIDIFilteredAnalog::FilteredAnalog
AH::FilteredAnalog< Sender::precision()> FilteredAnalog
Definition
Abstract/MIDIFilteredAnalog.hpp:88
MIDIFilteredAnalog::invert
void invert()
Invert the analog value.
Definition
Abstract/MIDIFilteredAnalog.hpp:61
MIDIFilteredAnalog::MIDIFilteredAnalog
MIDIFilteredAnalog(pin_t analogPin, MIDIAddress address, const Sender &sender)
Construct a new MIDIFilteredAnalog.
Definition
Abstract/MIDIFilteredAnalog.hpp:30
MIDIFilteredAnalog::getAddress
MIDIAddress getAddress() const
Get the MIDI address.
Definition
Abstract/MIDIFilteredAnalog.hpp:83
MIDIFilteredAnalog::begin
void begin() final override
Initialize this updatable.
Definition
Abstract/MIDIFilteredAnalog.hpp:35
MIDIFilteredAnalog::getRawValue
analog_t getRawValue() const
Get the raw value of the analog input (this is the value without applying the filter or the mapping f...
Definition
Abstract/MIDIFilteredAnalog.hpp:67
MIDIFilteredAnalog::filteredAnalog
FilteredAnalog filteredAnalog
Definition
Abstract/MIDIFilteredAnalog.hpp:89
MIDIFilteredAnalog::update
void update() final override
Update this updatable.
Definition
Abstract/MIDIFilteredAnalog.hpp:37
AH::analog_t
uint16_t analog_t
The type returned from analogRead and similar functions.
Definition
Hardware-Types.hpp:14
AH::ExtIO::pin_t
Type for storing pin numbers of Extended Input/Output elements.
Definition
Hardware-Types.hpp:25
Generated by
1.17.0