Microsoft MakeCode

How does the calibrateLight block work

I’m unclear how to the calibrateLight block works. How does it know the sensor is over the dark or light area? Does it sample several times a second and find the min and max reflection in a given time or until the program ends. Are the calibration values stored or do I run the procedure every time? Also, if there are two sensors do we calibrate them individually.

For reference, here is the impl: https://github.com/microsoft/pxt-ev3/blob/master/libs/color-sensor/color.ts#L333

It resets the sensor, then collects readings until it does not change anymore, compute min/max range and applies a threshold. It does not store the results yet but it’s an excellent suggestion.

2 sensors is not supported. You would have to write your own sequence. I guess when we store the data things would be easier as well.