Skip to content

aipaw/eeui-plugin-accelerometer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

加速器

安装

eeui plugin install https://github.com/aipaw/eeui-plugin-accelerometer

卸载

eeui plugin uninstall https://github.com/aipaw/eeui-plugin-accelerometer

引用

const accelerometer = app.requireModule("eeui/accelerometer");

get(callback) 获取当前加速度

参数

  1. [callback] (Function)

返回

  1. result (Object)
    • x (Float) (m/s^2)

    • y (Float) (m/s^2)

    • z (Float) (m/s^2)

示例

accelerometer.get((ret) => {
    console.log(ret)
})

watch(options, callback) 实时监听加速度

参数

  1. [options] (Object)

    • interval (Int) (ms, default: 32)
  2. [callback] (Function)

返回

  1. result (Object)
    • x (Float) (m/s^2)

    • y (Float) (m/s^2)

    • z (Float) (m/s^2)

示例

accelerometer.watch((ret) => {
    console.log(ret)
})

clearWatch(callback) 取消监听加速度

参数

  1. [callback] (Function)

示例

accelerometer.clearWatch(() => {
    console.log('cleared')
})

Error
ACCELEROMETER_PERMISSION_DENIED
ACCELEROMETER_NOT_SUPPORTED
ACCELEROMETER_INTERNAL_ERROR
GET_ACCELERATION_INVALID_ARGUMENT
WATCH_ACCELERATION_INVALID_ARGUMENT