1234567891011121314151617181920212223242526272829303132333435363738394041 |
- from GSV4BT import GSV4BT
- import time
- import bluetooth
- class LoadCells():
- def __init__(self):
- self.cells = (
- GSV4BT("addr1"),
- GSV4BT("addr2"),
- GSV4BT("addr3"),
- )
-
- def connect(self):
- success = True
- for cell in self.cells:
- if not cell.connect():
- success = False
- return success
- def getForces(self):
- return (
- self.cells[0].getForces(),
- self.cells[1].getForces(),
- self.cells[2].getForces()
- )
- if __name__ == "__main__":
- cells = LoadCells()
- while True:
- nearby_devices = bluetooth.discover_devices(lookup_names=True)
- print("Found {} devices.".format(len(nearby_devices)))
- for addr, name in nearby_devices:
- print(" {} - {}".format(addr, name))
- cells.connect()
- print(cells.getForces())
- cells.scan()
- time.sleep(1)
|