Skip to content

Python library for Unicorn pHAT and HAT. 32 or 64 blinding ws2812 pixels for your Raspberry Pi

License

MIT, GPL-2.0 licenses found

Licenses found

MIT
LICENSE
GPL-2.0
LICENSE.txt
Notifications You must be signed in to change notification settings

4goettma/unicorn-hat

 
 

Repository files navigation

Unicorn HAT/pHAT

Available from Pimoroni:
http://shop.pimoroni.com/products/unicorn-hat
http://shop.pimoroni.com/products/unicorn-phat

Important Notice

Because Unicorn HAT uses the PWM hardware, which is also how your Raspberry Pi generates analog audio, you may see random colour patterns and flickering.

If this happens, you should add the following to your /boot/config.txt:

hdmi_force_hotplug=1

Sound will work fine using speakers on, for example, an HDMI TV, but you will not be able to use your Pi's 3.5mm audio jack in conjunction with Unicorn HAT.

unicornhat Python Library & Examples

Here you'll find everything you need to start lighting up your Unicorn HAT or pHAT using python.

Python users should probably ignore most of this repository and just:

Full install ( recommended ):

\curl -sS https://get.pimoroni.com/unicornhat | bash

Install for Python 3:

sudo apt-get install python3-pip python3-dev
sudo pip3 install unicornhat

Install for Python 2:

sudo apt-get install python-pip python-dev
sudo pip install unicornhat

Install from GitHub

Note this library requires the rpi_ws281x Python library which you can find here: https://github.com/pimoroni/rpi_ws281x-python

git clone https://github.com/pimoroni/unicorn-hat
cd unicorn-hat/library/UnicornHat
sudo python setup.py install
cd ../..

Then proceed to examples.

Using with idle/idle3:

unicornhat needs root access to function. Please make sure you start LXTerminal and run idle or idle3 with the "sudo" command like so:

sudo idle

Error Codes

Sometimes Unicorn HAT may fail with an error code, this table details some of the places to look for answers in specific cases:

  • -1 Generic failure
  • -2 Out of memory
  • -3 Hardware revision is not supported - see: pimoroni#70
  • -4 Memory lock failed
  • -5 mmap() failed - you probably forgot to run your code as root, use sudo python yourcode.py
  • -6 Unable to map registers into userspace
  • -7 Unable to initialize GPIO
  • -8 Unable to initialize PWM"
  • -9 Failed to create mailbox device
  • -10 DMA error
  • -11 Selected GPIO not possible
  • -12 Unable to initialize PCM
  • -13 Unable to initialize SPI
  • -14 SPI transfer error

Documentation & Support

Based Upon rpi_ws281x

unicornhat is based upon a modified, Pi 2/3 compatible version of the RPi ws281x Library by Jeremy Garff.

The library was modified by Richard Hirst.

RaspberryPi-NeoPixel-WS2812

Note: unicornhat is no longer based upon this library, but this information is included for posterity.

unicornhat was previously based upon a modified version of the ws2812 C driver from: https://github.com/626Pilot/RaspberryPi-NeoPixel-WS2812

About

Python library for Unicorn pHAT and HAT. 32 or 64 blinding ws2812 pixels for your Raspberry Pi

Resources

License

MIT, GPL-2.0 licenses found

Licenses found

MIT
LICENSE
GPL-2.0
LICENSE.txt

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 70.0%
  • JavaScript 15.5%
  • Python 9.6%
  • HTML 2.2%
  • CSS 1.6%
  • Makefile 0.3%
  • Other 0.8%