-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (54 loc) · 1.73 KB
/
Copy pathmain.py
File metadata and controls
58 lines (54 loc) · 1.73 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def on_button_pressed_a():
global _type
while -2 > input.rotation(Rotation.PITCH) or input.rotation(Rotation.PITCH) > 2 or (-2 > input.rotation(Rotation.ROLL) or input.rotation(Rotation.ROLL) > 2):
basic.show_leds("""
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
""")
basic.clear_screen()
_type = 1
input.on_button_pressed(Button.A, on_button_pressed_a)
def gyroscope():
global plane
plane = game.create_sprite(2, 2)
if input.rotation(Rotation.ROLL) <= 15 and input.rotation(Rotation.ROLL) > 0:
plane.set(LedSpriteProperty.X, 3)
elif input.rotation(Rotation.ROLL) <= 35 and input.rotation(Rotation.ROLL) > 15:
plane.set(LedSpriteProperty.X, 4)
elif input.rotation(Rotation.ROLL) >= 325 and input.rotation(Rotation.ROLL) <= 359:
pass
elif False:
pass
else:
pass
def gforce():
basic.clear_screen()
for index in range(50):
if input.pin_is_pressed(TouchPin.P0) or input.logo_is_pressed() or input.button_is_pressed(Button.B):
basic.clear_screen()
break
else:
basic.show_number(input.acceleration(Dimension.STRENGTH) / 1000)
basic.clear_screen()
def on_button_pressed_b():
global _type
_type = 2
basic.clear_screen()
input.on_button_pressed(Button.B, on_button_pressed_b)
plane: game.LedSprite = None
_type = 0
input.set_accelerometer_range(AcceleratorRange.EIGHT_G)
_type = 0
basic.clear_screen()
def on_forever():
if _type == 1:
if input.pin_is_pressed(TouchPin.P0):
pass
if input.pin_is_pressed(TouchPin.P1):
gforce()
elif _type == 2:
pass
basic.forever(on_forever)