blob: 02f0c4e85242673118b8b551da372063a3d0dfcf [file] [log] [blame]
Reena Leec3c74792009-05-18 22:34:25 -07001page.title=Sensors
2pdk.version=1.0
3@jd:body
David Warren5c40a482009-06-05 15:11:21 -07004
5<div id="qv-wrapper">
6<div id="qv">
7<h2>In this document</h2>
8<a name="toc"/>
9<ul>
10<li><a href="#androidSensorsInterface">Interface</a></li>
11</ul>
12</div>
13</div>
14
Reena Leec3c74792009-05-18 22:34:25 -070015<p>Android defines a user space C abstraction interface for sensor hardware. The interface header is defined in
16<code>hardware/libhardware/include/hardware/sensors.h</code>.
17In order to integrate sensors with Android you need to build a shared library that implements this interface.
18
19The types of sensors currently supported by Android include:
20<ul>
21<li>Accelerometer</li>
22<li>Magnetic Field</li>
23<li>Orientation</li>
24<li>Gyroscope</li>
25<li>Light</li>
26<li>Pressure</li>
27<li>Temperature</li>
28<li>Proximity</li>
29</ul>
30</p>
31
David Warren5c40a482009-06-05 15:11:21 -070032<a name="androidSensorBuildingDriver"></a><h3>Building a Sensor Library</h3>
Reena Leec3c74792009-05-18 22:34:25 -070033<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
34<code>libsensors.so</code> so that it will get loaded from <code>/system/lib</code> at runtime.
Reena Leed39413e2009-06-11 13:26:29 -070035</p>
Reena Leec3c74792009-05-18 22:34:25 -070036
Reena Leed39413e2009-06-11 13:26:29 -070037<p> The following stub <code>Android.mk</code> file ensures that <code>libsensors</code> compiles and links to the appropriate libraries:</p>
38<pre>
39LOCAL_PATH := $(call my-dir)
40include $(CLEAR_VARS)
41
42LOCAL_MODULE := sensors
43
44LOCAL_PRELINK_MODULE := false
45
46LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
47
48LOCAL_SHARED_LIBRARIES := liblog
49# include any shared library dependencies
50
51LOCAL_SRC_FILES := sensors.c
52
53include $(BUILD_SHARED_LIBRARY)
54</pre>
Reena Leec3c74792009-05-18 22:34:25 -070055
David Warren5c40a482009-06-05 15:11:21 -070056<a name="androidSensorsInterface"></a><h3>Interface</h3>
Reena Leec3c74792009-05-18 22:34:25 -070057
58
David Warren5c40a482009-06-05 15:11:21 -070059<p><span class="lh3"><a name="androidDoxygenNote"></a></span>
Reena Leec3c74792009-05-18 22:34:25 -070060
61<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>
62
63
64<iframe onLoad="resizeDoxFrameHeight();" src="sensors_8h.html" scrolling="no" scroll="no" id="doxygen" marginwidth="0" marginheight="0"
65frameborder="0" style="width:100%;"></iframe>