Coder Social home page Coder Social logo

node-powermate's Introduction

node-powermate

A Node.js library for the Griffin PowerMate

Install

npm install node-powermate

Usage

var PowerMate = require('node-powermate');
var powermate = new PowerMate();
var powermater = new PowerMate(index); // optional index of PowerMate for multiple

Events

Button down:

powermate.on('buttonDown', callback);

Button up:

powermate.on('buttonUp', callback);

Wheel turn:

powermate.on('wheelTurn', callback(wheelDelta));

Disconnected:

powermate.on('disconnected', callback());

Brightness

Brightness range is: 0 - 255

Set:

powermate.setBrightness(brightness, [callback]);

Get:

powermate.brightness(callback(brightness));

Pulse Awake

Set:

powermate.setPulseAwake(pulseAwake, [callback]);

Get:

powermate.pulseAwake(callback(pulseAwake));

Pulse Asleep

Set:

powermate.setPulseAsleep(pulseAsleep, [callback]);

Get:

powermate.pulseAsleep(callback(pulseAsleep));

Pulse Speed

Pulse speed range: 0 - 511

Set:

powermate.setPulseSpeed(pulseSpeed, [callback]);

Get:

powermate.pulseSpeed(callback(pulseSpeed));

Button State

Get:

powermate.buttonState(callback(buttonState));

Close

powermate.close([callback]);

State:

powermate.isClosed(); // returns: true | false

Permissions

Depending on OS, you may get an error that looks something like

cannot open device with path 0001:0004:00

If this happens, it is likely because your user doesn't have permissions for the PowerMate device. In Linux (specifically Raspbian), creating the file /etc/udev/rules/95-powermate.rules and entering the following text:

SUBSYSTEM=="usb", ATTRS{idVendor}=="077d", ATTRS{idProduct}=="0410", SYMLINK+="powermate", MODE="660", GROUP="input"

will assign the PowerMate device to the "input" group, which the pi user belongs to. For other OSs, change the GROUP entry to a group that your user belongs to.

License

Copyright (C) 2014 Sandeep Mistry [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-powermate's People

Contributors

aldaviva avatar brnndnn avatar dannydulai avatar dkordik avatar fcsonline avatar foxxyz avatar hardillb avatar sandeepmistry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-powermate's Issues

Unable to use set brightness/speed

Set pulse speed only turns it solid or pulse, no speed change
set brightness sets it to the brightness then instantly changes it back

Error: could not send feature report to device

I can't get any of the LED-based methods to work. The .on('buttonDown') and .on('buttonUp') methods work fine, though. I'm using a Raspberry PI with Raspbian Jessie. Node v6.9.5. In an effort to isolate this bug from my own app code, I tried to run the manual-test.js script from this repo and got the same errors I get in my app (tried both with and without sudo):

pi@raspberrypi:/srv/app $ sudo node node_modules/node-powermate/manual-test.js 
/srv/app/node_modules/node-powermate/powermate.js:55
  this._hidDevice.sendFeatureReport(featureReport);
                  ^

Error: could not send feature report to device
    at Error (native)
    at PowerMate._sendCommand (/srv/app/node_modules/node-powermate/powermate.js:55:19)
    at PowerMate.setBrightness (/srv/app/node_modules/node-powermate/powermate.js:67:8)
    at Timeout._onTimeout (/srv/app/node_modules/node-powermate/manual-test.js:19:13)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

In my own app, all of the LED-methods (setBrightness, setPulseSpeed, setPulseAwake, setPulseAsleep) trigger this same error.

I DO have the proper udev permissions set for the pi account, as evidenced by the fact that the button functionality works without sudo.

Any ideas? Thank you for building & supporting this library.

Not working with atom electron

I'm running node 6.2.2 and electron 1.2

When ever I do any gesture with the powermate I get this error

#
# Fatal error in , line 0
# unreachable code
#

==== C stack trace ===============================

 1: V8_Fatal
 2: v8::internal::ToBooleanICStub::Types::UpdateStatus(v8::internal::Handle<v8::internal::Object>)
 3: v8::internal::ToBooleanICStub::UpdateStatus(v8::internal::Handle<v8::internal::Object>)
 4: v8::internal::Runtime_ToBooleanIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*)
 5: 0x1f12626079a7
 6: 0x1f126262ea65

Raspberry Pi Install

Cannot install on Raspberry Pi. Auto install always finds missing dependencies. A pre built install would be so much better.

Cannot open device

When I run new PowerMate() I get the following error from line 36 of powermate.js:

cannot open device with path USB_077d_0410_14530000`

Line 36:

this._hidDevice = new HID.HID(powerMateHIDdevice.path);

console.logging powerMateHIDdevice gives be the following:

{ vendorId: 1917,
  productId: 1040,
  path: 'USB_077d_0410_14530000',
  serialNumber: '',
  manufacturer: 'Griffin Technology, Inc.',
  product: 'Griffin PowerMate',
  release: 1024,
  interface: -1 }

Any idea what’s going wrong?

Using any of the commands raises featureReport error

I've got code that works flawlessly when run on a mac, but fails when run on an Intel edison (3.10.17-poky-edison+)

commands like:
powermate.setBrightness(0, function() {});

yield:

*/home/root/node_modules/node-powermate/powermate.js:55
this._hidDevice.sendFeatureReport(featureReport);

could not send feature report to device*

Any suggestions?

This is an awesome library, btw :) I'm using it to make a bunch of wireless music control knobs for my house.

14 - 1

N

Publish New Version

Can you please publish a new version to NPM? Last release was 2 years ago, would be nice to get some of the updates since then (E.G. disconnected event on disconnect).

Thanks!

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.