コード例 #1
0
def light_piglow(colour,rotations):
    colourmap = {14 : "red", 13 : "green", 11 : "blue", 1: "orange", 4 : "yellow", 15 : "white" }
    from piglow import PiGlow
    piglow = PiGlow()
#    piglow.all(0)
    if ( colour != "all" ):
        ledcolour = colourmap[colour]
        for j in range(rotations):
            piglow.colour(ledcolour,j)
            sleep(0.001*j) # As the intensity increases, sleep for longer periods
    else:
    #    print ("Trying to run all ")
        for j in range(rotations):
            for colour in (colourmap.values()):
                piglow.colour(("%s" % colour), 255)
                sleep(0.2)
                piglow.colour(colour, 0)
                sleep(0.01)
    piglow.all(0)
コード例 #2
0
    def start(self):
        """Creates the socket and starts the threads"""

        try:
            self.piglow = PiGlow()

        except IOError as e:

            if e[0] == errno.EACCES:
                print >> sys.stderr, "Permission denied, try running as root"
            else:
                print >> sys.stderr, "Unknown error accessing the PiGlow"

            sys.exit(1)

        self.piglow.all(0)

        self.clock = Clock(self.piglow)
        self.alert = Alert(self.piglow)
        self.in_progress = In_Progress(self.piglow)

        address = (self.cfg.HOST, self.cfg.PORT)

        serversock = socket(AF_INET, SOCK_STREAM)
        serversock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        serversock.bind(address)
        serversock.listen(5)

        self.check_jobs_thread = Thread(None, self.check_jobs, None, ())
        self.socket_manager_thread = Thread(None, self.socket_manager, None,
                                            (serversock, ))

        self.start_threads()

        while self.running == True:
            sleep(1)

        self.stop()
コード例 #3
0
ファイル: glowshow.py プロジェクト: captainwhippet/glowshow
class GlowShow(object):

    piglow = PiGlow(1)
    led_val = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    brightness = 25
    smoothness = 50
    speed = 10

    def set_speed(self, speed):
        print 'set_speed = ', speed
        self.speed = speed

    def set_brightness(self, brightness):
        print 'set_brightness = ', brightness
        self.brightness = brightness

    def set_pattern(self, pattern):
        print 'set_pattern = ', pattern
        led_last = list(self.led_val)
        self.led_val = self.map_vals(pattern)
        self.led_val = [v * self.brightness for v in self.led_val]

        # smooth transition from last to this value
        for i in range(0, self.smoothness + 1):
            led_step = [
                v0 + int((v1 - v0) * float(i) / float(self.smoothness))
                for v0, v1 in zip(led_last, self.led_val)
            ]

            # update the piglow with current values
            self.piglow.update_leds(led_step)
            time.sleep(1.0 / float(self.speed) / float(self.smoothness))

    def map_vals(self, led_set):
        led_map = [
            7, 8, 9, 6, 5, 10, 18, 17, 16, 14, 12, 11, 1, 2, 3, 4, 15, 13
        ]
        for i in range(0, len(led_map)):
            self.led_val[led_map[i] - 1] = led_set[i]
        return self.led_val
コード例 #4
0
  def start (self):
    """Creates the socket and starts the threads"""

    try:
      self.piglow = PiGlow ()

    except IOError as e:

      if e[0] == errno.EACCES:
        print >> sys.stderr, "Permission denied, try running as root"
      else:
        print >> sys.stderr, "Unknown error accessing the PiGlow"

      sys.exit (1)

    self.piglow.all (0)

    self.clock = Clock (self.piglow)
    self.alert = Alert (self.piglow)
    self.in_progress = In_Progress (self.piglow)

    address = (self.cfg.HOST, self.cfg.PORT)

    serversock = socket (AF_INET, SOCK_STREAM)
    serversock.setsockopt (SOL_SOCKET, SO_REUSEADDR, 1)
    serversock.bind (address)
    serversock.listen (5)

    self.check_jobs_thread = Thread (None, self.check_jobs, None, ())
    self.socket_manager_thread = Thread (None, self.socket_manager, None, (serversock, ))

    self.start_threads ()

    while self.running == True:
      sleep (1)

    self.stop ()
