-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo_v2.py
32 lines (25 loc) · 919 Bytes
/
demo_v2.py
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
31
32
# Description: This is a demo script to show how to use the pydglab library to interact with the DGLab device.
import asyncio
import logging
import pydglab
from pydglab import model_v2
logging.basicConfig(
format="%(module)s [%(levelname)s]: %(message)s", level=logging.INFO
)
async def _():
await pydglab.scan()
dglab_instance = pydglab.dglab()
try:
await dglab_instance.create()
except TimeoutError:
logging.error("Timeout, retrying...")
await dglab_instance.create()
await dglab_instance.get_strength()
await dglab_instance.set_strength_sync(1, 1)
await dglab_instance.set_wave_sync(0, 0, 0, 0, 0, 0)
await dglab_instance.set_wave_set(model_v2.Wave_set["Going_Faster"], model_v2.ChannelA)
await dglab_instance.get_batterylevel()
await dglab_instance.get_strength()
await asyncio.sleep(2)
await dglab_instance.close()
asyncio.run(_())