Merge lp:~thomas-voss/platform-api/add-magnetic-gyro-sensors-take-2 into lp:platform-api

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/platform-api/add-magnetic-gyro-sensors-take-2
Merge into: lp:platform-api
Prerequisite: lp:~thomas-voss/platform-api/fix-1448180
Diff against target: 1851 lines (+1536/-10)
16 files modified
android/default/default_ubuntu_application_sensor.cpp (+423/-0)
android/hybris/test_sensors_c_api.cpp (+40/-0)
android/include/private/application/sensors/events.h (+70/-10)
android/include/private/application/sensors/sensor_reading.h (+1/-0)
debian/libubuntu-application-api3.symbols (+26/-0)
examples/test_sensors_api.cpp (+40/-0)
include/ubuntu/application/sensors/CMakeLists.txt (+2/-0)
include/ubuntu/application/sensors/event/CMakeLists.txt (+2/-0)
include/ubuntu/application/sensors/event/gyroscope.h (+86/-0)
include/ubuntu/application/sensors/event/magnetic.h (+81/-0)
include/ubuntu/application/sensors/gyroscope.h (+144/-0)
include/ubuntu/application/sensors/magnetic.h (+142/-0)
src/ubuntu/application/desktop/ubuntu_application_sensors_desktop.cpp (+194/-0)
src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp (+213/-0)
src/ubuntu/application/touch/hybris/ubuntu_application_sensors_hybris.cpp (+36/-0)
src/ubuntu/application/ubuntu_application_api.cpp (+36/-0)
To merge this branch: bzr merge lp:~thomas-voss/platform-api/add-magnetic-gyro-sensors-take-2
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+290522@code.launchpad.net

Commit message

Add APIs for Gyroscopic and Magnetic Field sensors

Description of the change

Add APIs for Gyroscopic and Magnetic Field sensors

To post a comment you must log in.
324. By Thomas Voß

Fix event type.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

324. By Thomas Voß

Fix event type.

323. By Thomas Voß

* Add functions for subscribing to satellite visibility updates.
[ CI Train Bot ]
* debian/libubuntu-platform-hardware-api3.symbols: update to released
  version.
[ Simon Fels ]
* Workaround API break in Android GPS hardware abstraction API on MTK
  platforms. Each device which need this workaround has to add
[ Thomas Voß ]
* Expose performance boosting capabilities of the underlying
  HW/drivers.

322. By Gerry Boland

Fix debian symbols file for landing

321. By Gerry Boland

Merge trunk

320. By Gerry Boland

Merge trunk

319. By Gerry Boland

Make Sensor event accessors const

318. By Gerry Boland

Fix sensor-type errors, fixes up magnetic field sensor

317. By Gerry Boland

Fix up build on android

316. By Gerry Boland

Add Magnetic field sensor API

315. By Gerry Boland

Add new symbols to symbols file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'android/default/default_ubuntu_application_sensor.cpp'
2--- android/default/default_ubuntu_application_sensor.cpp 2014-09-17 23:38:05 +0000
3+++ android/default/default_ubuntu_application_sensor.cpp 2016-04-04 06:59:06 +0000
4@@ -21,6 +21,8 @@
5 #include <ubuntu/application/sensors/proximity.h>
6 #include <ubuntu/application/sensors/light.h>
7 #include <ubuntu/application/sensors/orientation.h>
8+#include <ubuntu/application/sensors/gyroscope.h>
9+#include <ubuntu/application/sensors/magnetic.h>
10
11 #include <private/application/sensors/sensor.h>
12 #include <private/application/sensors/sensor_listener.h>
13@@ -42,6 +44,8 @@
14 on_proximity_event(NULL),
15 on_light_event(NULL),
16 on_orientation_event(NULL),
17+ on_gyroscope_event(NULL),
18+ on_magnetic_event(NULL),
19 context(nullptr)
20 {
21 }
22@@ -118,6 +122,42 @@
23
24 break;
25 }
26+ case ubuntu::application::sensors::sensor_type_gyroscope:
27+ {
28+ if (!on_gyroscope_event)
29+ return;
30+
31+ ubuntu::application::sensors::GyroscopeEvent ev(
32+ reading->timestamp,
33+ reading->gyroscopic[0],
34+ reading->gyroscopic[1],
35+ reading->gyroscopic[2]
36+ );
37+
38+ on_gyroscope_event(
39+ &ev, this->context
40+ );
41+
42+ break;
43+ }
44+ case ubuntu::application::sensors::sensor_type_magnetic_field:
45+ {
46+ if (!on_magnetic_event)
47+ return;
48+
49+ ubuntu::application::sensors::MagneticEvent ev(
50+ reading->timestamp,
51+ reading->magnetic[0],
52+ reading->magnetic[1],
53+ reading->magnetic[2]
54+ );
55+
56+ on_magnetic_event(
57+ &ev, this->context
58+ );
59+
60+ break;
61+ }
62 }
63 }
64
65@@ -125,6 +165,8 @@
66 on_proximity_event_cb on_proximity_event;
67 on_light_event_cb on_light_event;
68 on_orientation_event_cb on_orientation_event;
69+ on_gyroscope_event_cb on_gyroscope_event;
70+ on_magnetic_event_cb on_magnetic_event;
71 void *context;
72 };
73
74@@ -132,10 +174,14 @@
75 ubuntu::application::sensors::Sensor::Ptr accelerometer;
76 ubuntu::application::sensors::Sensor::Ptr proximity;
77 ubuntu::application::sensors::Sensor::Ptr light;
78+ubuntu::application::sensors::Sensor::Ptr gyroscope;
79+ubuntu::application::sensors::Sensor::Ptr magnetic;
80 ubuntu::application::sensors::SensorListener::Ptr orientation_listener;
81 ubuntu::application::sensors::SensorListener::Ptr accelerometer_listener;
82 ubuntu::application::sensors::SensorListener::Ptr proximity_listener;
83 ubuntu::application::sensors::SensorListener::Ptr light_listener;
84+ubuntu::application::sensors::SensorListener::Ptr gyroscope_listener;
85+ubuntu::application::sensors::SensorListener::Ptr magnetic_listener;
86 }
87
88 static int32_t toHz(int32_t microseconds)
89@@ -844,3 +890,380 @@
90
91 return U_STATUS_SUCCESS;
92 }
93+
94+/*
95+ * Gyroscopic Sensor
96+ */
97+
98+UASensorsGyroscope*
99+ua_sensors_gyroscope_new()
100+{
101+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
102+ gyroscope =
103+ ubuntu::application::sensors::SensorService::sensor_for_type(
104+ ubuntu::application::sensors::sensor_type_gyroscope);
105+
106+ return gyroscope.get();
107+}
108+
109+UStatus
110+ua_sensors_gyroscope_enable(
111+ UASensorsGyroscope* sensor)
112+{
113+ if (sensor == NULL)
114+ return U_STATUS_ERROR;
115+
116+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
117+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
118+
119+ s->enable();
120+
121+ return U_STATUS_SUCCESS;
122+}
123+
124+UStatus
125+ua_sensors_gyroscope_disable(
126+ UASensorsGyroscope* sensor)
127+{
128+ if (sensor == NULL)
129+ return U_STATUS_ERROR;
130+
131+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
132+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
133+ s->disable();
134+
135+ return U_STATUS_SUCCESS;
136+}
137+
138+uint32_t
139+ua_sensors_gyroscope_get_min_delay(
140+ UASensorsGyroscope* sensor)
141+{
142+ if (sensor == NULL)
143+ return -1;
144+
145+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
146+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
147+ return toHz(s->min_delay());
148+}
149+
150+UStatus
151+ua_sensors_gyroscope_get_min_value(
152+ UASensorsGyroscope* sensor,
153+ float* value)
154+{
155+ if (sensor == NULL || value == NULL)
156+ return U_STATUS_ERROR;
157+
158+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
159+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
160+ *value = s->min_value();
161+
162+ return U_STATUS_SUCCESS;
163+}
164+
165+UStatus
166+ua_sensors_gyroscope_get_max_value(
167+ UASensorsGyroscope* sensor,
168+ float* value)
169+{
170+ if (sensor == NULL || value == NULL)
171+ return U_STATUS_ERROR;
172+
173+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
174+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
175+ *value = s->max_value();
176+
177+ return U_STATUS_SUCCESS;
178+}
179+
180+UStatus
181+ua_sensors_gyroscope_get_resolution(
182+ UASensorsGyroscope* sensor,
183+ float* value)
184+{
185+ if (sensor == NULL || value == NULL)
186+ return U_STATUS_ERROR;
187+
188+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
189+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
190+ *value = s->resolution();
191+
192+ return U_STATUS_SUCCESS;
193+}
194+
195+void
196+ua_sensors_gyroscope_set_reading_cb(
197+ UASensorsGyroscope* sensor,
198+ on_gyroscope_event_cb cb,
199+ void *ctx)
200+{
201+ if (sensor == NULL)
202+ return;
203+
204+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
205+
206+ SensorListener<ubuntu::application::sensors::sensor_type_gyroscope>* sl
207+ = new SensorListener<ubuntu::application::sensors::sensor_type_gyroscope>();
208+
209+ sl->on_gyroscope_event = cb;
210+ sl->context = ctx;
211+
212+ gyroscope_listener = sl;
213+ s->register_listener(gyroscope_listener);
214+}
215+
216+UStatus
217+ua_sensors_gyroscope_set_event_rate(
218+ UASensorsGyroscope* sensor,
219+ uint32_t rate)
220+{
221+ if (sensor == NULL)
222+ return U_STATUS_ERROR;
223+
224+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
225+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
226+ if (!s->set_event_rate(rate))
227+ return U_STATUS_ERROR;
228+
229+ return U_STATUS_SUCCESS;
230+}
231+
232+uint64_t
233+uas_gyroscope_event_get_timestamp(
234+ UASGyroscopeEvent* event)
235+{
236+ auto ev = static_cast<ubuntu::application::sensors::GyroscopeEvent*>(event);
237+ return ev->get_timestamp();
238+}
239+
240+UStatus
241+uas_gyroscope_event_get_rate_of_rotation_around_x(
242+ UASGyroscopeEvent* event,
243+ float* value)
244+{
245+ if (event == NULL || value == NULL)
246+ return U_STATUS_ERROR;
247+
248+ auto ev = static_cast<ubuntu::application::sensors::GyroscopeEvent*>(event);
249+ *value = ev->get_x_rotation_rate();
250+
251+ return U_STATUS_SUCCESS;
252+}
253+
254+UStatus
255+uas_gyroscope_event_get_rate_of_rotation_around_y(
256+ UASGyroscopeEvent* event,
257+ float* value)
258+{
259+ if (event == NULL || value == NULL)
260+ return U_STATUS_ERROR;
261+
262+ auto ev = static_cast<ubuntu::application::sensors::GyroscopeEvent*>(event);
263+ *value = ev->get_y_rotation_rate();
264+
265+ return U_STATUS_SUCCESS;
266+}
267+
268+UStatus
269+uas_gyroscope_event_get_rate_of_rotation_around_z(
270+ UASGyroscopeEvent* event,
271+ float* value)
272+{
273+ if (event == NULL || value == NULL)
274+ return U_STATUS_ERROR;
275+
276+ auto ev = static_cast<ubuntu::application::sensors::GyroscopeEvent*>(event);
277+ *value = ev->get_z_rotation_rate();
278+
279+ return U_STATUS_SUCCESS;
280+}
281+
282+
283+/*
284+ * Magnetic Field Sensor
285+ */
286+
287+UASensorsMagnetic*
288+ua_sensors_magnetic_new()
289+{
290+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
291+ magnetic =
292+ ubuntu::application::sensors::SensorService::sensor_for_type(
293+ ubuntu::application::sensors::sensor_type_magnetic_field);
294+
295+ return magnetic.get();
296+}
297+
298+UStatus
299+ua_sensors_magnetic_enable(
300+ UASensorsMagnetic* sensor)
301+{
302+ if (sensor == NULL)
303+ return U_STATUS_ERROR;
304+
305+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
306+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
307+
308+ s->enable();
309+
310+ return U_STATUS_SUCCESS;
311+}
312+
313+UStatus
314+ua_sensors_magnetic_disable(
315+ UASensorsMagnetic* sensor)
316+{
317+ if (sensor == NULL)
318+ return U_STATUS_ERROR;
319+
320+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
321+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
322+ s->disable();
323+
324+ return U_STATUS_SUCCESS;
325+}
326+
327+uint32_t
328+ua_sensors_magnetic_get_min_delay(
329+ UASensorsMagnetic* sensor)
330+{
331+ if (sensor == NULL)
332+ return -1;
333+
334+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
335+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
336+ return toHz(s->min_delay());
337+}
338+
339+UStatus
340+ua_sensors_magnetic_get_min_value(
341+ UASensorsMagnetic* sensor,
342+ float* value)
343+{
344+ if (sensor == NULL || value == NULL)
345+ return U_STATUS_ERROR;
346+
347+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
348+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
349+ *value = s->min_value();
350+
351+ return U_STATUS_SUCCESS;
352+}
353+
354+UStatus
355+ua_sensors_magnetic_get_max_value(
356+ UASensorsMagnetic* sensor,
357+ float* value)
358+{
359+ if (sensor == NULL || value == NULL)
360+ return U_STATUS_ERROR;
361+
362+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
363+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
364+ *value = s->max_value();
365+
366+ return U_STATUS_SUCCESS;
367+}
368+
369+UStatus
370+ua_sensors_magnetic_get_resolution(
371+ UASensorsMagnetic* sensor,
372+ float* value)
373+{
374+ if (sensor == NULL || value == NULL)
375+ return U_STATUS_ERROR;
376+
377+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
378+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
379+ *value = s->resolution();
380+
381+ return U_STATUS_SUCCESS;
382+}
383+
384+void
385+ua_sensors_magnetic_set_reading_cb(
386+ UASensorsMagnetic* sensor,
387+ on_magnetic_event_cb cb,
388+ void *ctx)
389+{
390+ if (sensor == NULL)
391+ return;
392+
393+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
394+
395+ SensorListener<ubuntu::application::sensors::sensor_type_magnetic_field>* sl
396+ = new SensorListener<ubuntu::application::sensors::sensor_type_magnetic_field>();
397+
398+ sl->on_magnetic_event = cb;
399+ sl->context = ctx;
400+
401+ magnetic_listener = sl;
402+ s->register_listener(magnetic_listener);
403+}
404+
405+UStatus
406+ua_sensors_magnetic_set_event_rate(
407+ UASensorsMagnetic* sensor,
408+ uint32_t rate)
409+{
410+ if (sensor == NULL)
411+ return U_STATUS_ERROR;
412+
413+ ALOGI("%s():%d", __PRETTY_FUNCTION__, __LINE__);
414+ auto s = static_cast<ubuntu::application::sensors::Sensor*>(sensor);
415+ if (!s->set_event_rate(rate))
416+ return U_STATUS_ERROR;
417+
418+ return U_STATUS_SUCCESS;
419+}
420+
421+uint64_t
422+uas_magnetic_event_get_timestamp(
423+ UASMagneticEvent* event)
424+{
425+ auto ev = static_cast<ubuntu::application::sensors::MagneticEvent*>(event);
426+ return ev->get_timestamp();
427+}
428+
429+UStatus
430+uas_magnetic_event_get_magnetic_field_x(
431+ UASMagneticEvent* event,
432+ float* value)
433+{
434+ if (event == NULL || value == NULL)
435+ return U_STATUS_ERROR;
436+
437+ auto ev = static_cast<ubuntu::application::sensors::MagneticEvent*>(event);
438+ *value = ev->get_x();
439+
440+ return U_STATUS_SUCCESS;
441+}
442+
443+UStatus
444+uas_magnetic_event_get_magnetic_field_y(
445+ UASMagneticEvent* event,
446+ float* value)
447+{
448+ if (event == NULL || value == NULL)
449+ return U_STATUS_ERROR;
450+
451+ auto ev = static_cast<ubuntu::application::sensors::MagneticEvent*>(event);
452+ *value = ev->get_y();
453+
454+ return U_STATUS_SUCCESS;
455+}
456+
457+UStatus
458+uas_magnetic_event_get_magnetic_field_z(
459+ UASMagneticEvent* event,
460+ float* value)
461+{
462+ if (event == NULL || value == NULL)
463+ return U_STATUS_ERROR;
464+
465+ auto ev = static_cast<ubuntu::application::sensors::MagneticEvent*>(event);
466+ *value = ev->get_z();
467+
468+ return U_STATUS_SUCCESS;
469+}
470
471=== modified file 'android/hybris/test_sensors_c_api.cpp'
472--- android/hybris/test_sensors_c_api.cpp 2014-05-27 07:05:12 +0000
473+++ android/hybris/test_sensors_c_api.cpp 2016-04-04 06:59:06 +0000
474@@ -26,6 +26,8 @@
475 #include <ubuntu/application/sensors/proximity.h>
476 #include <ubuntu/application/sensors/light.h>
477 #include <ubuntu/application/sensors/orientation.h>
478+#include <ubuntu/application/sensors/gyroscope.h>
479+#include <ubuntu/application/sensors/magnetic.h>
480
481 void on_new_accelerometer_event(UASAccelerometerEvent* event, void* context)
482 {
483@@ -82,12 +84,40 @@
484 printf("\tz: %f\n", z);
485 }
486
487+void on_new_gyroscope_event(UASGyroscopeEvent* event, void* context)
488+{
489+ float x; uas_gyroscope_event_get_rate_of_rotation_around_x(event, &x);
490+ float y; uas_gyroscope_event_get_rate_of_rotation_around_y(event, &y);
491+ float z; uas_gyroscope_event_get_rate_of_rotation_around_z(event, &z);
492+
493+ printf("%s \n", __PRETTY_FUNCTION__);
494+ printf("\ttime: %" PRIu64 "\n", uas_gyroscope_event_get_timestamp(event));
495+ printf("\tomega_x: %f\n", x);
496+ printf("\tomega_y: %f\n", y);
497+ printf("\tomega_z: %f\n", z);
498+}
499+
500+void on_new_magnetic_event(UASGyroscopeEvent* event, void* context)
501+{
502+ float x; uas_magnetic_event_get_magnetic_field_x(event, &x);
503+ float y; uas_magnetic_event_get_magnetic_field_y(event, &y);
504+ float z; uas_magnetic_event_get_magnetic_field_z(event, &z);
505+
506+ printf("%s \n", __PRETTY_FUNCTION__);
507+ printf("\ttime: %" PRIu64 "\n", uas_magnetic_event_get_timestamp(event));
508+ printf("\tx: %f\n", x);
509+ printf("\ty: %f\n", y);
510+ printf("\tz: %f\n", z);
511+}
512+
513 int main(int argc, char** argv)
514 {
515 UASensorsAccelerometer* accelerometer = ua_sensors_accelerometer_new();
516 UASensorsProximity* proximity = ua_sensors_proximity_new();
517 UASensorsLight* ambientlight = ua_sensors_light_new();
518 UASensorsOrientation* orientation = ua_sensors_orientation_new();
519+ UASensorsGyroscope* gyroscope = ua_sensors_gyroscope_new();
520+ UASensorsMagnetic* magnetic = ua_sensors_magnetic_new();
521
522 ua_sensors_accelerometer_set_reading_cb(accelerometer,
523 on_new_accelerometer_event,
524@@ -105,10 +135,20 @@
525 on_new_orientation_event,
526 NULL);
527
528+ ua_sensors_gyroscope_set_reading_cb(gyroscope,
529+ on_new_gyroscope_event,
530+ NULL);
531+
532+ ua_sensors_magnetic_set_reading_cb(magnetic,
533+ on_new_magnetic_event,
534+ NULL);
535+
536 ua_sensors_accelerometer_enable(accelerometer);
537 ua_sensors_proximity_enable(proximity);
538 ua_sensors_light_enable(ambientlight);
539 ua_sensors_orientation_enable(orientation);
540+ ua_sensors_gyroscope_enable(gyroscope);
541+ ua_sensors_magnetic_enable(magnetic);
542
543 while(true)
544 {
545
546=== modified file 'android/include/private/application/sensors/events.h'
547--- android/include/private/application/sensors/events.h 2014-09-17 23:38:05 +0000
548+++ android/include/private/application/sensors/events.h 2016-04-04 06:59:06 +0000
549@@ -38,14 +38,14 @@
550 roll(roll)
551 {}
552
553- uint64_t get_timestamp()
554+ uint64_t get_timestamp() const
555 {
556 return this->timestamp;
557 }
558
559- float get_azimuth() { return this->azimuth; }
560- float get_pitch() { return this->pitch; }
561- float get_roll() { return this->roll; }
562+ float get_azimuth() const { return this->azimuth; }
563+ float get_pitch() const { return this->pitch; }
564+ float get_roll() const { return this->roll; }
565
566 private:
567 uint64_t timestamp;
568@@ -68,14 +68,14 @@
569 z(z)
570 {}
571
572- uint64_t get_timestamp()
573+ uint64_t get_timestamp() const
574 {
575 return this->timestamp;
576 }
577
578- float get_x() { return this->x; }
579- float get_y() { return this->y; }
580- float get_z() { return this->z; }
581+ float get_x() const { return this->x; }
582+ float get_y() const { return this->y; }
583+ float get_z() const { return this->z; }
584
585 private:
586 uint64_t timestamp;
587@@ -95,12 +95,12 @@
588 distance(distance)
589 {}
590
591- uint64_t get_timestamp()
592+ uint64_t get_timestamp() const
593 {
594 return this->timestamp;
595 }
596
597- float get_distance() { return this->distance; }
598+ float get_distance() const { return this->distance; }
599
600 private:
601 uint64_t timestamp;
602@@ -133,6 +133,66 @@
603 LightEvent(const LightEvent&) = delete;
604 LightEvent& operator=(const LightEvent&) = delete;
605 };
606+
607+class GyroscopeEvent
608+{
609+public:
610+ GyroscopeEvent(uint64_t timestamp, float x_rate, float y_rate, float z_rate)
611+ : timestamp(timestamp),
612+ x_rate(x_rate),
613+ y_rate(y_rate),
614+ z_rate(z_rate)
615+ {}
616+
617+ uint64_t get_timestamp() const
618+ {
619+ return this->timestamp;
620+ }
621+
622+ float get_x_rotation_rate() const { return this->x_rate; }
623+ float get_y_rotation_rate() const { return this->y_rate; }
624+ float get_z_rotation_rate() const { return this->z_rate; }
625+
626+private:
627+ uint64_t timestamp;
628+ float x_rate;
629+ float y_rate;
630+ float z_rate;
631+
632+protected:
633+ GyroscopeEvent(const GyroscopeEvent&) = delete;
634+ GyroscopeEvent& operator=(const GyroscopeEvent&) = delete;
635+};
636+
637+class MagneticEvent
638+{
639+public:
640+ MagneticEvent(uint64_t timestamp, float x, float y, float z)
641+ : timestamp(timestamp),
642+ x(x),
643+ y(y),
644+ z(z)
645+ {}
646+
647+ uint64_t get_timestamp() const
648+ {
649+ return this->timestamp;
650+ }
651+
652+ float get_x() const { return this->x; }
653+ float get_y() const { return this->y; }
654+ float get_z() const { return this->z; }
655+
656+private:
657+ uint64_t timestamp;
658+ float x;
659+ float y;
660+ float z;
661+
662+protected:
663+ MagneticEvent(const MagneticEvent&) = delete;
664+ MagneticEvent& operator=(const MagneticEvent&) = delete;
665+};
666 }
667 }
668 }
669
670=== modified file 'android/include/private/application/sensors/sensor_reading.h'
671--- android/include/private/application/sensors/sensor_reading.h 2013-05-30 02:03:42 +0000
672+++ android/include/private/application/sensors/sensor_reading.h 2016-04-04 06:59:06 +0000
673@@ -65,6 +65,7 @@
674 Vector<3> vector; ///< Arbitrary vector, orientation and linear acceleration readings are reported here.
675 Vector<3> acceleration; ///< Acceleration vector containing acceleration readings for the three axis.
676 Vector<3> magnetic; ///< Readings from magnetometer, in three dimensions.
677+ Vector<3> gyroscopic; ///< Readings from the gyroscope, rate of rotation in three dimensions.
678 float temperature; ///< Ambient temperature.
679 float distance; ///< Discrete distance, everything > 5 is considered far, everything < 5 is considered near.
680 float light; ///< Ambient light conditions.
681
682=== modified file 'debian/libubuntu-application-api3.symbols'
683--- debian/libubuntu-application-api3.symbols 2015-11-27 19:02:31 +0000
684+++ debian/libubuntu-application-api3.symbols 2016-04-04 06:59:06 +0000
685@@ -71,6 +71,15 @@
686 ua_sensors_accelerometer_new@Base 0.18.1daily13.06.21
687 ua_sensors_accelerometer_set_event_rate@Base 2.1.0+14.10.20140623.1
688 ua_sensors_accelerometer_set_reading_cb@Base 0.18.1daily13.06.21
689+ ua_sensors_gyroscope_disable@Base 0replaceme
690+ ua_sensors_gyroscope_enable@Base 0replaceme
691+ ua_sensors_gyroscope_get_max_value@Base 0replaceme
692+ ua_sensors_gyroscope_get_min_delay@Base 0replaceme
693+ ua_sensors_gyroscope_get_min_value@Base 0replaceme
694+ ua_sensors_gyroscope_get_resolution@Base 0replaceme
695+ ua_sensors_gyroscope_new@Base 0replaceme
696+ ua_sensors_gyroscope_set_event_rate@Base 0replaceme
697+ ua_sensors_gyroscope_set_reading_cb@Base 0replaceme
698 ua_sensors_haptic_destroy@Base 3.0.1+16.04.20151127
699 ua_sensors_haptic_disable@Base 2.0.0+14.10.20140612
700 ua_sensors_haptic_enable@Base 2.0.0+14.10.20140612
701@@ -86,6 +95,15 @@
702 ua_sensors_light_new@Base 0.18.1daily13.06.21
703 ua_sensors_light_set_event_rate@Base 2.1.0+14.10.20140623.1
704 ua_sensors_light_set_reading_cb@Base 0.18.1daily13.06.21
705+ ua_sensors_magnetic_disable@Base 0replaceme
706+ ua_sensors_magnetic_enable@Base 0replaceme
707+ ua_sensors_magnetic_get_max_value@Base 0replaceme
708+ ua_sensors_magnetic_get_min_delay@Base 0replaceme
709+ ua_sensors_magnetic_get_min_value@Base 0replaceme
710+ ua_sensors_magnetic_get_resolution@Base 0replaceme
711+ ua_sensors_magnetic_new@Base 0replaceme
712+ ua_sensors_magnetic_set_event_rate@Base 0replaceme
713+ ua_sensors_magnetic_set_reading_cb@Base 0replaceme
714 ua_sensors_orientation_disable@Base 2.1.0+14.10.20140623.1
715 ua_sensors_orientation_enable@Base 2.1.0+14.10.20140623.1
716 ua_sensors_orientation_get_max_value@Base 2.1.0+14.10.20140623.1
717@@ -110,8 +128,16 @@
718 uas_accelerometer_event_get_acceleration_y@Base 0.18.1daily13.06.21
719 uas_accelerometer_event_get_acceleration_z@Base 0.18.1daily13.06.21
720 uas_accelerometer_event_get_timestamp@Base 0.18.1daily13.06.21
721+ uas_gyroscope_event_get_rate_of_rotation_around_x@Base 0replaceme
722+ uas_gyroscope_event_get_rate_of_rotation_around_y@Base 0replaceme
723+ uas_gyroscope_event_get_rate_of_rotation_around_z@Base 0replaceme
724+ uas_gyroscope_event_get_timestamp@Base 0replaceme
725 uas_light_event_get_light@Base 0.18.1daily13.06.21
726 uas_light_event_get_timestamp@Base 0.18.1daily13.06.21
727+ uas_magnetic_event_get_magnetic_field_x@Base 0replaceme
728+ uas_magnetic_event_get_magnetic_field_y@Base 0replaceme
729+ uas_magnetic_event_get_magnetic_field_z@Base 0replaceme
730+ uas_magnetic_event_get_timestamp@Base 0replaceme
731 uas_orientation_event_get_azimuth@Base 2.1.0+14.10.20140623.1
732 uas_orientation_event_get_pitch@Base 2.1.0+14.10.20140623.1
733 uas_orientation_event_get_roll@Base 2.1.0+14.10.20140623.1
734
735=== modified file 'examples/test_sensors_api.cpp'
736--- examples/test_sensors_api.cpp 2014-06-16 13:42:24 +0000
737+++ examples/test_sensors_api.cpp 2016-04-04 06:59:06 +0000
738@@ -26,6 +26,8 @@
739 #include <ubuntu/application/sensors/proximity.h>
740 #include <ubuntu/application/sensors/light.h>
741 #include <ubuntu/application/sensors/orientation.h>
742+#include <ubuntu/application/sensors/gyroscope.h>
743+#include <ubuntu/application/sensors/magnetic.h>
744
745 void on_new_accelerometer_event(UASAccelerometerEvent* event, void* context)
746 {
747@@ -82,12 +84,40 @@
748 printf("\tz: %f\n", z);
749 }
750
751+void on_new_gyroscope_event(UASGyroscopeEvent* event, void* context)
752+{
753+ float x; uas_gyroscope_event_get_rate_of_rotation_around_x(event, &x);
754+ float y; uas_gyroscope_event_get_rate_of_rotation_around_y(event, &y);
755+ float z; uas_gyroscope_event_get_rate_of_rotation_around_z(event, &z);
756+
757+ printf("%s \n", __PRETTY_FUNCTION__);
758+ printf("\ttime: %" PRIu64 "\n", uas_gyroscope_event_get_timestamp(event));
759+ printf("\tomega_x: %f\n", x);
760+ printf("\tomega_y: %f\n", y);
761+ printf("\tomega_z: %f\n", z);
762+}
763+
764+void on_new_magnetic_event(UASMagneticEvent* event, void* context)
765+{
766+ float x; uas_magnetic_event_get_magnetic_field_x(event, &x);
767+ float y; uas_magnetic_event_get_magnetic_field_y(event, &y);
768+ float z; uas_magnetic_event_get_magnetic_field_z(event, &z);
769+
770+ printf("%s \n", __PRETTY_FUNCTION__);
771+ printf("\ttime: %" PRIu64 "\n", uas_magnetic_event_get_timestamp(event));
772+ printf("\tx: %f\n", x);
773+ printf("\ty: %f\n", y);
774+ printf("\tz: %f\n", z);
775+}
776+
777 int main(int argc, char** argv)
778 {
779 UASensorsAccelerometer* accelerometer = ua_sensors_accelerometer_new();
780 UASensorsProximity* proximity = ua_sensors_proximity_new();
781 UASensorsLight* ambientlight = ua_sensors_light_new();
782 UASensorsOrientation* orientation = ua_sensors_orientation_new();
783+ UASensorsGyroscope* gyroscope = ua_sensors_gyroscope_new();
784+ UASensorsMagnetic* magnetic = ua_sensors_magnetic_new();
785
786 ua_sensors_accelerometer_set_reading_cb(accelerometer,
787 on_new_accelerometer_event,
788@@ -105,10 +135,20 @@
789 on_new_orientation_event,
790 NULL);
791
792+ ua_sensors_gyroscope_set_reading_cb(gyroscope,
793+ on_new_gyroscope_event,
794+ NULL);
795+
796+ ua_sensors_magnetic_set_reading_cb(magnetic,
797+ on_new_magnetic_event,
798+ NULL);
799+
800 ua_sensors_accelerometer_enable(accelerometer);
801 ua_sensors_proximity_enable(proximity);
802 ua_sensors_light_enable(ambientlight);
803 ua_sensors_orientation_enable(orientation);
804+ ua_sensors_gyroscope_enable(gyroscope);
805+ ua_sensors_magnetic_enable(magnetic);
806
807 while(true)
808 {
809
810=== modified file 'include/ubuntu/application/sensors/CMakeLists.txt'
811--- include/ubuntu/application/sensors/CMakeLists.txt 2014-05-27 07:54:20 +0000
812+++ include/ubuntu/application/sensors/CMakeLists.txt 2016-04-04 06:59:06 +0000
813@@ -1,7 +1,9 @@
814 set(
815 UBUNTU_APPLICATION_SENSORS_HEADERS
816 accelerometer.h
817+ gyroscope.h
818 light.h
819+ magnetic.h
820 proximity.h
821 haptic.h
822 orientation.h
823
824=== modified file 'include/ubuntu/application/sensors/event/CMakeLists.txt'
825--- include/ubuntu/application/sensors/event/CMakeLists.txt 2014-05-27 07:54:20 +0000
826+++ include/ubuntu/application/sensors/event/CMakeLists.txt 2016-04-04 06:59:06 +0000
827@@ -1,7 +1,9 @@
828 set(
829 UBUNTU_APPLICATION_SENSORS_EVENT_HEADERS
830 accelerometer.h
831+ gyroscope.h
832 light.h
833+ magnetic.h
834 proximity.h
835 orientation.h
836 )
837
838=== added file 'include/ubuntu/application/sensors/event/gyroscope.h'
839--- include/ubuntu/application/sensors/event/gyroscope.h 1970-01-01 00:00:00 +0000
840+++ include/ubuntu/application/sensors/event/gyroscope.h 2016-04-04 06:59:06 +0000
841@@ -0,0 +1,86 @@
842+/*
843+ * Copyright (C) 2015 Canonical, Ltd.
844+ *
845+ * This program is free software: you can redistribute it and/or modify it under
846+ * the terms of the GNU Lesser General Public License version 3, as published by
847+ * the Free Software Foundation.
848+ *
849+ * This program is distributed in the hope that it will be useful, but WITHOUT
850+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
851+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
852+ * Lesser General Public License for more details.
853+ *
854+ * You should have received a copy of the GNU Lesser General Public License
855+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
856+ *
857+ * Author: Gerry Boland <gerry.boland@canonical.com>
858+ */
859+
860+#ifndef UBUNTU_APPLICATION_SENSORS_GYROSCOPE_EVENT_H_
861+#define UBUNTU_APPLICATION_SENSORS_GYROSCOPE_EVENT_H_
862+
863+#include <ubuntu/visibility.h>
864+
865+#include <stdint.h>
866+
867+#ifdef __cplusplus
868+extern "C" {
869+#endif
870+
871+ /**
872+ * \brief Opaque type describing a gyroscope reading.
873+ * \ingroup sensor_access
874+ */
875+ typedef void UASGyroscopeEvent;
876+
877+ /**
878+ * \brief Query the timestamp of the sensor reading.
879+ * \ingroup sensor_access
880+ * \returns The timestamp of the sensor reading in [µs], timebase: monotonic clock.
881+ * \param[in] event The reading to be queried.
882+ */
883+ UBUNTU_DLL_PUBLIC uint64_t
884+ uas_gyroscope_event_get_timestamp(
885+ UASGyroscopeEvent* event);
886+
887+ /**
888+ * \brief Query the rate of rotation around the x-axis.
889+ * \ingroup sensor_access
890+ * \returns The rate of rotation around the x-axis in radians per second.
891+ * Positive values indicate counter-clockwise rotation
892+ * \param[in] event The reading to be queried.
893+ */
894+ UBUNTU_DLL_PUBLIC UStatus
895+ uas_gyroscope_event_get_rate_of_rotation_around_x(
896+ UASGyroscopeEvent* event,
897+ float* value);
898+
899+ /**
900+ * \brief Query the rate of rotation around the y-axis.
901+ * \ingroup sensor_access
902+ * \returns The rate of rotation around the y-axis in radians per second.
903+ * Positive values indicate counter-clockwise rotation
904+ * \param[in] event The reading to be queried.
905+ */
906+ UBUNTU_DLL_PUBLIC UStatus
907+ uas_gyroscope_event_get_rate_of_rotation_around_y(
908+ UASGyroscopeEvent* event,
909+ float* value);
910+
911+ /**
912+ * \brief Query the rate of rotation around the z-axis.
913+ * \ingroup sensor_access
914+ * \returns The rate of rotation around the z-axis in radians per second.
915+ * Positive values indicate counter-clockwise rotation
916+ * \param[in] event The reading to be queried.
917+ */
918+ UBUNTU_DLL_PUBLIC UStatus
919+ uas_gyroscope_event_get_rate_of_rotation_around_z(
920+ UASGyroscopeEvent* event,
921+ float* value);
922+
923+#ifdef __cplusplus
924+}
925+#endif
926+
927+#endif // UBUNTU_APPLICATION_SENSORS_GYROSCOPE_EVENT_H_
928
929=== added file 'include/ubuntu/application/sensors/event/magnetic.h'
930--- include/ubuntu/application/sensors/event/magnetic.h 1970-01-01 00:00:00 +0000
931+++ include/ubuntu/application/sensors/event/magnetic.h 2016-04-04 06:59:06 +0000
932@@ -0,0 +1,81 @@
933+/*
934+ * Copyright (C) 2015 Canonical, Ltd.
935+ *
936+ * This program is free software: you can redistribute it and/or modify it under
937+ * the terms of the GNU Lesser General Public License version 3, as published by
938+ * the Free Software Foundation.
939+ *
940+ * This program is distributed in the hope that it will be useful, but WITHOUT
941+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
942+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
943+ * Lesser General Public License for more details.
944+ *
945+ * You should have received a copy of the GNU Lesser General Public License
946+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
947+ */
948+
949+#ifndef UBUNTU_APPLICATION_SENSORS_MAGNETIC_EVENT_H_
950+#define UBUNTU_APPLICATION_SENSORS_MAGNETIC_EVENT_H_
951+
952+#include <ubuntu/visibility.h>
953+
954+#include <stdint.h>
955+
956+#ifdef __cplusplus
957+extern "C" {
958+#endif
959+
960+ /**
961+ * \brief Opaque type describing a magnetic field reading.
962+ * \ingroup sensor_access
963+ */
964+ typedef void UASMagneticEvent;
965+
966+ /**
967+ * \brief Query the timestamp of the sensor reading.
968+ * \ingroup sensor_access
969+ * \returns The timestamp of the sensor reading in [µs], timebase: monotonic clock.
970+ * \param[in] event The reading to be queried.
971+ */
972+ UBUNTU_DLL_PUBLIC uint64_t
973+ uas_magnetic_event_get_timestamp(
974+ UASMagneticEvent* event);
975+
976+ /**
977+ * \brief Query the intensity of the magnetic field in the x-axis.
978+ * \ingroup sensor_access
979+ * \returns The intensity of the magnetic field in the x-axis in micro-Tesla (uT)
980+ * \param[in] event The reading to be queried.
981+ */
982+ UBUNTU_DLL_PUBLIC UStatus
983+ uas_magnetic_event_get_magnetic_field_x(
984+ UASMagneticEvent* event,
985+ float* value);
986+
987+ /**
988+ * \brief Query the intensity of the magnetic field in the x-axis.
989+ * \ingroup sensor_access
990+ * \returns The intensity of the magnetic field in the x-axis in micro-Tesla (uT)
991+ * \param[in] event The reading to be queried.
992+ */
993+ UBUNTU_DLL_PUBLIC UStatus
994+ uas_magnetic_event_get_magnetic_field_y(
995+ UASMagneticEvent* event,
996+ float* value);
997+
998+ /**
999+ * \brief Query the intensity of the magnetic field in the x-axis.
1000+ * \ingroup sensor_access
1001+ * \returns The intensity of the magnetic field in the x-axis in micro-Tesla (uT)
1002+ * \param[in] event The reading to be queried.
1003+ */
1004+ UBUNTU_DLL_PUBLIC UStatus
1005+ uas_magnetic_event_get_magnetic_field_z(
1006+ UASMagneticEvent* event,
1007+ float* value);
1008+
1009+#ifdef __cplusplus
1010+}
1011+#endif
1012+
1013+#endif // UBUNTU_APPLICATION_SENSORS_MAGNETIC_EVENT_H_
1014
1015=== added file 'include/ubuntu/application/sensors/gyroscope.h'
1016--- include/ubuntu/application/sensors/gyroscope.h 1970-01-01 00:00:00 +0000
1017+++ include/ubuntu/application/sensors/gyroscope.h 2016-04-04 06:59:06 +0000
1018@@ -0,0 +1,144 @@
1019+/*
1020+ * Copyright (C) 2015 Canonical, Ltd.
1021+ *
1022+ * This program is free software: you can redistribute it and/or modify it under
1023+ * the terms of the GNU Lesser General Public License version 3, as published by
1024+ * the Free Software Foundation.
1025+ *
1026+ * This program is distributed in the hope that it will be useful, but WITHOUT
1027+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1028+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1029+ * Lesser General Public License for more details.
1030+ *
1031+ * You should have received a copy of the GNU Lesser General Public License
1032+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1033+ *
1034+ * Copyright: Gerry Boland <gerry.boland@canonical.com>
1035+ */
1036+
1037+#ifndef UBUNTU_APPLICATION_SENSORS_GYROSCOPE_H_
1038+#define UBUNTU_APPLICATION_SENSORS_GYROSCOPE_H_
1039+
1040+#include <ubuntu/status.h>
1041+#include <ubuntu/visibility.h>
1042+
1043+#include <ubuntu/application/sensors/event/gyroscope.h>
1044+
1045+#ifdef __cplusplus
1046+extern "C" {
1047+#endif
1048+
1049+ /**
1050+ * \brief Opaque type that models the gyroscope.
1051+ * \ingroup sensor_access
1052+ */
1053+ typedef void UASensorsGyroscope;
1054+
1055+ /**
1056+ * \brief Callback type used by applications to subscribe to orientation events.
1057+ * \ingroup sensor_access
1058+ */
1059+ typedef void (*on_gyroscope_event_cb)(UASGyroscopeEvent* event,
1060+ void* context);
1061+
1062+ /**
1063+ * \brief Create a new object for accessing the gyroscopic sensor.
1064+ * \ingroup sensor_access
1065+ * \returns A new instance or NULL in case of errors.
1066+ */
1067+ UBUNTU_DLL_PUBLIC UASensorsGyroscope*
1068+ ua_sensors_gyroscope_new();
1069+
1070+ /**
1071+ * \brief Enables the supplied gyroscopic sensor.
1072+ * \ingroup sensor_access
1073+ * \returns U_STATUS_SUCCESS if successful or U_STATUS_ERROR if an error occured.
1074+ * \param[in] sensor The sensor instance to be enabled.
1075+ */
1076+ UBUNTU_DLL_PUBLIC UStatus
1077+ ua_sensors_gyroscope_enable(
1078+ UASensorsGyroscope* sensor);
1079+
1080+ /**
1081+ * \brief Disables the supplied gyroscopic sensor.
1082+ * \ingroup sensor_access
1083+ * \returns U_STATUS_SUCCESS if successful or U_STATUS_ERROR if an error occured.
1084+ * \param[in] sensor The sensor instance to be disabled.
1085+ */
1086+ UBUNTU_DLL_PUBLIC UStatus
1087+ ua_sensors_gyroscope_disable(
1088+ UASensorsGyroscope* sensor);
1089+
1090+ /**
1091+ * \brief Queries the minimum delay between two readings for the supplied sensor.
1092+ * \ingroup sensor_access
1093+ * \returns The minimum delay between two readings in [ms].
1094+ * \param[in] sensor The sensor instance to be queried.
1095+ */
1096+ UBUNTU_DLL_PUBLIC uint32_t
1097+ ua_sensors_gyroscope_get_min_delay(
1098+ UASensorsGyroscope* sensor);
1099+
1100+ /**
1101+ * \brief Queries the minimum value that can be reported by the sensor.
1102+ * \ingroup sensor_access
1103+ * \returns The minimum value that can be reported by the sensor.
1104+ * \param[in] sensor The sensor instance to be queried.
1105+ */
1106+ UBUNTU_DLL_PUBLIC UStatus
1107+ ua_sensors_gyroscope_get_min_value(
1108+ UASensorsGyroscope* sensor,
1109+ float* value);
1110+
1111+ /**
1112+ * \brief Queries the maximum value that can be reported by the sensor.
1113+ * \ingroup sensor_access
1114+ * \returns The maximum value that can be reported by the sensor.
1115+ * \param[in] sensor The sensor instance to be queried.
1116+ */
1117+ UBUNTU_DLL_PUBLIC UStatus
1118+ ua_sensors_gyroscope_get_max_value(
1119+ UASensorsGyroscope* sensor,
1120+ float* value);
1121+
1122+ /**
1123+ * \brief Queries the numeric resolution supported by the sensor
1124+ * \ingroup sensor_access
1125+ * \returns The numeric resolution supported by the sensor.
1126+ * \param[in] sensor The sensor instance to be queried.
1127+ */
1128+ UBUNTU_DLL_PUBLIC UStatus
1129+ ua_sensors_gyroscope_get_resolution(
1130+ UASensorsGyroscope* sensor,
1131+ float* value);
1132+
1133+ /**
1134+ * \brief Set the callback to be invoked whenever a new sensor reading is available.
1135+ * \ingroup sensor_access
1136+ * \param[in] sensor The sensor instance to associate the callback with.
1137+ * \param[in] cb The callback to be invoked.
1138+ * \param[in] ctx The context supplied to the callback invocation.
1139+ */
1140+ UBUNTU_DLL_PUBLIC void
1141+ ua_sensors_gyroscope_set_reading_cb(
1142+ UASensorsGyroscope* sensor,
1143+ on_gyroscope_event_cb cb,
1144+ void *ctx);
1145+
1146+ /**
1147+ * \brief Set the sensor event delivery rate in nanoseconds..
1148+ * \ingroup sensor_access
1149+ * \returns U_STATUS_SUCCESS if successful or U_STATUS_ERROR if an error occured.
1150+ * \param[in] sensor The sensor instance to be modified.
1151+ * \param[in] rate The new event delivery rate.
1152+ */
1153+ UBUNTU_DLL_PUBLIC UStatus
1154+ ua_sensors_gyroscope_set_event_rate(
1155+ UASensorsGyroscope* sensor,
1156+ uint32_t rate);
1157+
1158+#ifdef __cplusplus
1159+}
1160+#endif
1161+
1162+#endif // UBUNTU_APPLICATION_SENSORS_GYROSCOPE_H_
1163
1164=== added file 'include/ubuntu/application/sensors/magnetic.h'
1165--- include/ubuntu/application/sensors/magnetic.h 1970-01-01 00:00:00 +0000
1166+++ include/ubuntu/application/sensors/magnetic.h 2016-04-04 06:59:06 +0000
1167@@ -0,0 +1,142 @@
1168+/*
1169+ * Copyright (C) 2015 Canonical, Ltd.
1170+ *
1171+ * This program is free software: you can redistribute it and/or modify it under
1172+ * the terms of the GNU Lesser General Public License version 3, as published by
1173+ * the Free Software Foundation.
1174+ *
1175+ * This program is distributed in the hope that it will be useful, but WITHOUT
1176+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1177+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1178+ * Lesser General Public License for more details.
1179+ *
1180+ * You should have received a copy of the GNU Lesser General Public License
1181+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1182+ */
1183+
1184+#ifndef UBUNTU_APPLICATION_SENSORS_MAGNETIC_H_
1185+#define UBUNTU_APPLICATION_SENSORS_MAGNETIC_H_
1186+
1187+#include <ubuntu/status.h>
1188+#include <ubuntu/visibility.h>
1189+
1190+#include <ubuntu/application/sensors/event/magnetic.h>
1191+
1192+#ifdef __cplusplus
1193+extern "C" {
1194+#endif
1195+
1196+ /**
1197+ * \brief Opaque type that models the Magnetic field.
1198+ * \ingroup sensor_access
1199+ */
1200+ typedef void UASensorsMagnetic;
1201+
1202+ /**
1203+ * \brief Callback type used by applications to subscribe to magnetic sensor events.
1204+ * \ingroup sensor_access
1205+ */
1206+ typedef void (*on_magnetic_event_cb)(UASMagneticEvent* event,
1207+ void* context);
1208+
1209+ /**
1210+ * \brief Create a new object for accessing the magnetic field sensor.
1211+ * \ingroup sensor_access
1212+ * \returns A new instance or NULL in case of errors.
1213+ */
1214+ UBUNTU_DLL_PUBLIC UASensorsMagnetic*
1215+ ua_sensors_magnetic_new();
1216+
1217+ /**
1218+ * \brief Enables the supplied magnetic field sensor.
1219+ * \ingroup sensor_access
1220+ * \returns U_STATUS_SUCCESS if successful or U_STATUS_ERROR if an error occured.
1221+ * \param[in] sensor The sensor instance to be enabled.
1222+ */
1223+ UBUNTU_DLL_PUBLIC UStatus
1224+ ua_sensors_magnetic_enable(
1225+ UASensorsMagnetic* sensor);
1226+
1227+ /**
1228+ * \brief Disables the supplied magnetic field sensor.
1229+ * \ingroup sensor_access
1230+ * \returns U_STATUS_SUCCESS if successful or U_STATUS_ERROR if an error occured.
1231+ * \param[in] sensor The sensor instance to be disabled.
1232+ */
1233+ UBUNTU_DLL_PUBLIC UStatus
1234+ ua_sensors_magnetic_disable(
1235+ UASensorsMagnetic* sensor);
1236+
1237+ /**
1238+ * \brief Queries the minimum delay between two readings for the supplied sensor.
1239+ * \ingroup sensor_access
1240+ * \returns The minimum delay between two readings in [ms].
1241+ * \param[in] sensor The sensor instance to be queried.
1242+ */
1243+ UBUNTU_DLL_PUBLIC uint32_t
1244+ ua_sensors_magnetic_get_min_delay(
1245+ UASensorsMagnetic* sensor);
1246+
1247+ /**
1248+ * \brief Queries the minimum value that can be reported by the sensor.
1249+ * \ingroup sensor_access
1250+ * \returns The minimum value that can be reported by the sensor.
1251+ * \param[in] sensor The sensor instance to be queried.
1252+ */
1253+ UBUNTU_DLL_PUBLIC UStatus
1254+ ua_sensors_magnetic_get_min_value(
1255+ UASensorsMagnetic* sensor,
1256+ float* value);
1257+
1258+ /**
1259+ * \brief Queries the maximum value that can be reported by the sensor.
1260+ * \ingroup sensor_access
1261+ * \returns The maximum value that can be reported by the sensor.
1262+ * \param[in] sensor The sensor instance to be queried.
1263+ */
1264+ UBUNTU_DLL_PUBLIC UStatus
1265+ ua_sensors_magnetic_get_max_value(
1266+ UASensorsMagnetic* sensor,
1267+ float* value);
1268+
1269+ /**
1270+ * \brief Queries the numeric resolution supported by the sensor
1271+ * \ingroup sensor_access
1272+ * \returns The numeric resolution supported by the sensor.
1273+ * \param[in] sensor The sensor instance to be queried.
1274+ */
1275+ UBUNTU_DLL_PUBLIC UStatus
1276+ ua_sensors_magnetic_get_resolution(
1277+ UASensorsMagnetic* sensor,
1278+ float* value);
1279+
1280+ /**
1281+ * \brief Set the callback to be invoked whenever a new sensor reading is available.
1282+ * \ingroup sensor_access
1283+ * \param[in] sensor The sensor instance to associate the callback with.
1284+ * \param[in] cb The callback to be invoked.
1285+ * \param[in] ctx The context supplied to the callback invocation.
1286+ */
1287+ UBUNTU_DLL_PUBLIC void
1288+ ua_sensors_magnetic_set_reading_cb(
1289+ UASensorsMagnetic* sensor,
1290+ on_magnetic_event_cb cb,
1291+ void *ctx);
1292+
1293+ /**
1294+ * \brief Set the sensor event delivery rate in nanoseconds..
1295+ * \ingroup sensor_access
1296+ * \returns U_STATUS_SUCCESS if successful or U_STATUS_ERROR if an error occured.
1297+ * \param[in] sensor The sensor instance to be modified.
1298+ * \param[in] rate The new event delivery rate.
1299+ */
1300+ UBUNTU_DLL_PUBLIC UStatus
1301+ ua_sensors_magnetic_set_event_rate(
1302+ UASensorsMagnetic* sensor,
1303+ uint32_t rate);
1304+
1305+#ifdef __cplusplus
1306+}
1307+#endif
1308+
1309+#endif /* UBUNTU_APPLICATION_SENSORS_MAGNETIC_H_ */
1310
1311=== modified file 'src/ubuntu/application/desktop/ubuntu_application_sensors_desktop.cpp'
1312--- src/ubuntu/application/desktop/ubuntu_application_sensors_desktop.cpp 2014-06-24 20:22:01 +0000
1313+++ src/ubuntu/application/desktop/ubuntu_application_sensors_desktop.cpp 2016-04-04 06:59:06 +0000
1314@@ -20,6 +20,8 @@
1315 #include <ubuntu/application/sensors/proximity.h>
1316 #include <ubuntu/application/sensors/light.h>
1317 #include <ubuntu/application/sensors/orientation.h>
1318+#include <ubuntu/application/sensors/gyroscope.h>
1319+#include <ubuntu/application/sensors/magnetic.h>
1320
1321 #include <stddef.h>
1322
1323@@ -364,3 +366,195 @@
1324
1325 return U_STATUS_SUCCESS;
1326 }
1327+
1328+// Gyroscope Sensor
1329+UASensorsGyroscope* ua_sensors_gyroscope_new()
1330+{
1331+ return NULL;
1332+}
1333+
1334+UStatus ua_sensors_gyroscope_enable(UASensorsGyroscope*)
1335+{
1336+ return (UStatus) 0;
1337+}
1338+
1339+UStatus ua_sensors_gyroscope_disable(UASensorsGyroscope*)
1340+{
1341+ return (UStatus) 0;
1342+}
1343+
1344+uint32_t ua_sensors_gyroscope_get_min_delay(UASensorsGyroscope*)
1345+{
1346+ return 0;
1347+}
1348+
1349+UStatus ua_sensors_gyroscope_get_min_value(UASensorsGyroscope*, float* value)
1350+{
1351+ if (!value)
1352+ return U_STATUS_ERROR;
1353+
1354+ *value = 0.f;
1355+
1356+ return U_STATUS_SUCCESS;
1357+}
1358+
1359+UStatus ua_sensors_gyroscope_get_max_value(UASensorsGyroscope*, float* value)
1360+{
1361+ if (!value)
1362+ return U_STATUS_ERROR;
1363+
1364+ *value = 0.f;
1365+
1366+ return U_STATUS_SUCCESS;
1367+}
1368+
1369+UStatus ua_sensors_gyroscope_get_resolution(UASensorsGyroscope*, float* value)
1370+{
1371+ if (!value)
1372+ return U_STATUS_ERROR;
1373+
1374+ *value = 0.f;
1375+
1376+ return U_STATUS_SUCCESS;
1377+}
1378+
1379+void ua_sensors_gyroscope_set_reading_cb(UASensorsGyroscope*, on_gyroscope_event_cb, void *)
1380+{
1381+}
1382+
1383+UStatus ua_sensors_gyroscope_set_event_rate(UASensorsGyroscope*, uint32_t)
1384+{
1385+ return U_STATUS_SUCCESS;
1386+}
1387+
1388+// Gyroscope Sensor Event
1389+uint64_t uas_gyroscope_event_get_timestamp(UASGyroscopeEvent*)
1390+{
1391+ return 0;
1392+}
1393+
1394+UStatus uas_gyroscope_event_get_rate_of_rotation_around_x(UASGyroscopeEvent*, float* value)
1395+{
1396+ if (!value)
1397+ return U_STATUS_ERROR;
1398+
1399+ *value = 0.f;
1400+
1401+ return U_STATUS_SUCCESS;
1402+}
1403+
1404+UStatus uas_gyroscope_event_get_rate_of_rotation_around_y(UASGyroscopeEvent*, float* value)
1405+{
1406+ if (!value)
1407+ return U_STATUS_ERROR;
1408+
1409+ *value = 0.f;
1410+
1411+ return U_STATUS_SUCCESS;
1412+}
1413+
1414+UStatus uas_gyroscope_event_get_rate_of_rotation_around_z(UASGyroscopeEvent*, float* value)
1415+{
1416+ if (!value)
1417+ return U_STATUS_ERROR;
1418+
1419+ *value = 0.f;
1420+
1421+ return U_STATUS_SUCCESS;
1422+}
1423+
1424+// Magnetic Field Sensor
1425+UASensorsMagnetic* ua_sensors_magnetic_new()
1426+{
1427+ return NULL;
1428+}
1429+
1430+UStatus ua_sensors_magnetic_enable(UASensorsMagnetic*)
1431+{
1432+ return (UStatus) 0;
1433+}
1434+
1435+UStatus ua_sensors_magnetic_disable(UASensorsMagnetic*)
1436+{
1437+ return (UStatus) 0;
1438+}
1439+
1440+uint32_t ua_sensors_magnetic_get_min_delay(UASensorsMagnetic*)
1441+{
1442+ return 0;
1443+}
1444+
1445+UStatus ua_sensors_magnetic_get_min_value(UASensorsMagnetic*, float* value)
1446+{
1447+ if (!value)
1448+ return U_STATUS_ERROR;
1449+
1450+ *value = 0.f;
1451+
1452+ return U_STATUS_SUCCESS;
1453+}
1454+
1455+UStatus ua_sensors_magnetic_get_max_value(UASensorsMagnetic*, float* value)
1456+{
1457+ if (!value)
1458+ return U_STATUS_ERROR;
1459+
1460+ *value = 0.f;
1461+
1462+ return U_STATUS_SUCCESS;
1463+}
1464+
1465+UStatus ua_sensors_magnetic_get_resolution(UASensorsMagnetic*, float* value)
1466+{
1467+ if (!value)
1468+ return U_STATUS_ERROR;
1469+
1470+ *value = 0.f;
1471+
1472+ return U_STATUS_SUCCESS;
1473+}
1474+
1475+UStatus ua_sensors_magnetic_set_event_rate(UASensorsMagnetic* s, uint32_t rate)
1476+{
1477+ return U_STATUS_SUCCESS;
1478+}
1479+
1480+void ua_sensors_magnetic_set_reading_cb(UASensorsMagnetic*, on_magnetic_event_cb, void*)
1481+{
1482+}
1483+
1484+// Acceleration Sensor Event
1485+uint64_t uas_magnetic_event_get_timestamp(UASMagneticEvent*)
1486+{
1487+ return 0;
1488+}
1489+
1490+UStatus uas_magnetic_event_get_magnetic_field_x(UASMagneticEvent*, float* value)
1491+{
1492+ if (!value)
1493+ return U_STATUS_ERROR;
1494+
1495+ *value = 0.f;
1496+
1497+ return U_STATUS_SUCCESS;
1498+}
1499+
1500+UStatus uas_magnetic_event_get_magnetic_field_y(UASMagneticEvent*, float* value)
1501+{
1502+ if (!value)
1503+ return U_STATUS_ERROR;
1504+
1505+ *value = 0.f;
1506+
1507+ return U_STATUS_SUCCESS;
1508+}
1509+
1510+UStatus uas_magnetic_event_get_magnetic_field_z(UASMagneticEvent*, float* value)
1511+{
1512+ if (!value)
1513+ return U_STATUS_ERROR;
1514+
1515+ *value = 0.f;
1516+
1517+ return U_STATUS_SUCCESS;
1518+}
1519
1520=== modified file 'src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp'
1521--- src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp 2015-01-22 19:37:40 +0000
1522+++ src/ubuntu/application/testbackend/ubuntu_application_sensors.cpp 2016-04-04 06:59:06 +0000
1523@@ -27,6 +27,8 @@
1524 #include <ubuntu/application/sensors/light.h>
1525 #include <ubuntu/application/sensors/orientation.h>
1526 #include <ubuntu/application/sensors/haptic.h>
1527+#include <ubuntu/application/sensors/gyroscope.h>
1528+#include <ubuntu/application/sensors/magnetic.h>
1529
1530 #include <cstddef>
1531 #include <cstdlib>
1532@@ -865,3 +867,214 @@
1533
1534 return U_STATUS_SUCCESS;
1535 }
1536+
1537+
1538+/***************************************
1539+ *
1540+ * Gyroscope API
1541+ *
1542+ ***************************************/
1543+
1544+UASensorsGyroscope* ua_sensors_gyroscope_new()
1545+{
1546+ return SensorController::instance().get(ubuntu_sensor_type_gyroscope);
1547+}
1548+
1549+UStatus ua_sensors_gyroscope_enable(UASensorsGyroscope* s)
1550+{
1551+ static_cast<TestSensor*>(s)->enabled = true;
1552+ return (UStatus) 0;
1553+}
1554+
1555+UStatus ua_sensors_gyroscope_disable(UASensorsGyroscope* s)
1556+{
1557+ static_cast<TestSensor*>(s)->enabled = true;
1558+ return (UStatus) 0;}
1559+
1560+uint32_t ua_sensors_gyroscope_get_min_delay(UASensorsGyroscope* s)
1561+{
1562+ return static_cast<TestSensor*>(s)->min_delay;
1563+}
1564+
1565+UStatus ua_sensors_gyroscope_get_min_value(UASensorsGyroscope* s, float* value)
1566+{
1567+ if (!value)
1568+ return U_STATUS_ERROR;
1569+
1570+ *value = static_cast<TestSensor*>(s)->min_value;
1571+
1572+ return U_STATUS_SUCCESS;
1573+}
1574+
1575+UStatus ua_sensors_gyroscope_get_max_value(UASensorsGyroscope* s, float* value)
1576+{
1577+ if (!value)
1578+ return U_STATUS_ERROR;
1579+
1580+ *value = static_cast<TestSensor*>(s)->max_value;
1581+
1582+ return U_STATUS_SUCCESS;
1583+}
1584+
1585+UStatus ua_sensors_gyroscope_get_resolution(UASensorsGyroscope* s, float* value)
1586+{
1587+ if (!value)
1588+ return U_STATUS_ERROR;
1589+
1590+ *value = static_cast<TestSensor*>(s)->resolution;
1591+
1592+ return U_STATUS_SUCCESS;
1593+}
1594+
1595+void ua_sensors_gyroscope_set_reading_cb(UASensorsGyroscope* s, on_gyroscope_event_cb cb, void *ctx)
1596+{
1597+ TestSensor* sensor = static_cast<TestSensor*>(s);
1598+ sensor->on_event_cb = cb;
1599+ sensor->event_cb_context = ctx;
1600+}
1601+
1602+UStatus ua_sensors_gyroscope_set_event_rate(UASensorsGyroscope*, uint32_t)
1603+{
1604+ return U_STATUS_SUCCESS;
1605+}
1606+
1607+// Gyroscope Sensor Event
1608+uint64_t uas_gyroscope_event_get_timestamp(UASGyroscopeEvent*)
1609+{
1610+ return 0;
1611+}
1612+
1613+UStatus uas_gyroscope_event_get_rate_of_rotation_around_x(UASGyroscopeEvent*, float* value)
1614+{
1615+ if (!value)
1616+ return U_STATUS_ERROR;
1617+
1618+ *value = 0.f;
1619+
1620+ return U_STATUS_SUCCESS;
1621+}
1622+
1623+UStatus uas_gyroscope_event_get_rate_of_rotation_around_y(UASGyroscopeEvent*, float* value)
1624+{
1625+ if (!value)
1626+ return U_STATUS_ERROR;
1627+
1628+ *value = 0.f;
1629+
1630+ return U_STATUS_SUCCESS;
1631+}
1632+
1633+UStatus uas_gyroscope_event_get_rate_of_rotation_around_z(UASGyroscopeEvent*, float* value)
1634+{
1635+ if (!value)
1636+ return U_STATUS_ERROR;
1637+
1638+ *value = 0.f;
1639+
1640+ return U_STATUS_SUCCESS;
1641+}
1642+
1643+/***************************************
1644+ *
1645+ * Magnetic Field sensor API
1646+ *
1647+ ***************************************/
1648+
1649+UASensorsMagnetic* ua_sensors_magnetic_new()
1650+{
1651+ return SensorController::instance().get(ubuntu_sensor_type_magnetic_field);
1652+}
1653+
1654+UStatus ua_sensors_magnetic_enable(UASensorsMagnetic* s)
1655+{
1656+ static_cast<TestSensor*>(s)->enabled = true;
1657+ return (UStatus) 0;
1658+}
1659+
1660+UStatus ua_sensors_magnetic_disable(UASensorsMagnetic* s)
1661+{
1662+ static_cast<TestSensor*>(s)->enabled = false;
1663+ return (UStatus) 0;
1664+}
1665+
1666+uint32_t ua_sensors_magnetic_get_min_delay(UASensorsMagnetic* s)
1667+{
1668+ return static_cast<TestSensor*>(s)->min_delay;
1669+}
1670+
1671+UStatus ua_sensors_magnetic_get_min_value(UASensorsMagnetic* s, float* value)
1672+{
1673+ if (!value)
1674+ return U_STATUS_ERROR;
1675+
1676+ *value = static_cast<TestSensor*>(s)->min_value;
1677+
1678+ return U_STATUS_SUCCESS;
1679+}
1680+
1681+UStatus ua_sensors_magnetic_get_max_value(UASensorsMagnetic* s, float* value)
1682+{
1683+ if (!value)
1684+ return U_STATUS_ERROR;
1685+
1686+ *value = static_cast<TestSensor*>(s)->max_value;
1687+
1688+ return U_STATUS_SUCCESS;
1689+}
1690+
1691+UStatus ua_sensors_magnetic_get_resolution(UASensorsMagnetic* s, float* value)
1692+{
1693+ if (!value)
1694+ return U_STATUS_ERROR;
1695+
1696+ *value = static_cast<TestSensor*>(s)->resolution;
1697+
1698+ return U_STATUS_SUCCESS;
1699+}
1700+
1701+UStatus ua_sensors_magnetic_set_event_rate(UASensorsMagnetic* s, uint32_t rate)
1702+{
1703+ return U_STATUS_SUCCESS;
1704+}
1705+
1706+void ua_sensors_magnetic_set_reading_cb(UASensorsMagnetic* s, on_magnetic_event_cb cb, void* ctx)
1707+{
1708+ TestSensor* sensor = static_cast<TestSensor*>(s);
1709+ sensor->on_event_cb = cb;
1710+ sensor->event_cb_context = ctx;
1711+}
1712+
1713+uint64_t uas_magnetic_event_get_timestamp(UASAccelerometerEvent* e)
1714+{
1715+ return static_cast<TestSensor*>(e)->timestamp;
1716+}
1717+
1718+UStatus uas_magnetic_event_get_magnetic_field_x(UASAccelerometerEvent* e, float* value)
1719+{
1720+ if (!value)
1721+ return U_STATUS_ERROR;
1722+
1723+ *value = static_cast<TestSensor*>(e)->x;
1724+
1725+ return U_STATUS_SUCCESS;
1726+}
1727+
1728+UStatus uas_magnetic_event_get_magnetic_field_y(UASAccelerometerEvent* e, float* value)
1729+{
1730+ if (!value)
1731+ return U_STATUS_ERROR;
1732+
1733+ *value = static_cast<TestSensor*>(e)->y;
1734+
1735+ return U_STATUS_SUCCESS;
1736+}
1737+
1738+UStatus uas_magnetic_event_get_magnetic_field_z(UASAccelerometerEvent* e, float* value)
1739+{
1740+ if (!value)
1741+ return U_STATUS_ERROR;
1742+
1743+ *value = static_cast<TestSensor*>(e)->z;
1744+
1745+ return U_STATUS_SUCCESS;
1746+}
1747
1748=== modified file 'src/ubuntu/application/touch/hybris/ubuntu_application_sensors_hybris.cpp'
1749--- src/ubuntu/application/touch/hybris/ubuntu_application_sensors_hybris.cpp 2014-05-27 07:54:20 +0000
1750+++ src/ubuntu/application/touch/hybris/ubuntu_application_sensors_hybris.cpp 2016-04-04 06:59:06 +0000
1751@@ -21,6 +21,8 @@
1752 #include <ubuntu/application/sensors/proximity.h>
1753 #include <ubuntu/application/sensors/light.h>
1754 #include <ubuntu/application/sensors/orientation.h>
1755+#include <ubuntu/application/sensors/gyroscope.h>
1756+#include <ubuntu/application/sensors/magnetic.h>
1757
1758 #include "hybris_module.h"
1759
1760@@ -89,3 +91,37 @@
1761 IMPLEMENT_FUNCTION2(UStatus, uas_orientation_event_get_azimuth, UASOrientationEvent*, float*);
1762 IMPLEMENT_FUNCTION2(UStatus, uas_orientation_event_get_pitch, UASOrientationEvent*, float*);
1763 IMPLEMENT_FUNCTION2(UStatus, uas_orientation_event_get_roll, UASOrientationEvent*, float*);
1764+
1765+// Gyroscope Sensor Event
1766+IMPLEMENT_CTOR0(UASensorsGyroscope*, ua_sensors_gyroscope_new);
1767+IMPLEMENT_FUNCTION1(UStatus, ua_sensors_gyroscope_enable, UASensorsGyroscope*);
1768+IMPLEMENT_FUNCTION1(UStatus, ua_sensors_gyroscope_disable, UASensorsGyroscope*);
1769+IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_gyroscope_get_min_delay, UASensorsGyroscope*);
1770+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_gyroscope_get_min_value, UASensorsGyroscope*, float*);
1771+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_gyroscope_get_max_value, UASensorsGyroscope*, float*);
1772+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_gyroscope_get_resolution, UASensorsGyroscope*, float*);
1773+IMPLEMENT_VOID_FUNCTION3(ua_sensors_gyroscope_set_reading_cb, UASensorsGyroscope*, on_gyroscope_event_cb, void*);
1774+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_gyroscope_set_event_rate, UASensorsGyroscope*, uint32_t);
1775+
1776+// Gyroscope Sensor Event
1777+IMPLEMENT_FUNCTION1(uint64_t, uas_gyroscope_event_get_timestamp, UASGyroscopeEvent*);
1778+IMPLEMENT_FUNCTION2(UStatus, uas_gyroscope_event_get_rate_of_rotation_around_x, UASGyroscopeEvent*, float*);
1779+IMPLEMENT_FUNCTION2(UStatus, uas_gyroscope_event_get_rate_of_rotation_around_y, UASGyroscopeEvent*, float*);
1780+IMPLEMENT_FUNCTION2(UStatus, uas_gyroscope_event_get_rate_of_rotation_around_z, UASGyroscopeEvent*, float*);
1781+
1782+// Magnetic Field Sensor
1783+IMPLEMENT_CTOR0(UASensorsMagnetic*, ua_sensors_magnetic_new);
1784+IMPLEMENT_FUNCTION1(UStatus, ua_sensors_magnetic_enable, UASensorsMagnetic*);
1785+IMPLEMENT_FUNCTION1(UStatus, ua_sensors_magnetic_disable, UASensorsMagnetic*);
1786+IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_magnetic_get_min_delay, UASensorsMagnetic*);
1787+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_magnetic_get_min_value, UASensorsMagnetic*, float*);
1788+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_magnetic_get_max_value, UASensorsMagnetic*, float*);
1789+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_magnetic_get_resolution, UASensorsMagnetic*, float*);
1790+IMPLEMENT_VOID_FUNCTION3(ua_sensors_magnetic_set_reading_cb, UASensorsMagnetic*, on_magnetic_event_cb, void*);
1791+IMPLEMENT_FUNCTION2(UStatus, ua_sensors_magnetic_set_event_rate, UASensorsMagnetic*, uint32_t);
1792+
1793+// Magnetic Field Sensor Event
1794+IMPLEMENT_FUNCTION1(uint64_t, uas_magnetic_event_get_timestamp, UASMagneticEvent*);
1795+IMPLEMENT_FUNCTION2(UStatus, uas_magnetic_event_get_magnetic_field_x, UASMagneticEvent*, float*);
1796+IMPLEMENT_FUNCTION2(UStatus, uas_magnetic_event_get_magnetic_field_y, UASMagneticEvent*, float*);
1797+IMPLEMENT_FUNCTION2(UStatus, uas_magnetic_event_get_magnetic_field_z, UASMagneticEvent*, float*);
1798
1799=== modified file 'src/ubuntu/application/ubuntu_application_api.cpp'
1800--- src/ubuntu/application/ubuntu_application_api.cpp 2016-04-04 06:59:06 +0000
1801+++ src/ubuntu/application/ubuntu_application_api.cpp 2016-04-04 06:59:06 +0000
1802@@ -28,6 +28,8 @@
1803 #include <ubuntu/application/sensors/light.h>
1804 #include <ubuntu/application/sensors/orientation.h>
1805 #include <ubuntu/application/sensors/haptic.h>
1806+#include <ubuntu/application/sensors/gyroscope.h>
1807+#include <ubuntu/application/sensors/magnetic.h>
1808
1809 #include <ubuntu/application/location/service.h>
1810 #include <ubuntu/application/location/heading_update.h>
1811@@ -152,6 +154,40 @@
1812 IMPLEMENT_FUNCTION2(sensors, UStatus, uas_orientation_event_get_pitch, UASOrientationEvent*, float*);
1813 IMPLEMENT_FUNCTION2(sensors, UStatus, uas_orientation_event_get_roll, UASOrientationEvent*, float*);
1814
1815+// Gyroscope Sensor Event
1816+IMPLEMENT_CTOR0(sensors, UASensorsGyroscope*, ua_sensors_gyroscope_new);
1817+IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_gyroscope_enable, UASensorsGyroscope*);
1818+IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_gyroscope_disable, UASensorsGyroscope*);
1819+IMPLEMENT_FUNCTION1(sensors, uint32_t, ua_sensors_gyroscope_get_min_delay, UASensorsGyroscope*);
1820+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_gyroscope_get_min_value, UASensorsGyroscope*, float*);
1821+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_gyroscope_get_max_value, UASensorsGyroscope*, float*);
1822+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_gyroscope_get_resolution, UASensorsGyroscope*, float*);
1823+IMPLEMENT_VOID_FUNCTION3(sensors, ua_sensors_gyroscope_set_reading_cb, UASensorsGyroscope*, on_gyroscope_event_cb, void*);
1824+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_gyroscope_set_event_rate, UASensorsGyroscope*, uint32_t);
1825+
1826+// Gyroscope Sensor Event
1827+IMPLEMENT_FUNCTION1(sensors, uint64_t, uas_gyroscope_event_get_timestamp, UASGyroscopeEvent*);
1828+IMPLEMENT_FUNCTION2(sensors, UStatus, uas_gyroscope_event_get_rate_of_rotation_around_x, UASGyroscopeEvent*, float*);
1829+IMPLEMENT_FUNCTION2(sensors, UStatus, uas_gyroscope_event_get_rate_of_rotation_around_y, UASGyroscopeEvent*, float*);
1830+IMPLEMENT_FUNCTION2(sensors, UStatus, uas_gyroscope_event_get_rate_of_rotation_around_z, UASGyroscopeEvent*, float*);
1831+
1832+// Magnetic Field Sensor
1833+IMPLEMENT_CTOR0(sensors, UASensorsMagnetic*, ua_sensors_magnetic_new);
1834+IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_magnetic_enable, UASensorsMagnetic*);
1835+IMPLEMENT_FUNCTION1(sensors, UStatus, ua_sensors_magnetic_disable, UASensorsMagnetic*);
1836+IMPLEMENT_FUNCTION1(sensors, uint32_t, ua_sensors_magnetic_get_min_delay, UASensorsMagnetic*);
1837+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_magnetic_get_min_value, UASensorsMagnetic*, float*);
1838+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_magnetic_get_max_value, UASensorsMagnetic*, float*);
1839+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_magnetic_get_resolution, UASensorsMagnetic*, float*);
1840+IMPLEMENT_VOID_FUNCTION3(sensors, ua_sensors_magnetic_set_reading_cb, UASensorsMagnetic*, on_magnetic_event_cb, void*);
1841+IMPLEMENT_FUNCTION2(sensors, UStatus, ua_sensors_magnetic_set_event_rate, UASensorsMagnetic*, uint32_t);
1842+
1843+// Magnetic Field Sensor Event
1844+IMPLEMENT_FUNCTION1(sensors, uint64_t, uas_magnetic_event_get_timestamp, UASAccelerometerEvent*);
1845+IMPLEMENT_FUNCTION2(sensors, UStatus, uas_magnetic_event_get_magnetic_field_x, UASAccelerometerEvent*, float*);
1846+IMPLEMENT_FUNCTION2(sensors, UStatus, uas_magnetic_event_get_magnetic_field_y, UASAccelerometerEvent*, float*);
1847+IMPLEMENT_FUNCTION2(sensors, UStatus, uas_magnetic_event_get_magnetic_field_z, UASAccelerometerEvent*, float*);
1848+
1849 // Location
1850
1851 IMPLEMENT_VOID_FUNCTION1(location, ua_location_service_controller_ref, UALocationServiceController*);

Subscribers

People subscribed via source and target branches