This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
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 
27  private:
29 
31  constexpr static uint8_t FLOOR_CORRECTION = 5;
32 };
33 
34 template <uint8_t NumLEDs>
35 class VULEDs : public GenericVU<VULEDsCallback<NumLEDs>> {
36  public:
37  VULEDs(const PinList<NumLEDs> &ledPins, uint8_t track,
38  unsigned int decayTime = VUDecay::Default)
39  : GenericVU<VULEDsCallback<NumLEDs>>{
40  track,
41  CHANNEL_1,
42  decayTime,
43  {ledPins},
44  } {}
45 
46  VULEDs(const PinList<NumLEDs> &ledPins, uint8_t track,
47  MIDICNChannel channelCN, unsigned int decayTime = VUDecay::Default)
48  : GenericVU<VULEDsCallback<NumLEDs>>{
49  track,
50  channelCN,
51  decayTime,
52  {ledPins},
53  } {}
54 };
55 
56 namespace Bankable {
57 
58 template <uint8_t NumBanks, uint8_t NumLEDs>
59 class VULEDs : public GenericVU<NumBanks, VULEDsCallback<NumLEDs>> {
60  public:
62  uint8_t track, unsigned int decayTime = VUDecay::Default)
63  : GenericVU<NumBanks, VULEDsCallback<NumLEDs>>{
64  config, track, CHANNEL_1, decayTime, {ledPins},
65  } {}
66 
68  uint8_t track, MIDICNChannel channelCN,
69  unsigned int decayTime = VUDecay::Default)
70  : GenericVU<NumBanks, VULEDsCallback<NumLEDs>>{
71  config, track, channelCN, decayTime, {ledPins},
72  } {}
73 };
74 
75 } // namespace Bankable
76 
77 } // namespace MCU
78 
MCU::VULEDsCallback::FLOOR_CORRECTION
constexpr static uint8_t FLOOR_CORRECTION
Definition: VULEDs.hpp:31
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
MCU::VULEDsCallback::leds
const DotBarDisplayLEDs< NumLEDs > leds
Definition: VULEDs.hpp:28
MCU::Bankable::GenericVU
A class for MIDI input elements that represent Mackie Control Universal VU meters.
Definition: VU.hpp:287
MCU::VULEDs::VULEDs
VULEDs(const PinList< NumLEDs > &ledPins, uint8_t track, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:37
MCU
Names and note and controller numbers for the Mackie Control Universal (MCU) protocol.
Definition: LCDDisplay.hpp:10
MCU::Bankable::VULEDs::VULEDs
VULEDs(BankConfig< NumBanks > config, const PinList< NumLEDs > &ledPins, uint8_t track, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:61
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::VULEDsCallback
Definition: VULEDs.hpp:11
Array< pin_t, N >
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:67
MCU::VULEDsCallback::VULEDsCallback
VULEDsCallback(const DotBarDisplayLEDs< NumLEDs > &leds)
Definition: VULEDs.hpp:13
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
MCU::VULEDs
Definition: VULEDs.hpp:35
LEDs::begin
void begin() const
Initialize (set LED pins as outputs).
Definition: LEDs.hpp:32
VU.hpp
MCU::VU_Base< 1, VULEDsCallback< NumLEDs > >::decayTime
unsigned int decayTime
Definition: VU.hpp:167
MCU::VULEDs::VULEDs
VULEDs(const PinList< NumLEDs > &ledPins, uint8_t track, MIDICNChannel channelCN, unsigned int decayTime=VUDecay::Default)
Definition: VULEDs.hpp:46
MCU::GenericVU
A class for MIDI input elements that represent Mackie Control Universal VU meters.
Definition: VU.hpp:183
MCU::VULEDsCallback::update
void update(T &t)
Definition: VULEDs.hpp:21
DotBarDisplayLEDs::display
void display(uint8_t value) const
Display the given number of LEDs on the LED bar.
Definition: DotBarDisplayLEDs.hpp:37
MIDICNChannel
A class for saving a MIDI channel and cable number.
Definition: MIDICNChannelAddress.hpp:19
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
DotBarDisplayLEDs.hpp
DotBarDisplayLEDs< NumLEDs >
BankConfig
A struct for selecting the bank of BankableMIDIInputs and the bank type.
Definition: BankConfig.hpp:39
CHANNEL_1
constexpr Channel CHANNEL_1
Definition: Channel.hpp:111
MCU::VULEDsCallback::begin
void begin(T &)
Definition: VULEDs.hpp:16
MCU::Bankable::VULEDs
Definition: VULEDs.hpp:59