Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Display
MCU
LCDDisplay.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
Banks/Bank.hpp
>
4
#include <
Display/DisplayElement.hpp
>
5
#include <
Display/DisplayInterface.hpp
>
6
#include <
MIDI_Inputs/MCU/LCD.hpp
>
7
8
BEGIN_CS_NAMESPACE
9
10
namespace
MCU
{
11
18
class
LCDDisplay
:
public
DisplayElement
{
19
public
:
39
LCDDisplay
(
DisplayInterface
&
display
,
LCD<>
&
lcd
,
const
OutputBank
&
bank
,
40
uint8_t
track
,
PixelLocation
loc, uint8_t textSize,
41
uint16_t
color
)
42
:
DisplayElement
(
display
),
lcd
(
lcd
),
bank
(&
bank
),
track
(
track
- 1),
43
line
(1),
x
(loc.
x
),
y
(loc.
y
),
size
(textSize),
color
(
color
) {
44
lcd
.addSubscriber();
45
}
46
68
LCDDisplay
(
DisplayInterface
&
display
,
LCD<>
&
lcd
,
const
OutputBank
&
bank
,
69
uint8_t
track
, uint8_t
line
,
PixelLocation
loc, uint8_t textSize,
70
uint16_t
color
)
71
:
DisplayElement
(
display
),
lcd
(
lcd
),
bank
(&
bank
),
track
(
track
- 1),
72
line
(
line
- 1),
x
(loc.
x
),
y
(loc.
y
),
size
(textSize),
color
(
color
) {
73
lcd
.addSubscriber();
74
}
75
93
LCDDisplay
(
DisplayInterface
&
display
,
LCD<>
&
lcd
, uint8_t
track
,
94
PixelLocation
loc, uint8_t textSize, uint16_t
color
)
95
:
DisplayElement
(
display
),
lcd
(
lcd
),
track
(
track
- 1),
line
(1),
96
x
(loc.
x
),
y
(loc.
y
),
size
(textSize),
color
(
color
) {
97
lcd
.addSubscriber();
98
}
99
119
LCDDisplay
(
DisplayInterface
&
display
,
LCD<>
&
lcd
, uint8_t
track
,
120
uint8_t
line
,
PixelLocation
loc, uint8_t textSize,
121
uint16_t
color
)
122
:
DisplayElement
(
display
),
lcd
(
lcd
),
track
(
track
- 1),
line
(
line
- 1),
123
x
(loc.
x
),
y
(loc.
y
),
size
(textSize),
color
(
color
) {
124
lcd
.addSubscriber();
125
}
126
127
LCDDisplay
(
const
LCDDisplay
&) =
delete
;
128
~LCDDisplay
() {
lcd
.removeSubscriber(); }
129
130
void
draw
()
override
{
131
// If it's a message across all tracks, don't display anything.
132
if
(
separateTracks
()) {
133
// Determine the track and line to display
134
uint8_t offset =
bank
?
bank
->getOffset() +
track
:
track
;
135
if
(offset > 7)
136
ERROR
(F(
"Track out of bounds ("
) << offset <<
')'
, 0xBA41);
137
if
(
line
> 1)
138
ERROR
(F(
"Line out of bounds ("
) <<
line
<<
')'
, 0xBA42);
139
140
// Extract the six-character substring for this track.
141
const
char
*text =
lcd
.getText() + 7 * offset + 56 *
line
;
142
char
buffer[7];
143
strncpy(buffer, text, 6);
144
buffer[6] =
'\0'
;
145
// Print it to the display
146
display
.setCursor(
x
,
y
);
147
display
.setTextSize(
size
);
148
display
.setTextColor(
color
);
149
display
.print(buffer);
150
}
151
lcd
.clearDirty();
152
}
153
154
bool
getDirty
()
const override
{
return
lcd
.getDirty(); }
155
173
bool
separateTracks
()
const
{
174
for
(uint8_t i = 0; i < 7; ++i) {
175
const
char
*text =
lcd
.getText() + 7 * i + 56 *
line
;
176
if
(text[6] !=
' '
)
177
return
false
;
178
}
179
return
true
;
180
}
181
185
void
setLine
(uint8_t
line
) { this->line =
line
- 1; }
186
187
private
:
188
LCD<>
&
lcd
;
189
const
OutputBank
*
bank
=
nullptr
;
190
uint8_t
track
;
191
uint8_t
line
;
192
int16_t
x
,
y
;
193
uint8_t
size
;
194
uint16_t
color
;
195
};
196
197
}
// namespace MCU
198
199
END_CS_NAMESPACE
Bank.hpp
DisplayElement.hpp
DisplayInterface.hpp
ERROR
#define ERROR(msg, errc)
Definition
Error.hpp:19
LCD.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
DisplayElement::DisplayElement
DisplayElement(DisplayInterface &display)
Create a new DisplayElement.
Definition
DisplayElement.hpp:18
DisplayElement::display
DisplayInterface & display
Definition
DisplayElement.hpp:103
DisplayInterface
An interface for displays.
Definition
DisplayInterface.hpp:16
MCU::LCDDisplay::getDirty
bool getDirty() const override
Check if this DisplayElement has to be re-drawn.
Definition
LCDDisplay.hpp:154
MCU::LCDDisplay::color
uint16_t color
Definition
LCDDisplay.hpp:194
MCU::LCDDisplay::bank
const OutputBank * bank
Definition
LCDDisplay.hpp:189
MCU::LCDDisplay::lcd
LCD & lcd
Definition
LCDDisplay.hpp:188
MCU::LCDDisplay::LCDDisplay
LCDDisplay(DisplayInterface &display, LCD<> &lcd, uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition
LCDDisplay.hpp:119
MCU::LCDDisplay::line
uint8_t line
Definition
LCDDisplay.hpp:191
MCU::LCDDisplay::LCDDisplay
LCDDisplay(DisplayInterface &display, LCD<> &lcd, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition
LCDDisplay.hpp:93
MCU::LCDDisplay::LCDDisplay
LCDDisplay(DisplayInterface &display, LCD<> &lcd, const OutputBank &bank, uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition
LCDDisplay.hpp:68
MCU::LCDDisplay::LCDDisplay
LCDDisplay(const LCDDisplay &)=delete
MCU::LCDDisplay::track
uint8_t track
Definition
LCDDisplay.hpp:190
MCU::LCDDisplay::LCDDisplay
LCDDisplay(DisplayInterface &display, LCD<> &lcd, const OutputBank &bank, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition
LCDDisplay.hpp:39
MCU::LCDDisplay::~LCDDisplay
~LCDDisplay()
Definition
LCDDisplay.hpp:128
MCU::LCDDisplay::x
int16_t x
Definition
LCDDisplay.hpp:192
MCU::LCDDisplay::size
uint8_t size
Definition
LCDDisplay.hpp:193
MCU::LCDDisplay::setLine
void setLine(uint8_t line)
Set the line number of the LCD to display.
Definition
LCDDisplay.hpp:185
MCU::LCDDisplay::y
int16_t y
Definition
LCDDisplay.hpp:192
MCU::LCDDisplay::separateTracks
bool separateTracks() const
Check if the display contains a message for each track separately.
Definition
LCDDisplay.hpp:173
MCU::LCDDisplay::draw
void draw() override
Draw this DisplayElement to the display buffer.
Definition
LCDDisplay.hpp:130
MCU::LCD
A class that represents the Mackie Control Universal LCD display and saves the text it receives.
Definition
LCD.hpp:51
OutputBank
A class for changing the address of BankableMIDIOutputs.
Definition
Bank.hpp:16
MCU
Definition
LCDDisplay.hpp:10
PixelLocation
A simple struct representing a pixel with integer coordinates.
Definition
Def.hpp:64
Generated by
1.17.0