tcs3472 - tcs3472 Color Sensor#

Adaptation status unknown

Note

This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!

Example

--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
local tcs3472 = require "tcs3472"
i2cid = 0
i2c_speed = i2c.FAST
sys.taskInit(function()
    i2c.setup(i2cid,i2c_speed)
    tcs3472.init(i2cid)--initialization, passing in i2c_id
    while 1 do
        local rgb_date = tcs3472.get_rgb()
        log.info("rgb_date.R:",rgb_date.R)
        log.info("rgb_date.G:",rgb_date.G)
        log.info("rgb_date.B:",rgb_date.B)
        log.info("rgb_date.C:",rgb_date.C)
        local lux_date = tcs3472.get_lux(rgb_date)
        log.info("lux_date:",lux_date)
        sys.wait(1000)
    end
end)

tcs3472.init(i2c_id)#

tcs3472 Initialization

Parameters

Incoming Value Type

Explanation

number

The i2c bus id

Return Value

return value type

explanation

bool

Successful return true

Examples

tcs3472.init(0)

tcs3472.get_rgb()#

Get RGB data

Parameters

None

Return Value

return value type

explanation

table

tcs3472 rgb Data

Examples

local rgb_date = tcs3472.get_rgb()
log.info("rgb_date.R:",rgb_date.R)
log.info("rgb_date.G:",rgb_date.G)
log.info("rgb_date.B:",rgb_date.B)
log.info("rgb_date.C:",rgb_date.C)

tcs3472.get_lux()#

Getting data for lux

Parameters

Incoming Value Type

Explanation

table

rgb_data rgb Data

Return Value

return value type

explanation

number

lux Data

Examples

local lux_date = tcs3472.get_lux(rgb_date)
log.info("lux_date:",lux_date)