qwiicpir-device

britt/sparkfun-qwiicpir/qwiicpir-device

Creates the qwiic_PIR device and checks for proper i2c communications.
qwiicpir-device
@/qwiicpir-device
Creates the qwiic_PIR device and checks for proper i2c communications.
I2Cxod/i2c/i2c
qwiicpir-device
DEV
I2C
DEV@/qwiicpir-device
To use the node in your project you should have the britt/sparkfun-qwiicpir 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

#pragma XOD require "https://github.com/sparkfun/SparkFun_Qwiic_PIR_Arduino_Library"

#include <SparkFun_Qwiic_PIR.h>
#define DEBOUNCE_TIME 750

node {

    meta {
    // define the custom type as a pointer
        using Type = QwiicPIR*;
    }

    QwiicPIR pir = QwiicPIR();

    void evaluate(Context ctx) {

         if (!isSettingUp())
            return;

        auto wire = getValue<input_I2C>(ctx);

        // init the pir sensor and returns an error if the i2c can not communicate with sensor
        if (pir.begin() == false) {
                raiseError(ctx);
                return;
            }

        // returns the the pir function in the output to be used by other nodes via the patch terminal node
          emitValue<output_DEV>(ctx, &pir);

    }
}