Rickta59 589 Posted November 16, 2012 Share Posted November 16, 2012 I ported over oPossum's ws2811 asm routines to msp430-gcc and wrapped it in simple Energia library. This class provides Energia users with a simple class with methods that allow you to configure the datapin, and set the leds colors in a ws2811 led strip. To install, stop running Energia and create a directory in your sketch folder called 'libraries'. Unzip the attached zip file into libraries directory. You should end up with a directory called libraries/WS2811Driver. Restart Energia and you should have some new items in your "File/Sketchbook/libraries/WS2811Driver/Examples" menu item. blink_strip example You need to create an instance of the WS2811Driver class. It provides methods that let you set the number of leds in your strip, it is called setLedCount(). The begin() methjod configures P1.7 as an output pin. The write() call is the main method for setting the leds. The write() method takes an array of uint8_t, it expects 3 bytes of color data per led in Green, Red, Blue order. See the blink_strip.ino example for more details. This could use a lot of work, however some might find it useful. I only ported the high speed 800KHz version of the asm code. One problem with using the asm routines with Energia is that they use cycle counting to achieve accurate timing. This will cause problems with the millis() accuracy. When I'm sending data I disable the watchdog before calling the asm routine and then reenable it after. I've only tested with the msp430g2553, however it might work with the other chips. I was testing with my development environment which is in flux at the moment. You can edit the ws2811.h file and change the port and pins if P1.7 doesn't work for you. -rick WS2811Driver_0_1.zip bluehash, energia, dubnet and 1 other 4 Quote Link to post Share on other sites
bobnova 59 Posted November 16, 2012 Share Posted November 16, 2012 Wonderful! I should have a strip showing up soon, I'll give this a whirl. Quote Link to post Share on other sites
bobnova 59 Posted November 18, 2012 Share Posted November 18, 2012 Got my strip and played with this a bit. It works great! Here's all 60 LEDs in my one meter strip with flowing colors. Max duty cycle is limited to 40, partly because these things are quite bright and partly because at full burn the strip eats ~1.2 amps and my regulator starts getting rather toasty. The LEDs are supplied with 5v (actually 4.5v after the LDO after coming out the USB3 port) from a seperate power board, the MSP430G2553 is on a standard Launchpad. #include <WS2811Driver.h> byte leds0[180]; WS2811Driver ledStrip; // uses P1_7 as datapin connect to DIN on strip void setup(void) { ledStrip.setLEDCount(60); // setup for 60 leds on a strip ledStrip.begin(); // configure P1.7 for output for (byte x = 0 ; x < 180 ; x++){ leds0[x] = 0; } } void loop() { for(byte x = 179; x >= 5 ; x--){ leds0[x] = leds0[x-3]; leds0[x-1] = leds0[x-4]; leds0[x-2] = leds0[x-5]; } leds0[0] = random(0,random(10,40)); leds0[1] = random(0,random(10,40)); leds0[2] = random(0,random(10,40)); ledStrip.write(leds0); // write to the LEDs delay(100); } Thanks for the library! It made this FAR easier! Rickta59 and bluehash 2 Quote Link to post Share on other sites
benbergman 1 Posted February 15, 2013 Share Posted February 15, 2013 I'm working on a board that will use an MSP430 to drive a number of WS2811 LEDs based on commands sent to it over I2C plus a single capacitive touch sensor. With the tight timing requirements, is it still possible to run I2C slave and capsense functions while writing to the LEDs? Likely the LEDs will only update after one of these is detected, but I might have functionality where these inputs affect a constantly running pattern. Quote Link to post Share on other sites
Rickta59 589 Posted February 15, 2013 Author Share Posted February 15, 2013 The WS2811Driver::write() method is blocking a call. It will disable the watchdog interval ISR while sending data to the ws2811 chip. This is the only way to achieve the required timing. If you are doing interrupt processing you should disable it before calling write(). It seems like you should be able to do what you want with some careful attention to what is running when. Of course it all depends on how many leds and the framerate of your animation. -rick Quote Link to post Share on other sites
stellarMex 0 Posted November 4, 2013 Share Posted November 4, 2013 this can be used with the stellaris lm4f? Quote Link to post Share on other sites
Rickta59 589 Posted November 5, 2013 Author Share Posted November 5, 2013 no, it is written using msp430 assembly Quote Link to post Share on other sites
ILAMtitan 86 Posted September 8, 2014 Share Posted September 8, 2014 Hey guys, I haven't been around much lately, but a recent project brought me back here and using this WS2811 library. I'm trying to enable more people to use the LaunchPad in some of my volunteer work (FIRST robotics) and flashing LEDs is a good eye catching way to do it. To help facilitate people who are already using Arduino and the venerable AdaFruit NeoPixels, I ported over almost all of her functionality to work in Energia. https://github.com/ILAMtitan/WS2811Driver With this, any project using the NeoPixel library will be near 100% compatible. I also took some time and worked out support for 25MHz on the 5529 LP (although it's a bit crude). My assembly knowledge is also only enough to get me so far. I haven't been able to work out the best way to enable PORT2 to be used since it's a #def in the assembly. If any of you guys can help work that out, it would be awesome. I know y'all are also really good at finding problems with code, so feel free to do some QA for me I've tested the timings up to 120 LEDs at 25MHz, but it might fail beyond that (I only had two strips to play with). And here's a little preview of the first project I'm working on with it: spirilis, reaper7, bluehash and 1 other 4 Quote Link to post Share on other sites
energia 485 Posted September 10, 2014 Share Posted September 10, 2014 @@ILAMtitan I just tried this lib and it works like a charm! Thanks for consolidating the code into a lib and thanks to @@Rickta59 and @@oPossum for the drive code! Quote Link to post Share on other sites
bluehash 1,581 Posted September 11, 2014 Share Posted September 11, 2014 @@ILAMtitan Good idea.. I might steal this shoe idea!!!! Quote Link to post Share on other sites
ILAMtitan 86 Posted September 11, 2014 Share Posted September 11, 2014 @@ILAMtitan I just tried this lib and it works like a charm! Thanks for consolidating the code into a lib and thanks to @@Rickta59 and @@oPossum for the drive code! I'm just standing on the shoulders of giant's here. @@ILAMtitan Good idea.. I might steal this shoe idea!!!! There sadly aren't many photos of the shoes during the build process so far, but I'll probably still do a project post about them when they are done. Quote Link to post Share on other sites
MORA99 9 Posted September 25, 2014 Share Posted September 25, 2014 Any chance of getting this working on cc3200 ? I tried replacing the msp includes to energia.h, and made an attempt at the pin declarations, the compiler isnt impressed though #define WS2811_BITMASK digitalPinToBitMask(3) #define WS2811_PORTDIR portDIRRegister(digitalPinToPort(3)) #define WS2811_PORTOUT digitalPinToPort(3) Quote Link to post Share on other sites
reaper7 67 Posted September 25, 2014 Share Posted September 25, 2014 @@MORA99 - do You see utility directory? many assembler stuff... Quote Link to post Share on other sites
MORA99 9 Posted September 26, 2014 Share Posted September 26, 2014 Yea I looked at it, hoped it would be compatible Even at 80MHz the timing is pretty tight, 72 cycles for the long delay if I remember correctly. Quote Link to post Share on other sites
ILAMtitan 86 Posted September 29, 2014 Share Posted September 29, 2014 @@MORA99 - This lib is very MSP430 asm dependent. The CC3200 uses an M4, so there is no chance of a direct port. You might have some luck looking into a Tiva WS2811 library since it's the same core, but I doubt it would be a simple port. Once I get my hands on a CC3200 LP I'll probably try to make a compatible WS2811 library for it, or expand this one to work with it as well. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.