Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 419d7ce

Browse filesBrowse files
author
sasilva1998
committed
mas opciones, borrado y ejecucion
1 parent 092da1f commit 419d7ce
Copy full SHA for 419d7ce

File tree

1 file changed

+71
-16
lines changed
Filter options

1 file changed

+71
-16
lines changed

‎app.py

Copy file name to clipboardExpand all lines: app.py
+71-16Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def startup(self):
4646
#switchs
4747
self.switchdio=toga.Switch('DIO', is_on=False, style=Pack(padding_left=10,padding_top=5))
4848

49+
#textinputs
50+
self.textfile=toga.TextInput(style=Pack(flex=1,width=200))
51+
52+
#intento de terminal
53+
self.textterminal=toga.MultilineTextInput(readonly=False,style=Pack(flex=1,width=600,height=600))
54+
55+
#textoutputs
56+
self.textoutputs=toga.MultilineTextInput(readonly=True,style=Pack(flex=1,width=200,height=200))
57+
4958
self.filelabel=toga.Label("No ha seleccionado ningun archivo", style=Pack(padding=2))
5059
self.fname=None
5160
self.main_window.content=toga.Box(
@@ -60,28 +69,84 @@ def startup(self):
6069
]),
6170

6271
toga.Box(style=Pack(direction=COLUMN,padding_top=7), children=[
63-
toga.Button("Seleccionar archivo", on_press=self.action_open_file_dialog, style=Pack(padding_top=15,padding_left=2)),
72+
toga.Button("Ver archivos en ESP", on_press=self.read_files, style=Pack(padding_top=15,padding_left=2)),
73+
toga.Button("Seleccionar archivo", on_press=self.action_open_file_dialog, style=Pack(padding=2)),
6474
self.filelabel,
65-
toga.Button("Grabar archivo en ESP", on_press=self.save_to_esp, style=Pack(padding=2))
75+
toga.Button("Ejecutar archivo en ESP", on_press=self.run_in_esp, style=Pack(padding=2)),
76+
toga.Button("Grabar archivo en ESP", on_press=self.save_to_esp, style=Pack(padding=2)),
77+
self.textfile,
78+
toga.Button("Borrar archivo de ESP", on_press=self.erase_from_esp, style=Pack(padding=2)),
79+
toga.Button("Obtener archivo de ESP", on_press=self.get_file_esp, style=Pack(padding=2)),
80+
self.textoutputs
6681
])
6782
]),
68-
toga.Box(style=box_style_verti, children=[
69-
toga.Button("Flashear",on_press=self.flash),
83+
toga.Box(style=box_style_verti, children=
84+
[ toga.Button("Flashear",on_press=self.flash),
7085
toga.Button("Borrar flash/firmware",on_press=self.eraseflash),
71-
toga.Button("Actualizar puertos",on_press=self.update_ports)
86+
toga.Button("Actualizar puertos",on_press=self.update_ports),
87+
self.textterminal
7288
])
7389
])
7490

7591
self.main_window.show()
7692

93+
#metodos para la parte de ampy
94+
def read_files(self,button):
95+
from uPy_IDE.pyboard import Pyboard
96+
from uPy_IDE import cli
97+
from uPy_IDE import files
98+
99+
eboard=files.Files(Pyboard(self.portselect.value))
100+
filesesp=eboard.ls()
101+
print(filesesp)
102+
lstext=""
103+
for f in filesesp:
104+
lstext=lstext+f+"\n"
105+
self.textoutputs.clear
106+
self.textoutputs.value=lstext
107+
108+
def action_open_file_dialog(self, widget):
109+
try:
110+
self.fname = self.main_window.open_file_dialog(
111+
title="Open file with Toga",
112+
)
113+
print(self.fname)
114+
except ValueError:
115+
print("ha ocurrido un error")
116+
self.filelabel.text="Archivo seleccionado: "+self.fname.split("/")[-1]
117+
118+
def run_in_esp_thread(self, archiv, disp, terp):
119+
import uPy_IDE.pyboard as pyboard
120+
self.textterminal.clear()
121+
pyboard.execfile(archiv, device=disp,terminal=terp)
122+
123+
def run_in_esp(self,button):
124+
import threading
125+
runespthread = threading.Thread(target=self.run_in_esp_thread, args=(self.fname, self.portselect.value, self.textterminal))
126+
runespthread.start()
77127

78128
def save_to_esp(self, button):
79129
from uPy_IDE.pyboard import Pyboard
80130
from uPy_IDE import cli
81131
eboard=Pyboard(self.portselect.value)
82132
cli.put(self.fname,board=eboard)
83133

134+
def erase_from_esp(self,button):
135+
from uPy_IDE.pyboard import Pyboard
136+
import uPy_IDE.files as files
137+
eboard=files.Files(Pyboard(self.portselect.value))
138+
eboard.rm(self.textfile.value)
139+
140+
def get_file_esp(self,button):
141+
from uPy_IDE.pyboard import Pyboard
142+
import uPy_IDE.files as files
143+
eboard=files.Files(Pyboard(self.portselect.value))
144+
fdata=eboard.get(self.textfile.value)
145+
self.textterminal.clear()
146+
self.textterminal.value=fdata
84147

148+
149+
#metodos para la parte de esptool
85150
def flash(self,button):
86151
port=self.portselect.value
87152
chip=self.chipselect.value
@@ -90,7 +155,7 @@ def flash(self,button):
90155
if chip == "ESP32":
91156
esptool.main(["--chip","esp32","--port",self.portselect.value,"write_flash","-z","0x1000","esp32/"+ver+'.bin'])
92157
elif chip == "ESP8266":
93-
if self.switchdio.get_is_on:
158+
if self.switchdio.is_on:
94159
esptool.main(["--port",self.portselect.value,"--baud","460800","write_flash","--flash_size=detect","0","uPy_IDE/esp8266/"+ver+'.bin'])
95160
else:
96161
esptool.main(["--port",self.portselect.value,"--baud","460800","write_flash","--flash_size=detect","-fm","dio","0","uPy_IDE/esp8266/"+ver+'.bin'])
@@ -122,15 +187,5 @@ def eraseflash(self,button):
122187
elif chip=='ESP8266':
123188
esptool.main(["-p",self.portselect.value,"erase_flash"])
124189

125-
def action_open_file_dialog(self, widget):
126-
try:
127-
self.fname = self.main_window.open_file_dialog(
128-
title="Open file with Toga",
129-
)
130-
print(self.fname)
131-
except ValueError:
132-
print("ha ocurrido un error")
133-
self.filelabel.text="Archivo seleccionado: "+self.fname.split("/")[-1]
134-
135190
def main():
136191
return uPyIDE("uPyIDE","org.funpython.upyide")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.