This is an old version of the documentation. View the latest version here.
Control Surface  1.0.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:
33  const OutputBank &bank, uint8_t track, PixelLocation loc,
34  uint8_t textSize, uint16_t color)
35  : DisplayElement(display), lcd(lcd), bank(bank), offset(track - 1),
36  line(0), x(loc.x), y(loc.y), size(textSize), color(color) {}
37 
52  const OutputBank &bank, uint8_t track, uint8_t line,
53  PixelLocation loc, uint8_t textSize, uint16_t color)
54  : DisplayElement(display), lcd(lcd), bank(bank), offset(track - 1),
55  line(line), x(loc.x), y(loc.y), size(textSize), color(color) {}
56 
57  void draw() override {
58  // If it's a message across all tracks, don't display anything.
59  if (!separateTracks())
60  return;
61  // Extract the six-character substring for this track.
62  uint8_t trackoffset = bank.getOffset() + offset;
63  if (trackoffset > 7) // TODO
64  trackoffset = 7;
65  if (line > 1) // TODO
66  line = 1;
67  const char *text = lcd.getText() + 7 * trackoffset + 56 * line;
68  char buffer[7];
69  strncpy(buffer, text, 6);
70  buffer[6] = '\0';
71  // Print it to the display
72  display.setCursor(x, y);
75  display.print(buffer);
76  }
77 
95  bool separateTracks() const {
96  for (uint8_t i = 0; i < 7; ++i) {
97  const char *text = lcd.getText() + 7 * i + 56 * line;
98  if (text[6] != ' ')
99  return false;
100  }
101  return true;
102  }
103 
104  void setLine(uint8_t line) { this->line = line; }
105 
106  private:
107  const MCU::LCD<> &lcd;
108  const OutputBank &bank;
109  uint8_t offset;
110  uint8_t line;
111  int16_t x, y;
112  uint8_t size;
113  uint16_t color;
114 };
115 
116 } // namespace MCU
117 
OutputBank
A class for changing the address of BankableMIDIOutputs.
Definition: Bank.hpp:20
MCU::LCDDisplay::setLine
void setLine(uint8_t line)
Definition: LCDDisplay.hpp:104
MCU::LCDDisplay::size
uint8_t size
Definition: LCDDisplay.hpp:112
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::x
int16_t x
Definition: LCDDisplay.hpp:111
MCU
Names and note and controller numbers for the Mackie Control Universal (MCU) protocol.
Definition: LCDDisplay.hpp:10
MCU::LCDDisplay::color
uint16_t color
Definition: LCDDisplay.hpp:113
MCU::LCDDisplay::y
int16_t y
Definition: LCDDisplay.hpp:111
OutputBank::getOffset
uint8_t getOffset() const
Get the offset (number of banks times the index of the selected bank)
Definition: Bank.hpp:61
DisplayInterface.hpp
MCU::LCDDisplay::separateTracks
bool separateTracks() const
Check if the display contains a message for each track separately.
Definition: LCDDisplay.hpp:95
PixelLocation
A simple struct representing a pixel with integer coordinates.
Definition: Def.hpp:74
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
DisplayElement.hpp
DisplayInterface::setCursor
virtual void setCursor(int16_t x, int16_t y)=0
Set the cursor position.
DisplayInterface::setTextSize
virtual void setTextSize(uint8_t size)=0
Set the text size.
MCU::LCDDisplay
Displays the text of the Mackie Control Universal LCD screen for a single track.
Definition: LCDDisplay.hpp:18
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
MCU::LCDDisplay::bank
const OutputBank & bank
Definition: LCDDisplay.hpp:108
DisplayElement::display
DisplayInterface & display
Definition: DisplayElement.hpp:44
MCU::LCD::getText
const char * getText() const
Definition: LCD.hpp:36
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:32
MCU::LCD
Definition: LCD.hpp:27
MCU::LCDDisplay::line
uint8_t line
Definition: LCDDisplay.hpp:110
Bank.hpp
MCU::LCDDisplay::offset
uint8_t offset
Definition: LCDDisplay.hpp:109
LCD.hpp
MCU::LCDDisplay::lcd
const MCU::LCD & lcd
Definition: LCDDisplay.hpp:107
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:51
MCU::LCDDisplay::draw
void draw() override
Draw this DisplayElement to the display buffer.
Definition: LCDDisplay.hpp:57
DisplayInterface::setTextColor
virtual void setTextColor(uint16_t color)=0
Set the text color.