Pattern Lifecycle Control / Code to Change Patterns?

Hi there, I’m a new PB user after finally pulling out a V3 I ordered long ago.
I’m considering it for a large project with 2880 APA102s.

My piece will have knobs/buttons etc. that choose the pattern and modify its variables. Is there a way to have code inside a pattern that switches to a different pattern? Moreover, it would be helpful to have code that runs “globally” outside of any particular pattern that handles some input/output stuff. That would be the right place to put code that, say, changes the pattern based on the position of a rotary switch, or sets a PWM value for an indicator light. (Come to think of it, analogWrite() isn’t supported, is it??)

I understand I could do this with websockets, which would probably mean a second ESP32? Connected over wifi? It’s not a great solution. Even a wired serial interface to another microcontroller would be an improvement.

Some of this was just discussed in this post but I’ll try and give an answer to your best approach (IMHO) and hopefully others including @wizard will chime in.

First of all, with 2880 lights, you’ll perhaps want to do multiple outputs (output expander) or even multiple PBs, depending greatly on the pattern complexity. It might be fine, or the frame rate might be slow. All depends on the pattern difficulty.

As for knobs and buttons, for pattern changing, I believe the built-in button (which you can wire in parallel to, to your own button) is the only way to change pattern, we don’t have an in-code method otherwise (yet). Nor “global code”. You can hook up some physical controls to replace a slider, or simulate a knob, and perhaps multiples depending on the pins available…

Yes, using websockets, you can externally control the PB, in the way you describe. You’re building a panel simulator then essentially just sending the results to the PB. That is likely the most functionality method. I could imagine using the sensor board interface for example but it would be half a solution probably at best.

Perhaps these items will rise toward the top of the development ToDo list, if the (few?) people asking reflects a big need, compared to other competing for time/energy development improvements requested. We have multiple threads of these requests already. Consolidating them and ranking them might be the next step.
But I know Ben has lots already queued up already.

Thanks, that other post is a great list of features that make sense to me.

So far I’ve gotten a reasonable FPS driving 2880 APA102s from a single output, as long as I run them at a high clock frequency. Some patterns are slow when rendering all those pixels, but I don’t think multiple outputs would help that.
Multiple PBs (using Firestorm?) would solve that problem, but I don’t think there’s a way for them to share a single pixel map. Because maps are normalized (usually a great thing), each controller would have its own coordinate space. I’m building one giant screen.

Overall, I don’t think PB is right for my project. It’s a large installation, it has an interactive control panel with mode control, I want it to do a few other things that aren’t LEDs (drive analog voltmeters/ammeters). It’s a shame, because I’m totally in love with some of the features, particularly use of the 5-bit brightness control on APA102 for high color depth. FastLED, usually my software of choice, doesn’t do this properly.

The secret is you include the corners of the total map space in both/all maps, at the end, so the normalizing is uniform across both/all maps.

So if you had a left half and right half, with bounds of 0-1000 in total on each axis, you’d include a 0,0 pixel and a 1000,1000 pixel in both, and then each half would be correct.

We’ve discussed this before, needs to be a advanced FAQ.

You could also use the new translation API.

Yeah, overall, you’ll have hurdles to overcome if you use PB and different hurdles if you Homebrew it from FastLED. No one true way.

Ah, good point, that would be the way for a single coordinate space. I think it would involve a few throwaway pixels? But that’s fine.

Don’t even have to be real pixels, just shove the coordinates at the end, tell it you have 2 more pixels than you actually do.

Hi Grant!

We love to optimize PB code here, so we might be able to help you improve your pattern performance!

Some of your fancy features are beyond PixelBlaze because of missing hardware, but as @Scruffynerf mentioned most things have workarounds until the software changes. Hopefully Ben has an unlimited supply of caffeine.

PB doesn’t have to be the only driver of your project, and the more processors, the merrier! I have a LattePanda which is an Intel CherryTrail and an Arduino Leonardo on a single board. I have a heart sensor on the Arduino side (I guess that could go on the PB sensor board) but on the Intel side I have a Bluetooth connection to a Muse EEG headband. I can control LEDs with my heartbeat and brainwaves.

I wonder if we can get TCP-over-USB on the PB’s USB port. We have discussed OSC and a couple of other protocols, too.

P.S.


