Skip to content

Commit 6c42761

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "support humidity sensor type"
2 parents 7ae7d31 + 5819051 commit 6c42761

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

api/current.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77615,6 +77615,17 @@
7761577615
visibility="public"
7761677616
>
7761777617
</field>
77618+
<field name="TYPE_RELATIVE_HUMIDITY"
77619+
type="int"
77620+
transient="false"
77621+
volatile="false"
77622+
value="12"
77623+
static="true"
77624+
final="true"
77625+
deprecated="not deprecated"
77626+
visibility="public"
77627+
>
77628+
</field>
7761877629
<field name="TYPE_ROTATION_VECTOR"
7761977630
type="int"
7762077631
transient="false"

core/java/android/hardware/Sensor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ public class Sensor {
9797
*/
9898
public static final int TYPE_ROTATION_VECTOR = 11;
9999

100+
/**
101+
* A constant describing a relative humidity sensor type.
102+
* See {@link android.hardware.SensorEvent SensorEvent}
103+
* for more details.
104+
*/
105+
public static final int TYPE_RELATIVE_HUMIDITY = 12;
106+
100107
/**
101108
* A constant describing all sensor types.
102109
*/

core/java/android/hardware/SensorEvent.java

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,65 @@ public class SensorEvent {
304304
* in the clockwise direction (mathematically speaking, it should be
305305
* positive in the counter-clockwise direction).
306306
* </p>
307-
*
307+
*
308+
* <h4>{@link android.hardware.Sensor#TYPE_RELATIVE_HUMIDITY
309+
* Sensor.TYPE_RELATIVE_HUMIDITY}:</h4>
310+
* <ul>
311+
* <p>
312+
* values[0]: Relative ambient air humidity in percent
313+
* </p>
314+
* </ul>
315+
* <p>
316+
* When relative ambient air humidity and ambient temperature are
317+
* measured, the dew point and absolute humidity can be calculated.
318+
* </p>
319+
* <u>Dew Point</u>
320+
* <p>
321+
* The dew point is the temperature to which a given parcel of air must be
322+
* cooled, at constant barometric pressure, for water vapor to condense
323+
* into water.
324+
* </p>
325+
* <center><pre>
326+
* ln(RH/100%) + m&#183;t/(T<sub>n</sub>+t)
327+
* t<sub>d</sub>(t,RH) = T<sub>n</sub> &#183; ------------------------------
328+
* m - [ln(RH/100%) + m&#183;t/(T<sub>n</sub>+t)]
329+
* </pre></center>
330+
* <dl>
331+
* <dt>t<sub>d</sub></dt> <dd>dew point temperature in &deg;C</dd>
332+
* <dt>t</dt> <dd>actual temperature in &deg;C</dd>
333+
* <dt>RH</dt> <dd>actual relative humidity in %</dd>
334+
* <dt>m</dt> <dd>17.62</dd>
335+
* <dt>T<sub>n</sub></dt> <dd>243.12 &deg;C</dd>
336+
* </dl>
337+
* <p>for example:</p>
338+
* <pre class="prettyprint">
339+
* h = Math.log(rh / 100.0) + (17.62 * t) / (243.12 + t);
340+
* td = 243.12 * h / (17.62 - h);
341+
* </pre>
342+
* <u>Absolute Humidity</u>
343+
* <p>
344+
* The absolute humidity is the mass of water vapor in a particular volume
345+
* of dry air. The unit is g/m<sup>3</sup>.
346+
* </p>
347+
* <center><pre>
348+
* RH/100%&#183;A&#183;exp(m&#183;t/(T<sub>n</sub>+t))
349+
* d<sub>v</sub>(t,RH) = 216.7 &#183; -------------------------
350+
* 273.15 + t
351+
* </pre></center>
352+
* <dl>
353+
* <dt>d<sub>v</sub></dt> <dd>absolute humidity in g/m<sup>3</sup></dd>
354+
* <dt>t</dt> <dd>actual temperature in &deg;C</dd>
355+
* <dt>RH</dt> <dd>actual relative humidity in %</dd>
356+
* <dt>m</dt> <dd>17.62</dd>
357+
* <dt>T<sub>n</sub></dt> <dd>243.12 &deg;C</dd>
358+
* <dt>A</dt> <dd>6.112 hPa</dd>
359+
* </dl>
360+
* <p>for example:</p>
361+
* <pre class="prettyprint">
362+
* dv = 216.7 *
363+
* (rh / 100.0 * 6.112 * Math.exp(17.62 * t / (243.12 + t)) / (273.15 + t));
364+
* </pre>
365+
*
308366
* @see SensorEvent
309367
* @see GeomagneticField
310368
*/

0 commit comments

Comments
 (0)