Exemple #1
0
    def __init__(self,
                 fname='/dev/ttyACM0',
                 brate=1000000,
                 dim=(12, 10),
                 gamma=2.2):
        """
Initialise a LedScreen object.

>>> screen = LedScreen()
        """
        if type(dim) not in (tuple, list) or len(dim) != 2:
            raise ValueError("Invalid dimension. Format is tuple(x,y)")
        self.tty = uspp.SerialPort(fname, timeout=0)
        #self.tty = uspp.SerialPort(fname, speed=brate, timeout=0)
        os.environ['LEDWALL_TTY'] = fname
        os.system("stty -F $LEDWALL_TTY " + str(brate))
        self.w, self.h = dim
        self.buf = [(0, 0, 0)] * self.w * self.h
        self.transform = Transform(*dim)

        gamma = float(gamma)
        max_gamma = 255.**gamma
        self.gamma_map = [
            int((1 + 2 * x**gamma / (max_gamma / 255.)) // 2)
            for x in xrange(256)
        ]
        for i, v in enumerate(self.gamma_map):
            if v == 254:
                self.gamma_map[i] = 253
Exemple #2
0
    def __init__(self,
                 dimension=(12, 10),
                 gamma=2.2,
                 devname='/dev/ttyACM0',
                 baudrate=1000000):
        """
Initialise a SerialScreen object.

>>> screen = SerialScreen()
        """
        ledscreen.LedScreen.__init__(self, dimension, gamma)
        import uspp
        self.tty = uspp.SerialPort(fname, timeout=0)
        #self.tty = uspp.SerialPort(fname, speed=brate, timeout=0)
        os.environ['LEDWALL_TTY'] = fname
        os.system('stty -F "$LEDWALL_TTY" ' + str(baudrate))
Exemple #3
0
def main():

    shm = SharkMonitor(ser=uspp.SerialPort("/dev/ttyUSB0", 1000, 38400))

    log_time_steps = get_times()
    msg_types, shm_msgs = get_messages()
    left_log_time_steps = get_times1()
    left_msg_types, left_shm_msgs = get_messages1()

    time0 = datetime.now()

    for i, (dt, msg_type,
            shm_msg) in enumerate(zip(log_time_steps, msg_types, shm_msgs)):

        while True:
            time1 = datetime.now()
            sent_dt = time1 - time0
            if sent_dt.microseconds >= dt:
                time0 = time1
                break

        shm_msg_to_be_send = shm.SendMessage(message_type=msg_type,
                                             message=shm_msg)

        while True:
            try:  # used try so that if user pressed other than the given key error will not be shown
                if keyboard.is_pressed('q'):  # if key 'q' is pressed
                    for i, (dt, msg_type, shm_msg) in enumerate(
                            zip(left_log_time_steps, left_msg_types,
                                left_shm_msgs)):

                        while True:
                            time1 = datetime.now()
                            sent_dt = time1 - time0
                            if sent_dt.microseconds >= dt:
                                time0 = time1
                                break

                        shm_msg_to_be_send = shm.SendMessage(
                            message_type=msg_type, message=shm_msg)

                    break  # finishing the loop
                else:
                    pass
            except:
                break
Exemple #4
0
    def __init__(self,
                 fname='/dev/ttyACM0',
                 brate=1000000,
                 dim=(12, 10),
                 gamma=2.2):
        """
Initialise a LedScreen object.

>>> screen = LedScreen()
        """
        if type(dim) not in (tuple, list) or len(dim) != 2:
            raise ValueError("Invalid dimension. Format is tuple(x,y)")
        abstractled.AbstractLed.__init__(self, dimension=dim, gamma=gamma)
        self.tty = uspp.SerialPort(fname, timeout=0)
        #self.tty = uspp.SerialPort(fname, speed=brate, timeout=0)
        os.environ['LEDWALL_TTY'] = fname
        os.system("stty -F $LEDWALL_TTY " + str(brate))

        self.transform = Transform(*dim)
        self.b = [(0, 0, 0)] * self.w * self.h
def main():

    shm = SharkMonitor(ser=uspp.SerialPort("/dev/ttyUSB0", 1000, 38400))

    log_time_steps = get_times()
    msg_types, shm_msgs, ori_msgs, hex_msgs = get_messages()

    time0 = datetime.now()

    for i, (dt, msg_type, shm_msg, ori_msg) in enumerate(
            zip(log_time_steps, msg_types, shm_msgs, ori_msgs)):

        while True:
            time1 = datetime.now()
            sent_dt = time1 - time0
            if sent_dt.microseconds >= dt:
                time0 = time1
                break

        shm_msg_to_be_send = shm.SendMessage(message_type=msg_type,
                                             message=shm_msg)
Exemple #6
0
 def __init__(self):
     self.ser = uspp.SerialPort("/dev/ttyS1", 1000, 38400)
Exemple #7
0
#!/usr/bin/python

import os, sys, string, time, datetime, gmpy, uspp, pygame
ser = uspp.SerialPort("/dev/ttyS2", 1000, 9600)

ser.write(chr(0x00)+chr(0xA0)+chr(0x00)+chr(0xAA)+chr(0x00)+chr(0xA5)+chr(0x00)+chr(0x05))
Exemple #8
0
 def __init__(self):
     self.ser = uspp.SerialPort("/dev/ttyUSB0", 1000, 38400)
     self._msg = None