Ejemplo n.º 1
0
 def _send_current_picture(self):
     """ sends the current picture and no more """
     # 2 boards, so just take one
     if self.image_pwm_current >= 0:
         #for byte in image_pwm_buffer[0][0][:100]:
             #print "%02x" % ord(byte)
         timeout = 5000
         if self.board_id > 2:
             led.run(self.dev, image_pwm_buffer_r[self.board][self.image_pwm_current],
                         timeout=timeout)
         else:
             led.run(self.dev, image_pwm_buffer[self.board][self.image_pwm_current],
                         timeout=timeout)
     if image_pwm_current > self.image_pwm_current: 
         self.image_pwm_current += 1
Ejemplo n.º 2
0
 def run(self):
     """ run is called by the thread and is an endless loop to send data 
         to the led boards
     """
     # realtime stuff - the shit!
     while self.running:
         try:
             if self.synchronize:
                 #self.send_control_data(1, [0]*7)
                 #time.sleep(0.01)
                 led.run(self.dev, [255] + [0]*63)
                 self.synchronize = False
             else:
                 self._send_current_picture()
         except USBError, e:
             if e.errno == 110: # usb operation timeout
                 print 'USBError: [Errno 110] Operation timed out'
                 self.synchronize = True
                 time.sleep(0.1)
             else:
                 raise e
Ejemplo n.º 3
0
#!/usr/bin/env python
import led
import time

dev = led.init()

led.run(dev, [255] + [0]*63, timeout=2000)
def pwm_1led(index):
    i = led.LED_ARR[index]
    shift = i % 8;
    number = [1 << shift]
    col = [0]*(i/8)+number+[0]*((63-i)/8)
    return col
    
for col_nr in range(3):
    for i in range(64):
        col = pwm_1led(i)

        if col_nr == 0:
            data = (2*col + 32*[0])*led.NUM_ROWS
        elif col_nr == 1:
            data = (16*[0]+2*col + 16*[0])*led.NUM_ROWS
        else:
            data = (32*[0] + 2*col)*led.NUM_ROWS

        led.run(dev, data, timeout=5000)
 def run(self):
     i = 0
     while self.running:
         led.run(self.dev, data)
Ejemplo n.º 5
0
#!/usr/bin/env python

import led

# 46'080 bytes should at least be written, so that the buffer's full
# 360 bytes per row -> 360'000 for a full turn 1000 pixels per second

led.init()

import time
while(1):
    # all LEDs
    led.run(([0]*120+[255]*120+[0]*120)*128) # red
    time.sleep(1)
    led.run(([0]*240+[255]*120)*128) # green
    time.sleep(1)
    led.run(([255]*120+[0]*240)*128) # blue
    time.sleep(1)
    led.run(([255]*360)*128) # white
    time.sleep(1)

    led.run(([255]*120+[0]*120+[255]*120)*128) # cyan
    time.sleep(1)
    led.run(([255]*240+[0]*120)*128) # magenta
    time.sleep(1)
    led.run(([0]*120+[255]*240)*128) # yellow
    time.sleep(1)

    # 1 LED
    # led.run(([1]+[0]*7)*15+[0]*240)
    # time.sleep(1)
Ejemplo n.º 6
0
#!/usr/bin/env python
import led
import time

led.init()

for col in range(3):
    img = bytearray(led.ROW*led.NUM_ROWS);
    counter = 0;
    for i, pixel in enumerate(img):
        if i % 3 == col:
            counter += 1
            if counter >= 64:
                counter = 0
            img[i] = min(counter*4, 255)

    data = led.pwm_data(img)

    led.run(data)
    time.sleep(2)
Ejemplo n.º 7
0
fastpwm.pwm_2bit_c(str(bytearray([0x0C,0x30,0xC3]*(64*344/4))), 0, blue)

"""
images = [
    buf, buf, buf, buf, buf, buf, buf, buf, 
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),
    [0]*(led.PWM_IMAGE_SIZE/2),


]
"""

images = [blue, green, red, blue2]

for b in boards:
    print b
    temp = 11862005 / led.NUM_ROWS
    led.run(b, [2]+[temp & 255]+[(temp >> 8) & 255]+
                     [(temp >> 16) & 255] + [(temp >> 24) & 255],
            endpoint=1);
    led.run(b, [255] + [0]*63, timeout=2000)
    for i in range(100):
        for img in images:
            led.run(b, img, timeout=5000)
Ejemplo n.º 8
0
 def send_control_data(self, command, data):
     """ send data to the control endpoint, which is the endpoint 4 """
     led.run(self.dev, [command] + data, endpoint=1)