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)) myTile.demo(1) # Argument (1) is used off-label... elif tile_command == 'flip': if myTile.getAddress() == 0: print("Please specify an address other than 0.") exit() print("Flipping tile at address " + str(address)) myTile.flip() elif tile_command == 'reset': print("Resetting tile at address " + str(address)) myTile.reset() elif tile_command == 'set': if set_command[0] == 'digit': myTile.setDigit(set_command[1]) if set_command[0] == 'color': myTile.setColor(set_command[1]) if set_command[0] == 'address': newaddr = set_command[1] if (newaddr < 0 or newaddr > 254):
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
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)) myTile.demo(1) # Argument (1) is used off-label... elif tile_command == 'flip': if myTile.getAddress() == 0: print("Please specify an address other than 0.") exit() print("Flipping tile at address " + str(address)) myTile.flip() elif tile_command == 'reset': print("Resetting tile at address " + str(address)) myTile.reset() elif tile_command == 'set': if set_command[0] == 'digit': myTile.setDigit(set_command[1]) if set_command[0] == 'color': myTile.setColor(set_command[1]) if set_command[0] == 'address': newaddr = set_command[1] if (newaddr < 0 or newaddr > 254):