-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfledge.lua
60 lines (53 loc) · 1.26 KB
/
fledge.lua
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
-- crow firmware updater
-- INTERNET REQUIRED
--
-- OPEN MAIDEN FIRST
-- for more detailed progress
running = false
note = "> k3 to begin"
function go()
notify("> checking install")
os.execute("sudo apt-get -y install python3-pip")
os.execute("sudo pip3 install pyusb usb")
notify("> get firmware url")
norns.system_cmd([[ curl -s \
https://raw.githubusercontent.com/monome/crow/main/version.txt \
]], ver)
end
function ver(result)
url = result:match("h.*")
url = url:sub(1,-2)
notify("> downloading firmware")
if util.file_exists('/home/we/dust/code/fledge/crow.dfu') then
norns.system_cmd('rm -rf /home/we/dust/code/fledge/crow.dfu')
end
local cmd = "sudo wget -T 180 -q -P /home/we/dust/code/fledge/ " .. url
print(cmd)
norns.system_cmd(cmd, flash)
end
function flash(result)
notify("> activate booloader mode")
crow.send("^^b")
os.execute("sleep 1")
notify("> flash")
os.execute("sudo python /home/we/dust/code/fledge/pydfu.py -u /home/we/dust/code/fledge/crow.dfu")
notify("> done")
end
function notify(text)
print(text)
note = text
redraw()
end
function redraw()
screen.clear()
screen.move(0,24)
screen.level(15)
screen.text(note)
screen.update()
end
function key(n,z)
if(n==3 and z==1 and running==false) then
running=true
go()
end
end