コード例 #5
0
ファイル: all.py プロジェクト: x41x41x90/x41-piglow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.all(255)
コード例 #6
0
class Luces:
    def __init__(self):
        self.piglow = PiGlow()

    def get_intensity(self, value):
        pass

    def encenderblanco(self, value=100):
        self.piglow.white(value)

    def apagarblanco(self):
        self.piglow.white(0)

    def parpadearblanco(self, tiempo=1, value=100):
        self.encenderblanco(value)
        time.sleep(tiempo)
        self.apagarblanco()

    def encenderazul(self, value=100):
        self.piglow.blue(value)

    def apagarazul(self):
        self.piglow.blue(0)

    def parpadearazul(self, tiempo=1, value=100):
        self.encenderazul(value)
        time.sleep(tiempo)
        self.apagarazul()

    def encenderverde(self, value=100):
        self.piglow.green(value)

    def apagarverde(self):
        self.piglow.green(0)

    def parpadearverde(self, tiempo=1, value=100):
        self.encenderverde(value)
        time.sleep(tiempo)
        self.apagarverde()

    def encenderamarillo(self, value=100):
        self.piglow.yellow(value)

    def apagaramarillo(self):
        self.piglow.yellow(0)

    def parpadearamarillo(self, tiempo=1, value=100):
        self.encenderamarillo(value)
        time.sleep(tiempo)
        self.apagaramarillo()

    def encendernaranja(self, value=100):
        self.piglow.orange(value)

    def apagarnaranja(self):
        self.piglow.orange(0)

    def parpadearnaranja(self, tiempo=1, value=100):
        self.encendernaranja(value)
        time.sleep(tiempo)
        self.apagarnarnanja()

    def encenderrojo(self, value=100):
        self.piglow.red(value)

    def apagarrojo(self):
        self.piglow.red(0)

    def parpadearrojo(self, tiempo=1, value=100):
        self.encenderrojo(value)
        time.sleep(tiempo)
        self.apagarrojo()

    def encendertodas(self, value=100):
        self.piglow.all(value)

    def apagartodas(self):
        self.piglow.all(0)

    def parpadeartodas(self, tiempo=1, value=100):
        self.encendertodas(value)
        time.sleep(tiempo)
        self.apagartodas()

    def encenderbrazo(self, arm, value=100):
        self.piglow.arm(arm, value)

    def apagarbrazo(self, arm):
        self.piglow.arm(arm, 0)

    def parpadearbrazo(self, arm, tiempo=1, value=100):
        self.encenderbrazo(arm, value)
        time.sleep(tiempo)
        self.apagarbrazo(arm)

    def encenderbrazo1(self, value=100):
        self.piglow.arm1(value)

    def apagarbrazo1(self):
        self.piglow.arm1(0)

    def parpadearbrazo1(self, tiempo=1, value=100):
        self.encenderbrazo1(value)
        time.sleep(tiempo)
        self.apagarbrazo1()

    def encenderbrazo2(self, value=100):
        self.piglow.arm2(value)

    def apagarbrazo2(self):
        self.piglow.arm2(0)

    def parpadearbrazo2(self, tiempo=1, value=100):
        self.encenderbrazo2(value)
        time.sleep(tiempo)
        self.apagarbrazo2()

    def encenderbrazo3(self, value=100):
        self.piglow.arm3(value)

    def apagarbrazo3(self):
        self.piglow.arm3(0)

    def parpadearbrazo3(self, tiempo=1, value=100):
        self.encenderbrazo3(value)
        time.sleep(tiempo)
        self.apagarbrazo3()

    def encendercolor(self, colour, value=10):
        if colour == 1 or colour == "blanco":
            self.piglow.colour("white", value)
        elif colour == 2 or colour == "azul":
            self.piglow.colour("blue", value)
        elif colour == 3 or colour == "verde":
            self.piglow.colour("green", value)
        elif colour == 4 or colour == "amarillo":
            self.piglow.colour("yellow", value)
        elif colour == 5 or colour == "naranja":
            self.piglow.colour("orange", value)
        elif colour == 6 or colour == "rojo":
            self.piglow.colour("red", value)
        else:
            print "Solo los colores de 1 - 6 o los nombres de colores estan permitidos"

    def apagarcolor(self, colour):
        value = 0

        if colour == 1 or colour == "blanco":
            self.piglow.colour("white", value)
        elif colour == 2 or colour == "azul":
            self.piglow.colour("blue", value)
        elif colour == 3 or colour == "verde":
            self.piglow.colour("green", value)
        elif colour == 4 or colour == "amarillo":
            self.piglow.colour("yellow", value)
        elif colour == 5 or colour == "naranja":
            self.piglow.colour("orange", value)
        elif colour == 6 or colour == "rojo":
            self.piglow.colour("red", value)
        else:
            print "Solo los colores de 1 - 6 o los nombres de colores estan permitidos"

    def parpadearcolor(self, colour, tiempo=1, value=100):
        self.encendercolor(colour, value)
        time.sleep(tiempo)
        self.apagarcolor(colour)

    def encenderluz(self, led, value=100):
        self.piglow.led(led, value)

    def apagarluz(self, led):
        self.piglow.led(led, 0)

    def parpadearluz(self, led, tiempo=1, value=100):
        self.encenderluz(led, value)
        time.sleep(tiempo)
        self.apagarluz(led)
コード例 #7
0
ファイル: mine.py プロジェクト: x41x41x90/x41-piglow
#!/usr/bin/env python
from piglow import PiGlow
import time
import random
i = 0
j = 1
k = 2
piglow = PiGlow()
piglow.all(0)
goingUp = 1


while True:
	time.sleep(.03)
	if goingUp == 1:
		piglow.colour(j, i)
		i+=5
	else:
		piglow.colour(j, i)
		i-=5

	if i == 255:
		goingUp = 0
	if i == 0:
		piglow.colour(j, i)
		goingUp = 1
		
		j = random.randint(1,6)
コード例 #8
0
ファイル: halloween.py プロジェクト: rixwoodling/betelnuts
##################################################
## Switch only yellow, orange and red to random ##
## brightness                                   ##
## Example by tng - @TommyBobbins               ##
##################################################

from piglow import PiGlow
from time import sleep
import random

# Maximum random sleep between switching an LED on or off
sleep_period = 0.001

piglow = PiGlow()
# Switch off all the lights first
piglow.all(0)

# We only want to select the Red, Orange and Yellow LEDs (roy)
roy_leds = ["01", "02", "03", "07", "08", "09", "13", "14", "15"]


def random_brightness():
    sleep(random.uniform(0, sleep_period))
    return random.randint(0, 255)


while True:
    # Switch one random roy LED to one random brightness
    led_to_switch = int(random.choice(roy_leds))
    piglow.led(led_to_switch, random_brightness())
    # Switch one random roy LED off
コード例 #9
0
ファイル: luces.py プロジェクト: castrofernandez/raspberry-pi
from piglow import PiGlow
from time import sleep

piglow = PiGlow()

def pata(min, max):
    i = min
    while i <= max:
        if i > min:
            piglow.led(i - 1, 0)
        piglow.led(i, 1)
        sleep(0.3)
        i += 1

def estrella():
    piglow.all(1)
    sleep(0.5)
    i = 6
    j = 12
    k = 18

    while i >= 1:
        piglow.led(i, 0)
        piglow.led(j, 0)
        piglow.led(k, 0)
        sleep(0.3)        

        i -= 1
        j -= 1
        k -= 1
コード例 #10
0
ファイル: cpu.py プロジェクト: jmMeessen/rpi-docker-images
import sys
from piglow import PiGlow
import psutil

class GracefulKiller:
  kill_now = False
  def __init__(self):
    signal.signal(signal.SIGINT, self.exit_gracefully)
    signal.signal(signal.SIGTERM, self.exit_gracefully)

  def exit_gracefully(self,signum, frame):
    self.kill_now = True

if __name__ == '__main__':
  killer = GracefulKiller()
  piglow = PiGlow()
  while True:
    cpu = psutil.cpu_percent()
    piglow.all(0)

    if cpu < 5:
        piglow.red(20)
    elif cpu < 20:
        piglow.red(20)
        piglow.orange(20)
    elif cpu < 40:
        piglow.red(20)
        piglow.orange(20)
        piglow.yellow(20)
    elif cpu < 60:
        piglow.red(20)
