read-distance

wayland/vl53l1x-time-of-flight/read-distance

Read distance (mm).
read-distance
@/read-distance
Read distance (mm).
DEV@/vl53l1x-device
A VL53L1X device.
UPDpulse
Update. Triggers read.
read-distance
RNG
PSCR
ACR
STAT
DONE
DEV
UPD
DONEpulse
Pulse on read.
STATnumber
Status of range measurement: 0 = range valid; 1 = standard deviation of measurement is above the internal defined threshold; 2 = signal value is below the internal defined threshold; 3 = target is below minimum detection threshold; 4 = nothing detected in range - try a longer distance mode if applicable; 5 = hardware failure; 6 = the range is valid, but the wraparound check has not been done; 7 = wrapped target, not matching phases; 9 = crosstalk signal failure; 10 = synchronization interrupt; 13 = target is below minimum detection threshold; 255 = no update.
ACRnumber
Ambient count rate (mega-counts per second).
PSCRnumber
Peak signal count rate (mega-counts per second).
RNGnumber
Range in millimetres.
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);
        sensor->read();

        emitValue<output_RNG>(ctx,sensor->ranging_data.range_mm);
        emitValue<output_PSCR>(ctx,sensor->ranging_data.peak_signal_count_rate_MCPS);
        emitValue<output_ACR>(ctx,sensor->ranging_data.ambient_count_rate_MCPS);
        emitValue<output_STAT>(ctx,sensor->ranging_data.range_status);
        emitValue<output_DONE>(ctx,1);
    }

}