Is there any software API for changing patterns? I built a control box with next/previous buttons wired to the sensor board’s analog inputs (as well as a pot for brightness control) assuming there was but I can’t find any explanation of how to do it.
There are multiple forum topics making this request but they all end up using some other solution which requires different wiring which is not possible for my project.
EDIT: After thinking about this for a little while, I guess as a very last resort I could add all the patterns I wanted into one source file and create an array of render2D functions and index into that with a “currentPattern” pointer which I update according to the button presses. Ugly hack, but manageable if I keep it under source control and I need to modify each pattern to use the brightness knob anyhow…
Would the pull-GPIO0-down-from-code trick mentioned (but not eventually used) in this post actually work? (I guess GPIO32 on a PixelBlaze v3)
(I’m kinda desperate for something—I have one unused line in the cable from the PB to the output expander/control box, but given GPIO0 needs to be pulled to ground to advance to the next pattern and the buttons are currently wired to pull up to 3.3V to make that work I’d have to entirely rewire the control box which I don’t want to have to do at this late stage… I fly out in 9 days!)
(@wizard, just a wild though on this general topic – would it be possible to set up a packet dispatcher in the Pixelblaze’s serial input reader so that we could send JSON websocket api commands as serial data?
That’d make it really easy to solve a lot of these physical control problems with super cheap IoT devices, without requiring wifi. It’s a low enough data rate that even the tiniest STM or arduino could handle physical controls, multiplex the sensor board data if present, and send the necessary JSON commands.)
Good news @ratkins !
Here’s a beta build with sequencer APIs. This should let you implement what you are looking for with a bit of pattern code. You’ll need to copy some code to each pattern for reading/debouncing SB inputs and going next/prev, but cleaner than making a mega pattern.
sequencerNext() Universal advance to next pattern, pretty much the same as button press. This API does nothing on a follower, so it won’t advance multiple times if you trigger it from a sensor board value; a follower will follow whatever pattern the leader is doing.
sequencerGetMode() returns the current mode, one of :
playlistGetPosition() current index of the playlist (starts at 0)
playlistSetPosition(position) switch to this item unless it’s already the playlist’s current position.
playlistGetLenght() number of items in the playlist
Going to the previous pattern is possible in playlist mode, and could work like this:
function previous() {
var p = playlistGetPosition() - 1;
p = mod(p, playlistGetLength()) //wrap back to beginning, and ensure position fits length
playlistSetPosition(p)
}
Wizard - are these functions still in beta? I don’t see them in the documentation (and don’t have a pixelbase handy right now to test if they’re in the editor)
Just wanted to clarify that these are still not showing up for me on any of my PBs on 3.51 (Pico or Standard). I have this post bookmarked for when I need to reference the docs.