コード例 #11
0
ファイル: construction.py プロジェクト: AdamOssenford/piglow
#!/usr/bin/python
from time import sleep
from piglow import PiGlow

piglow = PiGlow()
piglow.all(0)
# construction
for i in range(1, 20):
  piglow.orange(100)
  sleep(.5)
  piglow.all(0) 
  piglow.yellow(100)
  sleep(.5)
  piglow.all(0) 

コード例 #12
0
ファイル: pulse_01.py プロジェクト: jcoffey42/Python
#!/usr/bin/python
######################################################
## Create  a pulsing spiral lighting each led       ##
## Version 1 using a method I saw in another script ##
##                                                  ##
######################################################

# Import needed modules
import time
from piglow import PiGlow

# An alias, so you can type piglow rather than PiGlow()
piglow = PiGlow()

q = 0.0003   # Delay for time.sleep in seconds
x = 1        # Iniialize x, 0 causes .led to turn them off
             # Used to define led and brightness
       
y = 1        # Initialize y for main loop

piglow.all(0) # turn off all led, 

while y > 0:              # Begin the pulse loop
    
    for x in range(255):  # Start the brighten loop     

        m = (x % 19)      # Make sure to only have 1-18 for led
                          # by dividing by 19 and using the remainder

        if m == 0:        # LED can't be zero so if it is, set to 1
           m= m + 1
コード例 #13
0
#!/usr/bin/python

from piglow import PiGlow
import praw
import time


piglow = PiGlow()

# Reddit stuff

username = '******'
password = '******'

r = praw.Reddit('/u/'+username+' LED piglow orangered system by /u/balrogath, v 0.1')
r.login(username, password)

# notifications we've already been notified about
already_done = []

# forever!
while True:
	try:
		piglow.led1(0)
		unread = r.get_unread()
		unreadcount = 0
		for message in unread:
			unreadcount = unreadcount + 1
			if message.id not in already_done:
			  #flash to get attention! new message!
				piglow.led3(20)
コード例 #14
0
from piglow import PiGlow
from time import sleep

piglow = PiGlow()

print("You will now be asked how bright you would like each LED to be, choose a number between 0 and 255")
sleep(3)
val1 = input("White: ")
val2 = input("Blue: ")
val3 = input("Green: ")
val4 = input("Yellow: ")
val5 = input("Orange: ")
val6 = input("Red: ")
delay = input("How long is the delay between flashes? :")

while True:
    piglow.white(val1)
    sleep(delay)
    piglow.blue(val2)
    sleep(delay)
    piglow.green(val3)
    sleep(delay)
    piglow.yellow(val4)
    sleep(delay)
    piglow.orange(val5)
    sleep(delay)
    piglow.red(val6)
    sleep(delay)
    piglow.all(0)
コード例 #15
0
ファイル: sunny.py プロジェクト: tommybobbins/PiGlow
# sudo apt-get install python-scipy
# sudo pip install astral
from astral import *
from piglow import PiGlow
import time
import datetime
import logging
dt = datetime.datetime.now()
logging.basicConfig(filename='/home/pi/LOGGING/lightoutput_%i_%i_%i.log' %(dt.year, dt.month, dt.day),level=logging.INFO)
from scipy import stats
number_seconds_day=60*60*24
centre = 0.0
total_intensity=0
max_brightness=255
intensity={}
piglow = PiGlow()
piglow.all(0)

a = Astral()
location = a["Manchester"]
#print (" %s %s %s %s %s \n" % (dawn, sunrise, noon, sunset, dusk))
#Information for Manchester
# 2014-01-21 07:30:11+00:00 2014-01-21 08:10:06+00:00 2014-01-21 12:20:18+00:00 2014-01-21 16:30:35+00:00 2014-01-21 17:10:31+00:00
# For the local timezone
#print ("Time: %s" % t)

logging.info("Epoch_Time\tRed\tOrange\tYellow\tGreen\tBlue\tWhite\tTotal")

def calculate_intensity(x,centre,mu,max_brightness):
    #Normal distribution
    gaussian = stats.norm(loc=centre, scale=mu)
コード例 #16
0
 def __init__(self):
     self.piglow = PiGlow()
コード例 #17
0
##################################################
## Switch each colour on in sequence on and off ##
##                                              ##
## Example by Jason - @Boeeerb                  ##
##################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()
val = 20
colour = 1

while True:
    if colour == 19:
        colour = 1
        if val == 20:
            val = 0
        else:
            val = 20

    piglow.led(colour, val)
    sleep(0.2)

    colour = colour + 1
コード例 #18
0
ファイル: cpu.py プロジェクト: ElectroMisfit/PiGlow
##########################################################
## Show your current CPU usage on your PiGlow!          ##
##                                                      ##
## Requires psutil - sudo apt-get install python-psutil ##
##                                                      ##
## Example by Jason - @Boeeerb                          ##
##########################################################

from piglow import PiGlow
from time import sleep
import psutil

piglow = PiGlow()

while True:

    cpu = psutil.cpu_percent()
    piglow.all(0)

    if cpu < 5:
        piglow.white(20)
    elif cpu < 20:
        piglow.white(20)
        piglow.blue(20)
    elif cpu < 40:
        piglow.white(20)
        piglow.blue(20)
        piglow.green(20)
    elif cpu < 60:
        piglow.white(20)
        piglow.blue(20)
コード例 #19
0
ファイル: spiralS-2.py プロジェクト: shifty051/PiGlow
###############################################################
# Set the LEDs to turn on/off sequentially in a spiral fashion toward the centre
# This is a modified version of 'spiralS.py', where the LEDs remain on throughout the cycle.
# shifty051
###############################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()

while True:

  piglow.led(1,1)
  sleep(0.1)

  piglow.led(7,1)
  sleep(0.1)

  piglow.led(13,1)
  sleep(0.1)

  piglow.led(2,1)
  sleep(0.1)

  piglow.led(8,1)
  sleep(0.1)

  piglow.led(14,1)
  sleep(0.1)
コード例 #20
0
from piglow import PiGlow
from time import sleep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from os import curdir, sep
import random
import urlparse

PORT_NUMBER = 80

piglow = PiGlow()

val = 0
count = 1

gameCont = True

colorList = ['red', 'orange', 'yellow', 'green', 'blue', 'white']

numberOrder = []

levelCount = 0


class myHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        #get address
        parts = urlparse.urlparse(self.path)
        if parts.path == "/":
            self.path = "/index.html"

        #append to URL
コード例 #21
0
            try:

                if add == -1 and new_vals == [min(self.val_range)]:
                    break

            except IndexError:
                pass

            try:

                if new_vals[self.arm_length - 1] == max(self.val_range):
                    add = -1

            except IndexError:
                pass

            i = i + add


if __name__ == "__main__":

    times = 3
    piglow = PiGlow()
    alert = Alert(piglow)

    try:
        alert.show(times)
    except KeyboardInterrupt:
        alert.clear()
コード例 #22
0
ファイル: spiralS.py プロジェクト: shifty051/PiGlow
##################################################################
# Set the LEDs to turn on/off in a spiral fashion toward the centre
# shifty051
##################################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()

while True:

  piglow.led(1,1)
  piglow.led(18,0)
  sleep(0.1)

  piglow.led(7,1)
  piglow.led(1,0)
  sleep(0.1)

  piglow.led(13,1)
  piglow.led(7,0)
  sleep(0.1)

  piglow.led(2,1)
  piglow.led(13,0)
  sleep(0.1)

  piglow.led(8,1)
  piglow.led(2,0)
  sleep(0.1)
コード例 #23
0
ファイル: indiv.py プロジェクト: AlexanderHems/PiGlow
#######################################################
## Quickly increase and decrease each LED one by one ##
##                                                   ##
## Example by Jason - @Boeeerb                       ##
#######################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()
val = 0
count = 1
while True:
    leds = range(1, 19, +1)
    for led in leds:
        if count == 1:
            val = val + 1
            if val > 90:
                count = 0
        else:
            val = val - 1
            if val < 1:
                count = 1
        piglow.led(led, val)

        sleep(0.0075)
コード例 #24
0
from piglow import PiGlow
import psutil
import os
import sys

piglow = PiGlow()
pid = str(os.getpid())
pidfile = "/tmp/mydaemon.pid"

if os.path.isfile(pidfile): # a PID exists. Lets kill it and then run
    pidread = open('/tmp/mydaemon.pid', 'r')
    pidtokill = pidread.readline()
    cmdstring = "sudo kill %s" % (pidtokill) #this is the shell command string to kill the process
    os.system(cmdstring) # and this kills it with the predetermined command
    file(pidfile, 'w').write(pid)

else: #no pid file exists, lets go ahead and run
    file(pidfile, 'w').write(pid)

while 1:

    cpu = psutil.cpu_percent(interval=0.5)
    piglow.all(0)

    if cpu <= 10:
        piglow.green(1)
    elif cpu >= 11 and cpu <= 20:
        piglow.green(2)
    elif cpu >= 21 and cpu <= 30:
        piglow.green(3)
    elif cpu >= 31 and cpu <= 40:
コード例 #25
0
ファイル: red.py プロジェクト: x41x41x90/x41-piglow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.red(255)
コード例 #26
0
###############################################################
# Set the LEDs to turn on/off in pairs of 2 toward the centre,
# whilst increasing and decreasing in brightness
# shifty051
###############################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()

while True:

    piglow.red(1)
    sleep(0.1)

    piglow.red(2)
    sleep(0.1)

    piglow.red(3)
    piglow.orange(1)
    sleep(0.1)

    piglow.red(4)
    piglow.orange(2)
    sleep(0.1)

    piglow.red(3)
    piglow.orange(3)
    sleep(0.1)
コード例 #27
0
ファイル: pretty.py プロジェクト: stanleyyork11/ProjectPi
from piglow import PiGlow
from time import sleep

piglow = PiGlow()
while True

	###All LEDs###
	#Fade all LEDs on at the same time
	piglow.all(51)
	sleep(0.1)
	piglow.all(102)
	sleep(0.1)
	piglow.all(153)
	sleep(0.1)
	piglow.all(204)
	sleep(0.1)
	piglow.all(255)
	sleep(0.5)
	
	#Fade all LEDs off at the same time
	piglow.all(255)
	sleep(0.1)
	piglow.all(204)
	sleep(0.1)
	piglow.all(153)
	sleep(0.1)
	piglow.all(102)
	sleep(0.1)
	piglow.all(51)
	sleep(0.1)
	piglow.all(0)
コード例 #28
0
ファイル: yellow.py プロジェクト: x41x41x90/x41-piglow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.yellow(255)
コード例 #29
0
ファイル: test.py プロジェクト: Python3pkg/PiGlow
######################################################
## Set each colour to a brightness of your choosing ##
##                                                  ##
## Example by Jason - @Boeeerb                      ##
######################################################

from piglow import PiGlow

piglow = PiGlow()

val = eval(input("White: "))
piglow.white(val)

val = eval(input("Blue: "))
piglow.blue(val)

val = eval(input("Green: "))
piglow.green(val)

val = eval(input("Yellow: "))
piglow.yellow(val)

val = eval(input("Orange: "))
piglow.orange(val)

val = eval(input("Red: "))
piglow.red(val)

val = eval(input("All: "))
piglow.all(val)
コード例 #30
0
## Author: Daniel Pullan
## Github: GitHub.com/DanielPullan
## Website: DanielPullan.co.uk

from time import sleep
from config import email, password, mail
from piglow import PiGlow

## Init the current device
piglow = PiGlow()

## Device parameters
piglow.all(0)

if mail == 0:
        print "no mail"
        piglow.all(0)
        sleep(0.5)
elif mail < 5:
        print "mail count low"
        piglow.arm1(10)
        sleep(0.5)
elif mail < 10:
        print "mail count medium"
        piglow.arm1(10)
        piglow.arm2(10)
        sleep(0.5)
elif mail < 15:
        print "mail count high"
        piglow.arm1(10)
        piglow.arm2(10)
コード例 #31
0
ファイル: arm.py プロジェクト: theleestarr/PiGlow-1
#########################################################
## Set each arm of the PiGlow to a specific brightness ##
##                                                     ##
##  Example by Jason - @Boeeerb                        ##
#########################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()

piglow.all(0)

