def setAllSegments(self, segments):
     for port in self.realTiles.sharedSerials.keys():
         zeroTile = LSRealTile(self.realTiles.sharedSerials[port])
         zeroTile.assignAddress(0)
         zeroTile.setSegments(segments)
     for tile in self.tileList:
         tile.shape = segments[0]|segments[1]|segments[2]
 def setAllShape(self, shape):
     for port in self.realTiles.sharedSerials.keys():
         zeroTile = LSRealTile(self.realTiles.sharedSerials[port])
         zeroTile.assignAddress(0)
         zeroTile.setShape(shape)
     for tile in self.tileList:
         tile.shape = shape
 def setAllColor(self, color):
     for port in self.realTiles.sharedSerials.keys():
         zeroTile = LSRealTile(self.realTiles.sharedSerials[port])
         zeroTile.assignAddress(0)
         zeroTile.setColor(color)
     for tile in self.tileList:
         tile.color = color
 def clearAll(self):
     for port in self.realTiles.sharedSerials.keys():
         zeroTile = LSRealTile(self.realTiles.sharedSerials[port])
         zeroTile.assignAddress(0)
         zeroTile.blank()
     for tile in self.tileList:
         tile.shape = 0
         tile.color = 0
Beispiel #5
0
def main():
    print("\nTesting LSRealTile")

    tilepile = LSOpen()
    
    comPort = tilepile.selectPort()
    
    print("Attempting to open port " + comPort)
    theSerial = None
    try:
        # The serial read timeout may need to vary on different hosts.
        # On Acer netbook:
        # timeout = 0.003 misses a lot of sensor reads in writeAndPoll
        # timeout = 0.004 misses a few reads
        # timeout = 0.005 rarely misses a read
        # timeout = 0.006 never seen to miss a read
        theSerial = tilepile.lsSerial(comPort, 19200, timeout=0.006)
        print(comPort + " opened")

    except serial.SerialException:
        print(comPort + " is not available")
        
    if theSerial != None:
        print("\nStarting tests...")

        myTile = LSRealTile(tilepile.lsSerial(comPort))

        # start with tile address survey
        address = 8 # default address
        myTile.assignAddress(address)
        tiles = addressWalk(myTile, theSerial)
        testChoice = 6 # initialize for repeat

        reply = input("What is the tile address? (0 is global, <Enter> for default): ")
        if reply == "":  # try the first tile in the list
            address = tiles[0] # 64
        else:
            address = int(reply)
        
        myTile.assignAddress(address)
        result = myTile.getAddress()
        #print("Tile address = " + result)
        strRes = ""
        #strRes = ''.join( [ "0x%02X " %  x for x in result ] ).strip()
        strRes = repr(result)
        print("Tile address = " + strRes)
        testSleep()

        print("\nTesting reset")
        myTile.reset()
        testSleep(2)

        myTile.setDebug(0)
        for loop in range(1000000):
            print("\nTest choices or <Ctrl-C> to exit: ")
            print("    0 - full test suite")
            print("    1 - communications test")
            print("    2 - sensor test")
            print("    3 - sensorStatus test")
            print("    4 - run single digit mode")
            print("    5 - EEPROM tasks")
#            print("    6 - discovery walk thru the address space")
            print("    6 - test setSegments API")
            print("    7 - set segments and poll sensor")
            print("    8 - random tile address procedure")
            reply = input("\nWhat test do you want to run? <Enter> to repeat: ")
            if reply != "":
                testChoice = int(reply)
            if testChoice == 0:
                fullSuite(myTile)
            elif testChoice == 1:
                commTest(myTile, theSerial)
            elif testChoice == 2:
                sensorTest(myTile)
            elif testChoice == 3:
                sensorStatusTest(myTile)
            elif testChoice == 4:
                singleModeTest(theSerial)
            elif testChoice == 5:
                eepromTasks(myTile)
#            elif testChoice == 6:
#                addressWalk(myTile, theSerial)
            elif testChoice == 6:
                setSegmentsTest(myTile)
            elif testChoice == 7:
                writeAndPoll(myTile)
            elif testChoice == 8:
                setRandomTileAddress(theSerial, myTile)
            else:
                print("You did not enter a valid test choice")
        
        theSerial.close()
       
    input("\nDone - Press the Enter key to exit") # keeps double-click window open
