-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.py
93 lines (73 loc) · 1.81 KB
/
debug.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import time;
import ui;
import globs;
def debug_mode(): #{
print("[DEBUG ] Mode: Debug");
# Little flash
ui.led_toggle();
time.sleep(0.05); # 50 msec
ui.led_toggle();
time.sleep(0.05); # 50 msec
ui.led_toggle();
time.sleep(0.05); # 50 msec
# Turn the LED ON
ui.led_on();
# Fire up REPL
#uart = machine.UART(0, 115200);
#os.dupterm(uart)
globs.mode = globs.MODE_DEBUG;
import sys;
sys.exit(0);
#HARD# # Soft reset? (no more, now REPL)
#HARD# import sys;
#HARD# sys.exit();
# Hard reset
import machine;
machine.reset();
#}
# SOS (... --- ...)
def sos(err_code=0): #{
try: #{
ui.led_off();
for i in range(10): #{
# S (...)
for c in range(3): #{
ui.led_toggle();
time.sleep(0.10);
ui.led_toggle();
time.sleep(0.40);
#}
time.sleep(0.50);
# O (---)
for c in range(3): #{
ui.led_toggle();
time.sleep(0.40);
ui.led_toggle();
time.sleep(0.10);
#}
time.sleep(0.50);
# S (...)
for c in range(3): #{
ui.led_toggle();
time.sleep(0.10);
ui.led_toggle();
time.sleep(0.40);
#}
time.sleep(2);
# Err code
for c in range(err_code): #{
ui.led_toggle();
time.sleep(0.25);
ui.led_toggle();
time.sleep(0.25);
#}
time.sleep(2);
#}
# Hard reset
import machine;
machine.reset();
except KeyboardInterrupt: #}{
print("Break");
debug_mode();
#}
#}