-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.py
More file actions
40 lines (25 loc) · 791 Bytes
/
test.py
File metadata and controls
40 lines (25 loc) · 791 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
31
32
33
34
35
36
37
38
39
40
import time
import logging
import toio.data as td
from toio.factory import createCubesFromFile
logging.basicConfig(level=logging.DEBUG)
def log(s):
logging.info(s)
cubes = createCubesFromFile("toio-cubes.txt")
time.sleep(1)
for cube in cubes:
log(cube.battery.get())
log(cube.getConfigProtocolVersion())
cube.motion.enableNotification()
cube.button.enableNotification()
cube.toioID.enableNotification()
cube.setListener(log)
cube.setSoundByNotes([td.Note(0x3c, 0.3), td.Note(0x3e, 0.3), td.Note(0x40, 0.3)])
cube.setLight(0, 0, 255)
cube.setLightPattern([td.Light(255, 0, 0, 0.5), td.Light(0, 255, 0, 0.5)])
cube.setMotor(30, 10)
while True:
if not cube.peer.peripheral.waitForNotifications(5):
break
for c in cubes:
c.release()