This is an I2C driver for the Taos/AMS TSL4531 digital light sensor.
To initialize the chip and the driver
tsl-init must be called. This
places the chip in normal (continuous) conversion mode using a 400ms
tsl-data returns the result of the last
conversion as a 32-bit integer Lux value.
: tsl-init ( -- nak ) \ put device into normal mode, 400ms integration : tsl-data ( -- v ) \ read data
For low power operation (e.g. battery) the chip can be put to sleep
and woken up when a conversion is desired. Start with
and when a conversion is desired, use
tsl-convert to initiate
a one-shot conversion. It returns the number of milliseconds to wait
before the conversion data can be retrieved using
chip goes back to sleep automatically after the conversion.
: tsl-sleep ( -- ) \ put device to sleep : tsl-convert ( -- ms ) \ one-shot conversion, returns time to sleep before tsl-data
The I2C address is hard-coded as