print-at(text-lcd-i2c-device)

xod-dev/text-lcd/print-at(text-lcd-i2c-device)

No description
print-at(text-lcd-i2c-device)
@/print-at(text-lcd-i2c-device)
DEV@/text-lcd-i2c-device
An I2C text LCD device
ROWnumber
The row index on the display. Starts from 0.
POSnumber
Position in the row. Starts from 0.
LENnumber
The length of the allocated area on the LCD screen.
VALstring
Text to print on the row
DOpulse
Update the allocated area content
print-at(text-lcd-i2c-device)
DEV
ROW
POS
LEN
VAL
DO
DEV'
DONE
DONEpulse
Fires when the allocated area is updated
DEV'@/text-lcd-i2c-device
To use the node in your project you should have the xod-dev/text-lcd 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

node {
    static void printAt(LiquidCrystal_I2C* lcd, uint8_t rowIndex, uint8_t posIndex, uint8_t len, XString str) {
        lcd->setCursor(posIndex, rowIndex);
        uint8_t whitespace = len;
        for (auto it = str.iterate(); it && whitespace > 0; ++it, --whitespace)
            lcd->write(*it);

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

    void evaluate(Context ctx) {
        auto t = getValue<input_DEV>(ctx);

        if (isInputDirty<input_DO>(ctx)) {
            XString str = getValue<input_VAL>(ctx);
            uint8_t row = (uint8_t) getValue<input_ROW>(ctx);
            uint8_t pos = (uint8_t) getValue<input_POS>(ctx);

            Number _len = getValue<input_LEN>(ctx);
            uint8_t restLen = t.cols - pos;
            uint8_t len = (_len > restLen) ? restLen : (uint8_t) _len;

            if (row < 0 || row >= t.rows || pos < 0 || pos >= t.cols) {
                raiseError<output_DONE>(ctx);
                return;
            }

            printAt(t.lcd, row, pos, len, str);
            emitValue<output_DONE>(ctx, 1);
        }

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