Пример #1
0
#!/usr/bin/python
import time
import fox

# Create an istance on Daisy11 class to refer the L1 led
myled = fox.Daisy11('D2', 'L1')

# Create an istance on Daisy5 class to refer the P1 push button
mybutton = fox.Daisy5('D5', 'P1')

# Never ending loop
while True:
    # If mybutton (P1) is pressed...
    if mybutton.pressed():
        # ...turn on myled (L1)
        myled.on()
    else:
        # ... if not turn off it
        myled.off()
Пример #2
0
import threading


# This is the function that will be executed as a thread
def check_button(button, led):
    while True:
        if button.pressed():
            led.on()
        else:
            led.off()
        time.sleep(0.1)


# Define myled as the led labeled "L1" on the
# Daisy11 module wired on D2 connector
myled = fox.Daisy11('D2', 'L1')

# Define mybutton as the press button labeled "P1" on the
# Daisy5 module wired on D5 connector
mybutton = fox.Daisy5('D5', 'P1')

# Launch the funcion check_button as a thread
# and pass as arguments the button and led instances
thread.start_new_thread(check_button, (mybutton, myled))

# The main program flow continues and makes the L8 blinking
# to show you that it's running in parallel with the thread
blinking_led = fox.Daisy11('D2', 'L8')

while True:
    blinking_led.on()
Пример #3
0
#Commento di prova 
def check_button(button,led):
	while True:
		if button.pressed():
			led.on()
		else:
			led.off()
		time.sleep(0.1)
 
def timed_led(button,led,delay):
	while True:
		if button.pressed():
			led.on()
			time.sleep(delay)
			led.off()
 
myled = fox.Daisy11('D2','L1')
mybutton = fox.Daisy5('D5','P1')
 
myled_2 = fox.Daisy11('D2','L2')
mybutton_2 = fox.Daisy5('D5','P2')
 
thread.start_new_thread(check_button,(mybutton,myled))
thread.start_new_thread(timed_led,(mybutton_2,myled_2,5))
 
loop_counter=0
while True:
	print "loop # " , loop_counter
	loop_counter += 1
	time.sleep(1)
Пример #4
0
    try:
        #Create a web server and define the handler to manage the
        #incoming request
        server = HTTPServer(('', PORT_NUMBER), myHandler)
        print 'Started httpserver on port ', PORT_NUMBER

        #Wait forever for incoming htto requests
        server.serve_forever()

    except KeyboardInterrupt:
        print '^C received, shutting down the web server'
        server.socket.close()


# Runs the web server thread
thread.start_new_thread(WebServerThread, ())

# Use the L1 led on Daisy11 module
ledL1 = fox.Daisy11("D2", "L1")

#Forever loop
while True:
    # Check the blink flag
    if blink == True:
        ledL1.on()
        time.sleep(0.2)
        ledL1.off()
        time.sleep(0.2)
    else:
        ledL1.off()
Пример #5
0
import fox
import time
 
# Daisy connector on which is wired the
# Daisy11 module
connector = 'D2'
 
# Create a list istances for all the leds
led = [
	fox.Daisy11(connector,'L1'),
	fox.Daisy11(connector,'L2'),
	fox.Daisy11(connector,'L3'),
	fox.Daisy11(connector,'L4'),
	fox.Daisy11(connector,'L5'),
	fox.Daisy11(connector,'L6'),
	fox.Daisy11(connector,'L7'),
	fox.Daisy11(connector,'L8')
	]
 
while True:                        # Forever loop
	for i in range (0,8):      # Scan and turn on all the leds 
		led[i].on()        # each 100 mS
		time.sleep(0.1)
 
	for i in range (0,8):      # Scan and turn off all the leds 
		led[i].off()       # each 100 mS
		time.sleep(0.1)
Пример #6
0
import fox
import time

# Tests the first bits in input for Daisy18
# Daisy18 module wired on D2 connector

Mon1 = fox.Daisy11('D2', 'L1')
Mon2 = fox.Daisy11('D2', 'L2')
Mon3 = fox.Daisy11('D2', 'L3')
Mon4 = fox.Daisy11('D2', 'L4')

Act18 = fox.Daisy11('D2', 'L8')
Act19 = fox.Daisy11('D2', 'L7')

MonOk = fox.Daisy11('D2', 'L6')
MonErr = fox.Daisy11('D2', 'L5')

SlowTest = fox.Daisy5('D3', 'P5')
SelD18 = fox.Daisy5('D3', 'P7')
SelD19 = fox.Daisy5('D3', 'P8')

testD18 = False
testD19 = False
selTest = True
blinkOn = True
testDelay = 0.1

print "Select Test : "

while selTest: