-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_chart.py
More file actions
30 lines (21 loc) · 918 Bytes
/
example_chart.py
File metadata and controls
30 lines (21 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import asyncio
from Plot import Plot
from aidlab import AidlabManager, DataType, Device, DeviceDelegate, DisconnectReason
class MainManager(DeviceDelegate):
def __init__(self):
self.plot = Plot()
async def run(self):
devices = await AidlabManager().scan()
if len(devices) > 0:
await devices[0].connect(self)
while True:
await asyncio.sleep(1)
def did_connect(self, device: Device):
print(f"Connected to: {device.address}. You need to wear device to see samples.")
asyncio.create_task(device.collect([DataType.ECG], []))
self.plot.add(0)
def did_disconnect(self, device: Device, reason: DisconnectReason):
print("Disconnected from: ", device.address, reason)
def did_receive_ecg(self, device: Device, timestamp: int, value: float):
self.plot.add(value)
asyncio.run(MainManager().run())