text-lcd-i2c-device

wayland/text-lcd-i2c/text-lcd-i2c-device

Text LCD I²C device.
text-lcd-i2c-device
@/text-lcd-i2c-device
Text LCD I²C device.
I2Cxod/i2c/i2c
I²C bus.
ADDRbyte
I²C address.
COLSnumber
Number of columns.
ROWSnumber
Number of rows.
text-lcd-i2c-device
I2C
ADDR
COLS
ROWS
DEV
DEV@/text-lcd-i2c-device
A text-lcd-i2c-device.
To use the node in your project you should have the wayland/text-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

#pragma XOD error_raise enable

#pragma XOD require "https://github.com/WaylandM/Arduino-LiquidCrystal-I2C-library-MTW"

#include <Wire.h>
#include <LiquidCrystal_I2C_MTW.h>

node {
    meta {
        struct Type {
            LiquidCrystal_I2C_MTW* lcd;
            uint8_t rows;
            uint8_t cols;
        };
    }

    uint8_t mem[sizeof(LiquidCrystal_I2C_MTW)];

    void evaluate(Context ctx) {
        auto wire = getValue<input_I2C>(ctx);
        uint8_t addr = getValue<input_ADDR>(ctx);
        uint8_t rows = (uint8_t) getValue<input_ROWS>(ctx);
        uint8_t cols = (uint8_t) getValue<input_COLS>(ctx);

        if (addr > 127) {
            raiseError(ctx);
            return;
        }

        Type t;
        t.rows = rows;
        t.cols = cols;
        
        t.lcd = new (mem) LiquidCrystal_I2C_MTW(*wire, addr, cols, rows);
        
        
        //t.lcd->begin();

        emitValue<output_DEV>(ctx, t);
    }
}