sfm3x00-device

wayland/sfm3x00-flow-meter/sfm3x00-device

Create a SFM3x00 device.
sfm3x00-device
@/sfm3x00-device
Create a SFM3x00 device.
ADDRbyte
I²C address of device.
I2Cxod/i2c/i2c
I²C bus
sfm3x00-device
DEV
ADDR
I2C
DEV@/sfm3x00-device
A SFM3x00 device.
To use the node in your project you should have the wayland/sfm3x00-flow-meter 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/WaylandM/MTW-SFM3X00"

//Include C++ libraries
#include <Wire.h>
#include <SFM3X00.h>

node {
    meta {
        using Type = SFM3X00*;
    }

    uint8_t mem[sizeof(SFM3X00)];

    void evaluate(Context ctx) {
        if (!isSettingUp()) return;

        auto address = getValue<input_ADDR>(ctx);
        auto wire = getValue<input_I2C>(ctx);

        Type sensor = new (mem) SFM3X00(address, *wire);

        sensor->begin();

        emitValue<output_DEV>(ctx, sensor);

    }
}