sh1106g-oled-i2c-device

wayland/sh1106g-oled-i2c/sh1106g-oled-i2c-device

Create SH1306G OLED device.
sh1106g-oled-i2c-device
@/sh1106g-oled-i2c-device
Create SH1306G OLED device.
I2Cxod/i2c/i2c
I²C bus
WIDTHnumber
Display width in pixels (default 128).
HEIGHTnumber
Display height in pixels (default 64).
RESET_PINnumber
Reset pin (using Arduino pin numbering), or -1 if not used (some displays might be wired to share the microcontroller's reset pin).
sh1106g-oled-i2c-device
I2C
WIDTH
HEIGHT
RESET_PIN
DEV
DEV@/sh1106g-oled-i2c-device
An SH1106G OLED device.
To use the node in your project you should have the wayland/sh1106g-oled-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

// Tell XOD where it could download the library:
#pragma XOD require "https://github.com/adafruit/Adafruit_SH110x"
#pragma XOD require "https://github.com/adafruit/Adafruit-GFX-Library"
#pragma XOD require "https://github.com/adafruit/Adafruit_BusIO"

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

node {
    meta {
        using Type = Adafruit_SH1106G*;
    }

    uint8_t mem[sizeof(Adafruit_SH1106G)];

    void evaluate(Context ctx) {
        if (!isSettingUp())
            return;
        auto wire = getValue<input_I2C>(ctx);
        auto width = getValue<input_WIDTH>(ctx);
        auto height = getValue<input_HEIGHT>(ctx);
        auto reset_pin = getValue<input_RESET_PIN>(ctx);
        Type display = new (mem) Adafruit_SH1106G(width, height, wire, reset_pin);
        emitValue<output_DEV>(ctx, display);
    }
}