1 | import { Observable } from 'rxjs/Observable';
|
2 | /**
|
3 | * Interface that represent output data
|
4 | */
|
5 | export interface GyroscopeOrientation {
|
6 | /**
|
7 | * Represent x-axis
|
8 | */
|
9 | x: number;
|
10 | /**
|
11 | * Represent y-axis
|
12 | */
|
13 | y: number;
|
14 | /**
|
15 | * Represent z-axis
|
16 | */
|
17 | z: number;
|
18 | /**
|
19 | * Represent timestamp of sensor read. Default is 10000ms
|
20 | */
|
21 | timestamp: number;
|
22 | }
|
23 | /**
|
24 | * Interface that represent option data
|
25 | */
|
26 | export interface GyroscopeOptions {
|
27 | /**
|
28 | * Represent how often (in milliseconds) sensor should be read. Default is 10000 ms
|
29 | */
|
30 | frequency: number;
|
31 | }
|
32 | /**
|
33 | * @name Gyroscope
|
34 | * @description Read Gyroscope sensor data
|
35 | * @usage
|
36 | * ```
|
37 | * import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from 'ionic-native';
|
38 | *
|
39 | *
|
40 | * let options: GyroscopeOptions = {
|
41 | * frequency: 1000
|
42 | * };
|
43 | *
|
44 | * Gyroscope.getCurrent(options)
|
45 | * .then((orientation: GyroscopeOrientation) => {
|
46 | * console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
|
47 | * })
|
48 | * .catch()
|
49 | *
|
50 | *
|
51 | * Gyroscope.watch()
|
52 | * .subscribe((orientation: GyroscopeOrientation) => {
|
53 | * console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
|
54 | * });
|
55 | *
|
56 | * ```
|
57 | */
|
58 | export declare class Gyroscope {
|
59 | /**
|
60 | * Watching for gyroscope sensor changes
|
61 | * @param options {GyroscopeOptions} (optional)
|
62 | * @return {Observable<GyroscopeOrientation>} Returns an Observable that resolves GyroscopeOrientation
|
63 | */
|
64 | static watch(options?: GyroscopeOptions): Observable<GyroscopeOrientation>;
|
65 | /**
|
66 | * Get current data from gyroscope sensor
|
67 | * @param options {GyroscopeOptions} (optional)
|
68 | * @return {Promise<GyroscopeOrientation>} Returns a promise that resolves GyroscopeOrientation
|
69 | */
|
70 | static getCurrent(options?: GyroscopeOptions): Promise<GyroscopeOrientation>;
|
71 | }
|