#0x3F for PCF8474 AT LCD_ADDRESS = 0x27 delay = 0.4 ch1 = ablib.Daisy19("D2", "first", "CH1") ch2 = ablib.Daisy19("D2", "first", "CH2") ch3 = ablib.Daisy19("D2", "first", "CH3") ch4 = ablib.Daisy19("D2", "first", "CH4") Inp1 = ablib.Daisy18("D5", "first", "CH1") Inp2 = ablib.Daisy18("D5", "first", "CH2") Inp3 = ablib.Daisy18("D5", "first", "CH3") Inp4 = ablib.Daisy18("D5", "first", "CH4") L5 = ablib.Daisy11("D2", "L5") L6 = ablib.Daisy11("D2", "L6") L7 = ablib.Daisy11("D2", "L7") L8 = ablib.Daisy11("D2", "L8") lcd = ablib.Daisy24(0, LCD_ADDRESS) lcd.backlighton() lcd.setcurpos(6, 0) lcd.putstring("TEST") lcd.setcurpos(6, 1) lcd.putstring("D-19") #if lcd.pressed(0): ch = 0 while True:
#!/usr/bin/python #Factory test for Daisy-11 boards import ablib import time # Daisy connector on which is wired the # Daisy11 module connector = 'D2' # Create a list istances for all the leds led = [ ablib.Daisy11(connector, 'L1'), ablib.Daisy11(connector, 'L2'), ablib.Daisy11(connector, 'L3'), ablib.Daisy11(connector, 'L4'), ablib.Daisy11(connector, 'L5'), ablib.Daisy11(connector, 'L6'), ablib.Daisy11(connector, 'L7'), ablib.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)
import cherrypy import os import ablib L1 = ablib.Daisy11("D2","L1") L2 = ablib.Daisy11("D2","L2") L3 = ablib.Daisy11("D2","L3") L4 = ablib.Daisy11("D2","L4") L5 = ablib.Daisy11("D2","L5") L6 = ablib.Daisy11("D2","L6") L7 = ablib.Daisy11("D2","L7") L8 = ablib.Daisy11("D2","L8") L1.on() WEB_ROOT = os.getcwd() class MyServer(object): @cherrypy.expose def led(self,id,state): print id print state return cherrypy.server.socket_port = 8080 cherrypy.server.socket_host = '0.0.0.0' conf = { '/': { 'tools.staticdir.on' : True, 'tools.staticdir.dir' : WEB_ROOT, 'tools.staticdir.index' : 'daisy11.html'
except KeyboardInterrupt: print '^C received, shutting down the web server' server.socket.close() def add(self, module): print module return def __init__(self, port): self.port = port print "Sono qui" # Runs the web server thread thread.start_new_thread(self.webserver_thread, ()) # Use the L1 led on Daisy11 module ledL1 = ablib.Daisy11("D2", "L1") a = WebServer(8080) a.add(ledL1) #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()
class ledon(tornado.web.RequestHandler): def get(self): led.on() print "Led ON" self.write("Led ON") class ledoff(tornado.web.RequestHandler): def get(self): led.off() print "Led OFF" self.write("Led OFF") application = tornado.web.Application([ (r"/ledon", ledon), (r"/ledoff", ledoff), (r"/(.*)", tornado.web.StaticFileHandler, { "path": ".", "default_filename": "index.html" }), ]) if __name__ == "__main__": led = ablib.Daisy11('D11', 'L1') application.listen(8080, "0.0.0.0") tornado.ioloop.IOLoop.instance().start()