pimoroni / unicorn-hat

Python library for Unicorn pHAT and HAT. 32 or 64 blinding ws2812 pixels for your Raspberry Pi
https://shop.pimoroni.com/products/unicorn-hat
MIT License
370 stars 131 forks source link

Proposing two examples for unicornHAT #128

Closed christophercayce closed 5 years ago

christophercayce commented 5 years ago

I propose adding two python 3 scripts to the examples for unicornHAT.

First, is candle_unicornhat.py, which adapts the candle example from unicorn-hat-hd to the unicornHAT, by resizing the animation from 16x16 to 8x8 pixels. Based on: https://github.com/pimoroni/unicorn-hat-hd/blob/master/examples/candle.py

Second, candle_with_timer.py extends the above example by adding a timer with a fade-out effect. The purpose is make it easy to use the candle animation as a scheduled go-to-sleep light, with soothing warm colors and pleasant connotations of hearth and home. The fade-out effect is intended to simulate tapering the candle down, reducing the size and brightness of the flame gradually before the script ends and the flame shuts off. The timer length and fade-out length are variables in minutes, so each are easy to adjust within the script, and extensively commented.

Gadgetoid commented 5 years ago

Thank you for taking the time to write, contibute and explain these! I'm up-to-the-eyeballs in things to do at the moment, but I'll get these tested and merged as soon as I can.

christophercayce commented 5 years ago

You bet! Thanks for the note. -Cayce

On Jan 18, 2019, at 11:49 AM, Philip Howard notifications@github.com wrote:

Thank you for taking the time to write, contibute and explain these! I'm up-to-the-eyeballs in things to do at the moment, but I'll get these tested and merged as soon as I can.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

Gadgetoid commented 5 years ago

Merged! Thank you.

I made a minor tweak to candle_with_timer.py which you can see here: https://github.com/pimoroni/unicorn-hat/commit/e46a5b513cd8429db1c8d10f368af493ff955062

Basically switching from print("text ", value, " more text") to print("text {} more text".format(value)) so that the output string is formatted correctly.

A nice addition to candle_with_timer.py might be argument parsing, to specify how long it should run for on the command line, IE: ./candle_with_timer.py 5 for 5 minutes.

christophercayce commented 5 years ago

Great, thanks! I'll add argument parsing to my learning targets. This is my first github contribution, so an extra thank you to you and Pimoroni for making fun and accessible ways into coding.