read-lux

wayland/vl6180x-time-of-flight/read-lux

Measure ambient light intensity.
read-lux
@/read-lux
Measure ambient light intensity.
DEV@/vl6180x-device
A VL6180X device.
GAINbyte
Gain. Options: 06h = 1x gain; 05h = 1.25x; 04h = 1.67x; 03h = 2.5x; 02h = 5x; 01h = 10x; 00h = 20x; 07h = 40x.
UPDpulse
Update. Trigger read of lux.
read-lux
DEV
GAIN
UPD
LUX
DONE
DONEpulse
Pulse on read.
LUXnumber
Ambient light intensity (lux).
To use the node in your project you should have the wayland/vl6180x-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

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

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 `VL6180X` class instance
         auto sensor = getValue<input_DEV>(ctx);
         uint8_t gain = getValue<input_GAIN>(ctx);
         emitValue<output_LUX>(ctx,sensor->readLux(gain));
         emitValue<output_DONE>(ctx,1);
    }
}