Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
hat Tweaks to README Jul 18, 2017
phat default brightness set to 0.5 for all examples Nov 8, 2016
README.md Fix outdated entry in examples/README.md Jul 23, 2018
ascii_pic.py default brightness set to 0.5 for all examples Nov 8, 2016
binary_clock.py Cleaned up the comments Mar 5, 2018
bluesky_greengrass.py default brightness set to 0.5 for all examples Nov 8, 2016
clean.py simplified clean.py script to use unicornhat clear method Mar 5, 2018
cross.py default brightness set to 0.5 for all examples Nov 8, 2016
demo.py default brightness set to 0.5 for all examples Nov 8, 2016
detect.py Fixes to detect script Feb 23, 2018
drop.py default brightness set to 0.5 for all examples Nov 8, 2016
drop_four_orientation.py default brightness set to 0.5 for all examples Nov 8, 2016
figlet.py Bumped figlet console width to 1000 chars/pixels Jan 24, 2017
game_of_life.py default brightness set to 0.5 for all examples Nov 8, 2016
rainbow.py examples/rainbow.py: remove redundant assignments Mar 19, 2018
rainbow_blinky.py default brightness set to 0.5 for all examples Nov 8, 2016
random_blinky.py default brightness set to 0.5 for all examples Nov 8, 2016
random_sparkles.py default brightness set to 0.5 for all examples Nov 8, 2016
simple.py default brightness set to 0.5 for all examples Nov 8, 2016
snow.py default brightness set to 0.5 for all examples Nov 8, 2016
test_rotation.py Add () to print to be Python3 compatible. Tested on HAT and pHAT (req… Feb 14, 2017
toggle.py AUTO layout Apr 5, 2017

README.md

Unified Unicorn HAT and pHAT Examples

The examples in this folder must be run with sudo, like so:

sudo ./binary_clock.py

or

sudo python binary_clock.py

The library can detect if you're using a Unicorn HAT or a Unicorn pHAT. The recommended initialisation is as follows:

import unicornhat as unicorn
unicorn.set_layout(unicorn.AUTO)
unicorn.rotation(0)
unicorn.brightness(0.4)
width,height=unicorn.get_shape()

Explicitly setting the rotation to 0 lets users of your code adapt it to their orientation. Forcing the brightness to 0.4 is for safety. Always use the get_shape() call after having decided on the rotation. If your code uses width and height properly, it should adapt to current and future geometry.

Note: If you're only using a Unicorn pHAT you may want to specify it in your code, like so:

import unicornhat as unicorn
unicorn.set_layout(unicorn.PHAT)

Most examples work with both Unicorn HAT and pHAT, using autodetect. Examples that have not been adapted for the pHAT reside in hat folder. Similarly, examples that were specifically designed for the pHAT reside in the phat folder.

detect.py

Demo code to verify if the auto detection code properly identifies if you have a unicorn HAT or a unicorn pHAT. The code assumes that if height == width then you must have a HAT.

IMPORTANT: for the auto detection process to work, Unicorn HAT must be fitted onto the GPIO at boot time. If that was not the case, the auto detection will default to the pHAT layout of 8x4!

bluesky_greengrass.py

Example code to verify the rotation of the screen. The sky (top) should be blue and the grass (bottom) should be green. If you can not re-orientate the screen, use unicorn.rotation(90) or 180 or 270 until you get blue and green in the expected location.

demo.py

Multi-effect demo; twisty swirly goodness, roto-zooming checker board, weeee waaaah, rainbow search spotlights and zoom tunnel.

simple.py

Sets each pixel in turn and updates the display.

rainbow.py

Demonstrates the use of colorsys to animate through colour hues.

rainbow_blinky.py

Blinks a rainbow spot light on and off. Change fwhm to make the spot more/less focused (smaller numbers = more focused/larger numbers = less focused).

random_blinky.py

Blinks random yellow-orange-red LEDs.

random_sparkles.py

Random multi-coloured sparkles.

drop.py

Tetris like filling of a board with random color falling pixels.

drop_four_orientation.py

Tetris like filling of a board with random color falling pixels. The demo show the 4 rotation in loop.

cross.py

Crossing random multi-color pixels in the 4 directions.

snow.py

Falling snowflake pixels.

binary_clock.py

Use the first four lines of the display as a binary clock