-
Notifications
You must be signed in to change notification settings - Fork 2
/
skywriter.py
40 lines (32 loc) · 856 Bytes
/
skywriter.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
33
34
35
36
37
38
39
40
import skywriter
import json
import sys
some_value = 0
def to_node(type, message):
try:
print(json.dumps({ type: message }))
except:
pass
sys.stdout.flush()
to_node("info", "ready")
@skywriter.flick()
def flick(start, finish):
if start == "east" and finish == "west":
to_node("gesture", "left")
if start == "west" and finish == "east":
to_node("gesture", "right")
if start == "north" and finish == "south":
to_node("gesture", "down")
if start == "south" and finish == "north":
to_node("gesture", "up")
@skywriter.airwheel()
def spinny(delta):
global some_value
some_value += delta
if delta > 0:
to_node("rotate", "clockwise")
elif delta < 0:
to_node("rotate", "anticlockwise")
@skywriter.tap()
def tap(position):
to_node("tap", position)