Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
AH
Hardware
LEDs
LEDs.hpp
Go to the documentation of this file.
1
/* ✔ */
2
3
#pragma once
4
5
#include <
AH/Hardware/ExtendedInputOutput/ExtendedInputOutput.hpp
>
6
7
BEGIN_AH_NAMESPACE
8
17
template
<u
int
16_t N>
18
class
LEDs
{
19
public
:
26
LEDs
(
const
PinList<N>
&
ledPins
) :
ledPins
(
ledPins
) {}
27
31
void
begin
()
const
{
32
for
(
const
pin_t
&pin :
ledPins
)
33
ExtIO::pinMode
(pin,
OUTPUT
);
34
}
35
45
void
displayRange
(uint16_t startOn, uint16_t startOff)
const
{
46
for
(uint16_t pin = 0; pin < startOn; pin++)
47
clear
(pin);
48
for
(uint16_t pin = startOn; pin < startOff; pin++)
49
set
(pin);
50
for
(uint16_t pin = startOff; pin < N; pin++)
51
clear
(pin);
52
}
53
55
void
set
(uint16_t index)
const
{
56
// TODO: bounds check?
57
ExtIO::digitalWrite
(
ledPins
[index],
HIGH
);
58
}
59
61
void
clear
(uint16_t index)
const
{
62
// TODO: bounds check?
63
ExtIO::digitalWrite
(
ledPins
[index],
LOW
);
64
}
65
72
void
displayDot
(uint16_t led)
const
{
displayRange
(led, led + 1); }
73
77
void
clear
()
const
{
78
for
(
pin_t
pin :
ledPins
)
79
ExtIO::digitalWrite
(pin,
LOW
);
80
}
81
82
private
:
83
const
PinList<N>
ledPins
;
84
};
85
86
END_AH_NAMESPACE
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:14
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition
AH/Settings/NamespaceSettings.hpp:11
LOW
constexpr PinStatus_t LOW
Definition
Arduino-Hardware-Types.hpp:63
HIGH
constexpr PinStatus_t HIGH
Definition
Arduino-Hardware-Types.hpp:62
OUTPUT
constexpr PinMode_t OUTPUT
Definition
Arduino-Hardware-Types.hpp:65
ExtendedInputOutput.hpp
::LEDs
A class for collections of LEDs that can display ranges.
Definition
LEDs.hpp:18
AH::LEDs::ledPins
const PinList< N > ledPins
Definition
LEDs.hpp:83
AH::LEDs::clear
void clear(uint16_t index) const
Turn off the given LED.
Definition
LEDs.hpp:61
AH::LEDs::LEDs
LEDs(const PinList< N > &ledPins)
Create a LEDs object.
Definition
LEDs.hpp:26
AH::LEDs::set
void set(uint16_t index) const
Turn on the given LED.
Definition
LEDs.hpp:55
AH::LEDs::begin
void begin() const
Initialize (set LED pins as outputs).
Definition
LEDs.hpp:31
AH::LEDs::clear
void clear() const
Turn off all LEDs.
Definition
LEDs.hpp:77
AH::LEDs::displayDot
void displayDot(uint16_t led) const
Turn on a single LED, and turn off all others.
Definition
LEDs.hpp:72
AH::LEDs::displayRange
void displayRange(uint16_t startOn, uint16_t startOff) const
Turn on a range of the LEDs.
Definition
LEDs.hpp:45
AH::ExtIO::pinMode
void pinMode(pin_t pin, PinMode_t mode)
An ExtIO version of the Arduino function.
Definition
ExtendedInputOutput.cpp:32
AH::ExtIO::digitalWrite
void digitalWrite(pin_t pin, PinStatus_t val)
An ExtIO version of the Arduino function.
Definition
ExtendedInputOutput.cpp:43
AH::PinList
Array< pin_t, N > PinList
An easy alias for arrays of pins.
Definition
Hardware-Types.hpp:100
AH::ExtIO::pin_t
Type for storing pin numbers of Extended Input/Output elements.
Definition
Hardware-Types.hpp:25
Generated by
1.17.0