Can't get an animation to run from script

Hi folks, I’ve been fumbling around with this for a while, and finally decided it’s worth asking for help.

I’m trying to run animations directly a Python script and failing miserably. While it seems that Projects are the preferred approach with Bibliopixel 3.0, I’m struggling to make REST and Controls work the way I’d like.

I’m running a string of WS2812 from a Raspberry Pi and a PiPixel hat. A simple project illuminates the LED’s, as does a direct call to myStrip.set(i,color) - so I’m confident that wiring isn’t the issue.

This project file works great:

driver:

typename: pi_ws281x

gpio: 18

num: 10

animation:

typename: BiblioPixelAnimations.strip.ColorWipe.ColorWipe

Enter code here…

``

The Python script that doesn’t work is here:

import bibliopixel

from bibliopixel import Strip

from bibliopixel.drivers.PiWS281X import PiWS281X, ChannelOrder

import bibliopixel.colors as colors

import time

import random

bibliopixel.log.setLogLevel(bibliopixel.log.DEBUG)

numLeds = 10

driver = PiWS281X(num = numLeds, gpio = 18)

load the LEDStrip class

from bibliopixel.layout import *

led = Strip(driver)

color = (random.randint(1,180), random.randint(1,180), random.randint(1,180))

for i in range (numLeds):

print ('LED '+str(i+1))

led.set(i, color)

led.update()

time.sleep(0.1)

Nothing below here works

from BiblioPixelAnimations.strip.ColorWipe import ColorWipe

anim = ColorWipe(led)

anim.run()

``

There are no errors when running this, just … nothing happens after my for loop. Any guidance would be greatly appreciated.

-Jerry

I’m really sorry for this delay, Jerry - this email didn’t make it to me, and if I hadn’t accidentally seen this on groups.google.com I’d never have replied! :-/ (It isn’t in Spam so don’t worry about that…)

In general, if you don’t get a response fairly soon from me, please send me a message directly to tom@swirly.com.

···

On Sunday, 25 November 2018 05:24:35 UTC+1, Jerry Jones wrote:

Hi folks, I’ve been fumbling around with this for a while, and finally decided it’s worth asking for help.

I’m trying to run animations directly a Python script and failing miserably. While it seems that Projects are the preferred approach with Bibliopixel 3.0, I’m struggling to make REST and Controls work the way I’d like.

We now (as of yesterday) have a mechanism called the Project Builder that lets you experiment from the command line and use Projects.

Documentation is here: https://github.com/ManiacalLabs/BiblioPixel/blob/master/doc/tutorial/getting-started/the-project-builder.rst

My theory is that you should use that, because it lets you write main programs and fiddle around, but also is much slicker.


As for the current code:

for i in range (numLeds):

print ('LED '+str(i+1))
led.set(i, color)
led.update()

``

I think this is the issue here. led.update() pushes the whole state of all the LEDs to the driver. And you haven’t actually even initialized the drivers yet, so who knows what will happen?

There’s never a reason for a user to call Layout.update() and I just sent out a pull request to add comments.

Even if you removed that line, the whole loop wouldn’t actually do anything permanent! :-o

It would set the LED values before anything starts - but then when you run ColorWipe, it would erase all that before the first frame was displayed.

time.sleep(0.1)

``

You shouldn’t need to call time.sleep() in user code either. All the timing is handled for you!

But use the Project Builder. It’s much more fun and lets you experiment at the command line, and then paste the results into a program.

https://github.com/ManiacalLabs/BiblioPixel/blob/master/doc/tutorial/getting-started/the-project-builder.rst

Ack, somehow I didn’t get the email either! Thanks for getting back to me.

I have to admit, I come from an iOS background, and I sort of suck with Python - I find myself with really dumb questions. I’ll take a look at the project builder and see if I can make any progress there.

Thanks!

-Jerry

···

On Tuesday, November 27, 2018 at 3:48:55 AM UTC-8, Tom Swirly wrote:

I’m really sorry for this delay, Jerry - this email didn’t make it to me, and if I hadn’t accidentally seen this on groups.google.com I’d never have replied! :-/ (It isn’t in Spam so don’t worry about that…)

In general, if you don’t get a response fairly soon from me, please send me a message directly to t...@swirly.com.

On Sunday, 25 November 2018 05:24:35 UTC+1, Jerry Jones wrote:

Hi folks, I’ve been fumbling around with this for a while, and finally decided it’s worth asking for help.

I’m trying to run animations directly a Python script and failing miserably. While it seems that Projects are the preferred approach with Bibliopixel 3.0, I’m struggling to make REST and Controls work the way I’d like.

We now (as of yesterday) have a mechanism called the Project Builder that lets you experiment from the command line and use Projects.

Documentation is here: https://github.com/ManiacalLabs/BiblioPixel/blob/master/doc/tutorial/getting-started/the-project-builder.rst

My theory is that you should use that, because it lets you write main programs and fiddle around, but also is much slicker.


As for the current code:

for i in range (numLeds):

print ('LED '+str(i+1))
led.set(i, color)
led.update()

``

I think this is the issue here. led.update() pushes the whole state of all the LEDs to the driver. And you haven’t actually even initialized the drivers yet, so who knows what will happen?

There’s never a reason for a user to call Layout.update() and I just sent out a pull request to add comments.

Even if you removed that line, the whole loop wouldn’t actually do anything permanent! :-o

It would set the LED values before anything starts - but then when you run ColorWipe, it would erase all that before the first frame was displayed.

time.sleep(0.1)

``

You shouldn’t need to call time.sleep() in user code either. All the timing is handled for you!

But use the Project Builder. It’s much more fun and lets you experiment at the command line, and then paste the results into a program.

https://github.com/ManiacalLabs/BiblioPixel/blob/master/doc/tutorial/getting-started/the-project-builder.rst