• Stars
    star
    363
  • Rank 113,863 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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: #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

More Repositories

1

pimoroni-pico

Libraries and examples to support Pimoroni Pico add-ons in C++ and MicroPython.
C
1,209
star
2

inky

Combined library for V2/V3 Inky pHAT and Inky wHAT.
Python
552
star
3

enviroplus-python

Python library for the Enviro+ environmental monitoring board
Shell
377
star
4

hyperpixel4

Driver for the Pimoroni HyperPixel 4.0" Touchscreen Display
Shell
313
star
5

blinkt

Python Library for Blinkt; 8 APA102 LEDs for your Raspberry Pi
C
304
star
6

fanshim-python

Python library for the Fan SHIM for Raspberry Pi
Python
290
star
7

bme680-python

Python library for the BME680 gas, temperature, humidity and pressure sensor.
Python
258
star
8

pirate-audio

Examples and documentation for the Pirate Audio range of Raspberry Pi add-ons
Python
235
star
9

st7789-python

Python library to control an ST7789 240x240 1.3" TFT LCD display.
Python
188
star
10

phew

Python
184
star
11

keybow-firmware

Keybow Firmware for the Raspberry Pi Zero
C
178
star
12

unicorn-hat-hd

Python library and examples for Unicorn HAT HD
Python
172
star
13

scroll-phat-hd

Python library for Scroll pHAT HD
Python
159
star
14

explorer-hat

Python library for Explorer HAT
Python
158
star
15

displayotron

Libraries and examples for the Display-o-Tron 3000 and Display-o-Tron HAT
Python
145
star
16

piglow

Python library & examples for the Pimoroni PiGlow
Python
133
star
17

picosystem

PicoSystem libraries and examples.
C++
128
star
18

badger2040

Examples and firmware for Badger 2040 and Badger 2040 W
Python
126
star
19

inky-phat

Python library for Inky pHAT
Python
125
star
20

clean-shutdown

Python daemon to watch a GPIO pin and trigger a clean shutdown.
Shell
123
star
21

automation-hat

Python library and examples for the Pimoroni Automation HAT, pHAT and HAT Mini
Python
116
star
22

enviro-phat

Python libraries and examples for the Pimoroni Enviro pHAT
Python
106
star
23

scroll-phat

Library and examples for Scroll pHAT. 11x5 LEDs of goodness!
Python
103
star
24

pantilt-hat

Python library for the Pimoroni PanTilt servo and lighting HAT
Python
102
star
25

phat-beat

Python library for PHAT BEAT - A stereo DAC, AMP and VU for the Raspberry Pi
Python
98
star
26

enviro

Python
96
star
27

hyperpixel

Setup for the Pimoroni Hyper Pixel 800x480 pixel multi-touch display
Python
95
star
28

vl53l1x-python

Python library for the VL53L1X Laser Ranger
C
89
star
29

skywriter-hat

Skywriter python libraries and examples
Python
87
star
30

pico-boilerplate

A boilerplate C++, CMake project for the Raspberry Pi Pico.
CMake
77
star
31

pmk-circuitpython

Python
77
star
32

rainbow-hat

Python library and examples for the Pimoroni Rainbow HAT
Python
73
star
33

pibrella

Pibrella python library & examples
Python
71
star
34

breakout-garden

Documentation, software, and examples for the Breakout Garden ecosystem.
Shell
71
star
35

keybow2040-circuitpython

CircuitPython library for the Pimoroni Keybow 2040
Python
67
star
36

bme280-python

Python library for the BME280 temperature, pressure and humidity sensor
Python
63
star
37

picade-hat

Picade HAT input daemon and setup script
Shell
60
star
38

pivumeter

ALSA plugin for displaying VU meters on various Raspberry Pi add-ons - derived from ameter
Shell
59
star
39

adxl345-python

Python library for the ADXL345
Python
55
star
40

python-multitouch

Multi-touch pure Python driver for the official 7" touchscreen display.
Python
55
star
41

Piano-HAT

Python library and examples for Piano HAT Raspberry Pi Add-on board
Python
53
star
42

grow-python

Python libs for controlling the Grow HATs
Python
53
star
43

bmp280-python

Python library for the BMP280 temperature, pressure, and altitude sensor.
Python
53
star
44

speaker-phat

Software installer for Speaker pHAT
Python
51
star
45

microdot-phat

Python Library and Examples for Micro Dot pHAT. A 6-matrix driver for retro 5x7 displays!
Python
49
star
46

pms5003-python

Python library for the PMS5003 particulate sensor
Shell
49
star
47

pidi-spotify

Python
44
star
48

PanTiltFacetracker

Face Tracking for the Adafruit Mini Pan Tilt kit and Raspberry Pi camera
Python
44
star
49

icm20948-python

Python library for the Pimoroni ICM20948 breakout
Python
43
star
50

picovision

C++
40
star
51

