This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
DotBarDisplayLEDs.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
5 #include <Hardware/LEDs/LEDs.hpp>
6 
8 
12 enum class DotBarMode : bool {
13  Bar = false,
14  Dot = true,
15 };
16 
25 template <uint8_t N>
26 class DotBarDisplayLEDs : public LEDs<N> {
27  public:
30 
37  void display(uint8_t value) const {
38  if (value == 0)
39  this->clear();
40  else if (mode == DotBarMode::Bar)
41  this->displayRange(0, value);
42  else
43  this->displayDot(value - 1);
44  }
45 
52  void display(float value) const { display(uint8_t(value * (N + 1))); }
53 
60  void setMode(DotBarMode mode) { this->mode = mode; }
61 
64 
67 
68  private:
70 };
71 
DotBarDisplayLEDs::mode
DotBarMode mode
Definition: DotBarDisplayLEDs.hpp:69
LEDs::ledPins
const PinList< N > ledPins
Definition: LEDs.hpp:84
DotBarMode
DotBarMode
An enumeration type to set an LED display to either bar or dot mode.
Definition: DotBarDisplayLEDs.hpp:12
Array< pin_t, N >
DotBarMode::Dot
Turn on only the active LED.
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
LEDs::displayRange
void displayRange(uint8_t startOn, uint8_t startOff) const
Turn on a range of the LEDs.
Definition: LEDs.hpp:46
DotBarDisplayLEDs::setMode
void setMode(DotBarMode mode)
Set the mode to either dot or bar mode.
Definition: DotBarDisplayLEDs.hpp:60
LEDs::displayDot
void displayDot(uint8_t led) const
Turn on a single LED, and turn off all others.
Definition: LEDs.hpp:73
DotBarDisplayLEDs::display
void display(float value) const
Display the given fraction of the LED bar.
Definition: DotBarDisplayLEDs.hpp:52
DotBarDisplayLEDs::display
void display(uint8_t value) const
Display the given number of LEDs on the LED bar.
Definition: DotBarDisplayLEDs.hpp:37
DotBarDisplayLEDs::dotMode
void dotMode()
Set the mode to dot mode.
Definition: DotBarDisplayLEDs.hpp:63
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
LEDs.hpp
LEDs
A class for collections of LEDs that can display ranges.
Definition: LEDs.hpp:19
DotBarDisplayLEDs::DotBarDisplayLEDs
DotBarDisplayLEDs(const PinList< N > &ledPins)
Constructor from list of pins.
Definition: DotBarDisplayLEDs.hpp:29
DotBarMode::Bar
Turn on a range of LEDs up to the active LED.
DotBarDisplayLEDs::barMode
void barMode()
Set the mode to bar mode.
Definition: DotBarDisplayLEDs.hpp:66
DotBarDisplayLEDs
A class for LED bars.
Definition: DotBarDisplayLEDs.hpp:26
LEDs::clear
void clear() const
Turn off all LEDs.
Definition: LEDs.hpp:78