while True:
    piglow.arm(3,0)
    piglow.arm(1,20)
    sleep(0.5)
    piglow.arm(1,0)
    piglow.arm(2,20)
    sleep(0.5)
    piglow.arm(2,0)
    piglow.arm(3,20)
    sleep(0.5)

    piglow.all(0)
    piglow.arm1(10)
    sleep(0.5)
    piglow.all(0)
    piglow.arm2(10)
    sleep(0.5)
    piglow.all(0)
コード例 #32
0
class PiGlow_Status_Server:
    def __init__(self):

        self.cfg = PiGlow_Status_Config()
        self.commands = PiGlow_Status_Commands()
        self.idle_job = self.commands.CLOCK
        self.jobs = []
        self.running = None
        self.locked_thread = None
        self.check_jobs_thread = None
        self.socket_manager_thread = None
        self.piglow = None
        self.clock = None
        self.alert = None
        self.in_progress = None
        self.job_interval = 0.1
        self.quiet_time = False

    def start(self):
        """Creates the socket and starts the threads"""

        try:
            self.piglow = PiGlow()

        except IOError as e:

            if e[0] == errno.EACCES:
                print >> sys.stderr, "Permission denied, try running as root"
            else:
                print >> sys.stderr, "Unknown error accessing the PiGlow"

            sys.exit(1)

        self.piglow.all(0)

        self.clock = Clock(self.piglow)
        self.alert = Alert(self.piglow)
        self.in_progress = In_Progress(self.piglow)

        address = (self.cfg.HOST, self.cfg.PORT)

        serversock = socket(AF_INET, SOCK_STREAM)
        serversock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
        serversock.bind(address)
        serversock.listen(5)

        self.check_jobs_thread = Thread(None, self.check_jobs, None, ())
        self.socket_manager_thread = Thread(None, self.socket_manager, None,
                                            (serversock, ))

        self.start_threads()

        while self.running == True:
            sleep(1)

        self.stop()

    def stop(self):
        """Closes the threads and returns"""

        self.stop_threads()
        self.piglow.all(0)

    def start_threads(self):
        """Starts the threads"""

        self.running = True

        self.check_jobs_thread.start()
        self.socket_manager_thread.start()

    def stop_threads(self):
        """Stops the threads"""

        self.running = False
        self.unlock()

        try:
            self.check_jobs_thread.join()
        except (KeyboardInterrupt, SystemExit):
            pass

        try:
            self.socket_manager_thread.join()
        except (KeyboardInterrupt, SystemExit):
            pass

    def check_jobs(self):
        """Performs the actions in the job list"""

        while self.running == True:

            if self.quit_requested():
                self.running = False
                break

            if self.entering_quiet_time() == True:
                self.unlock()
                self.piglow.all(0)

            if self.in_quiet_time() == False:

                if self.locked_thread is None:
                    # No currently locking jobs, we can process the next job in the list as
                    # normal or run the idle task if none are scheduled
                    self.run_jobs()

                else:
                    # A locking job is currently running, screen the job list for tasks
                    # relating to it.
                    self.check_locked_jobs()

            sleep(self.job_interval)

    def quit_requested(self):
        """Returns true if the quit command is in the job list"""

        for job in self.jobs:

            if job[0] == self.commands.QUIT:
                return True

        return False

    def check_locked_jobs(self):
        """Goes through the job list searching for tasks relating to the current locked job"""

        jobs = self.jobs
        self.jobs = []

        for job in jobs:

            if job[0] == self.commands.CYCLE:

                try:
                    self.in_progress.set_speed(job[1])
                except IndexError:
                    pass

            elif job[0] == self.commands.UNLOCK:
                self.unlock()

            elif job[0] == self.commands.OFF:
                self.unlock()
                self.jobs.append(job)

            else:
                self.jobs.append(job)

    def run_jobs(self):
        """First the first job in the list or the current idle job"""

        if len(self.jobs) > 0:

            job = self.jobs[:1].pop()
            self.jobs = self.jobs[1:]

            self.handle_job(job)

        else:

            if self.idle_job is not None:
                self.run_idle_job()
            else:
                self.piglow.all(0)

    def run_idle_job(self):
        """Runs the current idle job"""

        if self.idle_job == self.commands.CLOCK:
            self.clock.run()

    def handle_job(self, job):
        """Performs the given job"""

        command = job[:1].pop()
        args = job[1:]

        if command == self.commands.QUIT:

            self.running = False

        elif command == self.commands.CYCLE:

            self.locked_thread = self.in_progress

            if len(args) > 0:
                self.in_progress.set_speed(args[0])

            self.in_progress.start()

        elif command == self.commands.ALERT:

            self.alert.show(*args)

        elif command == self.commands.OFF:

            self.idle_job = None

        elif command == self.commands.CLOCK:

            self.idle_job = self.commands.CLOCK

    def unlock(self):
        """Stops the currently locking thread"""

        if self.locked_thread is None:
            return

        self.locked_thread.stop()
        self.locked_thread = None

    def socket_manager(self, serversock):
        """Creates handlers for new data given to this process via the socket"""

        rlist = [serversock]
        wlist = []
        xlist = []

        while self.running == True:

            readable, writable, errored = select.select(
                rlist, wlist, xlist, self.cfg.TIMEOUT)

            for s in readable:

                if s is serversock:
                    clientsock, addr = serversock.accept()
                    self.socket_buffer_handler(clientsock)

    def socket_buffer_handler(self, clientsock):
        """Handles data in the socket buffer"""

        data = clientsock.recv(self.cfg.BUFF).rstrip()
        command = data.split(" ")

        if command == self.commands.CLOSE:
            clientsock.close()
        else:
            self.add_job(command)

    def add_job(self, job):
        """Adds a job to the list"""

        if self.cfg.quiet_time() == False or job == self.command.QUIT:
            self.jobs.append(job)

    def entering_quiet_time(self):
        """Returns true if we're entering quiet time"""

        return self.quiet_time == False and self.cfg.quiet_time() == True

    def in_quiet_time(self):
        """Returns true if we're in quiet time"""

        self.quiet_time = self.cfg.quiet_time()

        return self.quiet_time
