@@ -0,0 +1,1437 @@
+#!/usr/bin/env python%0Afrom time import time, sleep%0Afrom math import sin, pi%0Aimport argparse%0Aparser = argparse.ArgumentParser()%0Aparser.add_argument(%22--colour%22, '-c', help ='integer 0-255 r,g,b', default=%2210,40,0%22)%0Aparser.add_argument(%22--flash%22, '-f', help ='square wave (Hz)',%0A                    type=float)%0Aparser.add_argument(%22--pulse%22, '-p', help ='sine wave (Hz)',%0A                    type=float)%0Aparser.add_argument(%22--resolution%22, '-r', help ='updates per second',%0A                    default = 20.0, type=float)%0A%0Aargs = parser.parse_args()%0A%0Aoff = %5B0,0,0%5D%0Acolours = %7B'orange': '80,40,0', 'red':'80,0,0', 'green':'10,40,0', 'blue':'0,0,80', 'white':'40,40,40'%7D%0A%0Adef cie1931(L):%0A    L = L*100.0/255.0%0A    if L %3C= 8:%0A        return (L/902.3)*255.0%0A    else:%0A        return ((L+16.0)/116.0)**3.0 *255.0%0A%0Adef set_led(colour):%0A    #print %22set led to %7B%7D%22.format(colour)%0A    spi.write(%22%22.join(chr(int(i)) for i in colour))%0A    spi.flush()%0A%0Awith open(%22/dev/spidev0.0%22, 'w') as spi:%0A#if True:%0A    colour = colours.get(args.colour, args.colour)%0A    colour = %5Bint(cie1931(float(c))) for c in colour.split(',')%5D%0A    set_led(colour)%0A    while args.flash:%0A        set_led(off)%0A        sleep(1.0/args.flash)%0A        set_led(colour)%0A        sleep(1.0/args.flash)%0A    while args.pulse:%0A        s = sin(2*pi*time()*args.pulse)%0A        s = (s+1.0)/2.0%0A        c = %5Bi*s for i in colour%5D%0A        set_led(c)%0A        sleep(1.0/(args.resolution))%0A%0A%0A    %09%09%0A

add basic script