adxl34x - adxl34x 3 Axis accelerometer currently supports adxl345 adxl346#

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

adxl34x.init(i2c_id)#

adxl34x Initialization

Parameters

Incoming Value Type

Explanation

number

The i2c bus id

Return Value

return value type

explanation

bool

Successful return true

Examples

adxl34x.init(0)

adxl34x.get_data()#

Get adxl34x data

Parameters

None

Return Value

return value type

explanation

table

adxl34x Data

Examples

local adxl34x_data = adxl34x.get_data()
log.info("adxl34x_data", "adxl34x_data.x"..(adxl34x_data.x),"adxl34x_data.y"..(adxl34x_data.y),"adxl34x_data.z"..(adxl34x_data.z))

adxl34x.get_int_source()#

Get adxl34x interrupt source

Parameters

Incoming Value Type

Explanation

number

The i2c bus id

Return Value

None

Examples

adxl34x.get_int_source(i2cid)

adxl34x.set_thresh(i2cid, activity, inactivity, time_inactivity)#

Set adxl34x activity and static stop thresholds

Parameters

Incoming Value Type

Explanation

number

The i2c bus id

number

Activity threshold

number

Static threshold

number

Static time

Return Value

None

Examples

adxl34x.set_thresh(i2cid, string.char(0x05), string.char(0x02), string.char(0x05)) 
log.info("adxl34x_data", "adxl34x_data.x"..(adxl34x_data.x),"adxl34x_data.y"..(adxl34x_data.y),"adxl34x_data.z"..(adxl34x_data.z))

adxl34x.set_irqf(i2cid, irqf_map, irqf_act_ctl, irqf_enable)#

adxl34x Interrupt Settings

Parameters

Incoming Value Type

Explanation

number

The i2c bus id

number

interrupt mapping

number

Interrupt Activity Control

number

Interrupt enable

Return Value

None

Examples

adxl34x.set_irqf(i2cid, string.char(0x10), string.char(0xff), string.char(0x10))