def statusChanged(stat, parm=None): if stat == server.CONNECTED: print('success {}:{}'.format(parm[0], parm[1])) led.setLed(led.ON) ottoTone.sing('S_mode3') elif stat == server.DISCONNECTED: led.setLed(led.OFF) ottoTone.sing('S_disconnection')
def update(): list = [] dot1 = dot(10, 1, 8, 255, 0, 0) list.append(dot1) dot2 = dot(80, -2, 5, 0, 255, 0) list.append(dot2) dot3 = dot(50, 1, 10, 0, 0, 255) list.append(dot3) dot4 = dot(20, -3, 3, 255, 0, 255) list.append(dot4) dot5 = dot(70, -1, 3, 0, 255, 255) list.append(dot5) dot6 = dot(25, 2, 8, 255, 255, 0) list.append(dot6) dot7 = dot(110, -1, 5, 100, 200, 100) list.append(dot7) dot8 = dot(108, 3, 10, 0, 0, 100) list.append(dot8) dot9 = dot(43, -1, 3, 0, 127, 93) list.append(dot9) dot10 = dot(33, -1, 3, 50, 30, 120) list.append(dot10) while 1: led.setAllLed(0, 0, 0) for d in list: #led.setLed(d.pos, 0, 0, 0) d.pos = d.pos + d.dir if d.pos > numleds or d.pos < 0: d.dir = d.dir*-1 d.pos = d.pos + d.dir led.setLed(d.pos, d.r, d.g, d.b) # now the tail #for t in range(0,d.length): # pos = 0 # if d.dir < 0: # pos = d.pos + t + 1 # if pos > numleds: # pos = numleds - (pos - numleds) # else: # pos = d.pos - (t + 1) # if pos < 0: # pos = abs(pos) # led.setLed(pos, d.r, d.g, d.b) led.show() led.flush() time.sleep(.1)
def doit(): led.connect() led.setLed(20, 255, 0, 0) led.flush() led.show()
pinBuzzer = 23 ottoTone = OB.OTTOSound(pinBuzzer) ottoTone.sing('S_connection') def statusChanged(stat, parm=None): if stat == server.CONNECTED: print('success {}:{}'.format(parm[0], parm[1])) led.setLed(led.ON) ottoTone.sing('S_mode3') elif stat == server.DISCONNECTED: led.setLed(led.OFF) ottoTone.sing('S_disconnection') led.setLed(led.OFF) ser = server.tcpServer(callbackFunc=statusChanged) motor = l298.l298n() while True: sleep(0.01) pack = ser.pull() if pack is None: continue print(pack) pack.replace('\n', '') pack.replace('\r', '') p = pack.split(',') if len(p) >= 2: cmd = p[0].strip() if cmd == 'joy':