Git Product home page Git Product logo

cylon-keyboard's Introduction

Cylon.js For Keyboard Input

Cylon.js (http://cylonjs.com) is a JavaScript framework for robotics, physical computing, and the Internet of Things (IoT).

This repository contains the adaptor/driver for keyboard input. It uses the hybridgroup fork of the keypress module https://github.com/TooTallNate/keypress created by @TooTallNate thank you!

Want to use Ruby on robots? Check out our sister project Artoo (http://artoo.io)

Want to use the Go programming language to power your robots? Check out our sister project Gobot (http://gobot.io).

Build Status Code Climate Test Coverage

How to Install

Installing cylon.js with a keyboard support is pretty easy.

$ npm install cylon cylon-keyboard

How to Use

var Cylon = require('cylon');

Cylon.robot({
  connections: {
    keyboard: { adaptor: 'keyboard' }
  },

  devices: {
    keyboard: { driver: 'keyboard' }
  },

  work: function(my) {
    my.keyboard.on('a', function(key) {
      console.log("A PRESSED!");
    });
  }
}).start();

How to Connect

All that you need to do is plug the keyboard into your computer as usual.

Documentation

We're busy adding documentation to our web site at http://cylonjs.com/ please check there as we continue to work on Cylon.js

Thank you!

Contributing

For our contribution guidelines, please go to https://github.com/hybridgroup/cylon/blob/master/CONTRIBUTING.md .

Release History

For the release history, please go to https://github.com/hybridgroup/cylon-keyboard/blob/master/RELEASES.md .

License

Copyright (c) 2013-2016 The Hybrid Group. Licensed under the Apache 2.0 license.

cylon-keyboard's People

Contributors

stewart avatar deadprogram avatar xixebombilla avatar edgarsilva avatar rafmagana avatar zankavrogin avatar

Stargazers

Kiera Reed avatar Ivandro Jao avatar François Séguin avatar 0x44 0x46 avatar João Leite avatar

Watchers

 avatar Enrique Canals avatar  avatar  avatar James Cloos avatar  avatar Bruce Wen avatar Justin Zemlyansky avatar  avatar

Forkers

nvdnkpr nemo157

cylon-keyboard's Issues

Doesn't work with node-repl

Keyboard doesn't play nicely with node-repl module. Not sure if it is by design or something that could be fixed.

"use strict";

var cylon = require("cylon");

cylon.robot({
  name: "testbot",
  connections: {
    keyboard: {
      adaptor: "keyboard",
      devices: {
        keyboard: {
          driver: "keyboard"
        }
      }
    }
  },
  work: function (my) {

  }
}).start();

When you run with node-repl then each key is doubled on the console causing reference errors.

Doesn't work with Sphero

No matter what I try, I can't control Sphero with cylon-keyboard. Everything works well when I use one of them, but when I try to use both I get this output;

2017-12-17T11:08:30.179Z : [Robot 1] - Starting connection 'keyboard'.
2017-12-17T11:08:30.197Z : [Robot 1] - Starting connection 'sphero' on port /dev/tty.Sphero-RWP-AMP-SPP.
The method Logger#info has been deprecated.
It will be removed in Cylon 2.0.0.
Please switch to using the #log or #debug Logger methods
2017-12-17T11:08:30.200Z : Connecting to Sphero 'sphero'...
2017-12-17T11:08:31.549Z : [Robot 1] - Starting devices.
2017-12-17T11:08:31.549Z : [Robot 1] - Starting device 'keyboard'.
2017-12-17T11:08:31.551Z : [Robot 1] - Starting device 'sphero'.
/Users/apple/Development/riseofsphero/node_modules/cylon-sphero/lib/driver.js:38
  this.connection.setTempOptionFlags(0x01);
                  ^

TypeError: this.connection.setTempOptionFlags is not a function
    at Driver.start (/Users/apple/Development/riseofsphero/node_modules/cylon-sphero/lib/driver.js:38:19)
    at Robot.startDevice (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/robot.js:368:16)
    at Robot.<anonymous> (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/robot.js:339:19)
    at /Users/apple/Development/riseofsphero/node_modules/cylon/lib/utils/helpers.js:237:36
    at Array.forEach (native)
    at Object.parallel (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/utils/helpers.js:237:13)
    at Robot.startDevices (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/robot.js:343:12)
    at next (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/utils/helpers.js:266:22)
    at callback (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/utils/helpers.js:262:5)
    at callback (/Users/apple/Development/riseofsphero/node_modules/cylon/lib/utils/helpers.js:231:7)
    at Adaptor.<anonymous> (/Users/apple/Development/riseofsphero/node_modules/cylon-sphero/lib/adaptor.js:74:7)
    at /Users/apple/Development/riseofsphero/node_modules/sphero/lib/sphero.js:127:7
    at SerialPort.<anonymous> (/Users/apple/Development/riseofsphero/node_modules/sphero/lib/adaptors/serialport.js:71:5)
    at emitNone (events.js:86:13)
    at SerialPort.emit (events.js:185:7)
    at /Users/apple/Development/riseofsphero/node_modules/sphero/node_modules/serialport/lib/serialport.js:227:10

Source:

const Cylon = require('cylon');

var spheroSettings = {
  port: '/dev/tty.Sphero-RWP-AMP-SPP',
  speed: 120
};

Cylon.robot({
  connections: {
    keyboard: { adaptor: 'keyboard' },
    sphero: { adaptor: 'sphero', port: spheroSettings.port }
  },

  devices: {
    keyboard: { driver: 'keyboard' },
    sphero: { driver: 'sphero' }
  },

  work: function(my) {
    my.keyboard.on('a', function(key) {
      my.sphero.roll(120, 90);
    });
   }
}).start();

number key

hi,

are the numbers like
my.keyboard.on('9', function(key)...
not working?

best,
alex

missing events

When I'm typing in longer words then the last keys are missing, i.e. for 10-character word the last one is missing as is the case for a 9-character word. The program I'm using is:

"use strict";

var cylon = require("cylon");

cylon.robot({
  connections: {
    keyboard: {adaptor: "keyboard"}
  },
  devices: {
    keyboard: {name: "keyboard", driver: "keyboard"}
  },
  work: function (my) {
    my.keyboard.on("keydown", function (key) {
      console.log(key.name + " pressed");
    });
  }
}).start();

Is there some "speed limit" to these events?

setRawMode

I am trying to run the demo app, but I am getting this error message just after "Connecting to keyboard" : Object # has no method "setRawMode"

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.