【函数】 | boolean isReady() |
【说明】 | 判断距离传感器是否可用。 |
【返回】 | true或false。 |
【参数】 | 无 |
【示例】 |
alert(rexseeProximity.isReady());
运行示例
|
【函数】 | void start() |
【说明】 | 启动距离传感器。 |
【返回】 | 无 |
【参数】 | 无 |
【示例】 |
rexseeProximity.start();
事件代码
运行示例
启动后请将查看下面的方框。
rexseeDialog.toast('传感器已启动。'); No Data
|
【函数】 | void stop() |
【说明】 | 关闭距离传感器。 |
【返回】 | 无 |
【参数】 | 无 |
【示例】 |
rexseeProximity.stop();
运行示例
rexseeDialog.toast('传感器已关闭。'); |
【函数】 | String getLastKnownValue() |
【说明】 | 读取距离值,单位厘米,注意,有些设备只能读取基于一个标准值(例如3厘米)的”远“或”近“而不能获得精确的距离值。 |
【返回】 | 距离值,null表示没有值。 |
【参数】 | 无 |
【示例】 |
alert(rexseeProximity.getLastKnownValue());
运行示例
|
【函数】 | void setRate(String rate) |
【说明】 | 设置传感器响应速度,默认为“normal”。 |
【返回】 | 无 |
【参数】 | rate:传感器响应速度,“fastest”,“game”,“ui”或“normal”。 |
【示例】 |
rexseeProximity.setRate('fastest');
运行示例
rexseeDialog.toast('设置完毕。'); |
【函数】 | String getRate() |
【说明】 | 读取传感器响应速度。 |
【返回】 | 传感器响应速度,“fastest”,“game”,“ui”或“normal”。 |
【参数】 | 无 |
【示例】 |
alert(rexseeProximity.getRate());
运行示例
|
【函数】 | void setCycle(int milliseconds) |
【说明】 | 设置传感器检测周期,毫秒数,默认为100毫秒。 |
【返回】 | 无 |
【参数】 | milliseconds:传感器检测周期。 |
【示例】 |
rexseeProximity.setCycle(1000);
运行示例
rexseeDialog.toast('设置完毕。'); |
【函数】 | int getCycle() |
【说明】 | 读取传感器检测周期。 |
【返回】 | 传感器检测周期,毫秒数。 |
【参数】 | 无 |
【示例】 |
alert(rexseeProximity.getCycle());
运行示例
|
【函数】 | void setEventCycle(int milliseconds) |
【说明】 | 设置传感器触发事件的最短间隔,在该间隔内不会重复触发事件,毫秒数,默认为100毫秒。 |
【返回】 | 无 |
【参数】 | milliseconds:传感器触发事件的最短间隔。 |
【示例】 |
rexseeProximity.setEventCycle(1000);
运行示例
rexseeDialog.toast('设置完毕。'); |
【函数】 | int getEventCycle() |
【说明】 | 读取传感器触发事件的最短间隔。 |
【返回】 | 传感器触发事件的最短间隔,毫秒数。 |
【参数】 | 无 |
【示例】 |
alert(rexseeProximity.getEventCycle());
运行示例
|
【函数】 | void setAccuracy(float accuracy) |
【说明】 | 设置敏感度,两次检测的差异大于该敏感度才会触发事件,单位是厘米。 |
【返回】 | 无 |
【参数】 | accuracy:敏感度。 |
【示例】 |
rexseeProximity.setAccuracy(100);
运行示例
rexseeDialog.toast('设置完毕。'); |
【函数】 | float getAccuracy() |
【说明】 | 读取敏感度。 |
【返回】 | 敏感度,单位是厘米。 |
【参数】 | 无 |
【示例】 |
alert(rexseeProximity.getAccuracy());
运行示例
|