From 8ccb247aa7852047dd5e2211e3d9efb4b0faee07 Mon Sep 17 00:00:00 2001 From: Steve Lacy Date: Thu, 5 May 2016 17:44:15 -0700 Subject: [PATCH] normalize color names with other systems --- README.md | 6 +++--- examples/breathe.js | 4 ++-- examples/msi-kbd.js | 8 ++++---- lib/constants.json | 6 +++--- lib/findKeyboard.js | 4 ++-- lib/setMode.js | 16 ++++++++-------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 8b2de9d..d1b4427 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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);` diff --git a/examples/breathe.js b/examples/breathe.js index 43642f5..17dac60 100644 --- a/examples/breathe.js +++ b/examples/breathe.js @@ -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 */ diff --git a/examples/msi-kbd.js b/examples/msi-kbd.js index 8ab11e6..fbe3ca5 100755 --- a/examples/msi-kbd.js +++ b/examples/msi-kbd.js @@ -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' @@ -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]; diff --git a/lib/constants.json b/lib/constants.json index e08f5b7..3a3c38b 100644 --- a/lib/constants.json +++ b/lib/constants.json @@ -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 @@ -28,4 +28,4 @@ "demo": 4, "wave": 5 } -} \ No newline at end of file +} diff --git a/lib/findKeyboard.js b/lib/findKeyboard.js index 0142d34..910fce1 100644 --- a/lib/findKeyboard.js +++ b/lib/findKeyboard.js @@ -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) { @@ -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); diff --git a/lib/setMode.js b/lib/setMode.js index f4ce982..f20796f 100644 --- a/lib/setMode.js +++ b/lib/setMode.js @@ -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); } } @@ -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; @@ -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': @@ -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) @@ -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;