-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.py
54 lines (43 loc) · 1.26 KB
/
reset.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import utime
def reset_hardware():
# motor off
import motor
motor.stop(motor.MOT_AB)
# led off
import led
led.set_status_left(led.OFF)
led.set_status_right(led.OFF)
led.set_lightsensorbar_rgb(led.OFF)
led.set_lightsensorbar_white(False)
led.set_front_rgb(led.OFF)
# grappler to starting position
import grappler
grappler.pack()
# servo off
import servo
# servo.set_angle(servo.FOUR, -90)
# servo.set_angle(servo.THREE, -90)
utime.sleep_ms(500)
servo.off(servo.ONE)
servo.off(servo.TWO)
servo.off(servo.THREE)
servo.off(servo.FOUR)
def clear_modules():
import sys
# clear modules
# imported_modules = [
# 'adc_multi', 'blue', 'boot', 'button', 'calib', 'color', 'grappler',
# 'gyro', 'i2c', 'imu', 'led', 'lightsensor', 'linefollower', 'main',
# 'micropython_test', 'motor', 'pinesp32', 'vector3d', 'rotary_encoder',
# 'sensor', 'servo', 'shift_register', 'ssd1306', 'test'
# ]
imported_modules = []
for module in imported_modules:
if module in sys.modules:
del sys.modules[module]
# print("\n".join(sys.modules.keys()))
def run():
reset_hardware()
clear_modules()
if __name__ == "__main__":
run()