Sun, 16 May 2021 20:07:24 +0200
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
8119
1653972f2de5
EspDevices: fixed a typo and a little issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
7 | Module implementing the device interface class for ESP32 and ESP8266 based |
1653972f2de5
EspDevices: fixed a typo and a little issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
8 | boards. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
11 | import sys |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
12 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
13 | from PyQt6.QtCore import pyqtSlot, QProcess |
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
14 | from PyQt6.QtWidgets import QDialog |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
15 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
16 | from E5Gui import E5MessageBox |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
17 | from E5Gui.E5ProcessDialog import E5ProcessDialog |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
18 | from E5Gui.E5Application import e5App |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7059
diff
changeset
|
19 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | from .MicroPythonDevices import MicroPythonDevice |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
21 | from .MicroPythonWidget import HAS_QTCHART |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
23 | import Preferences |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
24 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | class EspDevice(MicroPythonDevice): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | Class implementing the device for ESP32 and ESP8266 based boards. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | """ |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8096
diff
changeset
|
30 | def __init__(self, microPythonWidget, deviceType, parent=None): |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | Constructor |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | @param microPythonWidget reference to the main MicroPython widget |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7125
diff
changeset
|
35 | @type MicroPythonWidget |
8117
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8096
diff
changeset
|
36 | @param deviceType device type assigned to this device interface |
aaa5e0eacd4e
MicroPython: changed the logic to synchronize the time because some devices don't implement long integer and failed defining the 'set_time()' function.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8096
diff
changeset
|
37 | @type str |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @param parent reference to the parent object |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | @type QObject |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8205
diff
changeset
|
41 | super().__init__(microPythonWidget, deviceType, parent) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | def setButtons(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | Public method to enable the supported action buttons. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8205
diff
changeset
|
47 | super().setButtons() |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.microPython.setActionButtons( |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | run=True, repl=True, files=True, chart=HAS_QTCHART) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | def forceInterrupt(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | Public method to determine the need for an interrupt when opening the |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | serial connection. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | @return flag indicating an interrupt is needed |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | @rtype bool |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | return True |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
7125
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
61 | def deviceName(self): |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
62 | """ |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
63 | Public method to get the name of the device. |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
64 | |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
65 | @return name of the device |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
66 | @rtype str |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
67 | """ |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
68 | return self.tr("ESP8266, ESP32") |
2028553ee58c
CircuitPythonDevices, EspDevices, MicroPythonDevices: added a method to get the device name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7115
diff
changeset
|
69 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | def canStartRepl(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | Public method to determine, if a REPL can be started. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | @return tuple containing a flag indicating it is safe to start a REPL |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | and a reason why it cannot. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | @rtype tuple of (bool, str) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7091
diff
changeset
|
78 | return True, "" |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | def canStartPlotter(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | Public method to determine, if a Plotter can be started. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | @return tuple containing a flag indicating it is safe to start a |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | Plotter and a reason why it cannot. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | @rtype tuple of (bool, str) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7091
diff
changeset
|
88 | return True, "" |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | def canRunScript(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | """ |
7091
84d2a73b448a
EspDevices, MicroPythonDevices: fixed a wrong source docu string.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7077
diff
changeset
|
92 | Public method to determine, if a script can be executed. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | @return tuple containing a flag indicating it is safe to start a |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | Plotter and a reason why it cannot. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
96 | @rtype tuple of (bool, str) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | """ |
8119
1653972f2de5
EspDevices: fixed a typo and a little issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
98 | return True, "" |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | def runScript(self, script): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | Public method to run the given Python script. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | @param script script to be executed |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | @type str |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | pythonScript = script.split("\n") |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | self.sendCommands(pythonScript) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | def canStartFileManager(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | Public method to determine, if a File Manager can be started. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | @return tuple containing a flag indicating it is safe to start a |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | File Manager and a reason why it cannot. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | @rtype tuple of (bool, str) |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | """ |
7095
8e10acb1cd85
Refactored and improved the MicroPython code to be able to show the file manager and the REPL simultaneously.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7091
diff
changeset
|
118 | return True, "" |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
120 | def addDeviceMenuEntries(self, menu): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
121 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
122 | Public method to add device specific entries to the given menu. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
123 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
124 | @param menu reference to the context menu |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
125 | @type QMenu |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
126 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
127 | connected = self.microPython.isConnected() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
128 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
129 | act = menu.addAction(self.tr("Erase Flash"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
130 | self.__eraseFlash) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
131 | act.setEnabled(not connected) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
132 | act = menu.addAction(self.tr("Flash MicroPython Firmware"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
133 | self.__flashMicroPython) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
134 | act.setEnabled(not connected) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
135 | menu.addSeparator() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
136 | act = menu.addAction(self.tr("Flash Additional Firmware"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
137 | self.__flashAddons) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
138 | act.setEnabled(not connected) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
139 | menu.addSeparator() |
7352 | 140 | act = menu.addAction(self.tr("Backup Firmware"), |
141 | self.__backupFlash) | |
142 | act.setEnabled(not connected) | |
143 | act = menu.addAction(self.tr("Restore Firmware"), | |
144 | self.__restoreFlash) | |
145 | act.setEnabled(not connected) | |
146 | menu.addSeparator() | |
7346 | 147 | act = menu.addAction(self.tr("Show Chip ID"), |
148 | self.__showChipID) | |
149 | act.setEnabled(not connected) | |
150 | act = menu.addAction(self.tr("Show Flash ID"), | |
151 | self.__showFlashID) | |
152 | act.setEnabled(not connected) | |
153 | act = menu.addAction(self.tr("Show MAC Address"), | |
154 | self.__showMACAddress) | |
155 | act.setEnabled(not connected) | |
156 | menu.addSeparator() | |
7174
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
157 | act = menu.addAction(self.tr("Reset Device"), self.__resetDevice) |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
158 | menu.addSeparator() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
159 | menu.addAction(self.tr("Install 'esptool.py'"), self.__installEspTool) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
160 | |
8096 | 161 | def hasFlashMenuEntry(self): |
162 | """ | |
163 | Public method to check, if the device has its own flash menu entry. | |
164 | ||
165 | @return flag indicating a specific flash menu entry | |
166 | @rtype bool | |
167 | """ | |
168 | return True | |
169 | ||
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
170 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
171 | def __eraseFlash(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
172 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
173 | Private slot to erase the device flash memory. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
174 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
175 | ok = E5MessageBox.yesNo( |
7173
f611c3b7313f
EspDevices, MicrobitDevices: fixed a few omissions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7161
diff
changeset
|
176 | self.microPython, |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
177 | self.tr("Erase Flash"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
178 | self.tr("""Shall the flash of the selected device really be""" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
179 | """ erased?""")) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
180 | if ok: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
181 | flashArgs = [ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
182 | "-u", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
183 | "-m", "esptool", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
184 | "--port", self.microPython.getCurrentPort(), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
185 | "erase_flash", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
186 | ] |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
187 | dlg = E5ProcessDialog(self.tr("'esptool erase_flash' Output"), |
7355
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
188 | self.tr("Erase Flash"), |
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
189 | showProgress=True) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
190 | res = dlg.startProcess(sys.executable, flashArgs) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
191 | if res: |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
192 | dlg.exec() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
193 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
194 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
195 | def __flashMicroPython(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
196 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
197 | Private slot to flash a MicroPython firmware to the device. |
7115
fe89c98430b6
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7114
diff
changeset
|
198 | |
fe89c98430b6
Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7114
diff
changeset
|
199 | @exception ValueError raised to indicate an unsupported chip type |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
200 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
201 | from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
202 | dlg = EspFirmwareSelectionDialog() |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8119
diff
changeset
|
203 | if dlg.exec() == QDialog.DialogCode.Accepted: |
8181 | 204 | chip, firmware, baudRate, flashMode, _ = dlg.getData() |
8205
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8185
diff
changeset
|
205 | if chip not in ("esp8266", "esp32"): |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8185
diff
changeset
|
206 | raise ValueError(self.tr("Unsupported chip type '{0}'.") |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8185
diff
changeset
|
207 | .format(chip)) |
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8185
diff
changeset
|
208 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
209 | if chip == "esp8266": |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
210 | flashAddress = "0x0000" |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
211 | elif chip == "esp32": |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
212 | flashAddress = "0x1000" |
8205
4a0f1f896341
Applied some code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8185
diff
changeset
|
213 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
214 | flashArgs = [ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
215 | "-u", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
216 | "-m", "esptool", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
217 | "--chip", chip, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
218 | "--port", self.microPython.getCurrentPort(), |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
219 | ] |
8181 | 220 | if baudRate != "115200": |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
221 | flashArgs += [ |
8181 | 222 | "--baud", baudRate |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
223 | ] |
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
224 | flashArgs.append("write_flash") |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
225 | if flashMode: |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
226 | flashArgs += [ |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
227 | "--flash_mode", flashMode |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
228 | ] |
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
229 | flashArgs += [ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
230 | flashAddress, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
231 | firmware, |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
232 | ] |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
233 | dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), |
7355
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
234 | self.tr("Flash MicroPython Firmware"), |
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
235 | showProgress=True) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
236 | res = dlg.startProcess(sys.executable, flashArgs) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
237 | if res: |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
238 | dlg.exec() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
239 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
240 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
241 | def __flashAddons(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
242 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
243 | Private slot to flash some additional firmware images. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
244 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
245 | from .EspFirmwareSelectionDialog import EspFirmwareSelectionDialog |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
246 | dlg = EspFirmwareSelectionDialog(addon=True) |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8119
diff
changeset
|
247 | if dlg.exec() == QDialog.DialogCode.Accepted: |
8181 | 248 | chip, firmware, baudRate, flashMode, flashAddress = dlg.getData() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
249 | flashArgs = [ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
250 | "-u", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
251 | "-m", "esptool", |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
252 | "--chip", chip, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
253 | "--port", self.microPython.getCurrentPort(), |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
254 | ] |
8181 | 255 | if baudRate != "115200": |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
256 | flashArgs += [ |
8181 | 257 | "--baud", baudRate |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
258 | ] |
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
259 | flashArgs.append("write_flash") |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
260 | if flashMode: |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
261 | flashArgs += [ |
7595
5db6bfeff23e
MicroPython: added code to allow the user to select the flash mod for flashing the MicroPython firmware for ESP32/ESP8266 devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
262 | "--flash_mode", flashMode |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
263 | ] |
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
264 | flashArgs += [ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
265 | flashAddress.lower(), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
266 | firmware, |
8185
c9acf46b54ce
MicroPython: fixed a few bugs introduced by the flash speed enhancement for ESP devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8181
diff
changeset
|
267 | ] |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
268 | dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), |
7355
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
269 | self.tr("Flash Additional Firmware"), |
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
270 | showProgress=True) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
271 | res = dlg.startProcess(sys.executable, flashArgs) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
272 | if res: |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
273 | dlg.exec() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
274 | |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
275 | @pyqtSlot() |
7352 | 276 | def __backupFlash(self): |
277 | """ | |
278 | Private slot to backup the currently flashed firmware. | |
279 | """ | |
280 | from .EspBackupRestoreFirmwareDialog import ( | |
281 | EspBackupRestoreFirmwareDialog | |
282 | ) | |
283 | dlg = EspBackupRestoreFirmwareDialog(backupMode=True) | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8119
diff
changeset
|
284 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7352 | 285 | chip, flashSize, flashMode, firmware = dlg.getData() |
286 | flashArgs = [ | |
287 | "-u", | |
288 | "-m", "esptool", | |
289 | "--chip", chip, | |
290 | "--port", self.microPython.getCurrentPort(), | |
291 | "read_flash", | |
292 | "0x0", flashSize, | |
293 | firmware, | |
294 | ] | |
295 | dlg = E5ProcessDialog(self.tr("'esptool read_flash' Output"), | |
7355
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
296 | self.tr("Backup Firmware"), |
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
297 | showProgress=True) |
7352 | 298 | res = dlg.startProcess(sys.executable, flashArgs) |
299 | if res: | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
300 | dlg.exec() |
7352 | 301 | |
302 | @pyqtSlot() | |
303 | def __restoreFlash(self): | |
304 | """ | |
305 | Private slot to restore a previously saved firmware. | |
306 | """ | |
307 | from .EspBackupRestoreFirmwareDialog import ( | |
308 | EspBackupRestoreFirmwareDialog | |
309 | ) | |
310 | dlg = EspBackupRestoreFirmwareDialog(backupMode=False) | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8119
diff
changeset
|
311 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7352 | 312 | chip, flashSize, flashMode, firmware = dlg.getData() |
313 | flashArgs = [ | |
314 | "-u", | |
315 | "-m", "esptool", | |
316 | "--chip", chip, | |
317 | "--port", self.microPython.getCurrentPort(), | |
318 | "write_flash", | |
319 | "--flash_mode", flashMode, | |
320 | ] | |
321 | if bool(flashSize): | |
322 | flashArgs.extend([ | |
323 | "--flash_size", flashSize, | |
324 | ]) | |
325 | flashArgs.extend([ | |
326 | "0x0", | |
327 | firmware, | |
328 | ]) | |
329 | dlg = E5ProcessDialog(self.tr("'esptool write_flash' Output"), | |
7355
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
330 | self.tr("Restore Firmware"), |
c7146f7e06aa
EspDevices: modified to show the process progress for flash reading and writing operations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7353
diff
changeset
|
331 | showProgress=True) |
7352 | 332 | res = dlg.startProcess(sys.executable, flashArgs) |
333 | if res: | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
334 | dlg.exec() |
7352 | 335 | |
336 | @pyqtSlot() | |
7346 | 337 | def __showChipID(self): |
338 | """ | |
339 | Private slot to show the ID of the ESP chip. | |
340 | """ | |
341 | args = [ | |
342 | "-u", | |
343 | "-m", "esptool", | |
344 | "--port", self.microPython.getCurrentPort(), | |
345 | "chip_id" | |
346 | ] | |
347 | dlg = E5ProcessDialog(self.tr("'esptool chip_id' Output"), | |
348 | self.tr("Show Chip ID")) | |
349 | res = dlg.startProcess(sys.executable, args) | |
350 | if res: | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
351 | dlg.exec() |
7346 | 352 | |
353 | @pyqtSlot() | |
354 | def __showFlashID(self): | |
355 | """ | |
356 | Private slot to show the ID of the ESP flash chip. | |
357 | """ | |
358 | args = [ | |
359 | "-u", | |
360 | "-m", "esptool", | |
361 | "--port", self.microPython.getCurrentPort(), | |
362 | "flash_id" | |
363 | ] | |
364 | dlg = E5ProcessDialog(self.tr("'esptool flash_id' Output"), | |
365 | self.tr("Show Flash ID")) | |
366 | res = dlg.startProcess(sys.executable, args) | |
367 | if res: | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
368 | dlg.exec() |
7346 | 369 | |
370 | @pyqtSlot() | |
371 | def __showMACAddress(self): | |
372 | """ | |
373 | Private slot to show the MAC address of the ESP chip. | |
374 | """ | |
375 | args = [ | |
376 | "-u", | |
377 | "-m", "esptool", | |
378 | "--port", self.microPython.getCurrentPort(), | |
379 | "read_mac" | |
380 | ] | |
381 | dlg = E5ProcessDialog(self.tr("'esptool read_mac' Output"), | |
382 | self.tr("Show MAC Address")) | |
383 | res = dlg.startProcess(sys.executable, args) | |
384 | if res: | |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7595
diff
changeset
|
385 | dlg.exec() |
7346 | 386 | |
387 | @pyqtSlot() | |
7174
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
388 | def __resetDevice(self): |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
389 | """ |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
390 | Private slot to reset the connected device. |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
391 | """ |
7353
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
392 | if self.microPython.isConnected(): |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
393 | self.microPython.commandsInterface().execute([ |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
394 | "import machine", |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
395 | "machine.reset()", |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
396 | ]) |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
397 | else: |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
398 | # perform a reset via esptool using flash_id command ignoring |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
399 | # the output |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
400 | args = [ |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
401 | "-u", |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
402 | "-m", "esptool", |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
403 | "--port", self.microPython.getCurrentPort(), |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
404 | "flash_id" |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
405 | ] |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
406 | proc = QProcess() |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
407 | proc.start(sys.executable, args) |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
408 | procStarted = proc.waitForStarted(10000) |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
409 | if procStarted: |
caa2ccd5677c
EspDevices: fixed an issue resetting the attached device when not connected.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7352
diff
changeset
|
410 | proc.waitForFinished(10000) |
7174
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
411 | |
de8175253dfc
MicroPython: did some fine tuning of the MicroPython interface.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7173
diff
changeset
|
412 | @pyqtSlot() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
413 | def __installEspTool(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
414 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
415 | Private slot to install the esptool package via pip. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
416 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
417 | pip = e5App().getObject("Pip") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7100
diff
changeset
|
418 | pip.installPackages(["esptool"], interpreter=sys.executable) |
7161
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
419 | |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
420 | def getDocumentationUrl(self): |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
421 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
422 | Public method to get the device documentation URL. |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
423 | |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
424 | @return documentation URL of the device |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
425 | @rtype str |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
426 | """ |
728018c32b09
MicroPythonWidget: added actions to show the device documentation and to open the configuration page to the hamburger menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
427 | return Preferences.getMicroPython("MicroPythonDocuUrl") |
7328 | 428 | |
429 | def getFirmwareUrl(self): | |
430 | """ | |
431 | Public method to get the device firmware download URL. | |
432 | ||
433 | @return firmware download URL of the device | |
434 | @rtype str | |
435 | """ | |
436 | return Preferences.getMicroPython("MicroPythonFirmwareUrl") |