init

wayland/vl53l0x-time-of-flight/init

Initialize VL53L0X device.
init
@/init
Initialize VL53L0X device.
DEV@/vl53l0x-device
A VL53L0X device.
TOnumber
Timeout (microseconds).
INITpulse
Trigger for initialization. Default is to initialize on boot.
init
DEV
TO
INIT
DONE
DONEpulse
Pulse on initialization.
To use the node in your project you should have the wayland/vl53l0x-time-of-flight 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 pulsei
    if (!isInputDirty<input_INIT>(ctx))
        return;

    Wire.begin();

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

    // Initialize VL53L0X module
    sensor->init();

    // Don't check for successful initialization - init() returns true even if no VL53L0X connected!
    // Attempt to initialize VL53L0X module; if attempt fails emit pulse from error port
    //if (!sensor->init()) {
        //emitValue<output_ERR>(ctx, 1);
        //return;
    //}

    // set timeout
    sensor->setTimeout(getValue<input_TO>(ctx));

    // Pulse to indicate initialization complete
    emitValue<output_DONE>(ctx, 1);
}