Created
September 8, 2015 07:37
-
-
Save mborromeo/2e506b79fcbba48dab6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RollingSpider = require("rolling-spider") | |
Keyboard = require('keypress'); | |
Keyboard(process.stdin); | |
drone = new RollingSpider | |
uuid: 'dde3787fc4804b8a895efa2757771448' | |
logger: console.log | |
forceConnect: false | |
drone.disconnect() | |
console.log ' - connecting to drone' | |
drone.connect -> | |
console.log ' - connected' | |
drone.setup -> | |
console.log ' - connected and setup' | |
drone.startPing() | |
takeoff = -> | |
console.log ' - takeoff' | |
try | |
drone.flatTrim() | |
drone.startPing() | |
drone.takeOff() | |
catch e | |
console.error e | |
land = -> | |
console.log ' - land' | |
try | |
drone.land() | |
catch e | |
console.error e | |
process.stdin.on 'keypress', (ch, key) -> | |
console.log 'got "keypress"', key | |
if key and key.name == 't' | |
console.log 'TAKEOFF' | |
takeoff() | |
if key and key.name == 'l' | |
console.log 'LAND' | |
land() | |
if key and key.ctrl and key.name == 'c' | |
process.stdin.pause() | |
return | |
process.stdin.setRawMode true | |
process.stdin.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment