Skip to content

Commit

Permalink
Merge pull request #27 from ohtangza/master
Browse files Browse the repository at this point in the history
Update README.md #12
  • Loading branch information
kprimice authored Dec 22, 2016
2 parents 74f0cb1 + bcb489e commit fec9a15
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
react-native-sensor-manager
============================

Wrapper for react-native. Accelerometer, Gyroscope, Magnetometer, Step Counter, Thermometer are supported for now.
Wrapper for react-native. Accelerometer, Gyroscope, Magnetometer, Orientation, Step Counter, Thermometer, LightSensor, and Proximity Sensor are supported for now.

Add it to your project
-------------------------
Expand All @@ -12,7 +12,7 @@ Add it to your project

`rnpm link`

### Option: Manually
### Option: Manually (try it if an runtime error occurs after `nrpm link`)

Make alterations to the following files:

Expand Down Expand Up @@ -74,7 +74,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
```java
import com.sensormanager.SensorManagerPackage; // <------ add package

public class MainActivity extends ReactActivity {
public class MainApplication extends Application implements ReactApplication {
// ...
@Override
protected List<ReactPackage> getPackages() {
Expand All @@ -94,21 +94,21 @@ import React, {
DeviceEventEmitter // will emit events that you can listen to
} from 'react-native';

var mSensorManager = require('NativeModules').SensorManager;
import { SensorManager } from 'NativeModules';
```


### Accelerometer
```js
mSensorManager.startAccelerometer(100); // To start the accelerometer with a minimum delay of 100ms between events.
SensorManager.startAccelerometer(100); // To start the accelerometer with a minimum delay of 100ms between events.
DeviceEventEmitter.addListener('Accelerometer', function (data) {
/**
* data.x
* data.y
* data.z
**/
});
mSensorManager.stopAccelerometer();
SensorManager.stopAccelerometer();
```

### Gyroscope
Expand All @@ -120,79 +120,79 @@ DeviceEventEmitter.addListener('Gyroscope', function (data) {
* data.z
**/
});
mSensorManager.startGyroscope(100);
mSensorManager.stopGyroscope();
SensorManager.startGyroscope(100);
SensorManager.stopGyroscope();
```

### Magnetometer
```js
mSensorManager.startMagnetometer(100);
SensorManager.startMagnetometer(100);
DeviceEventEmitter.addListener('Magnetometer', function (data) {
/**
* data.x
* data.y
* data.z
**/
});
mSensorManager.stopMagnetometer();
SensorManager.stopMagnetometer();
```

### Orientation
```js
mSensorManager.startOrientation(100);
SensorManager.startOrientation(100);
DeviceEventEmitter.addListener('Orientation', function (data) {
/**
* data.azimuth
* data.pitch
* data.roll
**/
});
mSensorManager.stopOrientation();
SensorManager.stopOrientation();
```

### Step Counter
```js
mSensorManager.startStepCounter(1000);
SensorManager.startStepCounter(1000);
DeviceEventEmitter.addListener('StepCounter', function (data) {
/**
* data.steps
**/
});
mSensorManager.stopStepCounter();
SensorManager.stopStepCounter();
```

### Thermometer
```js
mSensorManager.startThermometer(1000);
SensorManager.startThermometer(1000);
DeviceEventEmitter.addListener('Thermometer', function (data) {
/**
* data.temp
**/
});
mSensorManager.stopThermometer();
SensorManager.stopThermometer();
```

### LightSensor
```js
mSensorManager.startLightSensor(100);
SensorManager.startLightSensor(100);
DeviceEventEmitter.addListener('LightSensor', function (data) {
/**
* data.light
**/
});
mSensorManager.stopLightSensor();
SensorManager.stopLightSensor();
```


### Proximity Sensor
```js
mSensorManager.startProximity(100);
SensorManager.startProximity(100);
DeviceEventEmitter.addListener('Proximity', function (data) {
/**
* data.isNear: [Boolean] A flag representing whether something is near the screen.
* data.value: [Number] The raw value returned by the sensor (usually distance in cm).
* data.maxRange: [Number] The maximum range of the sensor.
**/
});
mSensorManager.stopProximity();
SensorManager.stopProximity();
```

0 comments on commit fec9a15

Please sign in to comment.