コード例 #33
0
class PiGlow_Status_Server:

  def __init__ (self):

    self.cfg = PiGlow_Status_Config ()
    self.commands = PiGlow_Status_Commands ()
    self.idle_job = self.commands.CLOCK
    self.jobs = []
    self.running = None
    self.locked_thread = None
    self.check_jobs_thread = None
    self.socket_manager_thread = None
    self.piglow = None
    self.clock = None
    self.alert = None
    self.in_progress = None
    self.job_interval = 0.1
    self.quiet_time = False


  def start (self):
    """Creates the socket and starts the threads"""

    try:
      self.piglow = PiGlow ()

    except IOError as e:

      if e[0] == errno.EACCES:
        print >> sys.stderr, "Permission denied, try running as root"
      else:
        print >> sys.stderr, "Unknown error accessing the PiGlow"

      sys.exit (1)

    self.piglow.all (0)

    self.clock = Clock (self.piglow)
    self.alert = Alert (self.piglow)
    self.in_progress = In_Progress (self.piglow)

    address = (self.cfg.HOST, self.cfg.PORT)

    serversock = socket (AF_INET, SOCK_STREAM)
    serversock.setsockopt (SOL_SOCKET, SO_REUSEADDR, 1)
    serversock.bind (address)
    serversock.listen (5)

    self.check_jobs_thread = Thread (None, self.check_jobs, None, ())
    self.socket_manager_thread = Thread (None, self.socket_manager, None, (serversock, ))

    self.start_threads ()

    while self.running == True:
      sleep (1)

    self.stop ()


  def stop (self):
    """Closes the threads and returns"""

    self.stop_threads ()
    self.piglow.all (0)


  def start_threads (self):
    """Starts the threads"""

    self.running = True

    self.check_jobs_thread.start ()
    self.socket_manager_thread.start ()


  def stop_threads (self):
    """Stops the threads"""

    self.running = False
    self.unlock ()

    try:
      self.check_jobs_thread.join ()
    except (KeyboardInterrupt, SystemExit):
      pass

    try:
      self.socket_manager_thread.join ()
    except (KeyboardInterrupt, SystemExit):
      pass


  def check_jobs (self):
    """Performs the actions in the job list"""

    while self.running == True:

      if self.quit_requested ():
        self.running = False
        break

      if self.entering_quiet_time () == True:
        self.unlock ()
        self.piglow.all (0)

      if self.in_quiet_time () == False:

        if self.locked_thread is None:
          # No currently locking jobs, we can process the next job in the list as
          # normal or run the idle task if none are scheduled
          self.run_jobs ()

        else:
          # A locking job is currently running, screen the job list for tasks
          # relating to it.
          self.check_locked_jobs ()

      sleep (self.job_interval)


  def quit_requested (self):
    """Returns true if the quit command is in the job list"""

    for job in self.jobs:

      if job[0] == self.commands.QUIT:
        return True

    return False


  def check_locked_jobs (self):
    """Goes through the job list searching for tasks relating to the current locked job"""

    jobs = self.jobs
    self.jobs = []

    for job in jobs:

      if job[0] == self.commands.CYCLE:

        try:
          self.in_progress.set_speed (job[1])
        except IndexError:
          pass

      elif job[0] == self.commands.UNLOCK:
        self.unlock ()

      elif job[0] == self.commands.OFF:
        self.unlock ()
        self.jobs.append (job)

      else:
        self.jobs.append (job)


  def run_jobs (self):
    """First the first job in the list or the current idle job"""

    if len (self.jobs) > 0:

      job = self.jobs[:1].pop ()
      self.jobs = self.jobs[1:]

      self.handle_job (job)

    else:

      if self.idle_job is not None:
        self.run_idle_job ()
      else:
        self.piglow.all (0)


  def run_idle_job (self):
    """Runs the current idle job"""

    if self.idle_job == self.commands.CLOCK:
      self.clock.run ()


  def handle_job (self, job):
    """Performs the given job"""

    command = job[:1].pop ()
    args = job[1:]

    if command == self.commands.QUIT:

      self.running = False

    elif command == self.commands.CYCLE:

      self.locked_thread = self.in_progress

      if len (args) > 0:
        self.in_progress.set_speed (args[0])

      self.in_progress.start ()

    elif command == self.commands.ALERT:

      self.alert.show (*args)

    elif command == self.commands.OFF:

      self.idle_job = None

    elif command == self.commands.CLOCK:

      self.idle_job = self.commands.CLOCK


  def unlock (self):
    """Stops the currently locking thread"""

    if self.locked_thread is None:
      return

    self.locked_thread.stop ()
    self.locked_thread = None


  def socket_manager (self, serversock):
    """Creates handlers for new data given to this process via the socket"""

    rlist = [serversock]
    wlist = []
    xlist = []

    while self.running == True:

      readable, writable, errored = select.select (rlist, wlist, xlist, self.cfg.TIMEOUT)

      for s in readable:

        if s is serversock:
          clientsock, addr = serversock.accept ()
          self.socket_buffer_handler (clientsock)


  def socket_buffer_handler (self, clientsock):
    """Handles data in the socket buffer"""

    data = clientsock.recv (self.cfg.BUFF).rstrip ()
    command = data.split (" ")

    if command == self.commands.CLOSE:
      clientsock.close ()
    else:
      self.add_job (command)


  def add_job (self, job):
    """Adds a job to the list"""

    if self.cfg.quiet_time () == False or job == self.command.QUIT:
      self.jobs.append (job)


  def entering_quiet_time (self):
    """Returns true if we're entering quiet time"""

    return self.quiet_time == False and self.cfg.quiet_time () == True


  def in_quiet_time (self):
    """Returns true if we're in quiet time"""

    self.quiet_time = self.cfg.quiet_time ()

    return self.quiet_time
コード例 #34
0
ファイル: reset_piglow.py プロジェクト: noelevans/sandpit
def main():
    piglow = PiGlow()
    piglow.all(0)
コード例 #35
0
ファイル: wheel.py プロジェクト: AdamOssenford/piglow
#!/usr/bin/python
from time import sleep
from piglow import PiGlow

piglow = PiGlow()

for i in range(1, 10):
  #on
  piglow.arm(1,100)
  sleep(0.5)
  piglow.arm(2,100)
  sleep(0.5)
  piglow.arm(3,100)
  sleep(0.5)
  #off
  piglow.arm(1,0)
  sleep(0.5)
  piglow.arm(2,0)
  sleep(0.5)
  piglow.arm(3,0)
  sleep(0.5)
