-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtester.js
56 lines (41 loc) · 1.22 KB
/
tester.js
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
45
46
47
48
49
50
51
52
53
54
55
56
const boost = require('./index');
(async () => {
// await boost.bleReadyAsync();
// const connectDetails = await boost.hubFoundAsync();
// const hub = await boost.connectAsync(connectDetails);
const hub = await boost.getHubAsync();
hub.on('error', err => {
console.log('error', err);
});
hub.on('disconnect', () => {
console.log('disconnect');
});
hub.on('distance', distance => {
console.log('distance', distance);
});
hub.on('rssi', rssi => {
console.log('rssi', rssi);
});
hub.on('port', portObject => {
console.log('port', JSON.stringify(portObject, null, 1));
});
hub.on('color', color => {
console.log('color', color);
});
hub.on('tilt', tilt => {
console.log('tilt', JSON.stringify(tilt, null, 1));
});
hub.on('rotation', rotation => {
console.log('rotation', JSON.stringify(rotation, null, 1));
});
// Insert commands here
await hub.ledAsync('red');
await hub.ledAsync('yellow');
await hub.ledAsync('green');
// Turn 180 degrees
await hub.motorAngleAsync('A', 980, 100, true);
await hub.motorTimeMultiAsync(2, 100, 100, true);
// Turn 180 degrees
await hub.motorAngleAsync('B', 980, 100, true);
await hub.ledAsync('red');
})();