RPi + Unicorn: Python 8x8 Matrix Summary of YOUR Codes


#21

Note that wildcard imports (*) are strongly discouraged. This is because it is way too easy to create a namespace conflict.

In principle, if you only import a single module that way, it would never happen, but it is very rare that only one module is used in a script and multiple such imports would quickly lead to ambiguous code and unexpected results.

A better way is to import only the methods you require, if you want the brievety inline:

from unicornhat import set_pixel, show, off


#22

Yesterday i made a Zelda heart boot script for retropie. Hope you like it:

#!/usr/bin/env python

import unicornhat
import time
import colorsys

unicornhat.brightness(1.0)
unicornhat.set_layout(unicornhat.AUTO)
unicornhat.rotation(0)

r1=0
r2=1

w1=0
w2=0

i=1.0
k=0.0

while k <= 1:

    # unicornhat.set_pixel_hsv(0, 0, r1, r2, k)
    # unicornhat.set_pixel_hsv(0, 1, r1, r2, k)
    # unicornhat.set_pixel_hsv(0, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(0, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(0, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(0, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(0, 6, r1, r2, k)
    # unicornhat.set_pixel_hsv(0, 7, r1, r2, k)

    # unicornhat.set_pixel_hsv(1, 0, r1, r2, k)
    # unicornhat.set_pixel_hsv(1, 1, r1, r2, k)
    unicornhat.set_pixel_hsv(1, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(1, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(1, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(1, 5, w1, w2, k)
    unicornhat.set_pixel_hsv(1, 6, w1, w2, k)
    unicornhat.set_pixel_hsv(1, 7, r1, r2, k)

    # unicornhat.set_pixel_hsv(2, 0, r1, r2, k)
    unicornhat.set_pixel_hsv(2, 1, r1, r2, k)
    unicornhat.set_pixel_hsv(2, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(2, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(2, 4, w1, w2, k)
    unicornhat.set_pixel_hsv(2, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(2, 6, r1, r2, k)
    unicornhat.set_pixel_hsv(2, 7, r1, r2, k)

    unicornhat.set_pixel_hsv(3, 0, r1, r2, k)
    unicornhat.set_pixel_hsv(3, 1, r1, r2, k)
    unicornhat.set_pixel_hsv(3, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(3, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(3, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(3, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(3, 6, r1, r2, k)
    # unicornhat.set_pixel_hsv(3, 7, r1, r2, k)

    unicornhat.set_pixel_hsv(4, 0, r1, r2, k)
    unicornhat.set_pixel_hsv(4, 1, r1, r2, k)
    unicornhat.set_pixel_hsv(4, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(4, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(4, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(4, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(4, 6, r1, r2, k)
    # unicornhat.set_pixel_hsv(4, 7, r1, r2, k)

    # unicornhat.set_pixel_hsv(5, 0, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 1, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 6, r1, r2, k)
    unicornhat.set_pixel_hsv(5, 7, r1, r2, k)

    # unicornhat.set_pixel_hsv(6, 0, r1, r2, k)
    # unicornhat.set_pixel_hsv(6, 1, r1, r2, k)
    unicornhat.set_pixel_hsv(6, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(6, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(6, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(6, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(6, 6, r1, r2, k)
    unicornhat.set_pixel_hsv(6, 7, r1, r2, k)

    # unicornhat.set_pixel_hsv(7, 0, r1, r2, k)
    # unicornhat.set_pixel_hsv(7, 1, r1, r2, k)
    # unicornhat.set_pixel_hsv(7, 2, r1, r2, k)
    unicornhat.set_pixel_hsv(7, 3, r1, r2, k)
    unicornhat.set_pixel_hsv(7, 4, r1, r2, k)
    unicornhat.set_pixel_hsv(7, 5, r1, r2, k)
    unicornhat.set_pixel_hsv(7, 6, r1, r2, k)
    # unicornhat.set_pixel_hsv(7, 7, r1, r2, k)


    unicornhat.show()
    time.sleep(0.01)

    k=k+0.0075

time.sleep(3)

# while i > 0:

# unicornhat.set_pixel_hsv(0, 0, r1, r2, i)
# unicornhat.set_pixel_hsv(0, 1, r1, r2, i)
# unicornhat.set_pixel_hsv(0, 2, r1, r2, i)
unicornhat.set_pixel_hsv(0, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(0, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(0, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(0, 6, r1, r2, 0)
# unicornhat.set_pixel_hsv(0, 7, r1, r2, i)

unicornhat.show()
time.sleep(1)

# unicornhat.set_pixel_hsv(1, 0, r1, r2, i)
# unicornhat.set_pixel_hsv(1, 1, r1, r2, i)
unicornhat.set_pixel_hsv(1, 2, r1, r2, 0)
unicornhat.set_pixel_hsv(1, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(1, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(1, 5, w1, w2, 0)
unicornhat.set_pixel_hsv(1, 6, w1, w2, 0)
unicornhat.set_pixel_hsv(1, 7, r1, r2, 0)

unicornhat.show()
time.sleep(1)


# unicornhat.set_pixel_hsv(2, 0, r1, r2, i)
unicornhat.set_pixel_hsv(2, 1, r1, r2, 0)
unicornhat.set_pixel_hsv(2, 2, r1, r2, 0)
unicornhat.set_pixel_hsv(2, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(2, 4, w1, w2, 0)
unicornhat.set_pixel_hsv(2, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(2, 6, r1, r2, 0)
unicornhat.set_pixel_hsv(2, 7, r1, r2, 0)

unicornhat.show()
time.sleep(1)

unicornhat.set_pixel_hsv(3, 0, r1, r2, 0)
unicornhat.set_pixel_hsv(3, 1, r1, r2, 0)
unicornhat.set_pixel_hsv(3, 2, r1, r2, 0)
unicornhat.set_pixel_hsv(3, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(3, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(3, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(3, 6, r1, r2, 0)
# unicornhat.set_pixel_hsv(3, 7, r1, r2, i)

unicornhat.show()
time.sleep(1)

unicornhat.set_pixel_hsv(4, 0, r1, r2, 0)
unicornhat.set_pixel_hsv(4, 1, r1, r2, 0)
unicornhat.set_pixel_hsv(4, 2, r1, r2, 0)
unicornhat.set_pixel_hsv(4, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(4, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(4, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(4, 6, r1, r2, 0)
# unicornhat.set_pixel_hsv(4, 7, r1, r2, i)

unicornhat.show()
time.sleep(1)

# unicornhat.set_pixel_hsv(5, 0, r1, r2, i)
unicornhat.set_pixel_hsv(5, 1, r1, r2, 0)
unicornhat.set_pixel_hsv(5, 2, r1, r2, 0)
unicornhat.set_pixel_hsv(5, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(5, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(5, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(5, 6, r1, r2, 0)
unicornhat.set_pixel_hsv(5, 7, r1, r2, 0)

unicornhat.show()
time.sleep(1)

# unicornhat.set_pixel_hsv(6, 0, r1, r2, i)
# unicornhat.set_pixel_hsv(6, 1, r1, r2, i)
unicornhat.set_pixel_hsv(6, 2, r1, r2, 0)
unicornhat.set_pixel_hsv(6, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(6, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(6, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(6, 6, r1, r2, 0)
unicornhat.set_pixel_hsv(6, 7, r1, r2, 0)

unicornhat.show()
time.sleep(1)

# unicornhat.set_pixel_hsv(7, 0, r1, r2, i)
# unicornhat.set_pixel_hsv(7, 1, r1, r2, i)
# unicornhat.set_pixel_hsv(7, 2, r1, r2, i)
unicornhat.set_pixel_hsv(7, 3, r1, r2, 0)
unicornhat.set_pixel_hsv(7, 4, r1, r2, 0)
unicornhat.set_pixel_hsv(7, 5, r1, r2, 0)
unicornhat.set_pixel_hsv(7, 6, r1, r2, 0)
# unicornhat.set_pixel_hsv(7, 7, r1, r2, i)

unicornhat.show()
time.sleep(1)

# unicornhat.show()
# time.sleep(0.01)
#
# i=i-0.009


#23

I have the absolute coolest project you will EVER see on a 8x8 unicorn.