コード例 #36
0
    def do_GET(self):
        parts = urlparse.urlparse(self.path)
        if parts.path == "/":
            self.path = "/index.html"

        piglow = PiGlow()

        if parts.query != "":
            qs = urlparse.parse_qs(parts.query)

            if "r" in qs:
                r = int(qs['r'][0])
                piglow.red(r)

            if "o" in qs:
                o = int(qs['o'][0])
                piglow.orange(o)

            if "y" in qs:
                y = int(qs['y'][0])
                piglow.yellow(y)

            if "g" in qs:
                g = int(qs['g'][0])
                piglow.green(g)

            if "b" in qs:
                b = int(qs['b'][0])
                piglow.blue(b)

            if "w" in qs:
                w = int(qs['w'][0])
                piglow.white(w)

            self.send_response(200)
            self.send_header('Content-type', "application/json")
            self.end_headers()
            self.wfile.write('"true"')
            return

        try:
            #Check the file extension required and
            #set the right mime type

            sendReply = False
            if self.path.endswith(".html"):
                mimetype = 'text/html'
                sendReply = True
            if self.path.endswith(".png"):
                mimetype = 'image/png'
                sendReply = True
            if self.path.endswith(".woff"):
                mimetype = 'application/x-font-woff'
                sendReply = True
            if self.path.endswith(".woff2"):
                mimetype = 'application/font-woff2'
                sendReply = True
            if self.path.endswith(".ttf"):
                mimetype = 'application/octet-stream'
                sendReply = True
            if self.path.endswith(".js"):
                mimetype = 'application/javascript'
                sendReply = True
            if self.path.endswith(".css"):
                mimetype = 'text/css'
                sendReply = True

            if sendReply == True:
                #Open the static file requested and send it
                f = open(curdir + sep + self.path)
                self.send_response(200)
                self.send_header('Content-type', mimetype)
                self.end_headers()
                self.wfile.write(f.read())
                f.close()
            return

        except IOError:
            self.send_error(404, 'File Not Found: %s' % self.path)
コード例 #37
0
ファイル: white.py プロジェクト: x41x41x90/x41-piglow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.white(255)
コード例 #38
0
ファイル: brightS.py プロジェクト: shifty051/PiGlow
###############################################################
# Set the LEDs to turn on/off in pairs of 2 toward the centre, 
# whilst increasing and decreasing in brightness
# shifty051
###############################################################

from piglow import PiGlow
from time import sleep
piglow = PiGlow()

piglow.all(0)

while True:
  
  i=0

  piglow.red(1)
  sleep(0.1)
  
  piglow.red(2)
  sleep(0.1)
  
  piglow.red(3)
  piglow.orange(1)
  sleep(0.1)
  
  piglow.red(4)
  piglow.orange(2)
  sleep(0.1)
  
  piglow.red(3)
コード例 #39
0
#!/usr/bin/python

from piglow import PiGlow
from time import sleep
import psutil

piglow = PiGlow()

# start at white
colour = 1

while True:
    # returns a value from 0 - 1 representing current CPU load
    cpu = psutil.cpu_percent()

    # now we need to scale that CPU level to the range 0 - 255 for PiGlow brightness
    brightness = max( (int)(cpu * 255), 1)

    # pick a speed that gets faster as the CPU usage increases
    speed = max ( 1.2 - cpu, 0.1 )

    # turn everything off, let's get ready to rumble
    piglow.all(0)

    # turn on the next "ring" of colour
    piglow.colour(colour, brightness)

    # sleep for a bit, i'm weary...
    sleep(speed)

    # increment to the next colour (reset to white if we're already on red)
コード例 #40
0
#!/usr/bin/python

# ===========================================================================
# Shut Down or Reset button for Raspberry Pi B+ (40 GPIO pins)              #
# Requires PiGlow Python class                                              #
# https://github.com/Boeeerb/PiGlow                                         #
# ===========================================================================

# Import the libraries to use time delays, send os commands and access GPIO pins
from piglow import PiGlow
from time import sleep

piglow = PiGlow()

ledbrightness = 3 # LED brightness
step = 6 # Count of steps (3 for arms or 6 for colors)

piglow.all(0)

while True:
    piglow.all(0)
    piglow.colour(step,ledbrightness)
    step -= 1
    if step == 0:
        step = 6
    sleep(1)

コード例 #41
0
##################################################
## Test the brightness of all the LEDs together ##
##                                              ##
## Example by Jason - @Boeeerb                  ##
##################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()

while True:
    count = range(0, 256, +1)
    for item in count:
        if item < 256:
            piglow.all(item)
            sleep(0.01)
        if item == 256:
            break
    count = range(255, 0, -1)
    print "Brightest"
    for item in count:
        if item > 0:
            piglow.all(item)
            sleep(0.01)
        if item == 0:
            piglow.all(0)
            break
    print "Fin"
    break
コード例 #42
0
ファイル: yellow.py プロジェクト: AdamOssenford/piglow
#!/usr/bin/python
from piglow import PiGlow
# yellow
piglow = PiGlow()
piglow.white(0)
piglow.blue(0)
piglow.green(0)
piglow.yellow(100)
piglow.orange(0)
piglow.red(0)
コード例 #43
0
ファイル: clock.py プロジェクト: iiSeymour/PiGlow
######################################
## A binary clock using the PiGlow  ##
##                                  ##
##  Example by Jason - @Boeeerb     ##
######################################

from piglow import PiGlow
from time import sleep
from datetime import datetime

piglow = PiGlow()

### You can customise these settings ###

show12hr = 1  # Show 12 or 24hr clock - 0= 24hr, 1= 12hr
ledbrightness = 10  # Set brightness of LED - 1-255 (recommend 10-20, put 0 and you won't see it!)
hourflash = 1  # Choose how to flash change of hour - 1= white leds, 2= all flash

armtop = "s"  # h= hour, m= minutes, s= seconds
armright = "m"
armbottom = "h"

### End of customising ###

piglow.all(0)

hourcount = 0
hourcurrent = 0

while True:
    time = datetime.now().time()
コード例 #44
0
ファイル: orange.py プロジェクト: x41x41x90/x41-piglow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.orange(255)
コード例 #45
0
ファイル: inprogress.py プロジェクト: mmawdsley/piglow-status
                colour = 1

                if val == 2:
                    val = 0
                else:
                    val = 2

            self.piglow.led(colour, val)
            sleep(self.delay)

            colour = colour + 1


