11 import sys |
11 import sys |
12 |
12 |
13 from PyQt6.QtCore import pyqtSlot, QProcess |
13 from PyQt6.QtCore import pyqtSlot, QProcess |
14 from PyQt6.QtWidgets import QDialog |
14 from PyQt6.QtWidgets import QDialog |
15 |
15 |
16 from E5Gui import E5MessageBox |
16 from E5Gui import EricMessageBox |
17 from E5Gui.E5ProcessDialog import E5ProcessDialog |
17 from E5Gui.EricProcessDialog import EricProcessDialog |
18 from E5Gui.E5Application import e5App |
18 from E5Gui.EricApplication import ericApp |
19 |
19 |
20 from .MicroPythonDevices import MicroPythonDevice |
20 from .MicroPythonDevices import MicroPythonDevice |
21 from .MicroPythonWidget import HAS_QTCHART |
21 from .MicroPythonWidget import HAS_QTCHART |
22 |
22 |
23 import Preferences |
23 import Preferences |
170 @pyqtSlot() |
170 @pyqtSlot() |
171 def __eraseFlash(self): |
171 def __eraseFlash(self): |
172 """ |
172 """ |
173 Private slot to erase the device flash memory. |
173 Private slot to erase the device flash memory. |
174 """ |
174 """ |
175 ok = E5MessageBox.yesNo( |
175 ok = EricMessageBox.yesNo( |
176 self.microPython, |
176 self.microPython, |
177 self.tr("Erase Flash"), |
177 self.tr("Erase Flash"), |
178 self.tr("""Shall the flash of the selected device really be""" |
178 self.tr("""Shall the flash of the selected device really be""" |
179 """ erased?""")) |
179 """ erased?""")) |
180 if ok: |
180 if ok: |
182 "-u", |
182 "-u", |
183 "-m", "esptool", |
183 "-m", "esptool", |
184 "--port", self.microPython.getCurrentPort(), |
184 "--port", self.microPython.getCurrentPort(), |
185 "erase_flash", |
185 "erase_flash", |
186 ] |
186 ] |
187 dlg = E5ProcessDialog(self.tr("'esptool erase_flash' Output"), |
187 dlg = EricProcessDialog(self.tr("'esptool erase_flash' Output"), |
188 self.tr("Erase Flash"), |
188 self.tr("Erase Flash"), |
189 showProgress=True) |
189 showProgress=True) |
190 res = dlg.startProcess(sys.executable, flashArgs) |
190 res = dlg.startProcess(sys.executable, flashArgs) |
191 if res: |
191 if res: |
192 dlg.exec() |
192 dlg.exec() |
263 ] |
263 ] |
264 flashArgs += [ |
264 flashArgs += [ |
265 flashAddress.lower(), |
265 flashAddress.lower(), |
266 firmware, |
266 firmware, |
267 ] |
267 ] |
268 dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), |
268 dlg = EricProcessDialog(self.tr("'esptool write_flash' Output"), |
269 self.tr("Flash Additional Firmware"), |
269 self.tr("Flash Additional Firmware"), |
270 showProgress=True) |
270 showProgress=True) |
271 res = dlg.startProcess(sys.executable, flashArgs) |
271 res = dlg.startProcess(sys.executable, flashArgs) |
272 if res: |
272 if res: |
273 dlg.exec() |
273 dlg.exec() |
290 "--port", self.microPython.getCurrentPort(), |
290 "--port", self.microPython.getCurrentPort(), |
291 "read_flash", |
291 "read_flash", |
292 "0x0", flashSize, |
292 "0x0", flashSize, |
293 firmware, |
293 firmware, |
294 ] |
294 ] |
295 dlg = E5ProcessDialog(self.tr("'esptool read_flash' Output"), |
295 dlg = EricProcessDialog(self.tr("'esptool read_flash' Output"), |
296 self.tr("Backup Firmware"), |
296 self.tr("Backup Firmware"), |
297 showProgress=True) |
297 showProgress=True) |
298 res = dlg.startProcess(sys.executable, flashArgs) |
298 res = dlg.startProcess(sys.executable, flashArgs) |
299 if res: |
299 if res: |
300 dlg.exec() |
300 dlg.exec() |
342 "-u", |
342 "-u", |
343 "-m", "esptool", |
343 "-m", "esptool", |
344 "--port", self.microPython.getCurrentPort(), |
344 "--port", self.microPython.getCurrentPort(), |
345 "chip_id" |
345 "chip_id" |
346 ] |
346 ] |
347 dlg = E5ProcessDialog(self.tr("'esptool chip_id' Output"), |
347 dlg = EricProcessDialog(self.tr("'esptool chip_id' Output"), |
348 self.tr("Show Chip ID")) |
348 self.tr("Show Chip ID")) |
349 res = dlg.startProcess(sys.executable, args) |
349 res = dlg.startProcess(sys.executable, args) |
350 if res: |
350 if res: |
351 dlg.exec() |
351 dlg.exec() |
352 |
352 |
359 "-u", |
359 "-u", |
360 "-m", "esptool", |
360 "-m", "esptool", |
361 "--port", self.microPython.getCurrentPort(), |
361 "--port", self.microPython.getCurrentPort(), |
362 "flash_id" |
362 "flash_id" |
363 ] |
363 ] |
364 dlg = E5ProcessDialog(self.tr("'esptool flash_id' Output"), |
364 dlg = EricProcessDialog(self.tr("'esptool flash_id' Output"), |
365 self.tr("Show Flash ID")) |
365 self.tr("Show Flash ID")) |
366 res = dlg.startProcess(sys.executable, args) |
366 res = dlg.startProcess(sys.executable, args) |
367 if res: |
367 if res: |
368 dlg.exec() |
368 dlg.exec() |
369 |
369 |
376 "-u", |
376 "-u", |
377 "-m", "esptool", |
377 "-m", "esptool", |
378 "--port", self.microPython.getCurrentPort(), |
378 "--port", self.microPython.getCurrentPort(), |
379 "read_mac" |
379 "read_mac" |
380 ] |
380 ] |
381 dlg = E5ProcessDialog(self.tr("'esptool read_mac' Output"), |
381 dlg = EricProcessDialog(self.tr("'esptool read_mac' Output"), |
382 self.tr("Show MAC Address")) |
382 self.tr("Show MAC Address")) |
383 res = dlg.startProcess(sys.executable, args) |
383 res = dlg.startProcess(sys.executable, args) |
384 if res: |
384 if res: |
385 dlg.exec() |
385 dlg.exec() |
386 |
386 |
412 @pyqtSlot() |
412 @pyqtSlot() |
413 def __installEspTool(self): |
413 def __installEspTool(self): |
414 """ |
414 """ |
415 Private slot to install the esptool package via pip. |
415 Private slot to install the esptool package via pip. |
416 """ |
416 """ |
417 pip = e5App().getObject("Pip") |
417 pip = ericApp().getObject("Pip") |
418 pip.installPackages(["esptool"], interpreter=sys.executable) |
418 pip.installPackages(["esptool"], interpreter=sys.executable) |
419 |
419 |
420 def getDocumentationUrl(self): |
420 def getDocumentationUrl(self): |
421 """ |
421 """ |
422 Public method to get the device documentation URL. |
422 Public method to get the device documentation URL. |