blob: d41dcd753859ad3337565db3896333d145f9afdf [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 Leec8f0e672009-06-13 15:08:56 -070037<p> The following stub file, <code>Android.mk</code>, ensures that <code>libsensors</code> compiles and links to the appropriate libraries:</p>
38
Reena Leed39413e2009-06-11 13:26:29 -070039<pre>
40LOCAL_PATH := $(call my-dir)
41include $(CLEAR_VARS)
42
43LOCAL_MODULE := sensors
44
45LOCAL_PRELINK_MODULE := false
46
47LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
48
49LOCAL_SHARED_LIBRARIES := liblog
50# include any shared library dependencies
51
52LOCAL_SRC_FILES := sensors.c
53
54include $(BUILD_SHARED_LIBRARY)
55</pre>
Reena Leec3c74792009-05-18 22:34:25 -070056
David Warren5c40a482009-06-05 15:11:21 -070057<a name="androidSensorsInterface"></a><h3>Interface</h3>
Reena Leec3c74792009-05-18 22:34:25 -070058
59
David Warren5c40a482009-06-05 15:11:21 -070060<p><span class="lh3"><a name="androidDoxygenNote"></a></span>
Reena Leec3c74792009-05-18 22:34:25 -070061
62<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>
63
64
65<iframe onLoad="resizeDoxFrameHeight();" src="sensors_8h.html" scrolling="no" scroll="no" id="doxygen" marginwidth="0" marginheight="0"
66frameborder="0" style="width:100%;"></iframe>