lcd-20x4-i2c

manatee/lcd-i2c/lcd-20x4-i2c

No description
lcd-20x4-i2c
@/lcd-20x4-i2c
ADDRnumber
Your LCD address converted from HEX to DEC
BLboolean
Turn blacklight ON/OFF. Default is ON(true)
L1string
First Line
L2string
Second Line
L3string
Third Line
L4string
Fourth Line
lcd-20x4-i2c
ADDR
BL
L1
L2
L3
L4
To use the node in your project you should have the manatee/lcd-i2c 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 <Wire.h>
#include <LiquidCrystal_I2C.h>
{{/global}}

struct State {
    LiquidCrystal_I2C* lcd;
};

{{ GENERATED_CODE }}

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

    //Clear remaining LCD lines
    while (whitespace--)
        lcd->write(' ');
}

void evaluate(Context ctx) {
    State* state = getState(ctx);
    auto lcd = state->lcd;
    if (!state->lcd)
    {
        uint8_t addr = getValue<input_ADDR>(ctx);
        state->lcd = lcd = new LiquidCrystal_I2C(addr, 20, 4);
        lcd->begin();
    }

    printLine(lcd, 0, getValue<input_L1>(ctx));
    printLine(lcd, 1, getValue<input_L2>(ctx));
    printLine(lcd, 2, getValue<input_L3>(ctx));
    printLine(lcd, 3, getValue<input_L4>(ctx));
    lcd->setBacklight(getValue<input_BL>(ctx));
}