Skip to content

Commit 3498121

Browse files
committed
migracion de uPyIDE a toolkit toga
1 parent 911bd46 commit 3498121

File tree

15 files changed

+133
-163
lines changed

15 files changed

+133
-163
lines changed
-865 Bytes
Binary file not shown.

Codigos/espui.py

Lines changed: 0 additions & 163 deletions
This file was deleted.

__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '0.0.1'

__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from uPyIDE.app import main
2+
3+
if __name__ == '__main__':
4+
main().main_loop()

app.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import toga
2+
from toga.style import Pack
3+
from toga.constants import COLUMN, ROW
4+
import os
5+
import sys
6+
import glob
7+
import serial
8+
9+
def serial_ports():
10+
11+
if sys.platform.startswith('win'):
12+
ports = ['COM%s' % (i + 1) for i in range(256)]
13+
elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
14+
# this excludes your current terminal "/dev/tty"
15+
ports = glob.glob('/dev/tty[A-Za-z]*')
16+
elif sys.platform.startswith('darwin'):
17+
ports = glob.glob('/dev/tty.*')
18+
else:
19+
raise EnvironmentError('Unsupported platform')
20+
21+
result = []
22+
for port in ports:
23+
try:
24+
s = serial.Serial(port)
25+
s.close()
26+
result.append(port)
27+
except:
28+
pass
29+
return result
30+
31+
class uPyIDE(toga.App):
32+
33+
def startup(self):
34+
35+
self.main_window=toga.MainWindow(title=self.name,size=(640,400))
36+
37+
label_style=Pack(flex=1,padding_right=24)
38+
box_style=Pack(direction=ROW,padding=10)
39+
40+
global portselect
41+
global chipselect
42+
global verselect
43+
44+
portselect=toga.Selection(items=None, on_select=self.updateslct)
45+
chipselect=toga.Selection(items=["ESP8266","ESP32"],on_select=self.updateslct)
46+
verselect=toga.Selection(items=["v1.8.7","v1.9.0","v1.9.1","v1.9.2","v1.9.3","v1.9.4","v1.10.0"])
47+
48+
self.main_window.content=toga.Box(
49+
children=[
50+
51+
toga.Box(style=box_style, children=[
52+
portselect,
53+
chipselect,
54+
verselect
55+
]),
56+
57+
toga.Box(style=box_style, children=[
58+
toga.Button("Flashear",on_press=self.flash),
59+
toga.Button("Borrar flash/firmware",on_press=self.eraseflash),
60+
toga.Button("Actualizar",on_press=self.updatebtn)
61+
])
62+
])
63+
self.main_window.show()
64+
65+
66+
67+
def flash(self,button):
68+
import os
69+
port=portselect.value
70+
chip=chipselect.value
71+
ver=verselect.value
72+
73+
if chip == "ESP32":
74+
command = 'esptool.py --chip esp32 --port '+port+' write_flash -z 0x1000 esp32/'+ver+'.bin'
75+
os.system(command)
76+
elif chip == "ESP8266":
77+
command = 'esptool.py --port '+port+' --baud 15200 write_flash --flash_size=detect 0 esp8266/'+ver+'.bin'
78+
os.system(command)
79+
80+
def updateslct(self, selection):
81+
portlist = serial_ports()
82+
micro=chipselect.value
83+
if not portlist:
84+
pass
85+
else:
86+
portselect.items(portlist)
87+
88+
if micro == "ESP32":
89+
versionlist=["v1.9.4","v1.10"]
90+
elif micro=="ESP8266":
91+
versionlist=["v1.8.7","v1.9.0","v1.9.1","v1.9.2","v1.9.3","v1.9.4","v1.10.0"]
92+
else:
93+
pass
94+
verselect.items(versionlist)
95+
96+
def updatebtn(self, button):
97+
portlist = serial_ports()
98+
micro=chipselect.value
99+
print(portlist)
100+
if not portlist:
101+
pass
102+
else:
103+
portselect.items(items=portlist)
104+
105+
if micro == "ESP32":
106+
versionlist=["v1.9.4","v1.10"]
107+
elif micro=="ESP8266":
108+
versionlist=["v1.8.7","v1.9.0","v1.9.1","v1.9.2","v1.9.3","v1.9.4","v1.10.0"]
109+
else:
110+
pass
111+
112+
verselect.items(items=versionlist)
113+
114+
def eraseflash(self,button):
115+
import os
116+
port=portselect.value
117+
chip=chipselect.value
118+
if chip=='ESP32':
119+
command='esptool.py --chip esp32 erase_flash'
120+
os.system(command)
121+
elif chip=='ESP8266':
122+
command='esptool.py --port '+port+' erase_flash'
123+
os.system(command)
124+
125+
126+
127+
def main():
128+
return uPyIDE("uPyIDE","org.funpython.upyide")

0 commit comments

Comments
 (0)