Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
LCDDisplay.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Banks/Bank.hpp>
7
9
10namespace MCU {
11
18class LCDDisplay : public DisplayElement {
19 public:
40 uint8_t track, PixelLocation loc, uint8_t textSize,
41 uint16_t color)
43 line(1), x(loc.x), y(loc.y), size(textSize), color(color) {
45 }
46
69 uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize,
70 uint16_t color)
72 line(line - 1), x(loc.x), y(loc.y), size(textSize), color(color) {
74 }
75
94 PixelLocation loc, uint8_t textSize, uint16_t color)
96 x(loc.x), y(loc.y), size(textSize), color(color) {
98 }
99
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) {
125 }
126
127 LCDDisplay(const LCDDisplay &) = delete;
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
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:
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
#define ERROR(msg, errc)
Definition Error.hpp:19
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
An interface for elements that draw to a display.
DisplayInterface & display
An interface for displays.
virtual void setTextColor(uint16_t color)=0
Set the text color.
virtual void setCursor(int16_t x, int16_t y)=0
Set the cursor position.
virtual void setTextSize(uint8_t size)=0
Set the text size.
Displays the text of the Mackie Control Universal LCD screen for a single track.
bool getDirty() const override
Check if this DisplayElement has to be re-drawn.
const OutputBank * bank
LCDDisplay(DisplayInterface &display, LCD<> &lcd, uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
LCDDisplay(DisplayInterface &display, LCD<> &lcd, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
LCDDisplay(DisplayInterface &display, LCD<> &lcd, const OutputBank &bank, uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
LCDDisplay(const LCDDisplay &)=delete
LCDDisplay(DisplayInterface &display, LCD<> &lcd, const OutputBank &bank, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
void setLine(uint8_t line)
Set the line number of the LCD to display.
bool separateTracks() const
Check if the display contains a message for each track separately.
void draw() override
Draw this DisplayElement to the display buffer.
A class that represents the Mackie Control Universal LCD display and saves the text it receives.
Definition LCD.hpp:51
const char * getText() const
Get a pointer to the null-terminated display text.
Definition LCD.hpp:138
void removeSubscriber()
Definition LCD.hpp:157
void addSubscriber()
Definition LCD.hpp:156
bool getDirty() const
Check if the text was updated since the last time the dirty flag was cleared.
Definition LCD.hpp:148
void clearDirty()
Clear the dirty flag.
Definition LCD.hpp:150
A class for changing the address of BankableMIDIOutputs.
Definition Bank.hpp:16
int8_t getOffset() const
Get the address offset (number of banks times the index of the selected bank after applying the offse...
Definition Bank.hpp:58
A simple struct representing a pixel with integer coordinates.
Definition Def.hpp:64