50template <u
int8_t BufferSize = 112>
67 for (uint8_t i = 0; i < BufferSize; i++)
buffer[i] =
' ';
73 if (midimsg.
getCable() != this->cable)
88 if (midimsg.
data[5] != 0x12)
91 const uint8_t midiOffset = midimsg.
data[6];
92 const uint8_t midiLength = midimsg.
length - 8;
93 const uint8_t *text = midimsg.
data + 7;
94 const uint8_t midiBufferEnd = midiOffset + midiLength;
96 const uint8_t bufferEnd = this->
offset + BufferSize;
100 if (midiOffset >= bufferEnd || this->
offset >= midiBufferEnd)
107 uint8_t srcStart = max(0, this->
offset - midiOffset);
108 uint8_t dstStart = max(0, midiOffset - this->
offset);
109 uint8_t length = midiBufferEnd - midiOffset -
110 max(0, this->
offset - midiOffset) -
111 max(0, midiBufferEnd - bufferEnd);
115 memcpy(&
buffer[dstStart], &text[srcStart], length);
117 for (uint8_t i = 0; i < length; ++i) {
118 buffer[dstStart + i] = text[srcStart + i];
119 assert(dstStart + i < BufferSize);
120 assert(srcStart + i < midiLength);
#define BEGIN_CS_NAMESPACE
A type-safe class for MIDI USB Cable numbers.
Counts the number of instances of the LCD class.
static uint8_t getInstances()
A class that represents the Mackie Control Universal LCD display and saves the text it receives.
const char * getText() const
Get a pointer to the null-terminated display text.
void markDirty()
Set the dirty counter to the number of subscribers (or one).
bool getDirty() const
Check if the text was updated since the last time the dirty flag was cleared.
void begin() override
Initialize the input element.
LCD(uint8_t offset=0, Cable cable=Cable_1)
Array< char, BufferSize+1 > buffer
bool updateWith(SysExMessage midimsg) override
void clearDirty()
Clear the dirty flag.
constexpr auto min(const T &a, const U &b) -> decltype(b< a ? b :a)
Return the smaller of two numbers/objects.
constexpr auto max(const T &a, const U &b) -> decltype(a< b ? b :a)
Return the larger of two numbers/objects.
An array wrapper for easy copying, comparing, and iterating.
Cable getCable() const
Get the MIDI USB cable number of the message.
bool isCompleteMessage() const