Control Surface  1.2.0
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 
10 namespace MCU {
11 
18 class LCDDisplay : public DisplayElement {
19  public:
40  const OutputBank &bank, uint8_t track, PixelLocation loc,
41  uint8_t textSize, uint16_t color)
42  : DisplayElement(display), lcd(lcd), bank(bank), offset(track - 1),
43  line(0), x(loc.x), y(loc.y), size(textSize), color(color) {}
44 
67  const OutputBank &bank, uint8_t track, uint8_t line,
68  PixelLocation loc, uint8_t textSize, uint16_t color)
69  : DisplayElement(display), lcd(lcd), bank(bank), offset(track - 1),
70  line(line), x(loc.x), y(loc.y), size(textSize), color(color) {}
71 
72  void draw() override {
73  // If it's a message across all tracks, don't display anything.
74  if (!separateTracks())
75  return;
76  // Extract the six-character substring for this track.
77  uint8_t trackoffset = bank.getOffset() + offset;
78  if (trackoffset > 7) // TODO
79  trackoffset = 7;
80  if (line > 1) // TODO
81  line = 1;
82  const char *text = lcd.getText() + 7 * trackoffset + 56 * line;
83  char buffer[7];
84  strncpy(buffer, text, 6);
85  buffer[6] = '\0';
86  // Print it to the display
87  display.setCursor(x, y);
90  display.print(buffer);
91  }
92 
110  bool separateTracks() const {
111  for (uint8_t i = 0; i < 7; ++i) {
112  const char *text = lcd.getText() + 7 * i + 56 * line;
113  if (text[6] != ' ')
114  return false;
115  }
116  return true;
117  }
118 
119  void setLine(uint8_t line) { this->line = line; }
120 
121  private:
122  const MCU::LCD<> &lcd;
123  const OutputBank &bank;
124  uint8_t offset;
125  uint8_t line;
126  int16_t x, y;
127  uint8_t size;
128  uint16_t color;
129 };
130 
131 } // namespace MCU
132 
OutputBank
A class for changing the address of BankableMIDIOutputs.
Definition: Bank.hpp:18
MCU::LCDDisplay::lcd
const MCU::LCD & lcd
Definition: LCDDisplay.hpp:122
DisplayElement
An interface for elements that draw to a display.
Definition: DisplayElement.hpp:11
DisplayInterface
An interface for displays.
Definition: DisplayInterface.hpp:14
MCU::LCDDisplay::LCDDisplay
LCDDisplay(DisplayInterface &display, const MCU::LCD<> &lcd, const OutputBank &bank, uint8_t track, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition: LCDDisplay.hpp:39
MCU
Definition: LCDDisplay.hpp:10
MCU::LCDDisplay::draw
void draw() override
Draw this DisplayElement to the display buffer.
Definition: LCDDisplay.hpp:72
DisplayInterface::setCursor
virtual void setCursor(int16_t x, int16_t y)=0
Set the cursor position.
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
MCU::LCDDisplay::offset
uint8_t offset
Definition: LCDDisplay.hpp:124
MCU::LCDDisplay::color
uint16_t color
Definition: LCDDisplay.hpp:128
MCU::LCDDisplay::LCDDisplay
LCDDisplay(DisplayInterface &display, const MCU::LCD<> &lcd, const OutputBank &bank, uint8_t track, uint8_t line, PixelLocation loc, uint8_t textSize, uint16_t color)
Constructor.
Definition: LCDDisplay.hpp:66
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
DisplayInterface.hpp
MCU::LCDDisplay::line
uint8_t line
Definition: LCDDisplay.hpp:125
DisplayElement.hpp
MCU::LCDDisplay::y
int16_t y
Definition: LCDDisplay.hpp:126
MCU::LCDDisplay
Displays the text of the Mackie Control Universal LCD screen for a single track.
Definition: LCDDisplay.hpp:18
MCU::LCDDisplay::setLine
void setLine(uint8_t line)
Definition: LCDDisplay.hpp:119
MCU::LCDDisplay::separateTracks
bool separateTracks() const
Check if the display contains a message for each track separately.
Definition: LCDDisplay.hpp:110
MCU::LCDDisplay::bank
const OutputBank & bank
Definition: LCDDisplay.hpp:123
PixelLocation
A simple struct representing a pixel with integer coordinates.
Definition: Def.hpp:60
DisplayElement::display
DisplayInterface & display
Definition: DisplayElement.hpp:44
DisplayInterface::setTextColor
virtual void setTextColor(uint16_t color)=0
Set the text color.
MCU::LCD
Definition: LCD.hpp:31
MCU::LCD::getText
const char * getText() const
Definition: LCD.hpp:40
OutputBank::getOffset
uint8_t getOffset() const
Get the offset (number of banks times the index of the selected bank)
Definition: Bank.hpp:59
Bank.hpp
LCD.hpp
MCU::LCDDisplay::size
uint8_t size
Definition: LCDDisplay.hpp:127
MCU::LCDDisplay::x
int16_t x
Definition: LCDDisplay.hpp:126
DisplayInterface::setTextSize
virtual void setTextSize(uint8_t size)=0
Set the text size.