forked from Lamprichauns/lamp-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
38 lines (31 loc) · 947 Bytes
/
tasks.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
import json
import tempfile
import time
import os
from pathlib import Path
from invoke import task
@task
def erase(c, port):
c.run(f"esptool --port {port} erase_flash")
@task
def flash(c, port):
c.run(f"esptool --chip esp32 --port {port} write_flash -z 0x1000 esp32-20230426-v1.20.0.bin")
@task
def upload(c, port):
for path in Path('src').rglob('*'):
dest_path = Path(*path.parts[1:])
if os.path.isdir(path):
c.run(f"ampy -d 1 --port {port} --baud 115200 mkdir {dest_path} ", echo=True)
else:
c.run(f"ampy -d 1 --port {port} --baud 115200 put {path} {dest_path}", echo=True)
print("Done!")
@task
def update(c, port, lamp):
c.run(f"ampy --port {port} put src/main.py main.py", echo=True)
c.run(f"ampy --port {port} put src/lamps/{lamp}.py lamps/{lamp}.py", echo=True)
print("Done!")
@task
def setup(c, port):
erase(c,port)
flash(c,port)
upload(c,port)