Control Surface  1.1.1
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::lcd
const MCU::LCD & lcd
Definition: LCDDisplay.hpp:107
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:32
MCU
Names and note and controller numbers for the Mackie Control Universal (MCU) protocol.
Definition: LCDDisplay.hpp:10
MCU::LCDDisplay::draw
void draw() override
Draw this DisplayElement to the display buffer.
Definition: LCDDisplay.hpp:57
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:109
MCU::LCDDisplay::color
uint16_t color
Definition: LCDDisplay.hpp:113
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
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
DisplayInterface.hpp
PixelLocation
A simple struct representing a pixel with integer coordinates.
Definition: Def.hpp:60
MCU::LCDDisplay::line
uint8_t line
Definition: LCDDisplay.hpp:110
DisplayElement.hpp
MCU::LCDDisplay::y
int16_t y
Definition: LCDDisplay.hpp:111
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:104
MCU::LCDDisplay::separateTracks
bool separateTracks() const
Check if the display contains a message for each track separately.
Definition: LCDDisplay.hpp:95
MCU::LCDDisplay::bank
const OutputBank & bank
Definition: LCDDisplay.hpp:108
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:61
Bank.hpp
LCD.hpp
MCU::LCDDisplay::size
uint8_t size
Definition: LCDDisplay.hpp:112
MCU::LCDDisplay::x
int16_t x
Definition: LCDDisplay.hpp:111
DisplayInterface::setTextSize
virtual void setTextSize(uint8_t size)=0
Set the text size.