Control Surface main
MIDI Control Surface library for Arduino
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) {}
44
67 uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize,
68 uint16_t color)
70 line(line - 1), x(loc.x), y(loc.y), size(textSize), color(color) {}
71
90 PixelLocation loc, uint8_t textSize, uint16_t color)
92 x(loc.x), y(loc.y), size(textSize), color(color) {}
93
114 uint8_t line, PixelLocation loc, uint8_t textSize,
115 uint16_t color)
116 : DisplayElement(display), lcd(lcd), track(track - 1), line(line - 1),
117 x(loc.x), y(loc.y), size(textSize), color(color) {}
118
119 void draw() override {
120 // If it's a message across all tracks, don't display anything.
121 if (!separateTracks())
122 return;
123
124 // Determine the track and line to display
125 uint8_t offset = bank ? bank->getOffset() + track : track;
126 if (offset > 7)
127 ERROR(F("Track number out of bounds (") << offset << ')', 0xBA41);
128 if (line > 1)
129 ERROR(F("Line number out of bounds (") << line << ')', 0xBA42);
130
131 // Extract the six-character substring for this track.
132 const char *text = lcd.getText() + 7 * offset + 56 * line;
133 char buffer[7];
134 strncpy(buffer, text, 6);
135 buffer[6] = '\0';
136 // Print it to the display
140 display.print(buffer);
141 lcd.clearDirty();
142 }
143
144 bool getDirty() const override { return lcd.getDirty(); }
145
163 bool separateTracks() const {
164 for (uint8_t i = 0; i < 7; ++i) {
165 const char *text = lcd.getText() + 7 * i + 56 * line;
166 if (text[6] != ' ')
167 return false;
168 }
169 return true;
170 }
171
175 void setLine(uint8_t line) { this->line = line - 1; }
176
177 private:
179 const OutputBank *bank = nullptr;
180 uint8_t track;
181 uint8_t line;
182 int16_t x, y;
183 uint8_t size;
184 uint16_t color;
185};
186
187} // namespace MCU
188
A simple struct representing a pixel with integer coordinates.
Definition: Def.hpp:62
#define ERROR(msg, errc)
Definition: Error.hpp:22
#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.
Definition: LCDDisplay.hpp:18
bool getDirty() const override
Check if this DisplayElement has to be re-drawn.
Definition: LCDDisplay.hpp:144
const OutputBank * bank
Definition: LCDDisplay.hpp:179
LCDDisplay(DisplayInterface &display, LCD<> &lcd, uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition: LCDDisplay.hpp:113
LCDDisplay(DisplayInterface &display, LCD<> &lcd, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition: LCDDisplay.hpp:89
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:66
LCDDisplay(DisplayInterface &display, LCD<> &lcd, const OutputBank &bank, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition: LCDDisplay.hpp:39
void setLine(uint8_t line)
Set the line number of the LCD to display.
Definition: LCDDisplay.hpp:175
bool separateTracks() const
Check if the display contains a message for each track separately.
Definition: LCDDisplay.hpp:163
void draw() override
Draw this DisplayElement to the display buffer.
Definition: LCDDisplay.hpp:119
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:137
bool getDirty() const
Check if the text was updated since the last time the dirty flag was cleared.
Definition: LCD.hpp:146
void clearDirty()
Clear the dirty flag.
Definition: LCD.hpp:148
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