def ScanForDevices(self): props = Properties() # Power off: print "Powering off..." props.PowerOff() time.sleep(5) # Power on: print "Powering back on..." props.PowerOn() adapter1 = self.bus.get(self.busName, self.path) adapter1.StartDiscovery() for i in range(10, 0, -1): print(i) time.sleep(1) # List devices: objMgr = ObjectManager() # objMgr.ListDevices() # List addresses: devices = objMgr.GetAddresses() for address in devices: print "%s\t%s" % (address, devices[address]['Name'])
def returnFirstPairedDevice(self): # Find all devices that are paired: pairedDevices = [] objMgr = ObjectManager() devices = objMgr.GetAddresses() for address in devices: if devices[address]['Paired']: return address return None
def returnPairedDevices(self): # Find all devices that are paired: pairedDevices = [] objMgr = ObjectManager() devices = objMgr.GetAddresses() for address in devices: if devices[address]['Paired']: pairedDevices.append(address) return pairedDevices
def __init__(self, scenarioType=None): self.players = [] self.objects = ObjectManager() self.harvestables = ObjectManager() self.astres = [] self.communicationManager = CommunicationManager() self.newGfxs = [] self.relations = {} self.tick = 0 self.uidsSent = {} ### loading world according to scenario if scenarioType: self.scenario = scenarioType(self)
def pairDevice(self, addressString): objMgr = ObjectManager() devices = objMgr.GetAddresses() newPath = objMgr.DoesDeviceExist(0, addressString) if newPath != None: print "Attempting to pair device at path: %s" % newPath device = self.bus.get(self.busName, newPath) device.Pair() else: print "Unable to find device at: %s" % addressString
def RemoveDevice(self, deviceAddress): objMgr = ObjectManager() qpath = objMgr.DoesDeviceExist(0, deviceAddress) if qpath == None: print("Device at %s not found" % deviceAddress) else: print("Removing device at path: %s" % qpath) adapter1 = self.bus.get(self.busName, self.path) adapter1.RemoveDevice(qpath) # Verify its gone: qpath = objMgr.DoesDeviceExist(0, deviceAddress) if qpath == None: print("Device Successfully removed") else: print("Unable to remove device")
#!/usr/bin/env python3 import pygame, display, controls from pygame.locals import * from objectmanager import ObjectManager #from gameobject import GameObject, Player FPS = 60 # initialisation fpsClock = pygame.time.Clock() pygame.init() objectmanager = ObjectManager() window = display.initialise((None, None)) gameOver = False # game loop while (gameOver == False): #test for quit event for event in pygame.event.get(): controls.handleEvent(event, objectmanager) #update the gameobjects objectmanager.update() #update graphics display.update(window, objectmanager.gameObjects) gameOver = objectmanager.gameOver() fpsClock.tick(FPS)