From 36b6668a98526bc4d08be817eb6b52bd387cd9b4 Mon Sep 17 00:00:00 2001 From: Russell Hay Date: Sat, 6 Dec 2014 11:42:04 -0800 Subject: [PATCH 1/4] Adding neopixel protocol proposal --- neopixel-proposal.md | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 neopixel-proposal.md diff --git a/neopixel-proposal.md b/neopixel-proposal.md new file mode 100644 index 0000000..25b1481 --- /dev/null +++ b/neopixel-proposal.md @@ -0,0 +1,100 @@ +neopixel proposal +=== + +This proposal is to allow you to control neopixel leds via firmata. + +An implementation of this proposal is currently available [here](https://github.com/RussTheAerialist/arduino/compare/firmata:configurable_dev...RussTheAerialist:neopixel_strip). + +``` +// wrapper for neopixel initialize function +// when initialition is finished, firmata sends done response to host +// see done response below +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_INIT (0x01) +3 NEOPIXEL_INIT_PARAM_PIN +4 NEOPIXEL_INIT_PARAM_COUNT (lsb) // Number of pixels on the strand +5 NEOPIXEL_INIT_PARAM_COUNT (msb) +6 NEOPIXEL_INIT_ORDER (see below) +7 NEOPIXEL_INIT_SPEED (see below) +8 END_SYSEX (0xF7) +``` + +``` +// wrapper for neopixel set pixel function +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_PIXEL (0x02) +3 NEOPIXEL_PIXEL_PARAM_LOCATION (lsb) // pos of the pixel to change, 0-based +4 NEOPIXEL_PIXEL_PARAM_LOCATION (msb) +5 NEOPIXEL_PIXEL_PARAM_RED (lsb) // Red value 0-255 +6 NEOPIXEL_PIXEL_PARAM_RED (msb) +7 NEOPIXEL_PIXEL_PARAM_GREEN (lsb) // Green value 0-255 +8 NEOPIXEL_PIXEL_PARAM_GREEN (msb) +9 NEOPIXEL_PIXEL_PARAM_BLUE (lsb) // Blue value 0-255 +10 NEOPIXEL_PIXEL_PARAM_BLUE (msb) +11 END_SYSEX (0xF7) +``` + +``` +// wrapper for show function (displays the next frame on the leds) +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_SHOW (0x05) +3 END_SYSEX (0xF7) +``` + +``` +// wrapper for clear function (sets all pixels to black) +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_CLEAR (0x04) +3 END_SYSEX (0xF7) +``` + +``` +// wrapper for set brightness function (scales the brightness of all leds) +// this is also a response from firmata back to the host computer +// see query brightness below +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_BRIGHTNESS (0x06) +3 NEOPIXEL_BRIGHTNESS_PARAM_VALUE (lsb) // 0-255 +4 NEOPIXEL_BRIGHTNESS_PARAM_VALUE (msb) // 0-255 +5 END_SYSEX (0xF7) +``` + +``` +// wrapper for query brightness (return the current brightness value) +// responds with above set brightness to host computer +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_BRIGHTNESS (0x06) +3 END_SYSEX (0xF7) +``` + +``` +// done response to host computer +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_DONE (0x07) +3 END_SYSEX (0xF7) +``` + +Order and Speed +--- + +Order and Speed are from the Adafruit Neopixel library. + +``` +// Order Values for the order of the rgb bytes +NEO_RGB (0x00) +NEO_GRB (0x01) +NEO_BRG (0x04) +``` + +``` +// Speed, either 400Khz (trinket, slower processors) or 800Khz (normal) +NEO_KHZ400 (0x00) +NEO_KHZ800 (0x02) +``` From aaa360964b6155adfe8cec7d4b7a5fc0c16037c8 Mon Sep 17 00:00:00 2001 From: Russell Hay Date: Sat, 6 Dec 2014 13:02:09 -0800 Subject: [PATCH 2/4] Adding frame command to reduce needed bytes for updating all pixels --- neopixel-proposal.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/neopixel-proposal.md b/neopixel-proposal.md index 25b1481..4dd38a1 100644 --- a/neopixel-proposal.md +++ b/neopixel-proposal.md @@ -81,6 +81,20 @@ An implementation of this proposal is currently available [here](https://github. 3 END_SYSEX (0xF7) ``` +``` +// set frame (send values for all pixels) +// all pixels set, and then show is called. +// This is to reduce the number of bytes necessary for updating all of the pixels and showing them +// useful if the host computer keeps copies of the led values +// done response is sent after the frame is shown +// (not currently implemented) +0 START_SYSEX (0xF0) +1 NEOPIXEL_DATA (0x62) +2 NEOPIXEL_CMD_FRAME (0x03) +3 ... (number of pixels * 6 bytes, RGB order, two bytes per channel with lsb, msb ordering) +N END_SYSEX (0xF7) +``` + Order and Speed --- From 4b251123d14432294200f68d4ef4e2f673e19404 Mon Sep 17 00:00:00 2001 From: Russell Hay Date: Sat, 6 Dec 2014 14:27:50 -0800 Subject: [PATCH 3/4] Renaming to ledstrip, changing initialization slightly to accomodate the fact that WS2801s need clock pin also --- neopixel-proposal.md => ledstrip-proposal.md | 82 +++++++++++--------- 1 file changed, 44 insertions(+), 38 deletions(-) rename neopixel-proposal.md => ledstrip-proposal.md (53%) diff --git a/neopixel-proposal.md b/ledstrip-proposal.md similarity index 53% rename from neopixel-proposal.md rename to ledstrip-proposal.md index 4dd38a1..0e423b5 100644 --- a/neopixel-proposal.md +++ b/ledstrip-proposal.md @@ -1,54 +1,57 @@ -neopixel proposal +led strip proposal === -This proposal is to allow you to control neopixel leds via firmata. +This proposal is to allow you to control led strip leds via firmata. An implementation of this proposal is currently available [here](https://github.com/RussTheAerialist/arduino/compare/firmata:configurable_dev...RussTheAerialist:neopixel_strip). ``` -// wrapper for neopixel initialize function +// wrapper for led strip initialize function // when initialition is finished, firmata sends done response to host // see done response below -0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_INIT (0x01) -3 NEOPIXEL_INIT_PARAM_PIN -4 NEOPIXEL_INIT_PARAM_COUNT (lsb) // Number of pixels on the strand -5 NEOPIXEL_INIT_PARAM_COUNT (msb) -6 NEOPIXEL_INIT_ORDER (see below) -7 NEOPIXEL_INIT_SPEED (see below) -8 END_SYSEX (0xF7) +0 START_SYSEX (0xF0) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_INIT (0x01) +3 LEDSTRIP_INIT_PARAM_DATA_PIN +4 LEDSTRIP_INIT_PARAM_COUNT (lsb) // Number of pixels on the strand +5 LEDSTRIP_INIT_PARAM_COUNT (msb) +... Additional Strip specific configuration information +N END_SYSEX (0xF7) ``` +For Neopixel, order and speed would be in the additional configuration +information +For WS2801, Clock Pin would be included in the additional configuratio information. + ``` -// wrapper for neopixel set pixel function +// wrapper for led strip set pixel function 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_PIXEL (0x02) -3 NEOPIXEL_PIXEL_PARAM_LOCATION (lsb) // pos of the pixel to change, 0-based -4 NEOPIXEL_PIXEL_PARAM_LOCATION (msb) -5 NEOPIXEL_PIXEL_PARAM_RED (lsb) // Red value 0-255 -6 NEOPIXEL_PIXEL_PARAM_RED (msb) -7 NEOPIXEL_PIXEL_PARAM_GREEN (lsb) // Green value 0-255 -8 NEOPIXEL_PIXEL_PARAM_GREEN (msb) -9 NEOPIXEL_PIXEL_PARAM_BLUE (lsb) // Blue value 0-255 -10 NEOPIXEL_PIXEL_PARAM_BLUE (msb) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_PIXEL (0x02) +3 LEDSTRIP_PIXEL_PARAM_LOCATION (lsb) // pos of the pixel to change, 0-based +4 LEDSTRIP_PIXEL_PARAM_LOCATION (msb) +5 LEDSTRIP_PIXEL_PARAM_RED (lsb) // Red value 0-255 +6 LEDSTRIP_PIXEL_PARAM_RED (msb) +7 LEDSTRIP_PIXEL_PARAM_GREEN (lsb) // Green value 0-255 +8 LEDSTRIP_PIXEL_PARAM_GREEN (msb) +9 LEDSTRIP_PIXEL_PARAM_BLUE (lsb) // Blue value 0-255 +10 LEDSTRIP_PIXEL_PARAM_BLUE (msb) 11 END_SYSEX (0xF7) ``` ``` // wrapper for show function (displays the next frame on the leds) 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_SHOW (0x05) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_SHOW (0x05) 3 END_SYSEX (0xF7) ``` ``` // wrapper for clear function (sets all pixels to black) 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_CLEAR (0x04) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_CLEAR (0x04) 3 END_SYSEX (0xF7) ``` @@ -57,10 +60,10 @@ An implementation of this proposal is currently available [here](https://github. // this is also a response from firmata back to the host computer // see query brightness below 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_BRIGHTNESS (0x06) -3 NEOPIXEL_BRIGHTNESS_PARAM_VALUE (lsb) // 0-255 -4 NEOPIXEL_BRIGHTNESS_PARAM_VALUE (msb) // 0-255 +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_BRIGHTNESS (0x06) +3 LEDSTRIP_BRIGHTNESS_PARAM_VALUE (lsb) // 0-255 +4 LEDSTRIP_BRIGHTNESS_PARAM_VALUE (msb) // 0-255 5 END_SYSEX (0xF7) ``` @@ -68,16 +71,16 @@ An implementation of this proposal is currently available [here](https://github. // wrapper for query brightness (return the current brightness value) // responds with above set brightness to host computer 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_BRIGHTNESS (0x06) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_BRIGHTNESS (0x06) 3 END_SYSEX (0xF7) ``` ``` // done response to host computer 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_DONE (0x07) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_DONE (0x07) 3 END_SYSEX (0xF7) ``` @@ -89,13 +92,16 @@ An implementation of this proposal is currently available [here](https://github. // done response is sent after the frame is shown // (not currently implemented) 0 START_SYSEX (0xF0) -1 NEOPIXEL_DATA (0x62) -2 NEOPIXEL_CMD_FRAME (0x03) +1 LEDSTRIP_DATA (0x62) +2 LEDSTRIP_CMD_FRAME (0x03) 3 ... (number of pixels * 6 bytes, RGB order, two bytes per channel with lsb, msb ordering) N END_SYSEX (0xF7) ``` -Order and Speed +Strip Specific Information +=== + +Adafruit Neopixel (and other WS2812 strips) --- Order and Speed are from the Adafruit Neopixel library. From b463d842b133d861c5fcadb4b81b0c7e2fd4cf00 Mon Sep 17 00:00:00 2001 From: Russell Hay Date: Mon, 8 Dec 2014 07:15:48 -0800 Subject: [PATCH 4/4] Adding a led strip type query command and response --- ledstrip-proposal.md | 77 +++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/ledstrip-proposal.md b/ledstrip-proposal.md index 0e423b5..49f40eb 100644 --- a/ledstrip-proposal.md +++ b/ledstrip-proposal.md @@ -5,16 +5,35 @@ This proposal is to allow you to control led strip leds via firmata. An implementation of this proposal is currently available [here](https://github.com/RussTheAerialist/arduino/compare/firmata:configurable_dev...RussTheAerialist:neopixel_strip). +``` +// wrapper for querying the type of LED Strip enabled on this firmata firmware +// responds with a LED_STRIP_CMD_QUERY response (see below) +0 START_SYSEX (0xF0) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_QUERY (0x00) +3 END_SYSEX (0xF7) +``` + +``` +// Response packet for the QUERY +0 START_SYSEX (0xF0) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_QUERY (0x00) +3 LED_STRIP_TYPE (0x00 for NEOPIXEL, 0x01 for WS2801) +4 END_SYSEX (0xF7) +``` + + ``` // wrapper for led strip initialize function // when initialition is finished, firmata sends done response to host // see done response below 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_INIT (0x01) -3 LEDSTRIP_INIT_PARAM_DATA_PIN -4 LEDSTRIP_INIT_PARAM_COUNT (lsb) // Number of pixels on the strand -5 LEDSTRIP_INIT_PARAM_COUNT (msb) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_INIT (0x01) +3 LED_STRIP_INIT_PARAM_DATA_PIN +4 LED_STRIP_INIT_PARAM_COUNT (lsb) // Number of pixels on the strand +5 LED_STRIP_INIT_PARAM_COUNT (msb) ... Additional Strip specific configuration information N END_SYSEX (0xF7) ``` @@ -26,32 +45,32 @@ For WS2801, Clock Pin would be included in the additional configuratio informati ``` // wrapper for led strip set pixel function 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_PIXEL (0x02) -3 LEDSTRIP_PIXEL_PARAM_LOCATION (lsb) // pos of the pixel to change, 0-based -4 LEDSTRIP_PIXEL_PARAM_LOCATION (msb) -5 LEDSTRIP_PIXEL_PARAM_RED (lsb) // Red value 0-255 -6 LEDSTRIP_PIXEL_PARAM_RED (msb) -7 LEDSTRIP_PIXEL_PARAM_GREEN (lsb) // Green value 0-255 -8 LEDSTRIP_PIXEL_PARAM_GREEN (msb) -9 LEDSTRIP_PIXEL_PARAM_BLUE (lsb) // Blue value 0-255 -10 LEDSTRIP_PIXEL_PARAM_BLUE (msb) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_PIXEL (0x02) +3 LED_STRIP_PIXEL_PARAM_LOCATION (lsb) // pos of the pixel to change, 0-based +4 LED_STRIP_PIXEL_PARAM_LOCATION (msb) +5 LED_STRIP_PIXEL_PARAM_RED (lsb) // Red value 0-255 +6 LED_STRIP_PIXEL_PARAM_RED (msb) +7 LED_STRIP_PIXEL_PARAM_GREEN (lsb) // Green value 0-255 +8 LED_STRIP_PIXEL_PARAM_GREEN (msb) +9 LED_STRIP_PIXEL_PARAM_BLUE (lsb) // Blue value 0-255 +10 LED_STRIP_PIXEL_PARAM_BLUE (msb) 11 END_SYSEX (0xF7) ``` ``` // wrapper for show function (displays the next frame on the leds) 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_SHOW (0x05) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_SHOW (0x05) 3 END_SYSEX (0xF7) ``` ``` // wrapper for clear function (sets all pixels to black) 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_CLEAR (0x04) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_CLEAR (0x04) 3 END_SYSEX (0xF7) ``` @@ -60,10 +79,10 @@ For WS2801, Clock Pin would be included in the additional configuratio informati // this is also a response from firmata back to the host computer // see query brightness below 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_BRIGHTNESS (0x06) -3 LEDSTRIP_BRIGHTNESS_PARAM_VALUE (lsb) // 0-255 -4 LEDSTRIP_BRIGHTNESS_PARAM_VALUE (msb) // 0-255 +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_BRIGHTNESS (0x06) +3 LED_STRIP_BRIGHTNESS_PARAM_VALUE (lsb) // 0-255 +4 LED_STRIP_BRIGHTNESS_PARAM_VALUE (msb) // 0-255 5 END_SYSEX (0xF7) ``` @@ -71,16 +90,16 @@ For WS2801, Clock Pin would be included in the additional configuratio informati // wrapper for query brightness (return the current brightness value) // responds with above set brightness to host computer 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_BRIGHTNESS (0x06) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_BRIGHTNESS (0x06) 3 END_SYSEX (0xF7) ``` ``` // done response to host computer 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_DONE (0x07) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_DONE (0x07) 3 END_SYSEX (0xF7) ``` @@ -92,8 +111,8 @@ For WS2801, Clock Pin would be included in the additional configuratio informati // done response is sent after the frame is shown // (not currently implemented) 0 START_SYSEX (0xF0) -1 LEDSTRIP_DATA (0x62) -2 LEDSTRIP_CMD_FRAME (0x03) +1 LED_STRIP_DATA (0x62) +2 LED_STRIP_CMD_FRAME (0x03) 3 ... (number of pixels * 6 bytes, RGB order, two bytes per channel with lsb, msb ordering) N END_SYSEX (0xF7) ```