1
0
mirror of https://github.com/danbee/unicorn synced 2025-03-04 08:49:07 +00:00

Update for Unicorn Hat HD

This commit is contained in:
Daniel Barber 2021-05-20 17:05:33 -04:00
parent 1c6518aa13
commit 40a5b8e696

24
fire.py
View File

@ -1,16 +1,16 @@
from random import randint from random import randint
import unicornhat as unicorn import unicornhathd as unicorn
from time import sleep from time import sleep
width = 8 width = 16
height = 8 height = 16
rows = [] rows = []
row_pointer = 0 row_pointer = 0
colours = [] colours = []
unicorn.brightness(0.4) unicorn.brightness(1)
unicorn.rotation(270) unicorn.rotation(0)
def init(): def init():
@ -33,6 +33,8 @@ def init():
g = (i - 24) * 6 g = (i - 24) * 6
if i > 48: if i > 48:
g = (i - 48) * 8 g = (i - 48) * 8
if i < 16:
b = 4 - (i / 4)
colours.append([r, g, b]) colours.append([r, g, b])
@ -56,7 +58,7 @@ def update_rows():
# create fire # create fire
for h in range(height): for h in range(height):
for w in range(width): for w in range(width):
rows[h][w + 1] = (rows[h + 1][w] + rows[h + 1][w + 1] + rows[h + 1][w + 2]) / 3.4 rows[h][w + 1] = (rows[h + 1][w] + rows[h + 1][w + 1] + rows[h + 1][w + 2]) / 3.3
def update_display(): def update_display():
@ -95,6 +97,10 @@ def step():
init() init()
while True: try:
step() while True:
sleep(0.05) step()
sleep(0.025)
except KeyboardInterrupt:
unicorn.off()