Pibrella / Python Confusion


Ok - hopefully this will make sense.

When running the basic Pibrella commands from Pibrella.com I get some interesting results and I am wondering if someone clear up the differences for me?

If I type from the Raspbian command line:

sudo python -i

and then run the following code in the interactive python shell that come up I get a nice throbbing setting of LEDs on the Pibrella.

import pibrella

If I type


and then launch the Python 2 IDLE from the desktop, it tells me i am not a root user.
How can I fix this , so I can run these commands in the IDLE?

And then…

If I build a .PY file using the same commands so i can run it from the terminal as a program, eg

sudo python test.py

I get no errors but the 3 LEDs do not give a satisfying throb, but a seemingly random flicker. Why does the pibrella.light.pulse give different results?



With the Python 2 idle, you will need to open LXTerminal first, and type in ‘sudo idle’ and hit enter, this opens IDLE with sudo privileges capable of writing to the GPIO pins.

As for the flicker, thats just down to the software, as it’s running in the X window gui, a lot of timing priority is taken up by Linux stuff, that has more importance over a small python script.

I’m not sure if @gadgetoid has any other way around smoothing out the bumps, usually it involved tying scripts in to the DMA registers to pull some more accurate timing.


sudo idle

Got it - makes sense. Thanks

Regarding the timing - That kind of makes sense but it also surprises me as this is not doing anything crazy!

So if I quit the window gui and run my test.py from the command line (is that the right term?) it will throb not flicker?

I have never written the word throb so much in one morning, since the last time I had to fill in a medical declaration form!



Yeah it should pulse nicely outside of X (hence startx), more cpu time is dedicated to python. If you wanted more stability a low level language like C performs much better as it has greater control over cpu and memory timing, but that comes at the cost of trying to pick up a complicated language.

And throb does sound like a weird word after saying it so many times… Throb… frob… throb…