接近传感器精度

编程入门 行业动态 更新时间:2024-10-22 17:25:02
本文介绍了接近传感器精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我测试的接近传感器与此code:

I'm testing the proximity sensor with this code:

final SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); final Sensor proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_FASTEST);

当我的手远离传感器和0.0时,它完全关闭传感器我只得到5.0的值。 (我测试在Nexus S,4.1) 我可以得到一个介于0和5的值?

And I'm getting only 5.0 value when my hand is far away from the sensor and 0.0 when it's completely closed the sensor. (I'm testing on Nexus S, 4.1) Can I get the values between 0 and 5?

推荐答案

在许多设备中,接近传感器本质上是布尔 - 近(0),或远(5),但是这依赖于实际的使用接近传感器。

On many devices, the proximity sensor is essentially boolean - 'near' (0), or 'far' (5), but this is dependent on the actual proximity sensor used.

我没有Nexus S的,所以我无法验证该设备,但我猜它类似于我的三星GS3,报告如下信息:  名称:GP2A接近传感器  供应商:夏普  版本:1  功率:0.75  最大量程:5.0  分辨率:5.0

I don't have a Nexus S, so I can't verify that device, but I'm guessing that it's similar to my Samsung GS3, which reports the following information: Name: GP2A Proximity Sensor Vendor: Sharp Version: 1 Power: 0.75 Maximum Range: 5.0 Resolution: 5.0

正如你可以在GS3看,分辨率是一样的最大范围内,所以0和5,我要去得到,不管我做什么,唯一的值。

As you can see on the GS3, the resolution is the same as the maximum range, so 0 and 5 are the only values that I'm going to get no matter what I do.

您可以检查出自己的设备使用类似的Android的传感器盒,或使用传感器API 的getMaximumRange()和getResolution()方法。

You can check out your own device by using an app like 'Android Sensor Box', or by using the Sensor API's getMaximumRange() and getResolution() methods.

更多推荐

接近传感器精度

本文发布于:2023-11-23 20:53:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:精度   传感器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!