Raspberry Pi 2- What works and what doesn't!

It works! I’m blind now, but at least I got to see it once!

Hurrah! Thank @Jon for persevering in the face of adversity. We’re still looking for a real solution, but this should let you damage your eyesight in the interim.

Well chuffed, it gets my LEDs blinking! Thanks for all the effort :)

i thought my unit was broken. For now at least it gets four LEDs on the upper right of my unicorn hat to light up. Hope things will be okay soon. Thanks for the effort guys!

That works but when I tried the clock.py I could see what you mean by hacky and temporary. Anyway, just want to confirm it runs and it’s a bit laggy. Keep up the good work!

There’s light ( blindingly bright rainbow light in fact ) at the end of the tunnel. A recent development with Servo Blaster has been demonstrated to work with WS2812 pixels too- a fully Pi 2 compatible, glorious Unicorn HAT library is not far off!

Excellent! Looking forward to it.

Aaaaannnnddd… we have a pre-release. See above for update instructions, or just:

sudo pip install unicornhat --upgrade

W00T! W00T! Good work.

tried all updates and getting nothing visual still.

getting plenty of errors though…

Traceback (most recent call last):
File “/home/pi/Pimoroni/unicornhat/rainbow.py”, line 3, in
import unicornhat as unicorn
File “/usr/local/lib/python3.2/dist-packages/unicornhat.py”, line 13, in
ws2812.begin()
File “/usr/local/lib/python3.2/dist-packages/neopixel.py”, line 100, in begin
raise RuntimeError(‘ws2811_init failed with code {0}’.format(resp))
RuntimeError: ws2811_init failed with code -1

Any ideas?

Hi @jonregler, I saw the same errors. It looks like insufficient permissions? I ran with “sudo” and the examples run fine.

Just tried pre-release out on 2B with ScratchGPIO and I’m back in NeoPixel business :)

FYI I’m getting this error when I ctrl-c my prog
Exception AttributeError: “‘NoneType’ object has no attribute ‘ws2811_fini’” in <bound method Adafruit_NeoPixel.del of <neopixel.Adafruit_NeoPixel object at 0xc0f4d0>> ignored
swig/python detected a memory leak of type ‘ws2811_t *’, no destructor found.

Simon

I think this is classic Python- where objects are too destroyed to finalize propeller on program exit. I’ll have to plumb the depths of the library and see if I can make it exit cleanly.

At the moment it tries to call “ws2811_fini” on the rpi_ws281x module to clean up after itself in the del method of the NeoPixel class, but at this point the rpi_ws281x module has already been destroyed- I’ll fix this up using atexit which seems to work pretty well for me in other cases.

I was seeing similar errors. Turns out I had /tmp mounted as a tmpfs filesystem with the nodev flag, which was causing ‘permission denied’ errors for rpi-ws281x. Remounting it without that flag made the problem go away.

Alternatively, could it be because you’re running with Python 3.2? Perhaps it’s not compatible.

It’s definitely Python 3.2 compatible- I’ve tested it. However, the /tmp mounted as tmpfs is an interesting finding.

Hi Gadgetoid - I tried this this morning (I have a pi 2 and unicorn hat) and I had problems installing it in the first place - either via pip install unicornhat --upgrade (or without --upgrade) and via git cloning and installing that way.

This is the error I got (hand copied from my monitor before I left for work, so hopefully it’s accurate):

Compiling ws281x library...
running build
running build_py
running build_ext
building '_rpi_ws281x' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g fwrapv -02 -Wall -Wstrict-prototypes -fPIC -Ilib/ -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp/linux-armv7l-2.7/rpi_ws281x_wrap.o

rpi_ws281x_wrap.c:125:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1

Have I forgotten to do part of the process? Why would the compilation be failing here? I had run sudo apt-get update and sudo apt-get upgrade (and rebooted) before trying this, so I can’t think what I’m doing wrong.

Thanks,
Will

Looks like you’re missing a crucial step:

sudo apt-get install python-dev

That should sort you out!

One other thing - I’d modified orig unicorn.hat to add in 2 functions to set/read any NeoPixels connected to a Pi (just bypassing the matrix maths). If you could add them in - it would make life much easier in future (both for me using your lib in ScratchGPIO users and Python programmers generally)

#Extra functions so that this becomes general NeoPixel interface
#added by Simon Walters
def set_neopixel(index, r, g, b):
 '''
 Set a single pixel to RGB colour
  '''
  ws2812.setPixelColorRGB(index, r, g, b)


def get_neopixel(index):
 '''
 Get the RGB value of a single pixel
  '''
 pixel = ws2812.getPixelColorRGB(index)
 return (int(pixel.r), int(pixel.g), int(pixel.b))

I also had error messages until running the samples as root. I note that the getting started page does show the use of sudo to run simple.py, so perhaps this is intended behaviour.

I would prefer that a script I leave running all the time not need root permissions just so it can talk to the unicorn.

Unfortunately requiring root is pretty much the norm on the Raspberry Pi. There’s also no way to talk to Unicorn HAT without it- whether you use a kernel module or a daemon or a straight script it’s always code running with elevated permissions.