-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexample-events.ts
More file actions
44 lines (36 loc) · 1.08 KB
/
example-events.ts
File metadata and controls
44 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { bootstrap, connectToDevice, logEvent } from '../utils'
// Uncomment to search for only your device
// ENTER DEVICE_ID to discover only a particular device
const DEVICE_ID: string | undefined = undefined
/**
* Main application entry point
*/
async function main() {
const device = await connectToDevice(DEVICE_ID)
// When button is pressed & released
device.on('click', () => {
logEvent('click')
device.orthoRemotePeripheral.setModulation(0.9)
})
// When button is pressed & released after a duration
device.on('longClick', () => {
logEvent('longClick')
})
// When button is pressed
device.on('buttonPressed', () => {
logEvent('buttonPressed')
})
// When button is released
device.on('buttonReleased', () => {
logEvent('buttonReleased')
})
// Rotation in any direction
device.on('rotate', (rotation, buttonPressed) => {
logEvent('rotate', {
rotation: rotation.toFixed(3),
buttonPressed,
})
})
}
// Boot strap async function
bootstrap(main)