draw-sd-error

nazarijtipusak080/prototype-relay/draw-sd-error

Writes string to display buffer. To show content of display buffer on screen use node send-buffer-to-display.
draw-sd-error
@/draw-sd-error
Writes string to display buffer. To show content of display buffer on screen use node send-buffer-to-display.
DEVwayland/ssd1306-oled-i2c/ssd1306-oled-i2c-device
An SSD1306 OLED device.
Xnumber
Cursor position x coordinate.
Ynumber
Cursor position y coordinate.
UPDpulse
Update. Trigger write to display buffer.
draw-sd-error
DEV
X
Y
UPD
DONE
DONEpulse
Pulses on completion.
To use the node in your project you should have the nazarijtipusak080/prototype-relay 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

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    // The node responds only if there is an input pulse
    if (!isInputDirty<input_UPD>(ctx))
        return;

    // Get a pointer to the `Adafruit_SSD1306` class instance
    auto display = getValue<input_DEV>(ctx);
    auto cursor_x = getValue<input_X>(ctx);
    auto cursor_y = getValue<input_Y>(ctx);
 
    // `length` returns the number of characters and you need an extra one to keep the
    // terminal NUL-character used in C string representation. Initialize to 0’s to
    // ensure the last char is indeed NUL
    // The following line worked on Arduino, but would not compile for esp8266:
    // char cString[length(xString) + 1] = { 0 };
    // Bug fixed by the following four lines provided by Martin Brader:
// Use full 256 char 'Code Page 437' font
    display->cp437(true);
    display->setTextWrap(true);
    display->setCursor(cursor_x, cursor_y);
    display->setTextSize(0x01);
    display->setTextColor(1);
    display->println("SD KAPTA - ERROR!");

    emitValue<output_DONE>(ctx, 1);
}