init

wayland/mprls-pressure-sensor/init

Initializes MPRLS device.
init
@/init
Initializes MPRLS device.
DEV@/mprls-device
An MPRLS device.
INITpulse
Trigger for initialization. Default is to initialize on boot.
init
DEV
INIT
OK
ERR
ERRpulse
Pulse if initialization failed.
OKpulse
Pulse if initialization successful.
To use the node in your project you should have the wayland/mprls-pressure-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

struct State {
};

{{ GENERATED_CODE }}

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

    // Get a pointer to the `Adafruit_MPRLS` class instance
    auto sensor = getValue<input_DEV>(ctx);

    // Attempt to initialize aos module; if attempt fails emit pulse from error port
    if (!sensor->begin()) {
        emitValue<output_ERR>(ctx, 1);
        return;
    }

    // Pulse that module initialized successfully
    emitValue<output_OK>(ctx, 1);
}