Skip to content

Commit

Permalink
normalize color names with other systems
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlacy committed May 6, 2016
1 parent 388abf6 commit 8ccb247
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ They will not affect hardware-default modes such as Wave and Breathing.

The following colors are defined:

off
black
red
orange
yellow
green
sky
cyan
blue
purple
white
Expand Down Expand Up @@ -153,7 +153,7 @@ 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 'off':
Passing in only one color argument defaults the secondaryColor to 'black':

`keyboard.mode(String mode, String primaryColor);`

Expand Down
4 changes: 2 additions & 2 deletions examples/breathe.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var keyboard = require('../')();

keyboard.mode('breathe', 'green', 'red', 'yellow'); //Keyboard will pulse from green, red, and yellow (in the left, middle, and right areas, respectively) high intensity to off (which is the default secondary color).
keyboard.mode('breathe', 'green', 'red', 'yellow'); //Keyboard will pulse from green, red, and yellow (in the left, middle, and right areas, respectively) high intensity to black (which is the default secondary color).

/*
keyboard.mode('breathe',
{color:'sky', intensity:'high', secondary:'purple'}, //Left area will alternate from sky to purple, with high light intensity
{color:'red', intensity:'high', secondary:{intensity:'light'}}, //Middle area will alternate from dark red (high intensity red) to a light pink (light intensity red)
{primary:{color:'green'},secondary:{color:'off'}}, //Right area will alternate from green (high intensity by default) to darkness (off)
{primary:{color:'green'},secondary:{color:'black'}}, //Right area will alternate from green (high intensity by default) to darkness (black)
1); //Pattern will repeat every 1 second
*/
8 changes: 4 additions & 4 deletions examples/msi-kbd.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ var argv = require('minimist')(process.argv.slice(2), {
});

var colors = [
'off',
'black',
'red',
'orange',
'yellow',
'green',
'sky',
'cyan',
'blue',
'purple',
'white'
Expand Down Expand Up @@ -63,8 +63,8 @@ function LightKbd(region, colorstr) {
var colorargs = colorstr.split(':');

for (i = 0; i < colorargs.length; i++) {
if (colorargs[i] === 'black' || colorargs[i] === 'none') {
colorargs[i] = 'off';
if (colorargs[i] === 'none') {
colorargs[i] = 'black';
}
if (colors.indexOf(colorargs[i]) > -1) {
colorSet = colorargs[i];
Expand Down
6 changes: 3 additions & 3 deletions lib/constants.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"right": 3
},
"colors": {
"off": 0,
"black": 0,
"red": 1,
"orange": 2,
"yellow": 3,
"green": 4,
"sky": 5,
"cyan": 5,
"blue": 6,
"purple": 7,
"white": 8
Expand All @@ -28,4 +28,4 @@
"demo": 4,
"wave": 5
}
}
}
4 changes: 2 additions & 2 deletions lib/findKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = function(){
/**
* One color parameter; set it as the
* primary color for all areas, leavings
* secondary off
* secondary black
*/
if (arguments.length == 2) {

Expand Down Expand Up @@ -82,7 +82,7 @@ module.exports = function(){
};

board.blinkRegion = function(region, color, time) {
board.color(region, 'off');
board.color(region, 'black');

setTimeout(function(){
board.color(region, color);
Expand Down
16 changes: 8 additions & 8 deletions lib/setMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ module.exports = function (keyboard, mode, regions, period){
sendData (keyboard, _k + 2, Def.secondary.color, Def.secondary.level, 0);
sendData (keyboard, _k + 3, period, period, period);
} else {
sendData (keyboard, _k + 1, 'off', 0, 0);
sendData (keyboard, _k + 2, 'off', 0, 0);
sendData (keyboard, _k + 1, 'black', 0, 0);
sendData (keyboard, _k + 2, 'black', 0, 0);
sendData (keyboard, _k + 3, period, period, period);
}
}
Expand All @@ -84,7 +84,7 @@ function getSettingsForRegion (data, region) {

regionDef = {
primary: {color: constants.colors[data], level: 0},
secondary: {color: constants.colors['off'], level: 0}
secondary: {color: constants.colors['black'], level: 0}
};
break;

Expand All @@ -94,7 +94,7 @@ function getSettingsForRegion (data, region) {

regionDef = {
primary: {color: data, level: 0},
secondary: {color: constants.colors['off'], level: 0}
secondary: {color: constants.colors['black'], level: 0}
};

case 'object':
Expand All @@ -107,9 +107,9 @@ function getSettingsForRegion (data, region) {

regionDef.secondary = getColorIntensityLevel (data.secondary, region);

//Default to off if both settings are unset
//Default to black if both settings are unset
if (regionDef.secondary.color < 0 && regionDef.secondary.level < 0)
regionDef.secondary = {color: constants.colors['off'], level: 0};
regionDef.secondary = {color: constants.colors['black'], level: 0};

//Default to primary settings if either are unset
if (regionDef.secondary.color < 0)
Expand All @@ -119,8 +119,8 @@ function getSettingsForRegion (data, region) {
regionDef.secondary.level = regionDef.primary.level;

} else {
//Default secondary to off if unset
regionDef.secondary = {color: constants.colors['off'], level: 0};
//Default secondary to black if unset
regionDef.secondary = {color: constants.colors['black'], level: 0};
}
break;

Expand Down

0 comments on commit 8ccb247

Please sign in to comment.