{"repo":"davesteele/pihut-xmas-asyncio","free":true,"listed":false,"github":"https://github.com/davesteele/pihut-xmas-asyncio","clone":"git clone https://github.com/davesteele/pihut-xmas-asyncio.git","description":"Demonstration driving The Pi Hut Raspberry Pi 3D Xmas tree using Python Asyncio","language":"Python","stars":17,"topics":["raspberry-pi","raspberrypi","raspbian","pihut","python","python3","asyncio","thepihut","xmas","3d-xmas-tree"],"license":"GPL-2.0","category":"self-hosted-apps","readme_excerpt":"pihut-xmas-asyncio Now with Twinkle! Demonstration driving the Raspberry Pi PiHut 3D Xmas tree using Python Asyncio The Pi Hut is selling a 3D Xmas Tree that plugs into the Raspberry Pi GPIO header. Raspbian includes a Python GPIO Module that facilitates working with PI I/O. Recent versions of Python include Asyncio, which provides tools to allow multiple I/O-bound functions to work cooperatively in a single-threaded event loop. This demo blinks each of the 25 lights on the tree at a constant, unique rate. Note that this is not for the PiHut 3D RGB Tree. I like the smaller (red) LEDs on this tree. How to Use It The script requires the rpi.gpio package, which may not be installed by default sudo apt-get update sudo apt-get install rpi.gpio Run ' ./xmas.py ' to see the lights blink. Change the constants in the script to change the blink parameters. run ' sudo ./install.sh ' to have the blink program come up automatically on boot. How it Works, in Brief In xmas.py, the async keyword turns a function into a coroutine , which is a cousin to a generator function. Instead of yield -ing, the coroutine returns control to the calling function when it passes control to another coroutine, flagged with the await keyword. The twinkling works by using Pulse Width Modulation (PWM) to randomly vary the brightness of the 'on' LEDs. This version of xmas.py requires more CPU power than the original ( 40% of one core on a Pi 3B, for the single-threaded code). The non-twinkling version, xmas-orig.","default_branch":null,"files":null,"tree":[],"storefront":"/r/davesteele","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/davesteele/pihut-xmas-asyncio/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}