def __init__(self, port=None, ledCount=10, buffered=True): """Creates a BlinkyPendant object and opens the port. Parameters: port Optional, port name as accepted by PySerial library: http://pyserial.sourceforge.net/pyserial_api.html#serial.Serial It is the same port name that is used in Arduino IDE. Ex.: COM5 (Windows), /dev/ttyACM0 (Linux). If no port is specified, the library will attempt to connect to the first port that looks like a BlinkyPendant. """ # If a port was not specified, try to find one and connect automatically if port == None: ports = listports.listPorts() if len(ports) == 0: raise IOError("BlinkyPendant not found!") port = listports.listPorts()[0] self.port = port # Path of the serial port to connect to self.ledCount = ledCount # Number of LEDs on the BlinkyTape self.buffered = buffered # If Frue, buffer output data before sending self.buf = "" # Color data to send self.serial = serial.Serial(port, 115200)
def __init__(self, port=None, ledCount=60, buffered=True): """Creates a BlinkyTape object and opens the port. Parameters: port Optional, port name as accepted by PySerial library: http://pyserial.sourceforge.net/pyserial_api.html#serial.Serial It is the same port name that is used in Arduino IDE. Ex.: COM5 (Windows), /dev/ttyACM0 (Linux). If no port is specified, the library will attempt to connect to the first port that looks like a BlinkyTape. ledCount Optional, total number of LEDs to work with, defaults to 60 LEDs. The limit is enforced and an attempt to send more pixel data will throw an exception. buffered Optional, enabled by default. If enabled, will buffer pixel data until a show command is issued. If disabled, the data will be sent in byte triplets as expected by firmware, with immediate flush of the serial buffers (slower). """ # If a port was not specified, try to find one and connect automatically if port == None: ports = listports.listPorts() if len(ports) == 0: raise IOError("BlinkyTape not found!") port = listports.listPorts()[0] self.port = port # Path of the serial port to connect to self.ledCount = ledCount # Number of LEDs on the BlinkyTape self.buffered = buffered # If Frue, buffer output data before sending self.buf = "" # Color data to send self.serial = serial.Serial(port, 115200)