blob: 61ca2d950aefbb78aa80b4137fd8a0576f230ceb [file] [log] [blame]
Reena Leec3c74792009-05-18 22:34:25 -07001page.title=Sensors
2pdk.version=1.0
Gaurav Mathurb8d30c12009-08-11 17:52:01 -07003doc.type=guide
Reena Leec3c74792009-05-18 22:34:25 -07004@jd:body
David Warren5c40a482009-06-05 15:11:21 -07005
6<div id="qv-wrapper">
7<div id="qv">
8<h2>In this document</h2>
9<a name="toc"/>
10<ul>
11<li><a href="#androidSensorsInterface">Interface</a></li>
12</ul>
13</div>
14</div>
15
Reena Leec3c74792009-05-18 22:34:25 -070016<p>Android defines a user space C abstraction interface for sensor hardware. The interface header is defined in
17<code>hardware/libhardware/include/hardware/sensors.h</code>.
18In order to integrate sensors with Android you need to build a shared library that implements this interface.
19
20The types of sensors currently supported by Android include:
21<ul>
22<li>Accelerometer</li>
23<li>Magnetic Field</li>
24<li>Orientation</li>
25<li>Gyroscope</li>
26<li>Light</li>
27<li>Pressure</li>
28<li>Temperature</li>
29<li>Proximity</li>
30</ul>
31</p>
32
David Warren5c40a482009-06-05 15:11:21 -070033<a name="androidSensorBuildingDriver"></a><h3>Building a Sensor Library</h3>
Reena Leec3c74792009-05-18 22:34:25 -070034<p> To implement a Sensors driver, create a shared library that implements the interface defined in <code>sensors.h</code>. You must name your shared library
35<code>libsensors.so</code> so that it will get loaded from <code>/system/lib</code> at runtime.
Reena Leed39413e2009-06-11 13:26:29 -070036</p>
Reena Leec3c74792009-05-18 22:34:25 -070037
Reena Leec8f0e672009-06-13 15:08:56 -070038<p> The following stub file, <code>Android.mk</code>, ensures that <code>libsensors</code> compiles and links to the appropriate libraries:</p>
39
Reena Leed39413e2009-06-11 13:26:29 -070040<pre>
41LOCAL_PATH := $(call my-dir)
42include $(CLEAR_VARS)
43
44LOCAL_MODULE := sensors
45
46LOCAL_PRELINK_MODULE := false
47
48LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
49
50LOCAL_SHARED_LIBRARIES := liblog
51# include any shared library dependencies
52
53LOCAL_SRC_FILES := sensors.c
54
55include $(BUILD_SHARED_LIBRARY)
56</pre>
Reena Leec3c74792009-05-18 22:34:25 -070057
David Warren5c40a482009-06-05 15:11:21 -070058<a name="androidSensorsInterface"></a><h3>Interface</h3>
Reena Leec3c74792009-05-18 22:34:25 -070059
60
David Warren5c40a482009-06-05 15:11:21 -070061<p><span class="lh3"><a name="androidDoxygenNote"></a></span>
Reena Leec3c74792009-05-18 22:34:25 -070062
63<p class="note"><strong>Note</strong>: This document relies on some Doxygen-generated content that appears in an iFrame below. To return to the Doxygen default content for this page, <a href="sensors.html">click here</a>.</p>
64
65
66<iframe onLoad="resizeDoxFrameHeight();" src="sensors_8h.html" scrolling="no" scroll="no" id="doxygen" marginwidth="0" marginheight="0"
67frameborder="0" style="width:100%;"></iframe>