Esempio n. 1
0
def start_proc(fname, lock, cur_running, priority, run_time, sleep_time):
    logger.info('going to run %s' % fname)
    RemoteDriver().set_lock(lock, cur_running, priority, run_time, sleep_time)
    g = globals()
    g['__name__'] = '__main__'

    execfile(fname, g)
    logger.info('hmm execfile returned, weird.')
Esempio n. 2
0
#!/usr/bin/python

# Fading Random Walk
# (gen.py and GenXMas)

from time import sleep
from bulbs import Bulbs
from remote import RemoteDriver
from gen import *
from random import choice
from itertools import chain

print "waiting our turn..."
driver = RemoteDriver("ExampleSnake")
print "it's go time!"
bulbs = Bulbs(driver)

gx = GenXMas(bulbs)

x = 50
while not driver.stop_signal():
    gx.add((fixed(x), chain(fader(bulbs.RED, bulbs.WHITE, 10), fader(bulbs.WHITE, bulbs.BLACK, 100))))
    gx.render()

    x += choice([1, -1])
    if x == 100:
        x = 0
    elif x < 0:
        x = 99
Esempio n. 3
0
        return tmp_idx 
    
    def quicksort(self, left, right):
        if left < right:
            pivot_idx = (left + right)/2     # play with different pivot selection
            pivot_new_idx = self.partition(left, right, pivot_idx)
            self.quicksort(left, pivot_new_idx - 1)
            self.quicksort(pivot_new_idx + 1, right)

    def sort(self):
        self.quicksort(0, 99)
        

if __name__=="__main__":
    print 'waiting...'
    import sys
    if len(sys.argv) > 1 and sys.argv[1] == "emulator":
        driver = RemoteDriver("QuickSort", "localhost")
    else:
        d = RemoteDriver("QuickSort")
    print 'our turn'
    
    sorter = QuickSort(Bulbs(d))
    sorter.sort()
    
    # Leave the sorted list up
    d.busy_wait()
    
    
Esempio n. 4
0
#!/usr/bin/python

# sine rainbow

from time import sleep
from math import sin
from remote import RemoteDriver

print "waiting our turn..."
import sys
if len(sys.argv) > 1 and sys.argv[1] == "emulator":
    driver = RemoteDriver("ExampleSine", "localhost")
else:
    driver = RemoteDriver("ExampleSine")
print "it's go time!"

offr = 0
offg = 0
offb = 0
offa = 0

while not driver.stop_signal():
    for i in range(100):
        xr = (i+offr) % 100
        xg = (i+offg) % 100
        xb = (i+offb) % 100
        xa = (i+offb) % 100
        yr = sin(xr/5.) * 8+7
        yg = sin(xg/5.) * 8+7
        yb = sin(xb/5.) * 8+7
        ya = sin(xa/10.) * 128+127
Esempio n. 5
0
from time import sleep
from remote import RemoteDriver

d = RemoteDriver("wheel")

idx = 0
count_up = True
colors = [0,0,15]

while True:

	# Set the color
	for i in range(100):
		d.write_led(i, 255, colors[0], colors[1], colors[2])

	# Cycle through the wheel
	if count_up is True:
		colors[idx] += 1
		if colors[idx] == 15:
			count_up = False
			idx = (idx-1)%3
	else:
		colors[idx] -= 1
		if colors[idx] == 0:
			count_up = True
			idx = (idx-1)%3
Esempio n. 6
0
#!/usr/bin/python

import sys
from time import sleep
from bulbs import Bulbs
from remote import RemoteDriver

import random

NUM_BALLS = random.randint(2,5)
NUM_BALLS = 2

print "waiting our turn..."
if len(sys.argv) > 1:
	d = RemoteDriver(name="test", addr="localhost")
else:
	d = RemoteDriver("Physics?")
print "it's go time!"
bulbs = Bulbs(d)


# Start by drawing bumpers at the edge
bumpers = set()
for f in range(5):
	bulbs.frame[f] = Bulbs.BLUE
	bumpers.add(f)
for f in range(95,100):
	bulbs.frame[f] = Bulbs.BLUE
	bumpers.add(f)
field = set(range(100)) - bumpers
Esempio n. 7
0
from remote import RemoteDriver
import time

print 'why no work'
print "what name are we: %s" % __name__

if __name__=="__main__":
    # Unit Test/Example Use:

    # This will block until it is your turn 
    print 'Waiting for our turn...'
    d = RemoteDriver("UnitTest")
    print 'Our turn!'

    # Turn off all the LEDs 
    for i in range(100):
        d.write_led(i, 0, 0, 0, 0)

    # Turn them back on from the top, with some delay (100*.05 = 5s)
    for i in range(100):
        d.write_led(i, 200, 13, 0, 13)
        time.sleep(.05)

    # Turn them off in chunks of 10 (10*2 = 20s)
    # Note that busy_wait must be used for delays >= 1s
    for i in range(100, 0, -10):
        for j in range(i, i-10, -1):
            d.write_led(j-1, 0, 0, 0, 0)
        d.busy_wait(2)