sc7a20 - sc7a20#

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 sc7a20 = require "sc7a20"
i2cid = 0
i2c_speed = i2c.FAST
sys.taskInit(function()
    i2c.setup(i2cid,i2c_speed)
    sc7a20.init(i2cid)--initialization, passing in i2c_id
    while 1 do
        local sc7a20_data = sc7a20.get_data()
        log.info("sc7a20_data", "sc7a20_data.x"..(sc7a20_data.x),"sc7a20_data.y"..(sc7a20_data.y),"sc7a20_data.z"..(sc7a20_data.z))
        sys.wait(1000)
    end
end)

sc7a20.init(i2c_id)#

sc7a20 Initialization

Parameters

Incoming Value Type

Explanation

number

i2c id

Return Value

return value type

explanation

bool

Successful return true

Examples

sc7a20.init(0)

sc7a20.get_data()#

Get sc7a20 data

Parameters

None

Return Value

return value type

explanation

table

sc7a20 Data

Examples

local sc7a20_data = sc7a20.get_data()
log.info("sc7a20_data", "sc7a20_data.x"..(sc7a20_data.x),"sc7a20_data.y"..(sc7a20_data.y),"sc7a20_data.z"..(sc7a20_data.z))

sc7a20.set_thresh (i2cid, activity, time_inactivity)#

Setting the sc7a20 activity threshold

Parameters

Incoming Value Type

Explanation

number

i2c id

number

Activity threshold

number

Activity Duration

Return Value

None

Examples

sc7a20.set_thresh(0, string.char(0x05), string.char(0x05)) 

sc7a20.set_irqf(i2cid, int, irqf_ths, irqf_duration, irqf_cfg)#

Set sc7a20 interrupt settings

Parameters

Incoming Value Type

Explanation

number

i2c id

number

Interrupt pin incoming 1 and configure INT1 pin, incoming 2 and configure INT2 pin

number

Interruption threshold

number

Interrupt duration

number

Interrupt Configuration

Return Value

None

Examples

sc7a20.set_irqf(0, 1, string.char(0x05), string.char(0x05), string.char(0x00))