Getting the Unicorn Hat up and running

I’ve downloaded and set up RetroPie so I can try myself.

You could try cloning the UnicornHat GitHub repository and installing the ws2812 driver from there, try this:

https://github.com/pimoroni/unicornhat
cd unicornhat/python/ws2812
sudo python setup.py install

Great stuff. Ok, I’ll give this a go. I’m just trying a vanilla RetroPie image and will try your script and other bits of advice to see if anything works.

Will report back.

Ok, I have just used the vanilla RetroPie image (v2.3) and then ran your install script and everything works fine! The Unicorn Hat is working as expected.

Great news, but also a pain for me - something I have installed has obviously got an issue. Not sure what, but it looks like I may have to reinstall RetroPie from scratch if I want to use the Unicon Hat on my Pi.

I’m going to the last bit of advice you gave before my two replies to see if that fixes it - last chance saloon!

I have now managed to get the Unicorn Hat working with Emulation Station installed. I’m not sure what I did differently, but I can get it to work!

What I now need to figure out is how to get Emulation Station to run a command when I launch a game. The idea being that when I play any NES game, I run sudo python mario.py and then the Unicorn Hat displays the image (based on the show_png.py script) and it displays a custom animation I created which is an 8 x 8 pixel logo of Mario that alternates to Luigi…

If you can’t get emulation station to actively run a script, you could always run another script that polls the process list for each emulator ( might even be able to find the rom that’s been loaded in from the command line ) and updates accordingly.

Something like: ps aux | grep dgen

Or whatever the emulator binaries are called!

Glad you got it working- I’ve had plenty of problems I’ve fixed without quite figuring out how.

Thanks - sounds like a plan! I’ve just shutdown now, but I’ll give it a go and see how it goes.

I got the Unicorn at the weekend and its beautiful…

Had some fund with code found on github, making some changes looking for user inputs etc - quite impressed myself actually!

However - I only seemed to be able to run my .py code after rooting, typing “sudo su” in the shell.

Why is this?

Does it not work if you use: “sudo python yourfile.py” ?

The method UnicornHat uses to actually drive the pixels involves some low-level memory twiddling that only the root user has access to. It’s a bit of a hassle, but there’s currently no way around it.

1 Like

Thanks for this - will try “sudo python yourfile.py” later.