本文整理汇总了Python中piglow.PiGlow类的典型用法代码示例。如果您正苦于以下问题:Python PiGlow类的具体用法?Python PiGlow怎么用?Python PiGlow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PiGlow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: light_piglow
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: start
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: main
def main():
piglow = PiGlow()
piglow.all(0)
示例4: 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)
示例5: PiGlow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.all(255)
示例6: PiGlow
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
示例7: PiGlow
#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)
示例8: PiGlow
#!/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
示例9: PiGlow
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)
示例10: PiGlow
#########################################################
## 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)
示例11: __init__
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
#.........这里部分代码省略.........
示例12: PiGlow
#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.red(255)
示例13: PiGlow
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)
示例14: 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)
示例15: 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)