if __name__ == "__main__":

    piglow = PiGlow()
    in_progress = In_Progress(piglow)
    in_progress.set_speed("medium")

    try:

        in_progress.start()

        while True:
            sleep(1)

    except KeyboardInterrupt:

        in_progress.stop()
        piglow.all(0)
コード例 #46
0
#Google Analytics to PiGlow LEDS
from piglow import PiGlow
import time
import urllib2

piglow = PiGlow()
#Test
i = 0
while (i < 2):
    piglow.arm1(127)
    time.sleep(0.1)
    piglow.arm1(0)
    piglow.arm2(127)
    time.sleep(0.1)
    piglow.arm2(000)
    piglow.arm3(127)
    time.sleep(0.1)
    piglow.arm3(0)
    #Test Completed
    i = i + 1

while True:
    response = urllib2.urlopen('http://ryanteck.org.uk/nginx_status')
    html = response.read()
    data = html.split('\n')
    active = data[0].split(":")
    count = active[1]
    count = int(count) - 1
    #print(count)

    if (count == 0):
コード例 #47
0
## Author: Daniel Pullan
## Github: GitHub.com/DanielPullan
## Website: DanielPullan.co.uk

from time import sleep
from config import email, password, mail
from piglow import PiGlow

## Init the current device
piglow = PiGlow()

## Device parameters
piglow.all(0)

if mail == 0:
    print "no mail"
    piglow.all(0)
    sleep(0.5)
elif mail < 5:
    print "mail count low"
    piglow.arm1(10)
    sleep(0.5)
elif mail < 10:
    print "mail count medium"
    piglow.arm1(10)
    piglow.arm2(10)
    sleep(0.5)
elif mail < 15:
    print "mail count high"
    piglow.arm1(10)
    piglow.arm2(10)
コード例 #48
0
ファイル: cycle2.py プロジェクト: theleestarr/PiGlow-1
##################################################
## Switch each colour on in sequence on and off ##
##                                              ##
## Example by Jason - @Boeeerb                  ##
##################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()
val = 20
colour = 1

while True:
    if colour == 7:
        colour = 1
        if val == 20:
            val = 0
        else:
            val = 20

    piglow.colour(colour, val)
    sleep(0.2)

    colour = colour + 1
コード例 #49
0
ファイル: TESTING-clock.py プロジェクト: kvvs/PiGlow
######################################
## A binary clock using the PiGlow  ##
##                                  ##
##  Example by Jason - @Boeeerb     ##
######################################

from piglow import PiGlow
from time import sleep
from datetime import datetime

piglow = PiGlow()


### You can customise these settings ###

show12hr = 1            # Show 12 or 24hr clock - 0= 24hr, 1= 12hr
ledbrightness = 10      # Set brightness of LED - 1-255 (recommend 10-20, put 0 and you won't see it!)
hourflash = 1           # Choose how to flash change of hour - 1= white leds, 2= all flash

armtop = "s"            # h= hour, m= minutes, s= seconds
armright = "m"
armbottom = "h"

### End of customising ###

piglow.all(0)

hourcount = 0
hourcurrent = 0

while True:
コード例 #50
0
ファイル: webglow.py プロジェクト: ryanteck/webGlow
#Google Analytics to PiGlow LEDS
from piglow import PiGlow
import time
import urllib2
piglow = PiGlow()
#Test
i = 0
while (i < 2):
	piglow.arm1(127)
	time.sleep(0.1)
	piglow.arm1(0)
	piglow.arm2(127)
	time.sleep(0.1)
	piglow.arm2(000)
	piglow.arm3(127)
	time.sleep(0.1)
	piglow.arm3(0)
	#Test Completed
	i = i+1

while True:
	response = urllib2.urlopen('http://ryanteck.org.uk/nginx_status')
	html = response.read()
	data = html.split('\n')
	active = data[0].split(":")
	count = active[1]
	count = int(count) -1;
	#print(count)
	
	if(count ==0):
		piglow.all(0)
コード例 #51
0
#######################################################
## Quickly increase and decrease each LED one by one ##
##                                                   ##
## Example by Jason - @Boeeerb                       ##
#######################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()
val = 0
count = 1
while True:
    leds = list(range(1, 19, +1))
    for led in leds:
        if count == 1:
            val = val + 1
            if val > 90:
                count = 0
        else:
            val = val - 1
            if val < 1:
                count = 1
        piglow.led(led, val)

        sleep(0.0075)
コード例 #52
0
ファイル: softS.py プロジェクト: shifty051/PiGlow
###############################################################
# Set the LEDs to turn on/off in pairs of 2 toward the centre, 
# whilst increasing and decreasing in brightness
# shifty051
###############################################################

from piglow import PiGlow
from time import sleep

piglow = PiGlow()

while True:

  piglow.red(1)
  sleep(0.1)
  
  piglow.red(2)
  sleep(0.1)
  
  piglow.red(3)
  piglow.orange(1)
  sleep(0.1)
  
  piglow.red(4)
  piglow.orange(2)
  sleep(0.1)
  
  piglow.red(3)
  piglow.orange(3)
  sleep(0.1)
  
コード例 #53
0
from astral import *
from piglow import PiGlow
import time
import datetime
import logging
dt = datetime.datetime.now()
logging.basicConfig(filename='/home/pi/LOGGING/lightoutput_%i_%i_%i.log' %
                    (dt.year, dt.month, dt.day),
                    level=logging.INFO)
from scipy import stats
number_seconds_day = 60 * 60 * 24
centre = 0.0
total_intensity = 0
max_brightness = 255
intensity = {}
piglow = PiGlow()
piglow.all(0)

a = Astral()
location = a["Manchester"]
#print (" %s %s %s %s %s \n" % (dawn, sunrise, noon, sunset, dusk))
#Information for Manchester
# 2014-01-21 07:30:11+00:00 2014-01-21 08:10:06+00:00 2014-01-21 12:20:18+00:00 2014-01-21 16:30:35+00:00 2014-01-21 17:10:31+00:00
# For the local timezone
#print ("Time: %s" % t)

logging.info("Epoch_Time\tRed\tOrange\tYellow\tGreen\tBlue\tWhite\tTotal")


def calculate_intensity(x, centre, mu, max_brightness):
    #Normal distribution