set-distance-mode

wayland/vl53l1x-time-of-flight/set-distance-mode

Set distance mode. The VL53L1X has three distance modes (DM): short, medium, and long. Long distance mode allows the longest possible ranging distance of 4 m to be reached. However, this maximum ranging distance is impacted by ambient light. Short distance mode is more immune to ambient light, but its maximum ranging distance is typically limited to 1.3 m.
set-distance-mode
@/set-distance-mode
Set distance mode. The VL53L1X has three distance modes (DM): short, medium, and long. Long distance mode allows the longest possible ranging distance of 4 m to be reached. However, this maximum ranging distance is impacted by ambient light. Short distance mode is more immune to ambient light, but its maximum ranging distance is typically limited to 1.3 m.
DEV@/vl53l1x-device
A VL53L1X device.
DMbyte
Distance mode: 00h = short; 01h = medium; 02h = long.
UPDpulse
Update. Trigger for setting distance mode.
set-distance-mode
DEV
DM
UPD
OK
OKpulse
Pulses when distance mode is set.
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 pulse
        if (!isInputDirty<input_UPD>(ctx))
            return;

        // Get a pointer to the `VL53L1X` class instance
        auto sensor = getValue<input_DEV>(ctx);
        // get distance mode
        auto mode = getValue<input_DM>(ctx);

        if(mode==0)
        {
            if(!sensor->setDistanceMode(VL53L1XMTW::Short)) {
                raiseError(ctx);
                return;
            }
        }

        if(mode==1)
        {
            if(!sensor->setDistanceMode(VL53L1XMTW::Medium)) {
                raiseError(ctx);
                return;
            }
        }

        if(mode==2)
        {
            if(!sensor->setDistanceMode(VL53L1XMTW::Long)) {
                raiseError(ctx);
                return;
            }
        }
        emitValue<output_OK>(ctx,1);
    }
}