tsl2591-device

wayland/tsl2591-light-sensor/tsl2591-device

Create a tsl2591-device.
tsl2591-device
@/tsl2591-device
Create a tsl2591-device.
I2Cxod/i2c/i2c
I²C bus.
tsl2591-device
DEV
I2C
DEV@/tsl2591-device
A TSL2591 device.
To use the node in your project you should have the wayland/tsl2591-light-sensor 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 can download the libraries:
#pragma XOD require "https://github.com/adafruit/Adafruit_Sensor"
#pragma XOD require "https://github.com/adafruit/Adafruit_TSL2591_Library"

//Include C++ libraries
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2591.h>

node {

    meta {
        // Define our custom type as a pointer on the class instance.
        using Type = Adafruit_TSL2591*;
    }

    // Create an object of class Adafruit_TSL2591
    Adafruit_TSL2591 sensor = Adafruit_TSL2591();

    void evaluate(Context ctx) {
        // It should be evaluated only once on the first (setup) transaction
        if (!isSettingUp())
            return;

        auto wire = getValue<input_I2C>(ctx);
        
        // Try to initialize sensor
        if (!sensor.begin(wire)) {
            raiseError(ctx);
            return;
        }
        emitValue<output_DEV>(ctx, &sensor);
    }
}