def __init__(self): LaserDisplay.__init__(self) self.__buffer = [] self.usbdev = usb.core.find(idVendor=0x9999, idProduct=0x5555) if self.usbdev is None: self.__send_initalization() self.usbdev = usb.core.find(idVendor=0x9999, idProduct=0x5555) if self.usbdev is None: raise IOError('Could not find laser device (9999:5555) ...') # set the active configuration # with no arguments, the first configuration will be the active one self.usbdev.set_configuration() # get an endpoint instance # first interface match the first OUT endpoint cfg = self.usbdev.get_active_configuration() interface_number = cfg[(0,0)].bInterfaceNumber alternate_setting = usb.control.get_interface(self.usbdev, interface_number) intf = usb.util.find_descriptor(cfg, bInterfaceNumber = interface_number, bAlternateSetting = alternate_setting) self.ep = usb.util.find_descriptor(intf, custom_match = \ lambda e: \ usb.util.endpoint_direction(e.bEndpointAddress) == \ usb.util.ENDPOINT_OUT ) assert self.ep is not None self.set_laser_configuration()
def __init__(self): LaserDisplay.__init__(self) self.__buffer = [] self.usbdev = usb.core.find(idVendor=0x9999, idProduct=0x5555) if self.usbdev is None: self.__send_initalization() self.usbdev = usb.core.find(idVendor=0x9999, idProduct=0x5555) if self.usbdev is None: raise IOError('Could not find laser device (9999:5555) ...') # set the active configuration # with no arguments, the first configuration will be the active one self.usbdev.set_configuration() # get an endpoint instance # first interface match the first OUT endpoint cfg = self.usbdev.get_active_configuration() interface_number = cfg[(0, 0)].bInterfaceNumber alternate_setting = usb.control.get_interface(self.usbdev, interface_number) intf = usb.util.find_descriptor(cfg, bInterfaceNumber=interface_number, bAlternateSetting=alternate_setting) self.ep = usb.util.find_descriptor(intf, custom_match = \ lambda e: \ usb.util.endpoint_direction(e.bEndpointAddress) == \ usb.util.ENDPOINT_OUT ) assert self.ep is not None self.set_laser_configuration()
def __init__(self): LaserDisplay.__init__(self) try: pygame.init() self.surface = pygame.display.set_mode((self.SIZE*self.SCALE, self.SIZE*self.SCALE)) self.surface.fill( (0,0,0) ) pygame.display.set_caption('Laser Display Simulator') except: raise IOError('Could not initialize pygame')
def __init__(self): LaserDisplay.__init__(self) try: pygame.init() self.surface = pygame.display.set_mode( (self.SIZE * self.SCALE, self.SIZE * self.SCALE)) self.surface.fill((0, 0, 0)) pygame.display.set_caption('Laser Display Simulator') except: raise IOError('Could not initialize pygame')
#!/usr/bin/env python mess = None from LaserDisplay import LaserDisplay LD = LaserDisplay() import xml from xml.sax.handler import ContentHandler import threading lock = threading.Lock() import sys import math class SVGHandler(xml.sax.handler.ContentHandler): def startElement(self, name, attrs): global LD if name=="path": tokens = attrs.get('d').replace('m',' m ').replace('c',' c ').replace('l',' l ').replace('h',' h ').replace('v',' v ').replace('z',' z ').replace(' ',' ').strip().split(" ") color = attrs.get('stroke') LD.set_color(color) i=0 x,y=0,0 x0,y0=x,y cmd = None while i<len(tokens): if tokens[i].lower() in ["m", "c", "l", "h", "v", "z"]:
def __init__(self, server, port = 31337): try: self.remote = telnetlib.Telnet(server, port) except: raise IOError('Cannot reach %s:%d ...' % (server, port)) LaserDisplay.__init__(self)
def set_color(self, color): LaserDisplay.set_color(self, color) self.remote.write('color %d %d %d\r\n' % (self.color['R'],self.color['G'],self.color['B']))
def update_position(self): self.x += self.vx self.y += self.vy self.vx += self.ax self.vy += self.ay if self.x < self.r or self.x > WIDTH-self.r or self.y < self.r or self.y > HEIGHT-self.r: self.reset() if random.random()<PROBAB_COLOR_CHANGE: self.color[0] = clamp(self.color[0] + random.random()*COLOR_CHANGE_MAXSTEP - COLOR_CHANGE_MAXSTEP/2, 0,255) self.color[1] = clamp(self.color[1] + random.random()*COLOR_CHANGE_MAXSTEP - COLOR_CHANGE_MAXSTEP/2, 0,255) self.color[2] = clamp(self.color[2] + random.random()*COLOR_CHANGE_MAXSTEP - COLOR_CHANGE_MAXSTEP/2, 0,255) LD = LaserDisplay() LD.set_scan_rate(40000) LD.set_blanking_delay(0) shapes = [] for _ in range (NUM_SHAPES): particles = [] for _ in range(NUM_POINTS): p = Particle(LD) particles.append(p) shapes.append(particles) LD.set_noise(NOISE)
size = WIDTH, HEIGHT screen = pygame.display.set_mode(size, pygame.FULLSCREEN) clock = pygame.time.Clock() FPS = 30 cont = 1 numbers = [] curve = [] curvelen = 0 snap = 1 LD = LaserDisplay({"server": "localhost", "port": 50000}) # LD = LaserDisplay() def clamp_int(value, min, max): if value > max: return max if value < min: return min return value while cont == 1: # clock.tick(FPS) for event in pygame.event.get():
def __init__(self, server, port=31337): try: self.remote = telnetlib.Telnet(server, port) except: raise IOError('Cannot reach %s:%d ...' % (server, port)) LaserDisplay.__init__(self)
def set_color(self, color): LaserDisplay.set_color(self, color) self.remote.write('color %d %d %d\r\n' % (self.color['R'], self.color['G'], self.color['B']))
def __init__(self, devices): self.devices = devices LaserDisplay.__init__(self)
def set_color(self, color): LaserDisplay.set_color(self, color) for i in self.devices: i.set_color(color)