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:
44
71
93
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;
185};
186
187} // namespace MCU
188
#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(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.
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
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32
A simple struct representing a pixel with integer coordinates.
Definition Def.hpp:62