Beispiel #6
0
            print("No address specified, using address 0 (all tiles).")
            address = 0
            print(
                "To target a tile at a specific address use the -a option...")
        else:
            print("Available addresses: " + repr(lsls.lsMatrix.get(com)))
            address = 0
            inaddr = input("What tile address would you like to control [0]: ")
            if inaddr:
                address = int(inaddr)

    print("Using communications port: " + repr(com) + "...")

    theSerial = lsls.lsSerial(com)

    myTile = LSRealTile(lsls.sharedSerials[com])
    myTile.assignAddress(address)

    if theSerial != None:
        if tile_command == None:
            print("No tile command provided, entering interactive mode...")
            raise NotImplementedError()  # No interactive mode
        if tile_command == 'blank':
            print("Blanking tile at address " + str(address))
            #   myTile.blank()     # Not implemented in LSRealTile
            myTile.setColor(0)  # A TEMPORARY hack
        elif tile_command == 'locate':
            print("Setting locate mode on for the tile at address " +
                  str(address))
            myTile.locate()
        elif tile_command == 'demo':
 def latchAll(self):
     for port in self.realTiles.sharedSerials.keys():
         zeroTile = LSRealTile(self.realTiles.sharedSerials[port])
         zeroTile.assignAddress(0)
         zeroTile.latch()
def configWithKeyboard(floorConfig, tilepile):
    config = list()
    mappedAddrs = list()
    print("Blanking all tiles.")
    for port in tilepile.lsMatrix:
        myTile = LSRealTile(tilepile.sharedSerials[port])
        myTile.assignAddress(0)
        #   myTile.blank()     # Not implemented in LSRealTile
        myTile.setColor(0)  # A TEMPORARY hack

    for port in tilepile.lsMatrix:
        for addr in tilepile.lsMatrix[port]:
            rcHash = 0
            while rcHash not in mappedAddrs:
                print("\nPort is: " + repr(port) + " Address is: " + repr(addr))
                myTile = LSRealTile(tilepile.sharedSerials[port])
                myTile.assignAddress(addr)
                myTile.demo(1)
                row = int(pickRow(floorConfig.rows, floorConfig.cols, "Which row?: "))
                col = int(pickCol(floorConfig.rows, floorConfig.cols, "Which col?: "))
                rcHash = int(str(row) + str(col))
                if rcHash not in mappedAddrs:
                    mappedAddrs.append(rcHash)
                    thisTile = (row - 1, col - 1, port, addr, (127, 127))
                    config.append(thisTile)
                    print("Added this tile: {:s}".format(str(thisTile)))
                else:
                    print("Tile ({:d}, {:d}) has already been configured!".format(row, col))
                    rcHash = 0
                myTile.setColor(0)
        print("")
    floorConfig.config = config
    return floorConfig
Beispiel #9
0
        if args['-p']:
            print("No address specified, using address 0 (all tiles).")
            address = 0
            print("To target a tile at a specific address use the -a option...")
        else:
            print("Available addresses: " + repr(lsls.lsMatrix.get(com)))
            address = 0
            inaddr = input("What tile address would you like to control [0]: ")
            if inaddr:
                address = int(inaddr)
            
    print("Using communications port: " + repr(com) + "...")
            
    theSerial=lsls.lsSerial(com)

    myTile = LSRealTile(lsls.sharedSerials[com])    
    myTile.assignAddress(address)

    if theSerial != None:
        if tile_command == None:
            print("No tile command provided, entering interactive mode...")
            raise NotImplementedError() # No interactive mode
        if tile_command == 'blank':
            print("Blanking tile at address " + str(address))
         #   myTile.blank()     # Not implemented in LSRealTile
            myTile.setColor(0)  # A TEMPORARY hack
        elif tile_command == 'locate':
            print("Setting locate mode on for the tile at address " + str(address))
            myTile.locate()
        elif tile_command == 'demo':
            print("Setting demo mode on for the tile at address " + str(address))