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 93e298a

Browse filesBrowse files
author
sasilva1998
committed
aumento de opciones
1 parent 419d7ce commit 93e298a
Copy full SHA for 93e298a

File tree

1 file changed

+53
-4
lines changed
Filter options

1 file changed

+53
-4
lines changed

‎app.py

Copy file name to clipboardExpand all lines: app.py
+53-4Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,27 @@ def startup(self):
4343
self.chipselect=toga.Selection(items=["ESP8266","ESP32"], on_select=self.update_selections)
4444
self.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"])
4545

46+
#puerto
47+
self.port = None
48+
self.port_open=False
49+
4650
#switchs
4751
self.switchdio=toga.Switch('DIO', is_on=False, style=Pack(padding_left=10,padding_top=5))
4852

4953
#textinputs
5054
self.textfile=toga.TextInput(style=Pack(flex=1,width=200))
55+
self.commandesp=toga.TextInput(style=Pack(flex=1,width=450))
5156

5257
#intento de terminal
5358
self.textterminal=toga.MultilineTextInput(readonly=False,style=Pack(flex=1,width=600,height=600))
5459

5560
#textoutputs
5661
self.textoutputs=toga.MultilineTextInput(readonly=True,style=Pack(flex=1,width=200,height=200))
5762

63+
#botones
64+
self.btnport=toga.Button("Abrir puerto", on_press=self.open_port, style=Pack(padding=2))
65+
66+
5867
self.filelabel=toga.Label("No ha seleccionado ningun archivo", style=Pack(padding=2))
5968
self.fname=None
6069
self.main_window.content=toga.Box(
@@ -80,12 +89,20 @@ def startup(self):
8089
self.textoutputs
8190
])
8291
]),
83-
toga.Box(style=box_style_verti, children=
84-
[ toga.Button("Flashear",on_press=self.flash),
92+
toga.Box(style=box_style_verti, children=[
93+
toga.Button("Flashear",on_press=self.flash),
8594
toga.Button("Borrar flash/firmware",on_press=self.eraseflash),
8695
toga.Button("Actualizar puertos",on_press=self.update_ports),
87-
self.textterminal
96+
self.btnport,
97+
self.textterminal,
98+
99+
toga.Box(style=Pack(direction=ROW,padding_top=7), children=[
100+
self.commandesp,
101+
toga.Button("Enviar comando", on_press=self.send_command, style=Pack(padding=2))
102+
])
103+
88104
])
105+
89106
])
90107

91108
self.main_window.show()
@@ -145,7 +162,28 @@ def get_file_esp(self,button):
145162
self.textterminal.clear()
146163
self.textterminal.value=fdata
147164

148-
165+
#======================================SOLO MANEJO DE PUERTO========================================================
166+
167+
def open_port(self,button):
168+
from uPy_IDE.pyboard import Pyboard
169+
if not self.port_open:
170+
self.btnport.label="Cerrar puerto"
171+
self.port_open=True
172+
self.textterminal.clear()
173+
self.port=Pyboard(self.portselect.value)
174+
self.port.enter_raw_repl()
175+
read_port(self.port, self.port_open)
176+
else:
177+
self.btnport.label="Abrir puerto"
178+
self.port_open=False
179+
self.port.exit_raw_repl()
180+
181+
def send_command(self,button):
182+
if self.port_open:
183+
print(self.commandesp.value)
184+
self.port.send(self.commandesp.value)
185+
186+
#===================================================================================================================
149187
#metodos para la parte de esptool
150188
def flash(self,button):
151189
port=self.portselect.value
@@ -187,5 +225,16 @@ def eraseflash(self,button):
187225
elif chip=='ESP8266':
188226
esptool.main(["-p",self.portselect.value,"erase_flash"])
189227

228+
def read_port_thread(port,port_status):
229+
while True:
230+
if port_status:
231+
ans=port.read_until(1, b'\x04', timeout=10, data_consumer=None)
232+
print(ans)
233+
234+
def read_port(port, portstatus):
235+
import threading
236+
runportthread = threading.Thread(target=read_port_thread, args=(port, portstatus))
237+
runportthread.start()
238+
190239
def main():
191240
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.