Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasRoeddiger authored Sep 29, 2023
1 parent 7aa57d7 commit 3381f0b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,46 @@ To use OpenEarable.js simply integrate the library found under `assets/js/OpenEa
<script src="./OpenEarable.js"></script>
```

### Usage Example
The following example shows how to use the OpenEarable library.

#### Connect to OpenEarable
```js
const openEarable = new OpenEarable();

// Read device identifier once connected
openEarable.bleManager.subscribeOnConnected(async () => {
const deviceId = await earable.readDeviceIdentifier();
console.log(`Connected to device: ${deviceId}`);
});

// Connect to the BLE device
openEarable.bleManager.connect();
```

#### Subscribe to Sensor Data
```js
// Subscribe to the sensor data
openEarable.subscribeOnSensorDataReceived((data) => {
// Process the received IMU data
console.log(data);
});

// Enable IMU at 30 Hz
wait sensorManager.writeSensorConfig(0, 30, 0); // 0 sensorId, 30 samplingRate
```

#### Play Audio
```js
// Play audio file from microSD card
openEarable.audioPlayer.wavFile(1, "music.wav"); // 1 state (play), music.wav file to play from microSD card
```

#### Control RGB LED
```js
// TODO
```

## License
Distributed under the MIT License. See LICENSE for more information.

Expand Down

0 comments on commit 3381f0b

Please sign in to comment.