Control Surface  1.1.1
MIDI Control Surface library for Arduino
VULEDs.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <MIDI_Inputs/MCU/VU.hpp>
5 
7 
8 namespace MCU {
9 
10 template <uint8_t NumLEDs>
12  public:
14 
15  template <class T>
16  void begin(T &) {
17  leds.begin();
18  }
19 
20  template <class T>
21  void update(T &t) {
22  uint8_t value = t.getValue(); // value in [0, 12]
23  value = (value * NumLEDs + FLOOR_CORRECTION) / 12; // value in [0, N]
24  leds.display(value);
25  }
26 
28  AH::DotBarMode getMode() const { return this->leds.getMode(); }
30  void setMode(AH::DotBarMode mode) { this->leds.setMode(mode); }
32  void dotMode() { this->leds.dotMode(); }
34  void barMode() { this->leds.barMode(); }
36  void toggleMode() { this->leds.toggleMode(); }
37 
38  private:
40 
42  constexpr static uint8_t FLOOR_CORRECTION = 5;
43 };
44 
45 template <uint8_t NumLEDs>
46 class VULEDs : public GenericVU<VULEDsCallback<NumLEDs>> {
47  public:
48  VULEDs(const PinList<NumLEDs> &ledPins, uint8_t track,
49  unsigned int decayTime = VUDecay::Default)
50  : GenericVU<VULEDsCallback<NumLEDs>>{
51  track,
52  CHANNEL_1,
53  decayTime,
54  {ledPins},
55  } {}
56 
57  VULEDs(const PinList<NumLEDs> &ledPins, uint8_t track,
58  MIDICNChannel channelCN, unsigned int decayTime = VUDecay::Default)
59  : GenericVU<VULEDsCallback<NumLEDs>>{
60  track,
61  channelCN,
62  decayTime,
63  {ledPins},
64  } {}
65 
67  AH::DotBarMode getMode() const { return this->callback.getMode(); }
69  void setMode(AH::DotBarMode mode) { this->callback.setMode(mode); }
71  void dotMode() { this->callback.dotMode(); }
73  void barMode() { this->callback.barMode(); }
75  void toggleMode() { this->callback.toggleMode(); }
76 };
77 
78 namespace Bankable {
79 
80 template <uint8_t NumBanks, uint8_t NumLEDs>
81 class VULEDs : public GenericVU<NumBanks, VULEDsCallback<NumLEDs>> {
82  public:
83  VULEDs(BankConfig<NumBanks> config, const PinList<NumLEDs> &ledPins,
84  uint8_t track, unsigned int decayTime = VUDecay::Default)
85  : GenericVU<NumBanks, VULEDsCallback<NumLEDs>>{
86  config, track, CHANNEL_1, decayTime, {ledPins},
87  } {}
88 
89  VULEDs(BankConfig<NumBanks> config, const PinList<NumLEDs> &ledPins,
90  uint8_t track, MIDICNChannel channelCN,
91  unsigned int decayTime = VUDecay::Default)
92  : GenericVU<NumBanks, VULEDsCallback<NumLEDs>>{
93  config, track, channelCN, decayTime, {ledPins},
94  } {}
95 
97  AH::DotBarMode getMode() const { return this->callback.getMode(); }
99  void setMode(AH::DotBarMode mode) { this->callback.setMode(mode); }
101  void dotMode() { this->callback.dotMode(); }
103  void barMode() { this->callback.barMode(); }
105  void toggleMode() { this->callback.toggleMode(); }
106 };
107 
108 } // namespace Bankable
109 
110 } // namespace MCU
111 
AH::DotBarDisplayLEDs::display
void display(uint8_t value) const
Display the given number of LEDs on the LED bar.
Definition: DotBarDisplayLEDs.hpp:40
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
MCU::Bankable::GenericVU
A class for MIDI input elements that represent Mackie Control Universal VU meters.
Definition: VU.hpp:287
AH::LEDs::begin
void begin() const
Initialize (set LED pins as outputs).
Definition: LEDs.hpp:34
MCU
Names and note and controller numbers for the Mackie Control Universal (MCU) protocol.
Definition: LCDDisplay.hpp:10
MCU::VULEDsCallback::update
void update(T &t)
Definition: VULEDs.hpp:21
AH::DotBarDisplayLEDs::barMode
void barMode()
Set the mode to bar mode.
Definition: DotBarDisplayLEDs.hpp:72
MCU::VU_Base< 1, VULEDsCallback< NumLEDs > >::decayTime
unsigned int decayTime
Definition: VU.hpp:167
MCU::VUDecay::Default
constexpr unsigned int Default
Decay one segment/block every 150 ms if no new values are received.
Definition: VU.hpp:43
MCU::VULEDs::VULEDs
VULEDs(const PinList< NumLEDs > &ledPins, uint8_t track, MIDICNChannel channelCN, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:57
MCU::Bankable::VULEDs::VULEDs
VULEDs(BankConfig< NumBanks > config, const PinList< NumLEDs > &ledPins, uint8_t track, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:83
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
MCU::VULEDsCallback
Definition: VULEDs.hpp:11
AH::DotBarDisplayLEDs::setMode
void setMode(DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: DotBarDisplayLEDs.hpp:66
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
AH::DotBarMode
DotBarMode
An enumeration type to set an LED display to either bar or dot mode.
Definition: DotBarDisplayLEDs.hpp:15
MCU::VULEDs::barMode
void barMode()
Set the mode to bar mode.
Definition: VULEDs.hpp:73
MCU::VULEDs::getMode
AH::DotBarMode getMode() const
Get the dot/bar mode.
Definition: VULEDs.hpp:67
MCU::VULEDs
Definition: VULEDs.hpp:46
MCU::VULEDsCallback::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: VULEDs.hpp:30
MCU::Bankable::VULEDs::VULEDs
VULEDs(BankConfig< NumBanks > config, const PinList< NumLEDs > &ledPins, uint8_t track, MIDICNChannel channelCN, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:89
MCU::VULEDsCallback::VULEDsCallback
VULEDsCallback(const AH::DotBarDisplayLEDs< NumLEDs > &leds)
Definition: VULEDs.hpp:13
MCU::VULEDsCallback::begin
void begin(T &)
Definition: VULEDs.hpp:16
VU.hpp
MCU::VULEDsCallback::leds
AH::DotBarDisplayLEDs< NumLEDs > leds
Definition: VULEDs.hpp:39
MCU::VULEDs::dotMode
void dotMode()
Set the mode to dot mode.
Definition: VULEDs.hpp:71
MCU::GenericVU
A class for MIDI input elements that represent Mackie Control Universal VU meters.
Definition: VU.hpp:183
MCU::Bankable::VULEDs::toggleMode
void toggleMode()
Toggle the dot/bar mode.
Definition: VULEDs.hpp:105
MCU::Bankable::VULEDs::dotMode
void dotMode()
Set the mode to dot mode.
Definition: VULEDs.hpp:101
MIDICNChannel
A class for saving a MIDI channel and cable number.
Definition: MIDICNChannelAddress.hpp:19
AH::DotBarDisplayLEDs::toggleMode
void toggleMode()
Toggle the dot/bar mode.
Definition: DotBarDisplayLEDs.hpp:75
MCU::VU_Base< 1, VULEDsCallback< NumLEDs > >::callback
VULEDsCallback< NumLEDs > callback
Definition: VU.hpp:171
AH::DotBarDisplayLEDs::getMode
DotBarMode getMode() const
Get the dot/bar mode.
Definition: DotBarDisplayLEDs.hpp:58
DotBarDisplayLEDs.hpp
MCU::VULEDsCallback::FLOOR_CORRECTION
constexpr static uint8_t FLOOR_CORRECTION
Definition: VULEDs.hpp:42
MCU::VULEDsCallback::getMode
AH::DotBarMode getMode() const
Get the dot/bar mode.
Definition: VULEDs.hpp:28
AH::DotBarDisplayLEDs::dotMode
void dotMode()
Set the mode to dot mode.
Definition: DotBarDisplayLEDs.hpp:69
MCU::Bankable::VULEDs::getMode
AH::DotBarMode getMode() const
Get the dot/bar mode.
Definition: VULEDs.hpp:97
MCU::VULEDsCallback::barMode
void barMode()
Set the mode to bar mode.
Definition: VULEDs.hpp:34
BankConfig
A struct for selecting the bank of BankableMIDIInputs and the bank type.
Definition: BankConfig.hpp:39
MCU::VULEDsCallback::dotMode
void dotMode()
Set the mode to dot mode.
Definition: VULEDs.hpp:32
MCU::Bankable::VULEDs::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: VULEDs.hpp:99
MCU::VULEDs::VULEDs
VULEDs(const PinList< NumLEDs > &ledPins, uint8_t track, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:48
MCU::VULEDsCallback::toggleMode
void toggleMode()
Toggle the dot/bar mode.
Definition: VULEDs.hpp:36
CHANNEL_1
constexpr Channel CHANNEL_1
Definition: Channel.hpp:111
MCU::Bankable::VULEDs
Definition: VULEDs.hpp:81
MCU::VULEDs::setMode
void setMode(AH::DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: VULEDs.hpp:69
MCU::Bankable::VULEDs::barMode
void barMode()
Set the mode to bar mode.
Definition: VULEDs.hpp:103
MCU::VULEDs::toggleMode
void toggleMode()
Toggle the dot/bar mode.
Definition: VULEDs.hpp:75
AH::DotBarDisplayLEDs< NumLEDs >