#!/usr/bin/pythonimport os,time,sys,mathrmbl = 0def send(cmd,rid,data): x="" for i in [cmd,rid]+data: x = x + chr(i) x=chr((len(data)+2))+x hid = open("/tmp/hid","w") hid.write(x) hid.flush() hid.close()CMD_SET_REPORT = 0x52RID_LEDS = 0x11def setleds(p1,p2,p3,p4): aux = 0 if p1: aux |= 0x10 if p2: aux |= 0x20 if p3: aux |= 0x40 if p4: aux |= 0x80 if rmbl: aux |= 0x01 send(CMD_SET_REPORT,RID_LEDS,[aux])DL_MAX = 20dl_acc = 0setleds(0,0,0,0)time.sleep(2)def deltasigma_leds(brightness): global dl_acc dl_acc += brightness if dl_acc >= DL_MAX: dl_acc -= DL_MAX setleds(1,1,1,1) else: setleds(0,0,0,0)for i in range(20000): v = (math.sin((i/400.0)-math.pi/2)+1)*(DL_MAX-1)/2 deltasigma_leds(v)