get-distance-mode

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

Read current distance mode of VL53L1X.
get-distance-mode
@/get-distance-mode
Read current distance mode of VL53L1X.
DEV@/vl53l1x-device
A VL53L1X device.
UPDpulse
Update. Triggers read of distance mode.
get-distance-mode
DM
DONE
DEV
UPD
DONEpulse
Pulse on read of distance mode.
DMbyte
Distance mode: 00h = short; 01h = medium; 02h = long; 03h = unknown.
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);

        VL53L1XMTW::DistanceMode mode = sensor->getDistanceMode();
        
        switch (mode)
        {
            case VL53L1XMTW::Short:
                emitValue<output_DM>(ctx,0);
                break;

            case VL53L1XMTW::Medium:
                emitValue<output_DM>(ctx,1);
                break;

            case VL53L1XMTW::Long:
                emitValue<output_DM>(ctx,2);
                break;

            default:
                emitValue<output_DM>(ctx,3);
        }
        emitValue<output_DONE>(ctx,1);
    }
}