diff --git a/firmware/src/libs/ws2812/ws2812.cpp b/firmware/src/libs/ws2812/ws2812.cpp index 1c2e75c..081f18f 100644 --- a/firmware/src/libs/ws2812/ws2812.cpp +++ b/firmware/src/libs/ws2812/ws2812.cpp @@ -94,7 +94,7 @@ void process_command(byte argc, byte *argv){ // TODO make this work with the strand length... // get the bottom 5 bits off for the pin value - uint8_t pin = (uint8_t)argv[1] & 0x31; + uint8_t pin = (uint8_t)argv[1] & 0x1F; // get the top two bits for the colour order type. uint8_t colour_type = (uint8_t)argv[1]>>5; switch (colour_type) { @@ -110,7 +110,7 @@ void process_command(byte argc, byte *argv){ } strip_0.updateLength(8); - //strip_0.setOutput(pin); + strip_0.setOutput(pin); break; } diff --git a/lib/pixel.js b/lib/pixel.js index c8cbee1..12cb64c 100644 --- a/lib/pixel.js +++ b/lib/pixel.js @@ -42,6 +42,7 @@ PIXEL_SET_STRIP = 0x04, PIXEL_CONFIG_FIRMATA = 0x05, PIXEL_CONFIG_BACKPACK = 0x06; + var PIN_DEFAULT = 6; // use this if not supplied var I2C_DEFAULT = 0x42; @@ -54,7 +55,7 @@ var Controllers = { var strip_length = opts.length || 6; // just an arbitrary val var data_pin = opts.data || DEFAULT_PIN; var firmata = opts.firmata || opts.board.io; - var colour_order = opts.colour_order || 0x0; // default GRB + var colour_order = opts.colour_order || COLOUR_TYPE.GRB; // default GRB var id = opts.strip_id || 0; // which strip are you talking to. if (firmata == undefined) { @@ -93,13 +94,11 @@ var Controllers = { // now send the config message with length and data point. var data = []; - colour_order = 2; data[0] = START_SYSEX; data[1] = PIXEL_COMMAND; //data[2] = PIXEL_CONFIG_FIRMATA; data[2] = PIXEL_CONFIG; data[3] = (colour_order << 5) | data_pin; - console.log("Data pin: %s", data_pin); data[4] = strip_length & FIRMATA_7BIT_MASK; data[5] = (strip_length >> 7) & FIRMATA_7BIT_MASK; data[6] = END_SYSEX; @@ -419,7 +418,7 @@ Pixel.prototype.colour = Pixel.prototype.color = function(color, opts) { if (options.sendmsg != undefined) { sendmsg = options.sendmsg; } var pixelcolor = null; - + if (color) { // get the color based on a string if(typeof(color) === "object") { @@ -453,4 +452,13 @@ Pixel.prototype.colour = Pixel.prototype.color = function(color, opts) { } }; -module.exports = { Strip: Strip}; +var COLOUR_TYPE = { + GRB: 0x00, + RGB: 0x01, + BRG: 0x02, +}; + +module.exports = { + Strip: Strip, + COLOUR_TYPE: COLOUR_TYPE, +};