Please find attached an Acapplaya memory from 2006.

2 Likes

Holy smokes, Hi Tom!!! Funny seeing you in this corner of the world! (Hah not really. This is another Burning Man project.)

I’ll write the patterns myself and I’m not too worried about performance, actually. It was only some of the stock patterns that were slow. For design/mechanical reasons I’d like to only have a single SPI output driving the piece, but I can flex on that and get multiple PBs if needed.

Multiple microcontrollers is a likely solution, and I’m fine with that. But as I said up-front, for the control I want this would probably be another ESP32 talking websockets over WiFi which, even if they’re millimeters from each other, I would be wary of. Communicating over the USB port or something hard-wired would make me much more comfortable.

It sounds like etherneted (or wifi) esp32, with most of them having e1.31 pushed pixels is the way to go for your project here. So WLED, and/or FastLED. Quindor’s new etherneted esp32 if you want wires.

Well if I have an ESP32 it’ll do everything, no need for multiple boards. I was hoping for something that uses the APA102 global brightness control intelligently for better color rendering (as PB does), so I’m looking into microcontroller options with that (and 16±bit color representation, also like PB). Maybe SmartMatrix, which is actually better supported on Teensy 3/4.

@grantpatterson ,
The low level PB library for APA102 is open source. It won’t help you calculate the global brightness, but does let you set it, and runs in a bufferless rendering pipeline for increased throughput.

For calculating global brightness, I do something like this (assume v is a value between 0 and 1):

v31 = v*31
pow = ceil(v31)
vOut = v31 / pow

Then vOut now holds the adjusted brightness value (scale that to 0-255), and pow is the global brightness.

e.g.

with v = 0.25:

v31 = 7.75
pow = 8
vOut = 0.96875

Would end up having a global brightness of 8/31, and channel brightness set to 247/255.

(8/31) * (247/255) is ~0.2499

2 Likes

Thanks @wizard, yeah I could use that. And I have code that calculates the GBC here: SmartMatrix/MatrixCommonApa102Calc_Impl.h at master · pixelmatix/SmartMatrix · GitHub

Obviously it would be really nice to just use PB! Or something else that makes writing patterns fun and easy. Looks like I may have to cobble together stuff from LED tools with limited function / graphics support.

Anyway, my PB wishlist probably boils down to:

  • Someplace to write global code
  • Support for global code that can manage which pattern is playing etc.
  • analogWrite()

OR, with a second ESP32 to read sensors and drive PWM for other things:

  • a way to send websocket commands over a wired interface
1 Like

PB will get there :slight_smile: I’d love PB to work out for you, but I also don’t want to push it where it doesn’t fit. At the end of the day we’re all still fans of good LED art.

Adding analogWrite wouldn’t be too hard. Global code and sequencer APIs are also things I want to add. Wired (probably serial) control has also requested. Though doing this right means a decent amount of work on my end, it could help PB fit in to some interesting projects!

What kind of sensors do you want to integrate? I’ve been thinking about adding I2C APIs too.

Understood! Yeah I know those features would need a lot of thought/work. I wish PB’s core code was open-source so we could contribute, but I understand why it’s not.

I’m making a control panel so it’s just switches and potentiometers, nothing fancy. The analogWrite() would be to “set” the value of a series of analog voltmeters on the panel I’m repurposing. I did that on this project and it’s pretty fun to watch the needle move around (it’s just displaying perlin noise): https://www.instagram.com/p/BteLcl8Hypk/

Hey @grantpatterson, here’s one idea… I think the output expander lets you set some outputs as APA102 protocol and others as WS28xx. Could you set your analog voltmeters by wiring up one or two WS2811 driver ICs? You’d get 3 analogWrite-ish “pins” per IC, up to 12VDC after an RC low pass filter.

1 Like

That’s a good idea! I was thinking about that for a few indicator lights on the panel. I see they come in a DIP 10pcs WS2811 WS2811D LED Drive IC Chip DIP8 - Newegg.com

Good to run into you here, Grant. Looking forward to seeing some crazy videos of your project.

Here’s a pic of my favourite meter. I have no idea what a NULL INDICATOR is, maybe some sort of Java debugger? This one is hooked up to a calculator solar cell. Oh … and that seems to be reflecting my increasingly shiny forehead:

1 Like