lcd20x4

smile/lcd20x4/lcd20x4

No description
lcd20x4
@/lcd20x4
RSnumber
Board GPIO port with LCD RS pin
ENnumber
Board GPIO port with LCD EN pin
D4number
Board GPIO port with LCD D4 pin
D5number
Board GPIO port with LCD D5 pin
D6number
Board GPIO port with LCD D6 pin
D7number
Board GPIO port with LCD D7 pin
L1string
Text for the first line
L3string
L2string
Text for the second line
L4string
lcd20x4
RS
EN
D4
D5
D6
D7
L1
L3
L2
L4
To use the node in your project you should have the smile/lcd20x4 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

{{#global}}
#include <LiquidCrystal.h>
{{/global}}

struct State {
    LiquidCrystal* lcd;
};

{{ GENERATED_CODE }}

void printLine(LiquidCrystal* lcd, uint8_t lineIndex, XString str) {
    lcd->setCursor(0, lineIndex);
    uint8_t whitespace = 16;
    for (auto it = str->iterate(); it; ++it, --whitespace)
        lcd->write(*it);

    // Clear the rest of the line
    while (whitespace--)
        lcd->write(' ');
}

void evaluate(Context ctx) {
    State* state = getState(ctx);
    auto lcd = state->lcd;
    if (!state->lcd) {
        state->lcd = lcd = new LiquidCrystal(
            (int)getValue<input_RS>(ctx),
            (int)getValue<input_EN>(ctx),
            (int)getValue<input_D4>(ctx),
            (int)getValue<input_D5>(ctx),
            (int)getValue<input_D6>(ctx),
            (int)getValue<input_D7>(ctx));

        lcd->begin(20, 4);
    }

    printLine(lcd, 0, getValue<input_L1>(ctx));
    printLine(lcd, 1, getValue<input_L2>(ctx));
    printLine(lcd, 2, getValue<input_L3>(ctx));
    printLine(lcd, 4, getValue<input_L4>(ctx));
}