sh1107-oled-i2c-device

wayland/sh1107-oled-i2c/sh1107-oled-i2c-device

Create SH1307 OLED device.
sh1107-oled-i2c-device
@/sh1107-oled-i2c-device
Create SH1307 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).
sh1107-oled-i2c-device
I2C
WIDTH
HEIGHT
RESET_PIN
DEV
DEV@/sh1107-oled-i2c-device
An SH1107 OLED device.
To use the node in your project you should have the wayland/sh1107-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_SH1107*;
    }

    uint8_t mem[sizeof(Adafruit_SH1107)];

    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_SH1107(width, height, wire, reset_pin);
        emitValue<output_DEV>(ctx, display);
    }
}