unicornhatmini-python

Python library for the Pimoroni Unicorn HAT Mini RGB LED Display
Python
40
star
52

Picade-Sketch

Picade Arduino sketch
C++
39
star
53

eagle

Custom Eagle parts that we've created where needed. Please feel free to use, extend, and share! (CC v3.0 Share-Alike You are welcome to use this library for commercial purposes.)
39
star
54

trackball-python

Python library for the Pimoroni Track Ball Breakout
Python
35
star
55

sgp30-python

Python library for the SGP30 air quality sensor
Shell
35
star
56

button-shim

Python library and examples for the Pimoroni Button SHIM
Python
33
star
57

led-shim

Python library for the Pimoroni LED SHIM
Python
31
star
58

keybow-python

Python library for the Pimoroni Keybow 3 and 12 key mechanical keyboard add-ons for Raspberry Pi
Python
31
star
59

hyperpixel2r

Shell
30
star
60

picade

All Picade related stuff.
C
30
star
61

fourletter-phat

Python library for the Pimoroni Four Letter pHAT
Python
28
star
62

drum-hat

Python library for the Pimoroni Drum HAT Raspberry Pi Add-on board.
Python
27
star
63

gfx-hat

Python library for the Pimoroni GFX HAT
Python
27
star
64

pmw3901-python

Python library for the PWM3901 optical flow-rate sensor
Python
26
star
65

rp_usbdisplay

Binary drivers for the RoboPeak/DFRobot 2.8 USB TFT, version 2
C
25
star
66

PiratePython

PiratePython: a minimal Raspbian for Python programmers
C
24
star
67

i2cdevice-python

Domain-specific language for describing smbus/i2c register maps
Python
24
star
68

flotilla-python

Python library for the Pimoroni Flotilla plug-and-play electronics ecosystem
Python
24
star
69

mote

Mote - drivers for the plug and play USB APA102 controller
Python
24
star
70

hyperpixel2r-python

Shell
23
star
71

propeller-hat

Propeller HAT library code, examples, documentation and SPIN source
Propeller Spin
23
star
72

displayhatmini-python

Python library for the Pimoroni Display HAT Mini
Shell
21
star
73

mopidy-raspberry-gpio

Mopidy GPIO Control Plugin for the Raspberry Pi (Using RPi.GPIO)
Python
20
star
74

weatherhat-python

Python
20
star
75

internet-of-seeds

The code that runs our IKEA VΓ„XER Internet of Seeds
Python
20
star
76

max30105-python

Python library for the Pimoroni MAX30105 breakout
Python
19
star
77

pico-circuitpython-examples

CircuitPython examples for Pimoroni RP2040 boards.
Python
18
star
78

as7262-python

Python library for the as7262 spectral sensor breakout
Python
17
star
79

node-red-nodes

Node-RED nodes for Pimoroni products
JavaScript
17
star
80

Raspberry-Pi-Web-RGB

Simple Raspberry Pi RGB LED control from your Web Browser using Python and Flask
HTML
17
star
81

trilobot-python

Python
17
star
82

plasma

Plasma LED driver, FX Sequencer and plugins
Python
16
star
83

fonts-python

Python font packaging framework
Python
15
star
84

ltr559-python

Python library for the LTR-559 optical presence/proximity sensor
Python
14
star
85

pa1010d-python

Python library for the Pimoroni PA1010D GPS Breakout
Shell
14
star
86

vl53l5cx-python

CTypes Python bindings for the VL53L5CX
C
13
star
87

programming-trinket-with-raspberry-pi

Programming Adafruit's Trinket (3v3) directly from a Raspberry Pi
C
13
star
88

drv2605-python

Python library for the Pimoroni Haptic Vibes DRV2605 breakout
Python
12
star
89

rgbmatrix5x5-python

Python library for the Pimoroni 5x5 RGB Matrix Breakout
Python
12
star
90

mote-phat

Drive four channels of APA102 pixels from your Pi Zero with Pimoroni Mote pHAT
Python
12
star
91

touch-phat

Python library and examples for Pimoroni Touch pHAT - six touch sensitive buttons to control your project.
Python
12
star
92

mopidy-pidi

Mopidy plugin host for pidi display plugins.
Python
11
star
93

sn3218

Python library for the SN3218 18-channel LED driver
Python
10
star
94

bh1745-python

Python library for the bh1745 colour sensor breakout
Python
10
star
95

EnviroPlus-FeatherWing

CircuitPython library for the Enviro+ FeatherWing
Python
10
star
96

pidi-plugins

🎡 plugins for Pirate Display. A mopidy/mpd album art downloader/displayer.
Python
10
star
97

pms5003-micropython

Python
10
star
98

enviro-ble

Python
9
star
99

rv3028-python

Python library for the RV3028 Real Time Clock
Python
9
star
100

st7036

Python library for the ST7036 LCD driver
Python
9
star