简体   繁体   English

具有增强型接近传感器的Android手机

[英]Android Phones with enhanced proximity sensor

I currently use the proximity sensor of an HTC Wildfire phone. 我目前使用的是HTC Wildfire手机的接近传感器。 The problem is that it only returns a boolean value if there is an object within 1 cm in front of the sensor. 问题是如果传感器前面1厘米内有一个物体,它只返回一个布尔值。

So, I want to ask if there is an Android phone available in the market that has a proximity sensor which is able to return actual distance values (cm) instead of a boolean.. 所以,我想问一下市场上是否有一款Android手机,它有一个能够返回实际距离值(cm)而不是布尔值的接近传感器。

Thank you 谢谢

Yes it is possible to obtain actual distance from the phone surface. 是的,可以从手机表面获得实际距离。

In fact ALL hardware sensors DO provide this information. 事实上,所有硬件传感器都提供此信息。 But unfortunately the sensor API defined in Android defines the proximity to be a boolean ie NEAR(1) OR FAR(0). 但遗憾的是,Android中定义的传感器API将接近度定义为布尔值,即NEAR(1)OR FAR(0)。

To get a boolean reading from the actual distance, the distance obtained from the proximity sensor hardware is compared with a threshold value. 为了从实际距离获得布尔读数,将从接近传感器硬件获得的距离与阈值进行比较。 This is often done in the sensor-HAL. 这通常在传感器-HAL中完成。

Also some light/proximity sensor-hardware ICs provide a proximity boolean themselves. 此外,一些光/接近传感器 - 硬件IC本身也提供接近布尔值。 In this case, the threshold is configurable in the hardware. 在这种情况下,阈值可在硬件中配置。 The hardware compares each sample obtained with the threshold internally and then reports the boolean "proximity". 硬件将内部获得的每个样本与阈值进行比较,然后报告布尔值“邻近度”。

Irrespective of the kind of sensor hardware in use, Android (upto v4.1 "jelly-bean") does NOT expose the proximity distance parameter as part of its sensor API . 无论使用何种传感器硬件, Android(upto v4.1“jelly-bean”)都不会将接近距离参数作为其传感器API的一部分公开 One can modify the sensor-HAL or try to interact with the proximity sensor driver directly (usually a sys-fs entry). 可以修改传感器-HAL或尝试直接与接近传感器驱动程序交互(通常是sys-fs条目)。

More details of Light/Proximity sensor on Android . Android上光/接近传感器的更多细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM