Writes text to the screen of an LCD-RGB device. ROW can be 0 or 1. COL can be an integer 0 to 15 inclusive.
draw-text
@/draw-text
Writes text to the screen of an LCD-RGB device. ROW can be 0 or 1. COL can be an integer 0 to 15 inclusive.
DEV@/text-lcd-rgb-device
UPDpulse
ROWnumber
COLnumber
TXTstring
DONEpulse
DEV_@/text-lcd-rgb-device
To use the node in your project you should have the rcb71/seeed-lcd-16x2 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD
node {
static void printAt(rgb_lcd* lcd, uint8_t rowIndex, uint8_t posIndex, XString str) {
lcd->setCursor(posIndex, rowIndex);
uint8_t whitespace = 16;
for (auto it = str.iterate(); it && whitespace > 0; ++it, --whitespace)
lcd->print(*it);
}
void evaluate(Context ctx) {
// The node responds only if there is an input pulse
if (!isInputDirty<input_UPD>(ctx))
return;
auto t = getValue<input_DEV>(ctx);
auto str = getValue<input_TXT>(ctx);
uint8_t row = (uint8_t) getValue<input_ROW>(ctx);
uint8_t pos = (uint8_t) getValue<input_COL>(ctx);
if (row < 0 || row >= t.rows || pos < 0 || pos >= t.cols) {
raiseError<output_DONE>(ctx);
return;
}
printAt(t.lcd, row, pos, str);
emitValue<output_DONE>(ctx, 1);
emitValue<output_DEV_>(ctx, t);
}
}