项目作者: stevelacy

项目描述 :
MSI SteelSeries Keyboard LED Controller
高级语言: JavaScript
项目地址: git://github.com/stevelacy/msi-keyboard.git
创建时间: 2013-11-18T03:54:57Z
项目社区:https://github.com/stevelacy/msi-keyboard

开源协议:MIT License

下载


MSI Keyboard LED Controller

OS independent* LED Controller for MSI Steelseries laptop keyboards Using Node.js

NPM version

Information

















Packagemsi-keyboard
DescriptionMSI Keyboard LED Controller
HardwareMSI GE, GT Steelseries Keyboard
Node Version>= 0.4

keyboard

Looking for a GUI application?

Usage

Make sure you have the needed usb lib requirements for your OS.

This project now supports full RGB/hex colors.

Generic Linux: libusb-dev libusb-1.0-0-dev

Use it as command line :

https://github.com/Kwaadpepper/msi-keyboard-CLI

if using as a stand alone module:

npm install

Note:

Linux and *nix systems may require sudo to access the hid device interface.

*Not tested on all platforms.
Platform tests appreciated

  1. // require the LED module
  2. var keyboard = require('msi-keyboard')();
  3. // Set left region to high intensity, color red
  4. keyboard.color('left', {
  5. color: 'red',
  6. intensity: 'high'
  7. });
  8. // Set middle region to green default high intensity
  9. keyboard.color('middle', 'green');
  10. // Set right region to blue with light intensity
  11. keyboard.color('right', {
  12. color: 'blue',
  13. intensity: 'light',
  14. });
  15. // Hardware modes
  16. // Setting .color() will Not affect the hardware defined colors for modes
  17. // Set Hardware mode to breath
  18. keyboard.mode('breathe', 'green');
  19. // Blinking
  20. // Set the keyboard.color() Before calling .blink()
  21. // Refer to examples/blinkMulti.js
  22. // Blink all the keyboard LEDs to 750ms
  23. keyboard.blink(750);
  24. // Blink Only left and right regions at 750ms
  25. keyboard.blink(['left','right'], 750);
  26. // Use the default blink, time: 1000ms
  27. keyboard.blink();
  28. // Stop the blink after 5000ms
  29. setTimeout(keyboard.stopBlink, 5000);

Colors

keyboard.colors(String region, String Color);

Colors must be set before using keyboard.blink();

They will not affect hardware-default modes such as Wave and Breathing.

All colors supported by Colors.js are now supported here

To set a color use keyboard.colors() There are two ways to set the color to a region:

  1. keyboard.color('middle', 'green');
  2. keyboard.color('middle', {color:'#ffffff', intensity:'high'});
  3. keyboard.color('middle', {color:'#4654BD', intensity:'high'});

Intensity

keyboard.colors(String region, {String color, String intensity});

The color intensity to white can be set via keyboard.colors();

The following intensities are used:

  1. light
  2. low
  3. med
  4. high

To set it:

  1. keyboard.color('right', {
  2. color: '#1CA626',
  3. intensity: 'med', // light, low, med, high
  4. });

Modes

keyboard.mode(String mode, String primaryColor, String secondaryColor);
keyboard.mode(String mode, Object left, Object middle, Object right, Integer cyclePeriod);

MSI Steelseries keyboards have built modes.

Breathe and Wave modes support fading between colors, which can be set when calling the keyboard.mode() method.

Passing in only one color argument defaults the secondaryColor to ‘black’:

keyboard.mode(String mode, String primaryColor);

You can also set each region’s color individually:

keyboard.mode(String mode, String leftPrimary, String middlePrimary, String rightPrimary, Integer cyclePeriod);

keyboard.mode(String mode, Object left, Object middle, Object right, Integer cyclePeriod);

Region objects are defined as such:

  1. right: {
  2. primary: {
  3. color: 'red',
  4. intensity: 'high'
  5. },
  6. secondary: {
  7. color: 'blue',
  8. intensity: 'high'
  9. }
  10. }

Which is equivalent to:

  1. right: {
  2. color: 'red',
  3. intensity: 'high',
  4. secondary: {
  5. color: 'blue',
  6. intensity: 'high'
  7. }
  8. }

You can also define just the primary and secondary colors, leaving the intensities to their default (high):

  1. right: {
  2. primary: 'red',
  3. secondary: 'blue'
  4. }

If you specify the color and intensity directly in the Region object, you can set just one of the secondary fields and the other will take the default from the primary (secondary color will be red with light intensity):

  1. right: {
  2. color: 'red',
  3. intensity: 'high',
  4. secondary: {intensity:'light'}
  5. }

The cyclePeriod defaults to 2 seconds when not passed in.

The modes defined by the hardware are:

  1. Normal
  2. Gaming
  3. Breathe
  4. Demo
  5. Wave

Usage:

  1. keyboard.mode('breathe', 'green', 'red', 'yellow');

Regions

keyboard.colors(String region, String color);

There are three regions on the Steelseries keyboard:

  1. Left
  2. Middle
  3. Right

Each can have a color and intensity set.

keyboard.blink(Time milliseconds);

The time is the speed in which the keyboard is to blink.

keyboard.colors(); Must be set before using keyboard.blink();

Usage:

  1. // keyboard.color(...);
  2. keyboard.blink(750);

To blink one, or two regions only:

  1. // keyboard.color(...);
  2. keyboard.blink(['left','right'], 750);

Examples

You can view more examples in the example folder.

Confirmed Systems

  1. OS: Debain 8
  2. Kernel: Linux 4.4.0 AMD
  3. Node: v5 / v6
  4. libusb-dev: v0.1.12
  5. ---
  6. OS: Arch Linux
  7. Kernel: 4.5.1-1-ARCH
  8. Node: v6.0.0
  9. libusb v0.1.12
  10. ---
  11. OS: Ubuntu 16.04
  12. Kernel: 4.4.14
  13. Node: v6
  14. libusb v0.1.12

LICENSE

(MIT License)

Copyright (c) 2013 | Steve Lacy (http://slacy.me)

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.