-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
54 lines (38 loc) · 1.39 KB
/
main.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
# Power interruption during slow blink will switch picoweb into 'ap' mode on following
# power up. Picoweb will run in 'ap' mode for 5 minutes before rebooting into "sta" mode
import time
import machine
import sys
led = machine.Pin("LED", machine.Pin.OUT); led.off()
'''====================== AP Option ======================='''
try:
from power_up_record import last_power_up
print('last_power_up =',last_power_up)
if last_power_up == 'interrupted':
for i in range(10):
led.on()
time.sleep(.02)
led.off()
time.sleep(.2)
with open('power_up_record.py','w') as file:
file.write("last_power_up = 'clean'")
with open('picoweb_mode.py','w') as file:
file.write("mode = 'ap'")
print("importing picoweb: mode = 'ap'")
import picoweb
except:
pass
''' ==================== STA Option ========================='''
with open('power_up_record.py','w') as file: # write file
file.write("last_power_up = 'interrupted'")
for i in range(10):
led.on()
time.sleep(.1)
led.off()
time.sleep(.9)
with open('power_up_record.py','w') as file: # write file
file.write("last_power_up = 'clean'")
with open('picoweb_mode.py','w') as file: # write file
file.write("mode = 'sta'")
print("importing picoweb: mode = 'sta'")
import picoweb