Trigger for initialization. Default is to initialize on boot.
OKpulse
Pulse if initialization successful.
To use the node in your project you should have the wayland/vl53l1x-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
node {
void evaluate(Context ctx) {
// The node responds only if there is an input pulsei
if (!isInputDirty<input_INIT>(ctx))
return;
Wire.begin();
Wire.setClock(400000); // use 400 kHz I2C
// Get a pointer to the `VL53L1X` class instance
auto sensor = getValue<input_DEV>(ctx);
sensor->setTimeout(getValue<input_TO>(ctx));
// Attempt to initialize VL53L1X module; if attempt fails emit error
if (!sensor->init()) {
raiseError(ctx);
return;
}
// Pulse that module initialized successfully
emitValue<output_OK>(ctx, 1);
}
}