Skip to content

Commit 30ebb83

Browse files
k9ertk9ert
andauthored
release: prepare release (#340)
Co-authored-by: k9ert <kim@swanbitcoin.com>
1 parent 6bbec30 commit 30ebb83

2 files changed

Lines changed: 62 additions & 62 deletions

File tree

boot/main/boot.py

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
1-
# boot.py -- run on boot-up
2-
# can run arbitrary Python, but best to keep it minimal
3-
import pyb, os, micropython, time
4-
import sys
5-
6-
# Clean sys.path from qspi
7-
# Shouldn't happen in production, but just in case.
8-
for p in sys.path:
9-
if "qspi" in sys.path:
10-
sys.path.remove(p)
11-
12-
# power hold
13-
pwr = pyb.Pin("B15", pyb.Pin.OUT)
14-
pwr.on()
15-
16-
version = "<version:tag10>0100900099</version:tag10>"
17-
18-
# get i2c
19-
i2c = pyb.I2C(1)
20-
i2c.init()
21-
# start measurements
22-
if 112 in i2c.scan():
23-
i2c.mem_write(0b00010000, 112, 0)
24-
25-
leds = [pyb.LED(i) for i in range(1,5)]
26-
# poweroff on button press
27-
def pwrcb(e):
28-
micropython.schedule(poweroff, 0)
29-
30-
# callback scheduled from the interrupt
31-
def poweroff(_):
32-
# make sure it disables power no matter what
33-
try:
34-
for led in leds:
35-
led.toggle()
36-
# stop battery manangement
37-
if 112 in i2c.scan():
38-
i2c.mem_write(0, 112, 0)
39-
# sync filesystem
40-
os.sync()
41-
time.sleep_ms(300)
42-
finally:
43-
# disable power
44-
pwr.off()
45-
time.sleep_ms(300)
46-
# will never reach here
47-
for led in leds:
48-
led.toggle()
49-
50-
pyb.ExtInt(pyb.Pin('B1'), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_NONE, pwrcb)
51-
52-
# configure usb from start if you want,
53-
# otherwise will be configured after PIN
54-
# pyb.usb_mode("VCP+MSC") # debug mode with USB and mounted storages from start
55-
# pyb.usb_mode("VCP") # debug mode with USB from start
56-
# disable at start
57-
pyb.usb_mode(None)
58-
os.dupterm(None,0)
59-
os.dupterm(None,1)
60-
61-
# inject version and i2c to platform module
1+
# boot.py -- run on boot-up
2+
# can run arbitrary Python, but best to keep it minimal
3+
import pyb, os, micropython, time
4+
import sys
5+
6+
# Clean sys.path from qspi
7+
# Shouldn't happen in production, but just in case.
8+
for p in sys.path:
9+
if "qspi" in sys.path:
10+
sys.path.remove(p)
11+
12+
# power hold
13+
pwr = pyb.Pin("B15", pyb.Pin.OUT)
14+
pwr.on()
15+
16+
version = "<version:tag10>0101000099</version:tag10>"
17+
18+
# get i2c
19+
i2c = pyb.I2C(1)
20+
i2c.init()
21+
# start measurements
22+
if 112 in i2c.scan():
23+
i2c.mem_write(0b00010000, 112, 0)
24+
25+
leds = [pyb.LED(i) for i in range(1,5)]
26+
# poweroff on button press
27+
def pwrcb(e):
28+
micropython.schedule(poweroff, 0)
29+
30+
# callback scheduled from the interrupt
31+
def poweroff(_):
32+
# make sure it disables power no matter what
33+
try:
34+
for led in leds:
35+
led.toggle()
36+
# stop battery manangement
37+
if 112 in i2c.scan():
38+
i2c.mem_write(0, 112, 0)
39+
# sync filesystem
40+
os.sync()
41+
time.sleep_ms(300)
42+
finally:
43+
# disable power
44+
pwr.off()
45+
time.sleep_ms(300)
46+
# will never reach here
47+
for led in leds:
48+
led.toggle()
49+
50+
pyb.ExtInt(pyb.Pin('B1'), pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_NONE, pwrcb)
51+
52+
# configure usb from start if you want,
53+
# otherwise will be configured after PIN
54+
# pyb.usb_mode("VCP+MSC") # debug mode with USB and mounted storages from start
55+
# pyb.usb_mode("VCP") # debug mode with USB from start
56+
# disable at start
57+
pyb.usb_mode(None)
58+
os.dupterm(None,0)
59+
os.dupterm(None,1)
60+
61+
# inject version and i2c to platform module
6262
import platform
6363
platform.version = version
6464
platform.i2c = i2c

0 commit comments

Comments
 (0)