Skip to content

Instantly share code, notes, and snippets.

@mborromeo
Created September 8, 2015 07:37
Show Gist options
  • Save mborromeo/2e506b79fcbba48dab6b to your computer and use it in GitHub Desktop.
Save mborromeo/2e506b79fcbba48dab6b to your computer and use it in GitHub Desktop.
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