0

Neopixels: Programming for multiple, dissimilar pixel 'strip
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Neopixels: Programming for multiple, dissimilar pixel 'strip

by danowar on Thu Dec 04, 2014 1:19 pm

Hey all. I am turning a large, commercial type 1940s-era multimeter into a crazy glowing disco box of sorts; my hardware is at this point largely complete, and now I'm starting to work on the software side.

This project involves several different banks of NeoPixels -- there are 4 groups of 4 NeoPixels (2 of these groups are the 8mm standalone traditional LED type of form factor, and the other 2 groups are the same but are 5mm instead, which should make no difference from a programming standpoint). Another 'group' is a NeoPixel Jewel, which has 7 pixels. Another is a single, standalone NeoPixel, and the last group is an 80-pixel matrix (consisting of an 8x8 pixel matrix with a 1x8 pixel stick on each side). Each group is on its own PWM pin, with the exception of the single standalone pixel, which is on digital pin 2 (this one is effectively just a power light).

Everything is all wired up and it all works just fine; what I'm trying to figure out now is how to write a sketch that can talk to each of them. I've seen a number of examples of this where multiple strip objects are declared and placed in an array; this works fine if all of the light strips are logically identical (and indeed I have tested this successfully for the 4 4-pixel groups), but in this case, 4 of the 7 strips are identical, and each of the other 3 are unique.

Additionally, while the identical strips are intended to generally mirror one another, the other 3 light groups will each need to have separate instructions. I realize I will have to figure some stuff out to allow everything to work without using delay() -- lest each light group execute its instruction, then hang out, and then on to the next group, which is not going to work for me here -- and I can probably sort that out sooner or later, but how can multiple, dissimilar LED strips be viably addressed in this fashion? I am still trying to decide on the best library to use for this purpose as well -- Adafruit's NeoPIxel library is excellent, but I've been looking into FastLED as well. Board is an Arduino Mega 2560.

Thanks very much!

danowar
 
Posts: 19
Joined: Fri Jul 04, 2014 7:16 pm

Re: Neopixels: Programming for multiple, dissimilar pixel 's

by adafruit_support_bill on Thu Dec 04, 2014 1:45 pm

I'm hoping to address many of these issues with respect to programming neopixels in an upcoming tutorial, but it is still in the early stages at this point and I don't have any sample code for you. I can point you to the first tutorial in the series so you can see some of the basic techniques for multitasking on a simple platform like the Arduino: https://learn.adafruit.com/multi-taskin ... 1/overview

adafruit_support_bill
 
Posts: 71426
Joined: Sat Feb 07, 2009 10:11 am

Re: Neopixels: Programming for multiple, dissimilar pixel 's

by danowar on Thu Dec 04, 2014 2:16 pm

adafruit_support_bill wrote:I'm hoping to address many of these issues with respect to programming neopixels in an upcoming tutorial, but it is still in the early stages at this point and I don't have any sample code for you. I can point you to the first tutorial in the series so you can see some of the basic techniques for multitasking on a simple platform like the Arduino: https://learn.adafruit.com/multi-taskin ... 1/overview


Awesome, I'm looking forward to it! I've run across this tutorial before in fact, and have taken its lessons to heart (that excellent tutorial is why I've learned to attempt to avoid using delay() at all costs).

Would it be feasible to put all of the groups in a single array (or a hash table, if that's a thing in Arduinoworld), refer to the number of pixels in each of them as a static value, and then set a variable that refers to that value during a loop, such that as the loop is iterated through, the PIXEL_COUNT or whatever variable is set at that time? I'm really new to Arduino programming, and indeed "real" programming in general, but I've done rather a lot of shell scripting (bash and PowerShell), and this is probably how I would approach it there.... but bash and PowerShell are horses of a very different color.

I don't really need any sample code, I'm happy with any suggestions or advice you might have.

Here are a couple pictures of the box, if you're at all curious. Thanks very much!

http://imgur.com/a/seZuR

Edit :: Pictures of the wiring and such as well, FWIW: http://imgur.com/a/yjSea
Last edited by danowar on Thu Dec 04, 2014 2:55 pm, edited 2 times in total.

danowar
 
Posts: 19
Joined: Fri Jul 04, 2014 7:16 pm

Re: Neopixels: Programming for multiple, dissimilar pixel 's

by adafruit_support_bill on Thu Dec 04, 2014 2:29 pm

Nice looking build! Thanks for the photos.

My current thinking is to create a base-class that wraps a pattern interface with a strip. Then to derive the individual patterns from the base class. Then you can have an array of pattern pointers and update them all polymorphically.

adafruit_support_bill
 
Posts: 71426
Joined: Sat Feb 07, 2009 10:11 am

Re: Neopixels: Programming for multiple, dissimilar pixel 's

by danowar on Thu Dec 04, 2014 3:02 pm

Hey thanks! I'm pretty proud, this is my first real project (outside of screwing around with a breadboard and making some LEDs light up and going "I MAED A LIGHT HAPPEN").

adafruit_support_bill wrote:Nice looking build! Thanks for the photos.

My current thinking is to create a base-class that wraps a pattern interface with a strip. Then to derive the individual patterns from the base class. Then you can have an array of pattern pointers and update them all polymorphically.


Wow, I guess maybe I do need some sample code. I don't know what half of that means. :P

A couple followup questions, then:

What is a base class?
What do you mean by 'wrapping a pattern interface with a strip'?
'Polymorphically'? o.O

I'm googling for these things presently, but any insight would be most helpful. Thanks a ton!

danowar
 
Posts: 19
Joined: Fri Jul 04, 2014 7:16 pm

Re: Neopixels: Programming for multiple, dissimilar pixel 's

by adafruit_support_bill on Thu Dec 04, 2014 3:13 pm

What is a base class?
What do you mean by 'wrapping a pattern interface with a strip'?

The base class defines common properties of all patterns (e.g.: they all have a strip and an update method).
The individual pattern classes derived from that can each do their own thing, but they will all have a strip and an update method.
'Polymorphically'? o.O

Since they are all derived from the same class, you can manage them as a collection of the same kind of thing. But when you call update(), each pattern will do what it needs to do.

adafruit_support_bill
 
Posts: 71426
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.