當前位置: 首頁>>代碼示例>>Python>>正文


Python piglow.PiGlow類代碼示例

本文整理匯總了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)
開發者ID:tommybobbins,項目名稱:minecraft_flashcards,代碼行數:19,代碼來源:lighthouse_setup.py

示例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 ()
開發者ID:mmawdsley,項目名稱:piglow-status,代碼行數:37,代碼來源:piglow_status.py

示例3: main

def main():
    piglow = PiGlow()
    piglow.all(0)
開發者ID:noelevans,項目名稱:sandpit,代碼行數:3,代碼來源:reset_piglow.py

示例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)
開發者ID:tommybobbins,項目名稱:PiGlow,代碼行數:31,代碼來源:sunny.py

示例5: PiGlow

#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.all(255)
開發者ID:x41x41x90,項目名稱:x41-piglow,代碼行數:4,代碼來源:all.py

示例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
開發者ID:castrofernandez,項目名稱:raspberry-pi,代碼行數:30,代碼來源:luces.py

示例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)
開發者ID:ryanteck,項目名稱:webGlow,代碼行數:31,代碼來源:webglow.py

示例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
開發者ID:jcoffey42,項目名稱:Python,代碼行數:31,代碼來源:pulse_01.py

示例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)
開發者ID:lesp,項目名稱:PiGlow_Examples,代碼行數:29,代碼來源:piglow_cycleLED.py

示例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)
開發者ID:AlexanderHems,項目名稱:PiGlow,代碼行數:31,代碼來源:arm.py

示例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
#.........這裏部分代碼省略.........
開發者ID:mmawdsley,項目名稱:piglow-status,代碼行數:101,代碼來源:piglow_status.py

示例12: PiGlow

#!/usr/bin/env python
from piglow import PiGlow
piglow = PiGlow()
piglow.red(255)
開發者ID:x41x41x90,項目名稱:x41-piglow,代碼行數:4,代碼來源:red.py

示例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)
開發者ID:stanleyyork11,項目名稱:ProjectPi,代碼行數:31,代碼來源:pretty.py

示例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)
開發者ID:AlexanderHems,項目名稱:PiGlow,代碼行數:26,代碼來源:indiv.py

示例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)
開發者ID:shifty051,項目名稱:PiGlow,代碼行數:30,代碼來源:spiralS-2.py


注:本文中的piglow.PiGlow類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。