Created
August 16, 2013 10:20
-
-
Save Gadgetoid/6248761 to your computer and use it in GitHub Desktop.
Various patterns, cross fades, fades and helpful functions for PiGlow. Hopefully to be implemented into WiringPi2-Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wiringpi2 as wiringpi | |
from math import floor | |
io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS) | |
wiringpi.piGlowSetup(1) | |
def toggleAll(led,intensity): | |
wiringpi.piGlowLeg(0,intensity) | |
wiringpi.piGlowLeg(1,intensity) | |
wiringpi.piGlowLeg(2,intensity) | |
def spiral1(num,intensity): | |
if num >= 0 and num <= 17: | |
ring = int(floor(num/3)) | |
leg = int(num%3) | |
wiringpi.piGlow1(leg,ring,intensity) | |
def seq1(num,intensity): | |
if num >= 0 and num <= 17: | |
leg = int(floor(num/6)) | |
ring = int(num - (floor(num/6)*6)) | |
wiringpi.piGlow1(leg,ring,intensity) | |
def fadeIn(delay,intensity,fn,led): | |
for i in xrange(0,intensity): | |
fn(led,i) | |
wiringpi.delay(delay) | |
def fadeOut(delay,intensity,fn,led): | |
for i in reversed(xrange(0,intensity)): | |
fn(led,i) | |
wiringpi.delay(delay) | |
def crossFade(delay,intensity,fn,led1,led2): | |
for i in xrange(0,intensity+1): | |
fn(led1,i) | |
fn(led2,intensity-i) | |
wiringpi.delay(delay) | |
intensity = 60 | |
delay = 150/intensity | |
while 1: | |
for x in xrange(0,4): | |
fadeIn(1,intensity,toggleAll,0) | |
fadeOut(delay,intensity,toggleAll,0) | |
wiringpi.delay(100) | |
lastring = -1; | |
for ring in xrange(0,6): | |
crossFade(delay,intensity,wiringpi.piGlowRing,ring,lastring) | |
lastring = ring | |
wiringpi.delay(50) | |
for ring in reversed(xrange(0,6)): | |
crossFade(delay,intensity,wiringpi.piGlowRing,ring,lastring) | |
lastring = ring | |
wiringpi.delay(50) | |
fadeOut(delay,intensity,toggleAll,0) | |
lastleg = -1; | |
for x in xrange(0,2): | |
for leg in xrange(0,3): | |
crossFade(delay,intensity,wiringpi.piGlowLeg,leg,lastleg) | |
lastleg = leg | |
wiringpi.delay(50) | |
fadeOut(delay,intensity,toggleAll,0) | |
for led in xrange(0,18): | |
crossFade(delay,intensity,spiral1,led,led-1) | |
for led in reversed(xrange(0,18)): | |
crossFade(delay,intensity,spiral1,led,led+1) | |
for led in xrange(0,18): | |
crossFade(delay,intensity,seq1,led,led-1) | |
for led in reversed(xrange(0,18)): | |
crossFade(delay,intensity,seq1,led,led+1) | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment