UNPKG

853 BJavaScriptView Raw
1'use strict';
2
3var WiFli = require('../index')
4 , MockConnection = require('../lib/mock-connection')
5 ;
6
7var kopter = new WiFli({hoverSpeed : 20, charge : 100, trim : -5});
8
9// replace this with a real connect() call to send to real copter
10kopter.connection = new MockConnection();
11
12kopter.on('launch', function () { console.log('WiFli launched'); });
13kopter.on('land', function () { console.log('WiFli landed'); });
14
15kopter.once('launch', function () {
16 kopter.runQueue(function (q) {
17 q.on('end', function () { kopter.land(2500); });
18
19 q.enqueue({hover : true, pitch : 30, yaw : 31}, 2000);
20 });
21});
22
23kopter.once('land', function () { kopter.end(); });
24kopter.once('end', function () { console.log("all done!"); });
25
26kopter.launch(2000);
27
28// uncomment and put the above in here for a real run
29// kopter.connect(function () {
30// });