Control Surface pin-t-adl
MIDI Control Surface library for Arduino
AudioVULEDs.hpp
Go to the documentation of this file.
1/* ✔ */
2
3#pragma once
4
6#include <Audio/AudioVU.hpp>
7#include <Def/Def.hpp>
8
10
20template <uint8_t N>
21class AudioVULEDs : public AudioVU, public AH::Updatable<AudioVU> {
22 public:
36 float gain = 1.0)
37 : AudioVU(level, gain, N), vuleds(vuleds) {}
38
42 void begin() override { vuleds.begin(); }
43
47 void update() override {
48 uint8_t newValue = this->getValue();
49 if (newValue != previousValue) {
50 vuleds.display(newValue);
51 previousValue = newValue;
52 }
53 }
54
61 void setMode(AH::DotBarMode mode) { vuleds.setMode(mode); }
62
66 void dotMode() { vuleds.dotMode(); }
67
71 void barMode() { vuleds.barMode(); }
72
73 private:
75 uint8_t previousValue = 0;
76};
77
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class for LED bars.
A super class for object that have to be updated regularly.
Definition: Updatable.hpp:173
A VU meter that reads from an Audio stream using the AudioAnalyzePeak class, and displays it on an LE...
Definition: AudioVULEDs.hpp:21
void update() override
Update the LEDs with the latest level.
Definition: AudioVULEDs.hpp:47
AH::DotBarDisplayLEDs< N > vuleds
Definition: AudioVULEDs.hpp:74
void begin() override
Initialize.
Definition: AudioVULEDs.hpp:42
uint8_t previousValue
Definition: AudioVULEDs.hpp:75
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: AudioVULEDs.hpp:61
AudioVULEDs(const AH::DotBarDisplayLEDs< N > &vuleds, AudioAnalyzePeak &level, float gain=1.0)
Create a new AudioVULEDs object.
Definition: AudioVULEDs.hpp:35
void dotMode()
Set the mode to dot mode.
Definition: AudioVULEDs.hpp:66
void barMode()
Set the mode to bar mode.
Definition: AudioVULEDs.hpp:71
A VU meter that reads from an Audio stream using the Analyzer class.
Definition: AudioVU.hpp:16
uint8_t getValue() override
Get the value of the VU meter.
Definition: AudioVU.hpp:60
class AudioVU::Analyzer level
float gain
Definition: AudioVU.hpp:135
DotBarMode
An enumeration type to set an LED display to either bar or dot mode.