Fri, 19 Jan 2024 09:36:51 +0100
MicroPython
- Changed the logic in some places to better show the code flow if the active editor is None.
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10428
diff
changeset
|
3 | # Copyright (c) 2019 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the MicroPython REPL widget. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
10 | import contextlib |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
11 | import functools |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
12 | import os |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
13 | import time |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
10011 | 15 | from PyQt6.QtCore import Qt, pyqtSignal, pyqtSlot |
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
|
16 | from PyQt6.QtWidgets import ( |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
17 | QDialog, |
9844 | 18 | QInputDialog, |
19 | QLineEdit, | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | QMenu, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
21 | QToolButton, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
22 | QWidget, |
7067
3fc4082fc6ba
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7066
diff
changeset
|
23 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
25 | from eric7 import Preferences |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
26 | from eric7.EricGui import EricPixmapCache |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
27 | from eric7.EricGui.EricOverrideCursor import EricOverrideCursor, EricOverridenCursor |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9470
diff
changeset
|
28 | from eric7.EricWidgets import EricFileDialog, EricMessageBox |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
29 | from eric7.EricWidgets.EricApplication import ericApp |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
30 | from eric7.EricWidgets.EricListSelectionDialog import EricListSelectionDialog |
9847
d8c7ded575cb
Corrected some code style and formatting issues and regenerated the source documentation accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9844
diff
changeset
|
31 | from eric7.EricWidgets.EricPlainTextDialog import EricPlainTextDialog |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
32 | from eric7.EricWidgets.EricProcessDialog import EricProcessDialog |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
33 | from eric7.SystemUtilities import FileSystemUtilities, OSUtilities |
9470
34f2493c1d3f
Prepared the code for isort imports reordering.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
34 | from eric7.UI.Info import BugAddress |
10482
72d9b5ea39b4
Changed some state/mode definitiuons to an enum.Enum class and corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
35 | from eric7.UI.UserInterface import UserInterfaceSide |
9470
34f2493c1d3f
Prepared the code for isort imports reordering.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
36 | |
9915 | 37 | from . import ConvertToUF2Dialog, Devices, UF2FlashDialog |
9855 | 38 | from .BluetoothDialogs.BluetoothController import BluetoothController |
9878 | 39 | from .EthernetDialogs.EthernetController import EthernetController |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
40 | from .MicroPythonFileManager import MicroPythonFileManager |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
41 | from .MicroPythonFileManagerWidget import MicroPythonFileManagerWidget |
10008 | 42 | from .MicroPythonWebreplDeviceInterface import MicroPythonWebreplDeviceInterface |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
43 | from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
9776
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
44 | from .WifiDialogs.WifiController import WifiController |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
46 | try: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
47 | from .MicroPythonGraphWidget import MicroPythonGraphWidget |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
48 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
49 | HAS_QTCHART = True |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
50 | except ImportError: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
51 | HAS_QTCHART = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
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:
7094
diff
changeset
|
53 | try: |
9990 | 54 | from .MicroPythonSerialDeviceInterface import MicroPythonSerialDeviceInterface |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
55 | |
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:
7094
diff
changeset
|
56 | HAS_QTSERIALPORT = True |
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:
7094
diff
changeset
|
57 | except ImportError: |
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:
7094
diff
changeset
|
58 | HAS_QTSERIALPORT = False |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
7134
21d23ca51680
Renamed "MicroPythonReplWidget" to "MicroPythonWidget".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7133
diff
changeset
|
61 | class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | Class implementing the MicroPython REPL widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
65 | @signal dataReceived(data) emitted to send data received via the serial |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
66 | connection for further processing |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | |
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:
8139
diff
changeset
|
69 | DeviceTypeRole = Qt.ItemDataRole.UserRole |
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:
8139
diff
changeset
|
70 | DeviceBoardRole = Qt.ItemDataRole.UserRole + 1 |
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:
8139
diff
changeset
|
71 | DevicePortRole = Qt.ItemDataRole.UserRole + 2 |
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:
8139
diff
changeset
|
72 | DeviceVidRole = Qt.ItemDataRole.UserRole + 3 |
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:
8139
diff
changeset
|
73 | DevicePidRole = Qt.ItemDataRole.UserRole + 4 |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
74 | DeviceSerNoRole = Qt.ItemDataRole.UserRole + 5 |
9990 | 75 | DeviceInterfaceTypeRole = Qt.ItemDataRole.UserRole + 6 |
10008 | 76 | DeviceWebreplUrlRole = Qt.ItemDataRole.UserRole + 7 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
78 | dataReceived = pyqtSignal(bytes) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
79 | |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
80 | ManualMarker = "<manual>" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
81 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | def __init__(self, parent=None): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
85 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | @param parent reference to the parent widget |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | @type QWidget |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
89 | super().__init__(parent) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
91 | |
8604
d25390ea2f19
Changed the margins of some right side bar managed items to (0, 3, 0, 0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8366
diff
changeset
|
92 | self.layout().setContentsMargins(0, 3, 0, 0) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
93 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
94 | self.__ui = parent |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | |
9776
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
96 | self.__wifiController = WifiController(self, self) |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
97 | self.__wifiMenu = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
98 | |
9855 | 99 | self.__bluetoothController = BluetoothController(self, self) |
100 | self.__btMenu = None | |
101 | ||
9878 | 102 | self.__ethernetController = EthernetController(self, self) |
103 | self.__ethernetMenu = None | |
104 | ||
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
105 | self.__superMenu = QMenu(self) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
106 | self.__superMenu.aboutToShow.connect(self.__aboutToShowSuperMenu) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
107 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
108 | self.menuButton.setObjectName("micropython_supermenu_button") |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
109 | self.menuButton.setIcon(EricPixmapCache.getIcon("superMenu")) |
7147
7f30b93eb51d
Updated German and English translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7140
diff
changeset
|
110 | self.menuButton.setToolTip(self.tr("MicroPython Menu")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
111 | self.menuButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
112 | self.menuButton.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) |
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:
8139
diff
changeset
|
113 | self.menuButton.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
114 | self.menuButton.setAutoRaise(True) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
115 | self.menuButton.setShowMenuInside(True) |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
116 | self.menuButton.setMenu(self.__superMenu) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
117 | |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
118 | self.deviceIconLabel.setPixmap(Devices.getDeviceIcon("", False)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
119 | |
10009 | 120 | self.repopulateButton.setIcon(EricPixmapCache.getIcon("question")) |
121 | self.webreplConfigButton.setIcon(EricPixmapCache.getIcon("edit")) | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
122 | self.runButton.setIcon(EricPixmapCache.getIcon("start")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
123 | self.replButton.setIcon(EricPixmapCache.getIcon("terminal")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
124 | self.filesButton.setIcon(EricPixmapCache.getIcon("filemanager")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
125 | self.chartButton.setIcon(EricPixmapCache.getIcon("chart")) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
126 | self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
127 | |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
128 | self.__fileManager = None |
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:
7094
diff
changeset
|
129 | self.__fileManagerWidget = None |
7535
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
130 | self.__chartWidget = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
131 | |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
132 | self.__unknownPorts = [] |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
133 | self.__lastPort = None |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
134 | self.__lastDeviceType = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
135 | |
10010 | 136 | self.__lastWebreplUrl = None |
137 | ||
9990 | 138 | self.__interface = None |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | self.__device = None |
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:
7094
diff
changeset
|
140 | self.__connected = False |
9749 | 141 | self.__linkConnected = False |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
142 | self.__setConnected(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
143 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
144 | if not HAS_QTSERIALPORT: |
10011 | 145 | self.replWidget.replEdit().setHtml( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
146 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
147 | "<h3>The QtSerialPort package is not available.<br/>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
148 | "MicroPython support is deactivated.</h3>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
149 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
150 | ) |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | self.setEnabled(False) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
153 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | self.__populateDeviceTypeComboBox() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
155 | |
10009 | 156 | self.repopulateButton.clicked.connect(self.__populateDeviceTypeComboBox) |
157 | self.webreplConfigButton.clicked.connect(self.__configureWebreplUrls) | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
158 | self.__ui.preferencesChanged.connect(self.__handlePreferencesChanged) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
159 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
160 | self.__handlePreferencesChanged() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
161 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | def __populateDeviceTypeComboBox(self): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | Private method to populate the device type selector. |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | """ |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
166 | currentDevice = self.deviceTypeComboBox.currentText() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
167 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | self.deviceTypeComboBox.clear() |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | self.deviceInfoLabel.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
170 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
171 | self.deviceTypeComboBox.addItem("", "") |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
172 | devices, unknownDevices, unknownPorts = Devices.getFoundDevices() |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | if devices: |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
174 | supportedMessage = self.tr( |
10008 | 175 | "%n supported serial device(s) detected.", "", len(devices) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
176 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
177 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
178 | for index, ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
179 | boardType, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
180 | boardName, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
181 | description, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
182 | portName, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
183 | vid, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
184 | pid, |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
185 | serialNumber, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
186 | ) in enumerate(sorted(devices), 1): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | self.deviceTypeComboBox.addItem( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
188 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
189 | "{0} - {1} ({2})", "board name, description, port name" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | ).format(boardName, description, portName) |
8055
52fdd41517f3
MicroPython: made the value shown in the deveice selection list more descriptive.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8053
diff
changeset
|
191 | ) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
192 | self.deviceTypeComboBox.setItemData( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
193 | index, boardType, self.DeviceTypeRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
194 | ) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
195 | self.deviceTypeComboBox.setItemData( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
196 | index, boardName, self.DeviceBoardRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
197 | ) |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
198 | self.deviceTypeComboBox.setItemData( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
199 | index, portName, self.DevicePortRole |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
200 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
201 | self.deviceTypeComboBox.setItemData(index, vid, self.DeviceVidRole) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
202 | self.deviceTypeComboBox.setItemData(index, pid, self.DevicePidRole) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
203 | self.deviceTypeComboBox.setItemData( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
204 | index, serialNumber, self.DeviceSerNoRole |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
205 | ) |
9990 | 206 | self.deviceTypeComboBox.setItemData( |
207 | index, "serial", self.DeviceInterfaceTypeRole | |
208 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
209 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | else: |
10008 | 211 | supportedMessage = self.tr("No supported serial devices detected.") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
212 | |
8135
7cbb1ebf8d2d
MicroPython: fixed some logic issues related to handling of unknown devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8134
diff
changeset
|
213 | self.__unknownPorts = unknownPorts |
7cbb1ebf8d2d
MicroPython: fixed some logic issues related to handling of unknown devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8134
diff
changeset
|
214 | if self.__unknownPorts: |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
215 | unknownMessage = self.tr( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
216 | "\n%n unknown device(s) for manual selection.", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
217 | "", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
218 | len(self.__unknownPorts), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
219 | ) |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
220 | if self.deviceTypeComboBox.count(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
221 | self.deviceTypeComboBox.insertSeparator(self.deviceTypeComboBox.count()) |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
222 | self.deviceTypeComboBox.addItem(self.tr("Manual Selection")) |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
223 | self.deviceTypeComboBox.setItemData( |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
224 | self.deviceTypeComboBox.count() - 1, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
225 | self.ManualMarker, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
226 | self.DeviceTypeRole, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
227 | ) |
8139
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
228 | else: |
418c2d9a767d
MicroPython: refined the selection of unknown dvices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8137
diff
changeset
|
229 | unknownMessage = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
230 | |
10009 | 231 | # add WebREPL entries |
10008 | 232 | self.deviceTypeComboBox.insertSeparator(self.deviceTypeComboBox.count()) |
10009 | 233 | self.deviceTypeComboBox.addItem(self.tr("WebREPL (manual)")) |
10008 | 234 | index = self.deviceTypeComboBox.count() - 1 |
235 | self.deviceTypeComboBox.setItemData( | |
236 | index, "webrepl", self.DeviceInterfaceTypeRole | |
237 | ) | |
10009 | 238 | webreplUrlsDict = Preferences.getMicroPython("WebreplUrls") |
239 | for name in sorted(webreplUrlsDict): | |
240 | self.deviceTypeComboBox.addItem(webreplUrlsDict[name]["description"]) | |
241 | index = self.deviceTypeComboBox.count() - 1 | |
242 | self.deviceTypeComboBox.setItemData( | |
243 | index, webreplUrlsDict[name]["device_type"], self.DeviceTypeRole | |
244 | ) | |
245 | self.deviceTypeComboBox.setItemData( | |
246 | index, "webrepl", self.DeviceInterfaceTypeRole | |
247 | ) | |
248 | self.deviceTypeComboBox.setItemData( | |
249 | index, webreplUrlsDict[name]["url"], self.DeviceWebreplUrlRole | |
250 | ) | |
10010 | 251 | webreplMessage = ( |
10011 | 252 | self.tr("\n%n WebREPL connection(s) defined.", "", len(webreplUrlsDict)) |
10010 | 253 | if webreplUrlsDict |
254 | else "" | |
255 | ) | |
10008 | 256 | |
10009 | 257 | self.deviceInfoLabel.setText(supportedMessage + unknownMessage + webreplMessage) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
258 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
259 | index = self.deviceTypeComboBox.findText( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
260 | currentDevice, Qt.MatchFlag.MatchExactly |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
261 | ) |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
262 | if index == -1: |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
263 | # entry is no longer present |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
264 | index = 0 |
9749 | 265 | if self.__linkConnected: |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
266 | # we are still connected, so disconnect |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
267 | self.on_connectButton_clicked() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
268 | self.__device = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
269 | |
9944 | 270 | if self.__device is None: |
271 | self.on_deviceTypeComboBox_activated(index) | |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
272 | self.deviceTypeComboBox.setCurrentIndex(index) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
273 | |
7588
881eebfefd34
MicroPython: added code to report detected non-supported devices to the user asking to report them.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7545
diff
changeset
|
274 | if unknownDevices: |
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:
7592
diff
changeset
|
275 | ignoredUnknown = { |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
276 | tuple(d) for d in Preferences.getMicroPython("IgnoredUnknownDevices") |
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:
7592
diff
changeset
|
277 | } |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
278 | uf2Devices = {(*x[2], x[1]) for x in UF2FlashDialog.getFoundDevices()} |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
279 | newUnknownDevices = set(unknownDevices) - ignoredUnknown - uf2Devices |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
280 | if newUnknownDevices: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
281 | button = EricMessageBox.information( |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
282 | self, |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
283 | self.tr("Unknown MicroPython Device"), |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
284 | self.tr( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
285 | "<p>Detected these unknown serial devices</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
286 | "<ul>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
287 | "<li>{0}</li>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
288 | "</ul>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
289 | "<p>Please report them together with the board name" |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
290 | ' and a short description to <a href="mailto:{1}">' |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
291 | " the eric bug reporting address</a> if it is a" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
292 | " MicroPython board.</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
293 | ).format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
294 | "</li><li>".join( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
295 | [ |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
296 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
297 | "{0} (0x{1:04x}/0x{2:04x})", "description, VId, PId" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
298 | ).format(desc, vid, pid) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
299 | for vid, pid, desc in newUnknownDevices |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
300 | ] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
301 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
302 | BugAddress, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
303 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
304 | EricMessageBox.Ignore | EricMessageBox.Ok, |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
305 | ) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
306 | if button == EricMessageBox.Ignore: |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
307 | ignoredUnknown = list(ignoredUnknown | newUnknownDevices) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
308 | Preferences.setMicroPython("IgnoredUnknownDevices", ignoredUnknown) |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
309 | else: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
310 | yes = EricMessageBox.yesNo( |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
311 | self, |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
312 | self.tr("Unknown MicroPython Device"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
313 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
314 | """Would you like to add them to the list of""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
315 | """ manually configured devices?""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
316 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
317 | yesDefault=True, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
318 | ) |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
319 | if yes: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
320 | self.__addUnknownDevices(list(newUnknownDevices)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
321 | |
7069
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
322 | def __handlePreferencesChanged(self): |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
323 | """ |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
324 | Private slot to handle a change in preferences. |
a09a30251d4e
MicroPythonReplWidget: extended the color support with selectable color schemes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7067
diff
changeset
|
325 | """ |
10011 | 326 | self.replWidget.replEdit().handlePreferencesChanged() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
327 | |
9990 | 328 | if self.__interface is not None: |
329 | self.__interface.handlePreferencesChanged | |
330 | ||
7535
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
331 | if self.__chartWidget is not None: |
dac9bc72a0f3
MicroPython: made the chart widget color scheme aware and added a config option to configure a specific chart color theme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7360
diff
changeset
|
332 | self.__chartWidget.preferencesChanged() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
333 | |
10009 | 334 | @pyqtSlot() |
335 | def __configureWebreplUrls(self): | |
336 | """ | |
337 | Private slot to configure the list of selectable WebREPL URLs. | |
338 | """ | |
339 | from .MicroPythonWebreplUrlsConfigDialog import ( | |
10010 | 340 | MicroPythonWebreplUrlsConfigDialog, |
10009 | 341 | ) |
342 | ||
343 | webreplUrlsDict = Preferences.getMicroPython("WebreplUrls") | |
344 | dlg = MicroPythonWebreplUrlsConfigDialog(webreplUrlsDict) | |
345 | if dlg.exec() == QDialog.DialogCode.Accepted: | |
346 | webreplUrlsDict = dlg.getWebreplDict() | |
347 | Preferences.setMicroPython("WebreplUrls", webreplUrlsDict) | |
348 | ||
349 | self.__populateDeviceTypeComboBox() | |
350 | ||
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
351 | def deviceInterface(self): |
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:
7094
diff
changeset
|
352 | """ |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
353 | Public method to get a reference to the device interface object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
354 | |
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:
7094
diff
changeset
|
355 | @return reference to the commands interface object |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
356 | @rtype MicroPythonDeviceInterface |
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:
7094
diff
changeset
|
357 | """ |
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:
7094
diff
changeset
|
358 | return self.__interface |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
359 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
360 | def isMicrobit(self): |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
361 | """ |
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
362 | Public method to check, if the connected/selected device is a |
8038
73ec029d4107
MicroPython: improved the support for "BBC micro:bit" and "Calliope mini".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8024
diff
changeset
|
363 | BBC micro:bit or Calliope mini. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
364 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
365 | @return flag indicating a micro:bit device |
10428
a071d4065202
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10230
diff
changeset
|
366 | @rtype bool |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
367 | """ |
9766
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
368 | if ( |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
369 | self.__device |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
370 | and ( |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
371 | "micro:bit" in self.__device.deviceName() |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
372 | or "Calliope" in self.__device.deviceName() |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
373 | ) |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
374 | and not self.__device.hasCircuitPython() |
8038
73ec029d4107
MicroPython: improved the support for "BBC micro:bit" and "Calliope mini".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8024
diff
changeset
|
375 | ): |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
376 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
377 | |
7126
376deb7fefe7
microbit: added the minimal filesystem commands which are supported by the BBC micro:bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7123
diff
changeset
|
378 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
379 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
380 | @pyqtSlot(int) |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
381 | def on_deviceTypeComboBox_activated(self, index): |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
382 | """ |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
383 | Private slot handling the selection of a device type. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
384 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
385 | @param index index of the selected device |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
386 | @type int |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
387 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
388 | deviceType = self.deviceTypeComboBox.itemData(index, self.DeviceTypeRole) |
8137
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
389 | if deviceType == self.ManualMarker: |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
390 | self.connectButton.setEnabled(bool(self.__unknownPorts)) |
97d37389fbfd
MicroPython: changed the logic of the device/port selector slightly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8135
diff
changeset
|
391 | else: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
392 | self.deviceIconLabel.setPixmap(Devices.getDeviceIcon(deviceType, False)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
393 | |
9738 | 394 | boardName = self.deviceTypeComboBox.itemData(index, self.DeviceBoardRole) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
395 | vid = self.deviceTypeComboBox.itemData(index, self.DeviceVidRole) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
396 | pid = self.deviceTypeComboBox.itemData(index, self.DevicePidRole) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
397 | serNo = self.deviceTypeComboBox.itemData(index, self.DeviceSerNoRole) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
398 | |
10009 | 399 | if deviceType or (vid is not None and pid is not None): |
9944 | 400 | deviceWorkspace = ( |
9972
68ac01294544
Corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9944
diff
changeset
|
401 | self.__device.getWorkspace() if self.__device is not None else None |
9944 | 402 | ) |
9759
4543b7876047
Adapted some MicroPython modules to the new package layout.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9752
diff
changeset
|
403 | self.__device = Devices.getDevice( |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
404 | deviceType, self, vid, pid, boardName=boardName, serialNumber=serNo |
9738 | 405 | ) |
9496
05017f795c24
Changed MicroPython device imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
406 | self.__device.setButtons() |
9944 | 407 | if deviceWorkspace: |
408 | self.__device.setWorkspace(deviceWorkspace) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
409 | |
9496
05017f795c24
Changed MicroPython device imports to use importlib.import_module().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
410 | self.connectButton.setEnabled(bool(deviceType)) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
411 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
412 | self.__device = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
413 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
414 | def setActionButtons(self, **kwargs): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
416 | Public method to set the enabled state of the various action buttons. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
417 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
418 | @keyparam kwargs keyword arguments containg the enabled states (keys |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
419 | are 'run', 'repl', 'files', 'chart', 'open', 'save' |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
420 | @type dict |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
422 | if "run" in kwargs: |
9749 | 423 | self.runButton.setEnabled(kwargs["run"] and self.__connected) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
424 | if "repl" in kwargs: |
9749 | 425 | self.replButton.setEnabled(kwargs["repl"] and self.__linkConnected) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
426 | if "files" in kwargs: |
9749 | 427 | self.filesButton.setEnabled(kwargs["files"] and self.__connected) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
428 | if "chart" in kwargs: |
9749 | 429 | self.chartButton.setEnabled( |
430 | kwargs["chart"] and HAS_QTCHART and self.__connected | |
431 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
432 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
433 | def __setConnected(self, connected): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
434 | """ |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
435 | Private method to set the connection status LED. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
436 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
437 | @param connected connection state |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
438 | @type bool |
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
439 | """ |
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:
7094
diff
changeset
|
440 | self.__connected = connected |
9990 | 441 | self.__linkConnected = bool(self.__interface) and self.__interface.isConnected() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
442 | |
9749 | 443 | self.deviceConnectedLed.setOn(self.__linkConnected) |
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:
7094
diff
changeset
|
444 | if self.__fileManagerWidget: |
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:
7094
diff
changeset
|
445 | self.__fileManagerWidget.deviceConnectedLed.setOn(connected) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
446 | |
9749 | 447 | self.deviceTypeComboBox.setEnabled(not self.__linkConnected) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
448 | |
9749 | 449 | if self.__linkConnected: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
450 | self.connectButton.setIcon(EricPixmapCache.getIcon("linkDisconnect")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
451 | self.connectButton.setToolTip( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
452 | self.tr("Press to disconnect the current device") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
453 | ) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
454 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
455 | self.connectButton.setIcon(EricPixmapCache.getIcon("linkConnect")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
456 | self.connectButton.setToolTip( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
457 | self.tr("Press to connect the selected device") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
458 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
459 | |
9887
52a659bdc65a
Corrected the tear off menu deletion upon device disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9878
diff
changeset
|
460 | if not connected: |
52a659bdc65a
Corrected the tear off menu deletion upon device disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9878
diff
changeset
|
461 | for menu in (self.__wifiMenu, self.__btMenu, self.__ethernetMenu): |
52a659bdc65a
Corrected the tear off menu deletion upon device disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9878
diff
changeset
|
462 | if menu and menu.isTearOffMenuVisible(): |
52a659bdc65a
Corrected the tear off menu deletion upon device disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9878
diff
changeset
|
463 | menu.hideTearOffMenu() |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
464 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
465 | def isConnected(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
466 | """ |
9749 | 467 | Public method to get the MicroPython device connection state. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
468 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
469 | @return connection state |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
470 | @rtype bool |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
471 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
472 | return self.__connected |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
473 | |
9749 | 474 | def isLinkConnected(self): |
475 | """ | |
476 | Public method to get the link connection state. | |
477 | ||
478 | @return connection state | |
479 | @rtype bool | |
480 | """ | |
481 | return self.__linkConnected | |
482 | ||
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
483 | def __showNoDeviceMessage(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
484 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
485 | Private method to show a message dialog indicating a missing device. |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
486 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
487 | EricMessageBox.critical( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
488 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
489 | self.tr("No device attached"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
490 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
491 | """Please ensure the device is plugged into your""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
492 | """ computer and selected.\n\nIt must have a version""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
493 | """ of MicroPython (or CircuitPython) flashed onto""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
494 | """ it before anything will work.\n\nFinally press""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
495 | """ the device's reset button and wait a few seconds""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
496 | """ before trying again.""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
497 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
498 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
499 | |
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:
7094
diff
changeset
|
500 | @pyqtSlot(bool) |
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:
7094
diff
changeset
|
501 | def on_replButton_clicked(self, checked): |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | """ |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
503 | Private slot to connect to enable or disable the REPL widget. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
504 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
505 | If the selected device is not connected yet, this will be done now. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
506 | |
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:
7094
diff
changeset
|
507 | @param checked state of the button |
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:
7094
diff
changeset
|
508 | @type bool |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
509 | """ |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
510 | if not self.__device: |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
511 | self.__showNoDeviceMessage() |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
512 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
513 | |
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:
7094
diff
changeset
|
514 | if checked: |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
515 | ok, reason = self.__device.canStartRepl() |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
516 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
517 | EricMessageBox.warning( |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
518 | self, |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
519 | self.tr("Start REPL"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
520 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
521 | """<p>The REPL cannot be started.</p><p>Reason:""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
522 | """ {0}</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
523 | ).format(reason), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
524 | ) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
525 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
526 | |
10011 | 527 | self.replWidget.replEdit().clear() |
528 | self.__interface.dataReceived.connect( | |
529 | self.replWidget.replEdit().processData | |
530 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
531 | |
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:
7094
diff
changeset
|
532 | if not self.__interface.isConnected(): |
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:
7094
diff
changeset
|
533 | self.__connectToDevice() |
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:
7094
diff
changeset
|
534 | if self.__device.forceInterrupt(): |
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:
7094
diff
changeset
|
535 | # send a Ctrl-B (exit raw mode) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
536 | self.__interface.write(b"\x02") |
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:
7094
diff
changeset
|
537 | # send Ctrl-C (keyboard interrupt) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
538 | self.__interface.write(b"\x03") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
539 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
540 | self.__device.setRepl(True) |
10011 | 541 | self.replWidget.replEdit().setFocus(Qt.FocusReason.OtherFocusReason) |
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:
7094
diff
changeset
|
542 | else: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
543 | with contextlib.suppress(TypeError): |
9990 | 544 | if self.__interface is not None: |
10011 | 545 | self.__interface.dataReceived.disconnect( |
546 | self.replWidget.replEdit().processData | |
547 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
548 | if not self.chartButton.isChecked() and not self.filesButton.isChecked(): |
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:
7094
diff
changeset
|
549 | self.__disconnectFromDevice() |
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:
7094
diff
changeset
|
550 | self.__device.setRepl(False) |
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:
7094
diff
changeset
|
551 | self.replButton.setChecked(checked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
552 | |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
553 | @pyqtSlot() |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
554 | def on_connectButton_clicked(self): |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
555 | """ |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
556 | Private slot to connect to the selected device or disconnect from the |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
557 | currently connected device. |
7054
fb84d8489bc1
Started implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
558 | """ |
10011 | 559 | self.replWidget.clearOSD() |
9749 | 560 | if self.__linkConnected: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
561 | with EricOverrideCursor(): |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
562 | self.__disconnectFromDevice() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
563 | |
7120
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
564 | if self.replButton.isChecked(): |
89ee83fadec9
MicroPythonReplWidget: fixed the devices rescan behaviour.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7111
diff
changeset
|
565 | self.on_replButton_clicked(False) |
7111
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
566 | if self.filesButton.isChecked(): |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
567 | self.on_filesButton_clicked(False) |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
568 | if self.chartButton.isChecked(): |
62191d1aeeed
MicroPythonReplWidget: made the connect button more intelligent.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7108
diff
changeset
|
569 | self.on_chartButton_clicked(False) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
570 | else: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
571 | with EricOverrideCursor(): |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
572 | self.__connectToDevice(withAutostart=True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
573 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
574 | def getCurrentPort(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
575 | """ |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
576 | Public method to determine the port path of the selected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
577 | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
578 | @return path of the port of the selected device |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
579 | @rtype str |
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
580 | """ |
8072
58491f4c99d6
MicroPython: added code to give a hint for CircuitPython devices, that do not support the UF2 bootloader for flashing.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8071
diff
changeset
|
581 | portName = self.deviceTypeComboBox.currentData(self.DevicePortRole) |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
582 | if portName: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
583 | if OSUtilities.isWindowsPlatform(): |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
584 | # return it unchanged |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
585 | return portName |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
586 | else: |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
587 | # return with device path prepended |
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
588 | return "/dev/{0}".format(portName) |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
589 | else: |
8133
4d1d1c248f79
MicroPython: started adding manual connection capability with device type and port selection.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8121
diff
changeset
|
590 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
591 | |
9776
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
592 | def getDevice(self): |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
593 | """ |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
594 | Public method to get a reference to the current device. |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
595 | |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
596 | @return reference to the current device |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
597 | @rtype BaseDevice |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
598 | """ |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
599 | return self.__device |
210bf87ae5c7
Continued implementing WiFi functionality for RP2040 based devices.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9775
diff
changeset
|
600 | |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
601 | def getDeviceWorkspace(self): |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
602 | """ |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
603 | Public method to get the workspace directory of the device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
604 | |
7130
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
605 | @return workspace directory of the device |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
606 | @rtype str |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
607 | """ |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
608 | if self.__device: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
609 | return self.__device.getWorkspace() |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
610 | else: |
6014d37d9683
Started to prepare the MicroPython file manager to access the device file system via a local directory.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7127
diff
changeset
|
611 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
612 | |
9767
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
613 | def deviceSupportsLocalFileAccess(self): |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
614 | """ |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
615 | Public method to indicate that the device access the device file system |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
616 | via a local directory. |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
617 | |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
618 | @return flag indicating file access via local directory |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
619 | @rtype bool |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
620 | """ |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
621 | return self.__device is not None and self.__device.supportsLocalFileAccess() |
2eed840795c0
Fixed a few issues in the MicroPython file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9766
diff
changeset
|
622 | |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
623 | def __connectToDevice(self, withAutostart=False): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
624 | """ |
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:
7094
diff
changeset
|
625 | Private method to connect to the selected device. |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
626 | |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
627 | @param withAutostart flag indicating to start the repl and file manager |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
628 | automatically |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
629 | @type bool |
9990 | 630 | @exception ValueError raised to indicate an unsupported interface type |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
631 | """ |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
632 | from .ConnectionSelectionDialog import ConnectionSelectionDialog |
10010 | 633 | from .MicroPythonWebreplConnectionDialog import ( |
634 | MicroPythonWebreplConnectionDialog, | |
635 | ) | |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
636 | |
9990 | 637 | interfaceType = ( |
638 | self.deviceTypeComboBox.currentData(self.DeviceInterfaceTypeRole) | |
639 | or "serial" | |
640 | ) # 'serial' is the default | |
641 | ||
642 | if interfaceType not in ("serial", "webrepl"): | |
643 | raise ValueError( | |
644 | "Unsupported interface type detected ('{0}')".format(interfaceType) | |
645 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
646 | |
9990 | 647 | if interfaceType == "serial": |
648 | port = self.getCurrentPort() | |
649 | if not port: | |
650 | with EricOverridenCursor(): | |
651 | dlg = ConnectionSelectionDialog( | |
652 | self.__unknownPorts, self.__lastPort, self.__lastDeviceType | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
653 | ) |
9990 | 654 | if dlg.exec() == QDialog.DialogCode.Accepted: |
655 | vid, pid, port, deviceType = dlg.getData() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
656 | |
9990 | 657 | self.deviceIconLabel.setPixmap( |
658 | Devices.getDeviceIcon(deviceType, False) | |
659 | ) | |
660 | self.__device = Devices.getDevice(deviceType, self, vid, pid) | |
661 | ||
662 | self.__lastPort = port | |
663 | self.__lastDeviceType = deviceType | |
664 | else: | |
665 | return | |
666 | ||
667 | self.__interface = MicroPythonSerialDeviceInterface(self) | |
668 | elif interfaceType == "webrepl": | |
10008 | 669 | port = self.deviceTypeComboBox.currentData(self.DeviceWebreplUrlRole) |
670 | if not port: | |
10010 | 671 | with EricOverridenCursor(): |
672 | dlg = MicroPythonWebreplConnectionDialog( | |
673 | self.__lastWebreplUrl, self.__lastDeviceType | |
674 | ) | |
675 | if dlg.exec() == QDialog.DialogCode.Accepted: | |
676 | port, deviceType = dlg.getWebreplConnectionParameters() | |
677 | ||
678 | self.deviceIconLabel.setPixmap( | |
679 | Devices.getDeviceIcon(deviceType, False) | |
680 | ) | |
681 | self.__device = Devices.getDevice(deviceType, self, None, None) | |
682 | ||
683 | self.__lastWebreplUrl = port | |
684 | self.__lastDeviceType = deviceType | |
685 | else: | |
686 | return | |
10008 | 687 | |
688 | self.__interface = MicroPythonWebreplDeviceInterface(self) | |
10011 | 689 | self.replWidget.replEdit().setInterface(self.__interface) |
10012 | 690 | self.__interface.osdInfo.connect(self.replWidget.setOSDInfo) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
691 | |
10229
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
692 | ok, error = self.__interface.connectToDevice(port) |
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
693 | if ok: |
9749 | 694 | deviceResponding = self.__interface.probeDevice() |
695 | self.__setConnected(deviceResponding) | |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
696 | self.__device.setConnected(deviceResponding) |
9749 | 697 | if deviceResponding: |
698 | if ( | |
699 | Preferences.getMicroPython("SyncTimeAfterConnect") | |
700 | and self.__device.hasTimeCommands() | |
701 | ): | |
702 | self.__synchronizeTime(quiet=True) | |
703 | else: | |
704 | with EricOverridenCursor(): | |
705 | EricMessageBox.warning( | |
706 | self, | |
707 | self.tr("Serial Device Connect"), | |
708 | self.tr( | |
709 | """<p>The device at serial port <b>{0}</b> does not""" | |
710 | """ respond. It may not have a MicroPython firmware""" | |
711 | """ flashed.</p>""" | |
712 | ).format(port), | |
713 | ) | |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
714 | else: |
10229
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
715 | msg = self.tr( |
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
716 | "<p>Cannot connect to device at serial port <b>{0}</b>.</p>" |
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
717 | "<p><b>Reason:</b> {1}</p>" |
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
718 | ).format(port, error if error else self.tr("unknown")) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
719 | with EricOverridenCursor(): |
10229
e50bbf250343
Extended the MicroPython code to give an indication, why the connection to a device failed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10173
diff
changeset
|
720 | EricMessageBox.warning(self, self.tr("Serial Device Connect"), msg) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
721 | |
9749 | 722 | self.__device.setButtons() |
9763
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
723 | if withAutostart: |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
724 | self.on_replButton_clicked( |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
725 | self.replButton.isEnabled() and self.__linkConnected |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
726 | ) |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
727 | self.on_filesButton_clicked( |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
728 | self.filesButton.isEnabled() and self.__connected |
52f982c08301
Removed the 'Open' and 'Save' buttons from the MicroPython widget and made the repl and file manager start automatically upon connecting to the selected device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9759
diff
changeset
|
729 | ) |
9749 | 730 | |
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:
7094
diff
changeset
|
731 | def __disconnectFromDevice(self): |
7058
bdd583f96e96
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7054
diff
changeset
|
732 | """ |
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:
7094
diff
changeset
|
733 | Private method to disconnect from the device. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
734 | """ |
9907
2b638931707c
Fixed an issue caused by a member being None.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9895
diff
changeset
|
735 | self.__device and self.__device.setConnected(False) |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
736 | self.__setConnected(False) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
737 | |
9990 | 738 | if self.__interface is not None: |
739 | self.__interface.disconnectFromDevice() | |
740 | self.__interface.deleteLater() | |
741 | self.__interface = None | |
10011 | 742 | self.replWidget.replEdit().setInterface(None) |
9990 | 743 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
744 | @pyqtSlot() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
745 | def on_runButton_clicked(self): |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
746 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
747 | Private slot to execute the script of the active editor on the |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
748 | selected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
749 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
750 | If the REPL is not active yet, it will be activated, which might cause |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
751 | an unconnected device to be connected. |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
752 | """ |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
753 | if not self.__device: |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
754 | self.__showNoDeviceMessage() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
755 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
756 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
757 | aw = ericApp().getObject("ViewManager").activeWindow() |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
758 | if aw is None: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
759 | EricMessageBox.critical( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
760 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
761 | self.tr("Run Script"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
762 | self.tr("""There is no editor open. Abort..."""), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
763 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
764 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
765 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
766 | script = aw.text() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
767 | if not script: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
768 | EricMessageBox.critical( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
769 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
770 | self.tr("Run Script"), |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
771 | self.tr("""The current editor does not contain a script. Abort..."""), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
772 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
773 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
774 | |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
775 | ok, reason = self.__device.canRunScript() |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
776 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
777 | EricMessageBox.warning( |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
778 | self, |
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
779 | self.tr("Run Script"), |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
780 | self.tr("""<p>Cannot run script.</p><p>Reason: {0}</p>""").format( |
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
781 | reason |
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
782 | ), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
783 | ) |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
784 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
785 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
786 | if not self.replButton.isChecked(): |
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
787 | # activate on the REPL |
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:
7094
diff
changeset
|
788 | self.on_replButton_clicked(True) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
789 | if self.replButton.isChecked(): |
7059
a8fad276cbd5
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7058
diff
changeset
|
790 | self.__device.runScript(script) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
791 | |
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:
7094
diff
changeset
|
792 | @pyqtSlot(bool) |
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:
7094
diff
changeset
|
793 | def on_chartButton_clicked(self, checked): |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
794 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
795 | Private slot to open a chart view to plot data received from the |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
796 | connected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
797 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
798 | If the selected device is not connected yet, this will be done now. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
799 | |
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:
7094
diff
changeset
|
800 | @param checked state of the button |
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:
7094
diff
changeset
|
801 | @type bool |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
802 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
803 | if not HAS_QTCHART: |
8343
242d5dae2937
Corrected some place to import QtCharts instead of QtChart.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8322
diff
changeset
|
804 | # QtCharts not available => fail silently |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
805 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
806 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
807 | if not self.__device: |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
808 | self.__showNoDeviceMessage() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
809 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
810 | |
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:
7094
diff
changeset
|
811 | if checked: |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
812 | ok, reason = self.__device.canStartPlotter() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
813 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
814 | EricMessageBox.warning( |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
815 | self, |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
816 | self.tr("Start Chart"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
817 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
818 | """<p>The Chart cannot be started.</p><p>Reason:""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
819 | """ {0}</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
820 | ).format(reason), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
821 | ) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
822 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
823 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
824 | self.__chartWidget = MicroPythonGraphWidget(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
825 | self.__interface.dataReceived.connect(self.__chartWidget.processData) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
826 | self.__chartWidget.dataFlood.connect(self.handleDataFlood) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
827 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
828 | self.__ui.addSideWidget( |
10482
72d9b5ea39b4
Changed some state/mode definitiuons to an enum.Enum class and corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
829 | UserInterfaceSide.Bottom, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
830 | self.__chartWidget, |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
831 | EricPixmapCache.getIcon("chart"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
832 | self.tr("µPy Chart"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
833 | ) |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
834 | self.__ui.showSideWidget(self.__chartWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
835 | |
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:
7094
diff
changeset
|
836 | if not self.__interface.isConnected(): |
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:
7094
diff
changeset
|
837 | self.__connectToDevice() |
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:
7094
diff
changeset
|
838 | if self.__device.forceInterrupt(): |
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:
7094
diff
changeset
|
839 | # send a Ctrl-B (exit raw mode) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
840 | self.__interface.write(b"\x02") |
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:
7094
diff
changeset
|
841 | # send Ctrl-C (keyboard interrupt) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
842 | self.__interface.write(b"\x03") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
843 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
844 | self.__device.setPlotter(True) |
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:
7094
diff
changeset
|
845 | else: |
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:
7094
diff
changeset
|
846 | if self.__chartWidget.isDirty(): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
847 | res = EricMessageBox.okToClearData( |
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:
7094
diff
changeset
|
848 | self, |
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:
7094
diff
changeset
|
849 | self.tr("Unsaved Chart Data"), |
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:
7094
diff
changeset
|
850 | self.tr("""The chart contains unsaved data."""), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
851 | self.__chartWidget.saveData, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
852 | ) |
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:
7094
diff
changeset
|
853 | if not res: |
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:
7094
diff
changeset
|
854 | # abort |
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:
7094
diff
changeset
|
855 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
856 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
857 | self.__interface.dataReceived.disconnect(self.__chartWidget.processData) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
858 | self.__chartWidget.dataFlood.disconnect(self.handleDataFlood) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
859 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
860 | if not self.replButton.isChecked() and not self.filesButton.isChecked(): |
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:
7094
diff
changeset
|
861 | self.__disconnectFromDevice() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
862 | |
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:
7094
diff
changeset
|
863 | self.__device.setPlotter(False) |
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:
7094
diff
changeset
|
864 | self.__ui.removeSideWidget(self.__chartWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
865 | |
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:
7094
diff
changeset
|
866 | self.__chartWidget.deleteLater() |
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:
7094
diff
changeset
|
867 | self.__chartWidget = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
868 | |
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:
7094
diff
changeset
|
869 | self.chartButton.setChecked(checked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
870 | |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
871 | @pyqtSlot() |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
872 | def handleDataFlood(self): |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
873 | """ |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
874 | Public slot handling a data flood from the device. |
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
875 | """ |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
876 | self.on_connectButton_clicked() |
7065
e3d04faced34
Continued implementing the MicroPython support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7062
diff
changeset
|
877 | self.__device.handleDataFlood() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
878 | |
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:
7094
diff
changeset
|
879 | @pyqtSlot(bool) |
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:
7094
diff
changeset
|
880 | def on_filesButton_clicked(self, checked): |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
881 | """ |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
882 | Private slot to open a file manager window to the connected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
883 | |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
884 | If the selected device is not connected yet, this will be done now. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
885 | |
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:
7094
diff
changeset
|
886 | @param checked state of the button |
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:
7094
diff
changeset
|
887 | @type bool |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
888 | """ |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
889 | if not self.__device: |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
890 | self.__showNoDeviceMessage() |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
891 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
892 | |
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:
7094
diff
changeset
|
893 | if checked: |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
894 | ok, reason = self.__device.canStartFileManager() |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
895 | if not ok: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
896 | EricMessageBox.warning( |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
897 | self, |
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
898 | self.tr("Start File Manager"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
899 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
900 | """<p>The File Manager cannot be started.</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
901 | """<p>Reason: {0}</p>""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
902 | ).format(reason), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
903 | ) |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
904 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
905 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
906 | with EricOverrideCursor(): |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
907 | if not self.__interface.isConnected(): |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
908 | self.__connectToDevice() |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
909 | if self.__connected: |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
910 | self.__fileManager = MicroPythonFileManager(self.__device, self) |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
911 | self.__fileManagerWidget = MicroPythonFileManagerWidget( |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
912 | self.__fileManager, self |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
913 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
914 | |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
915 | self.__ui.addSideWidget( |
10482
72d9b5ea39b4
Changed some state/mode definitiuons to an enum.Enum class and corrected some code style and formatting issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
916 | UserInterfaceSide.Bottom, |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
917 | self.__fileManagerWidget, |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
918 | EricPixmapCache.getIcon("filemanager"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
919 | self.tr("µPy Files"), |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
920 | ) |
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
921 | self.__ui.showSideWidget(self.__fileManagerWidget) |
7077
3b7475b7a1ef
MicroPython: started to implement the file manager widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7069
diff
changeset
|
922 | |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
923 | self.__device.setFileManager(True) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
924 | |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
925 | self.__fileManagerWidget.start() |
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:
7094
diff
changeset
|
926 | else: |
9738 | 927 | if self.__fileManagerWidget is not None: |
928 | self.__fileManagerWidget.stop() | |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
929 | self.__fileManagerWidget.deleteLater() |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
930 | if self.__fileManager is not None: |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
931 | self.__fileManager.deleteLater() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
932 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
933 | if not self.replButton.isChecked() and not self.chartButton.isChecked(): |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
934 | self.__disconnectFromDevice() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
935 | |
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:
7094
diff
changeset
|
936 | self.__device.setFileManager(False) |
7103
aea236dc8002
MicroPythonReplWidget: streamlined the code a little bit and changed the 'disconnect' button to a 'connect/disconnect' button.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7095
diff
changeset
|
937 | self.__ui.removeSideWidget(self.__fileManagerWidget) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
938 | |
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:
7094
diff
changeset
|
939 | self.__fileManagerWidget = None |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
940 | self.__fileManager = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
941 | |
7127
aa6fc2d252ad
MicroPythonReplWidget: fixed an issue resetting the files button on disconnect.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7126
diff
changeset
|
942 | self.filesButton.setChecked(checked) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
943 | |
9853
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
944 | def getFileManager(self): |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
945 | """ |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
946 | Public method to get a reference to the file manager interface. |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
947 | |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
948 | @return reference to the file manager interface |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
949 | @rtype MicroPythonFileManager |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
950 | """ |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
951 | return self.__fileManager |
080e060a0383
Added the capability to save from an editor to a connected MicroPython device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9847
diff
changeset
|
952 | |
9823
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
953 | def shutdown(self): |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
954 | """ |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
955 | Public method to perform some shutdown actions. |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
956 | """ |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
957 | if self.__linkConnected: |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
958 | with EricOverrideCursor(): |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
959 | self.__disconnectFromDevice() |
31eeccd92f86
Added some code to ensure a proper shutdown of the MicroPython widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9812
diff
changeset
|
960 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
961 | ################################################################## |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
962 | ## Super Menu related methods below |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
963 | ################################################################## |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
964 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
965 | def __aboutToShowSuperMenu(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
966 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
967 | Private slot to populate the Super Menu before showing it. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
968 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
969 | self.__superMenu.clear() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
970 | |
10151 | 971 | if ( |
972 | self.__device | |
973 | and self.__linkConnected | |
974 | and not self.__device.hasCircuitPython() | |
975 | ): | |
10138 | 976 | networkConnected = self.__device.isNetworkConnected() |
977 | useLocalMip = ( | |
978 | ( | |
979 | self.__device.getDeviceData("mip") | |
980 | or self.__device.getDeviceData("upip") | |
10144 | 981 | ) |
982 | and not networkConnected | |
10138 | 983 | ) or self.__device.getDeviceData("local_mip") |
984 | hasMip = self.__device.getDeviceData("mip") and networkConnected | |
985 | hasUPip = self.__device.getDeviceData("upip") and networkConnected | |
9844 | 986 | else: |
987 | hasMip = False | |
988 | hasUPip = False | |
9979 | 989 | useLocalMip = False |
9844 | 990 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
991 | # prepare the download menu |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
992 | if self.__device: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
993 | menuEntries = self.__device.getDownloadMenuEntries() |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
994 | if menuEntries: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
995 | downloadMenu = QMenu(self.tr("Downloads"), self.__superMenu) |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
996 | for text, url in menuEntries: |
8121
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
997 | if text == "<separator>": |
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
998 | downloadMenu.addSeparator() |
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
999 | else: |
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1000 | downloadMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1001 | text, functools.partial(self.__downloadFromUrl, url) |
8121
9a2aa5353a32
MicroPythonWidget: added the capability to have menu separators in the downloads sub-menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8117
diff
changeset
|
1002 | ) |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1003 | else: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1004 | downloadMenu = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1005 | |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1006 | # prepare the WiFi menu |
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1007 | if self.__device and self.__connected and self.__device.getDeviceData("wifi"): |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1008 | if self.__wifiMenu is not None: |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1009 | self.__wifiMenu.deleteLater() |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1010 | self.__wifiMenu = self.__wifiController.createMenu(self.__superMenu) |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1011 | else: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1012 | self.__wifiMenu = None |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1013 | |
9855 | 1014 | # prepare the Bluetooth menu |
1015 | if ( | |
1016 | self.__device | |
1017 | and self.__connected | |
1018 | and self.__device.getDeviceData("bluetooth") | |
1019 | ): | |
1020 | if self.__btMenu is not None: | |
1021 | self.__btMenu.deleteLater() | |
1022 | self.__btMenu = self.__bluetoothController.createMenu(self.__superMenu) | |
1023 | else: | |
1024 | self.__btMenu = None | |
1025 | ||
9878 | 1026 | # prepare the Ethernet menu |
1027 | if ( | |
1028 | self.__device | |
1029 | and self.__connected | |
1030 | and self.__device.getDeviceData("ethernet") | |
1031 | ): | |
1032 | if self.__ethernetMenu is not None: | |
1033 | self.__ethernetMenu.deleteLater() | |
1034 | self.__ethernetMenu = self.__ethernetController.createMenu(self.__superMenu) | |
1035 | else: | |
1036 | self.__ethernetMenu = None | |
1037 | ||
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1038 | # populate the super menu |
8234
fcb6b4b96274
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
1039 | hasTime = self.__device.hasTimeCommands() if self.__device else False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1040 | |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1041 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1042 | self.tr("Show Version"), self.__showDeviceVersion |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1043 | ).setEnabled(self.__connected) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1044 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1045 | self.tr("Show Implementation"), self.__showImplementation |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1046 | ).setEnabled(self.__connected) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1047 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1048 | self.tr("Show Board Data"), self.__showBoardInformation |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1049 | ).setEnabled(self.__connected) |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1050 | self.__superMenu.addSeparator() |
7123
94948e2aa0a5
Implemented the support for the 'BBC micro:bit' device.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7120
diff
changeset
|
1051 | if hasTime: |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1052 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1053 | self.tr("Synchronize Time"), self.__synchronizeTime |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1054 | ).setEnabled(self.__connected) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1055 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1056 | self.tr("Show Device Time"), self.__showDeviceTime |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1057 | ).setEnabled(self.__connected) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1058 | self.__superMenu.addAction(self.tr("Show Local Time"), self.__showLocalTime) |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1059 | if hasTime: |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1060 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1061 | self.tr("Show Time"), self.__showLocalAndDeviceTime |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1062 | ).setEnabled(self.__connected) |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1063 | self.__superMenu.addSeparator() |
9748 | 1064 | self.__superMenu.addAction( |
1065 | self.tr("Show Builtin Modules"), self.__showBuiltinModules | |
1066 | ).setEnabled(self.__connected) | |
9844 | 1067 | if hasMip: |
1068 | self.__superMenu.addAction( | |
1069 | self.tr("Install Package"), lambda: self.__installPackage("mip") | |
1070 | ).setEnabled(self.__connected) | |
1071 | elif hasUPip: | |
1072 | self.__superMenu.addAction( | |
1073 | self.tr("Install Packages"), lambda: self.__installPackage("upip") | |
1074 | ).setEnabled(self.__connected) | |
9979 | 1075 | elif useLocalMip: |
1076 | self.__superMenu.addAction( | |
1077 | self.tr("Install Package"), lambda: self.__installPackage("local_mip") | |
1078 | ).setEnabled(self.__connected) | |
9748 | 1079 | self.__superMenu.addSeparator() |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1080 | if not OSUtilities.isWindowsPlatform(): |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1081 | available = self.__mpyCrossAvailable() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1082 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1083 | self.tr("Compile Python File"), self.__compileFile2Mpy |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1084 | ).setEnabled(available) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1085 | aw = ericApp().getObject("ViewManager").activeWindow() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1086 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1087 | self.tr("Compile Current Editor"), self.__compileEditor2Mpy |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1088 | ).setEnabled(available and bool(aw)) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1089 | self.__superMenu.addSeparator() |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1090 | if self.__device: |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1091 | self.__device.addDeviceMenuEntries(self.__superMenu) |
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:
7150
diff
changeset
|
1092 | self.__superMenu.addSeparator() |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1093 | if self.__wifiMenu is not None: |
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1094 | self.__superMenu.addMenu(self.__wifiMenu) |
9855 | 1095 | if self.__btMenu is not None: |
1096 | self.__superMenu.addMenu(self.__btMenu) | |
9878 | 1097 | if self.__ethernetMenu is not None: |
1098 | self.__superMenu.addMenu(self.__ethernetMenu) | |
1099 | if ( | |
1100 | self.__wifiMenu is not None | |
1101 | or self.__btMenu is not None | |
1102 | or self.__ethernetMenu is not None | |
1103 | ): | |
9775
c6806d24468b
Created new branch <mpy_network>.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9772
diff
changeset
|
1104 | self.__superMenu.addSeparator() |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1105 | if downloadMenu is None: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1106 | # generic download action |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1107 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1108 | self.tr("Download Firmware"), self.__downloadFirmware |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1109 | ).setEnabled(self.__device.hasFirmwareUrl()) |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1110 | else: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1111 | # download sub-menu |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1112 | self.__superMenu.addMenu(downloadMenu) |
7328 | 1113 | self.__superMenu.addSeparator() |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1114 | self.__superMenu.addAction( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1115 | self.tr("Show Documentation"), self.__showDocumentation |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1116 | ).setEnabled(self.__device.hasDocumentationUrl()) |
8096 | 1117 | self.__superMenu.addSeparator() |
9915 | 1118 | self.__superMenu.addAction(self.tr("Convert To UF2"), self.__convertToUF2) |
9812
cf625a86a861
Changed the MicroPython super menu to always present the 'Flash UF2 Device' menu entry because some devices don't have a valid serial port when in UF2 'bootloader' mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9807
diff
changeset
|
1119 | self.__superMenu.addAction(self.tr("Flash UF2 Device"), self.__flashUF2) |
cf625a86a861
Changed the MicroPython super menu to always present the 'Flash UF2 Device' menu entry because some devices don't have a valid serial port when in UF2 'bootloader' mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9807
diff
changeset
|
1120 | self.__superMenu.addSeparator() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1121 | self.__superMenu.addAction( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1122 | self.tr("Manage Unknown Devices"), self.__manageUnknownDevices |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1123 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1124 | self.__superMenu.addAction( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1125 | self.tr("Ignored Serial Devices"), self.__manageIgnored |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1126 | ) |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1127 | self.__superMenu.addSeparator() |
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:
7150
diff
changeset
|
1128 | self.__superMenu.addAction(self.tr("Configure"), self.__configure) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1129 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1130 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1131 | def __showDeviceVersion(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1132 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1133 | Private slot to show some version info about MicroPython of the device. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1134 | """ |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1135 | data = self.__device.getDeviceData() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1136 | if data: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1137 | msg = self.tr("<h3>Device Version Information</h3>") |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1138 | msg += "<table>" |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1139 | for key in ("sysname", "nodename", "release", "version", "machine"): |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1140 | msg += "<tr><td><b>{0}</b></td><td>{1}</td></tr>".format( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1141 | key.capitalize(), data[key] |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1142 | ) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1143 | msg += "</table>" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1144 | EricMessageBox.information(self, self.tr("Device Version Information"), msg) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1145 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1146 | EricMessageBox.critical( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1147 | self, |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1148 | self.tr("Device Version Information"), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1149 | self.tr("No version information available."), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1150 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1151 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1152 | @pyqtSlot() |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1153 | def __showImplementation(self): |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1154 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1155 | Private slot to show some implementation related information. |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1156 | """ |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1157 | data = self.__device.getDeviceData() |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1158 | if data: |
9772
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1159 | # name |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1160 | if data["mpy_name"] == "micropython": |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1161 | name = "MicroPython" |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1162 | elif data["mpy_name"] == "circuitpython": |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1163 | name = "CircuitPython" |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1164 | elif data["mpy_name"] == "unknown": |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1165 | name = self.tr("unknown") |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1166 | else: |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1167 | name = data["mpy_name"] |
9772
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1168 | |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1169 | # version |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1170 | if data["mpy_variant_version"]: |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1171 | version = data["mpy_variant_version"] |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1172 | elif data["mpy_version"] == "unknown": |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1173 | version = self.tr("unknown") |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1174 | else: |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1175 | version = data["mpy_version"] |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1176 | |
06ef28082c4d
Changed the RP2040 related code of the MicroPython package to show the version info for a MicroPython variant (like Pimoroni Pico) if such is available (e.g. Pimoroni Pico 1.19.14 or newer).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9767
diff
changeset
|
1177 | # variant |
9747 | 1178 | variant = ( |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1179 | self.tr(" ({0})").format(data["mpy_variant"]) |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1180 | if data["mpy_variant"] |
9747 | 1181 | else "" |
1182 | ) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1183 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1184 | EricMessageBox.information( |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1185 | self, |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1186 | self.tr("Device Implementation Information"), |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1187 | self.tr( |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1188 | "<h3>Device Implementation Information</h3>" |
9747 | 1189 | "<p>This device contains <b>{0} {1}{2}</b>.</p>" |
1190 | ).format(name, version, variant), | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1191 | ) |
9751
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1192 | else: |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1193 | EricMessageBox.critical( |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1194 | self, |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1195 | self.tr("Device Implementation Information"), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1196 | self.tr("No device implementation information available."), |
606ac0e26533
Various enhancements and improvements to the MicroPython/CircuitPython related modules.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9749
diff
changeset
|
1197 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1198 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1199 | @pyqtSlot() |
8928 | 1200 | def __showBoardInformation(self): |
1201 | """ | |
1202 | Private slot to show all available information about a board. | |
1203 | """ | |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
1204 | from .BoardDataDialog import BoardDataDialog |
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
1205 | |
8928 | 1206 | try: |
10173 | 1207 | with EricOverrideCursor(): |
1208 | boardInfo = self.__device.getBoardInformation() | |
1209 | boardInfo.update( | |
1210 | self.__device.getDeviceData( | |
1211 | [ | |
1212 | "wifi", | |
1213 | "bluetooth", | |
1214 | "ethernet", | |
1215 | "mip", | |
1216 | "upip", | |
1217 | "local_mip", | |
1218 | ] | |
1219 | ) | |
10034 | 1220 | ) |
10230
1311cd5d117e
MicroPython interface
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10229
diff
changeset
|
1221 | boardInfo["ntp"] = self.__device.hasNetworkTime() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1222 | |
8928 | 1223 | dlg = BoardDataDialog(boardInfo) |
1224 | dlg.exec() | |
1225 | except Exception as exc: | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1226 | self.showError("getBoardInformation()", str(exc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1227 | |
8928 | 1228 | @pyqtSlot() |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1229 | def __synchronizeTime(self, quiet=False): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1230 | """ |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1231 | Private slot to set the time of the connected device to the local |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1232 | computer's time. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1233 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1234 | @param quiet flag indicating to not show a message |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1235 | @type bool |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1236 | """ |
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:
8104
diff
changeset
|
1237 | if self.__device and self.__device.hasTimeCommands(): |
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:
8104
diff
changeset
|
1238 | try: |
9766
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1239 | self.__device.syncTime( |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1240 | self.__device.getDeviceType(), |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1241 | hasCPy=self.__device.hasCircuitPython(), |
f0e22f3a5878
Fixed a few issue introduced during the recent changes to the MicroPython package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9765
diff
changeset
|
1242 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1243 | |
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:
8104
diff
changeset
|
1244 | if not quiet: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1245 | with EricOverridenCursor(): |
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1246 | EricMessageBox.information( |
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:
8104
diff
changeset
|
1247 | self, |
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:
8104
diff
changeset
|
1248 | self.tr("Synchronize Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1249 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1250 | "<p>The time of the connected device was" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1251 | " synchronized with the local time.</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1252 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1253 | + self.__getDeviceTime(), |
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:
8104
diff
changeset
|
1254 | ) |
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:
8104
diff
changeset
|
1255 | except Exception as exc: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1256 | self.showError("syncTime()", str(exc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1257 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1258 | def __getDeviceTime(self): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1259 | """ |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1260 | Private method to get a string containing the date and time of the |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1261 | connected device. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1262 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1263 | @return date and time of the connected device |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1264 | @rtype str |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1265 | """ |
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:
8104
diff
changeset
|
1266 | if self.__device and self.__device.hasTimeCommands(): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1267 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1268 | dateTimeString = self.__device.getTime() |
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:
8104
diff
changeset
|
1269 | try: |
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:
8104
diff
changeset
|
1270 | date, time = dateTimeString.strip().split(None, 1) |
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:
8104
diff
changeset
|
1271 | return self.tr( |
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:
8104
diff
changeset
|
1272 | "<h3>Device Date and Time</h3>" |
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:
8104
diff
changeset
|
1273 | "<table>" |
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:
8104
diff
changeset
|
1274 | "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
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:
8104
diff
changeset
|
1275 | "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
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:
8104
diff
changeset
|
1276 | "</table>" |
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:
8104
diff
changeset
|
1277 | ).format(date, time) |
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:
8104
diff
changeset
|
1278 | except ValueError: |
9576
be9f8e7e42e0
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9573
diff
changeset
|
1279 | return self.tr("<h3>Device Date and Time</h3><p>{0}</p>").format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1280 | dateTimeString.strip() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1281 | ) |
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:
8104
diff
changeset
|
1282 | except Exception as exc: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1283 | self.showError("getTime()", str(exc)) |
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:
8104
diff
changeset
|
1284 | return "" |
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:
8104
diff
changeset
|
1285 | else: |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1286 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1287 | |
7135
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1288 | @pyqtSlot() |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1289 | def __showDeviceTime(self): |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1290 | """ |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1291 | Private slot to show the date and time of the connected device. |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1292 | """ |
44fcfc99b864
MicroPython: added an option to synchronize the device time to the host time after connecting the serial port.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7134
diff
changeset
|
1293 | msg = self.__getDeviceTime() |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1294 | if msg: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1295 | EricMessageBox.information(self, self.tr("Device Date and Time"), msg) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1296 | |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1297 | @pyqtSlot() |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1298 | def __showLocalTime(self): |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1299 | """ |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1300 | Private slot to show the local date and time. |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1301 | """ |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1302 | localdatetime = time.localtime() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1303 | localdate = time.strftime("%Y-%m-%d", localdatetime) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1304 | localtime = time.strftime("%H:%M:%S", localdatetime) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1305 | EricMessageBox.information( |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1306 | self, |
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1307 | self.tr("Local Date and Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1308 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1309 | "<h3>Local Date and Time</h3>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1310 | "<table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1311 | "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1312 | "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1313 | "</table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1314 | ).format(localdate, localtime), |
7133
7aa4832b3730
MicroPythonReplWidget: moved the "Show Local Time" function to the repl widget super menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7130
diff
changeset
|
1315 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1316 | |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1317 | @pyqtSlot() |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1318 | def __showLocalAndDeviceTime(self): |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1319 | """ |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1320 | Private slot to show the local and device time side-by-side. |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1321 | """ |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1322 | localdatetime = time.localtime() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1323 | localdate = time.strftime("%Y-%m-%d", localdatetime) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1324 | localtime = time.strftime("%H:%M:%S", localdatetime) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1325 | |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1326 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1327 | deviceDateTimeString = self.__device.getTime() |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1328 | try: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1329 | devicedate, devicetime = deviceDateTimeString.strip().split(None, 1) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1330 | EricMessageBox.information( |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1331 | self, |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1332 | self.tr("Date and Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1333 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1334 | "<table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1335 | "<tr><th></th><th>Local Date and Time</th>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1336 | "<th>Device Date and Time</th></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1337 | "<tr><td><b>Date</b></td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1338 | "<td align='center'>{0}</td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1339 | "<td align='center'>{2}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1340 | "<tr><td><b>Time</b></td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1341 | "<td align='center'>{1}</td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1342 | "<td align='center'>{3}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1343 | "</table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1344 | ).format(localdate, localtime, devicedate, devicetime), |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1345 | ) |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1346 | except ValueError: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1347 | EricMessageBox.information( |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1348 | self, |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1349 | self.tr("Date and Time"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1350 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1351 | "<table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1352 | "<tr><th>Local Date and Time</th>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1353 | "<th>Device Date and Time</th></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1354 | "<tr><td align='center'>{0} {1}</td>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1355 | "<td align='center'>{2}</td></tr>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1356 | "</table>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1357 | ).format(localdate, localtime, deviceDateTimeString.strip()), |
7325
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1358 | ) |
f05a814aeddc
MicroPythonWidget
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7321
diff
changeset
|
1359 | except Exception as exc: |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1360 | self.showError("getTime()", str(exc)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1361 | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1362 | def showError(self, method, error): |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1363 | """ |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1364 | Public method to show some error message. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1365 | |
7108
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1366 | @param method name of the method the error occured in |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1367 | @type str |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1368 | @param error error message |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1369 | @type str |
4f6133a01c6a
Started rearranging menu structure and testing and fixing on CircuitPython.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7103
diff
changeset
|
1370 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1371 | with EricOverridenCursor(): |
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1372 | EricMessageBox.warning( |
8061
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1373 | self, |
979562f350bf
MicroPython: implemented fixes for a few issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8055
diff
changeset
|
1374 | self.tr("Error handling device"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1375 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1376 | "<p>There was an error communicating with the" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1377 | " connected device.</p><p>Method: {0}</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1378 | "<p>Message: {1}</p>" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1379 | ).format(method, error), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1380 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1381 | |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1382 | def __mpyCrossAvailable(self): |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1383 | """ |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1384 | Private method to check the availability of mpy-cross. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1385 | |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1386 | @return flag indicating the availability of mpy-cross |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1387 | @rtype bool |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1388 | """ |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1389 | available = False |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1390 | program = Preferences.getMicroPython("MpyCrossCompiler") |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1391 | if not program: |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1392 | program = "mpy-cross" |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1393 | if FileSystemUtilities.isinpath(program): |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1394 | available = True |
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1395 | else: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1396 | if FileSystemUtilities.isExecutable(program): |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1397 | available = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1398 | |
7150
cfe71cde2eec
MicroPythonWidget: made the cross compile actions enable only, if the mpy-cross utility is found or properly configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7148
diff
changeset
|
1399 | return available |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1400 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1401 | def __crossCompile(self, pythonFile="", title=""): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1402 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1403 | Private method to cross compile a Python file to a .mpy file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1404 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1405 | @param pythonFile name of the Python file to be compiled |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1406 | @type str |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1407 | @param title title for the various dialogs |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1408 | @type str |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1409 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1410 | program = Preferences.getMicroPython("MpyCrossCompiler") |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1411 | if not program: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1412 | program = "mpy-cross" |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9576
diff
changeset
|
1413 | if not FileSystemUtilities.isinpath(program): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1414 | EricMessageBox.critical( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1415 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1416 | title, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1417 | self.tr( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1418 | """The MicroPython cross compiler""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1419 | """ <b>mpy-cross</b> cannot be found. Ensure it""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1420 | """ is in the search path or configure it on""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1421 | """ the MicroPython configuration page.""" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1422 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1423 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1424 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1425 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1426 | if not pythonFile: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1427 | defaultDirectory = "" |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1428 | aw = ericApp().getObject("ViewManager").activeWindow() |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1429 | if aw: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1430 | fn = aw.getFileName() |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1431 | if fn: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1432 | defaultDirectory = os.path.dirname(fn) |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1433 | if not defaultDirectory: |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1434 | defaultDirectory = ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1435 | Preferences.getMicroPython("MpyWorkspace") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1436 | or Preferences.getMultiProject("Workspace") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1437 | or os.path.expanduser("~") |
8067
a467ab075be0
MicroPython: added buttons to go to the 'home' directory (local and on device) to the MicroPython file manager and improved the workspace handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8061
diff
changeset
|
1438 | ) |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1439 | pythonFile = EricFileDialog.getOpenFileName( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1440 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1441 | title, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1442 | defaultDirectory, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1443 | self.tr("Python Files (*.py);;All Files (*)"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1444 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1445 | if not pythonFile: |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1446 | # user cancelled |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1447 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1448 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1449 | if not os.path.exists(pythonFile): |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1450 | EricMessageBox.critical( |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1451 | self, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1452 | title, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1453 | self.tr( |
9573
9960d19d66b5
Corrected some 'wrong' string quotes caused by the Black line merging.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9496
diff
changeset
|
1454 | """The Python file <b>{0}</b> does not exist. Aborting...""" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1455 | ).format(pythonFile), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1456 | ) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1457 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1458 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1459 | compileArgs = [ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1460 | pythonFile, |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1461 | ] |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1462 | dlg = EricProcessDialog(self.tr("'mpy-cross' Output"), title) |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1463 | res = dlg.startProcess(program, compileArgs) |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1464 | if res: |
7759
51aa6c6b66f7
Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7609
diff
changeset
|
1465 | dlg.exec() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1466 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1467 | @pyqtSlot() |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1468 | def __compileFile2Mpy(self): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1469 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1470 | Private slot to cross compile a Python file (*.py) to a .mpy file. |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1471 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1472 | self.__crossCompile(title=self.tr("Compile Python File")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1473 | |
7140
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1474 | @pyqtSlot() |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1475 | def __compileEditor2Mpy(self): |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1476 | """ |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1477 | Private slot to cross compile the current editor to a .mpy file. |
22f5fd76c10f
MicroPythonWidget: added menu entries to cross compile a selectable Python file or the current editor to a .mpy file.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7139
diff
changeset
|
1478 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1479 | aw = ericApp().getObject("ViewManager").activeWindow() |
10512 | 1480 | if aw: |
1481 | if not aw.checkDirty(): | |
1482 | # editor still has unsaved changes, abort... | |
1483 | return | |
1484 | ||
1485 | if not aw.isPyFile(): | |
1486 | # no Python file | |
1487 | EricMessageBox.critical( | |
1488 | self, | |
1489 | self.tr("Compile Current Editor"), | |
1490 | self.tr( | |
1491 | """The current editor does not contain a Python""" | |
1492 | """ file. Aborting...""" | |
1493 | ), | |
1494 | ) | |
1495 | return | |
1496 | ||
1497 | self.__crossCompile( | |
1498 | pythonFile=aw.getFileName(), title=self.tr("Compile Current Editor") | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1499 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1500 | |
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:
7150
diff
changeset
|
1501 | @pyqtSlot() |
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:
7150
diff
changeset
|
1502 | def __showDocumentation(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:
7150
diff
changeset
|
1503 | """ |
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:
7150
diff
changeset
|
1504 | Private slot to open the documentation URL for the selected 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:
7150
diff
changeset
|
1505 | """ |
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:
7150
diff
changeset
|
1506 | if self.__device is None or not self.__device.hasDocumentationUrl(): |
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:
7150
diff
changeset
|
1507 | # abort silently |
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:
7150
diff
changeset
|
1508 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1509 | |
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:
7150
diff
changeset
|
1510 | url = self.__device.getDocumentationUrl() |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1511 | ericApp().getObject("UserInterface").launchHelpViewer(url) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1512 | |
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:
7150
diff
changeset
|
1513 | @pyqtSlot() |
7328 | 1514 | def __downloadFirmware(self): |
1515 | """ | |
1516 | Private slot to open the firmware download page. | |
1517 | """ | |
1518 | if self.__device is None or not self.__device.hasFirmwareUrl(): | |
1519 | # abort silently | |
1520 | return | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1521 | |
8038
73ec029d4107
MicroPython: improved the support for "BBC micro:bit" and "Calliope mini".
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8024
diff
changeset
|
1522 | self.__device.downloadFirmware() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1523 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1524 | def __downloadFromUrl(self, url): |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1525 | """ |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1526 | Private method to open a web browser for the given URL. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1527 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1528 | @param url URL to be opened |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1529 | @type str |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1530 | """ |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1531 | if self.__device is None: |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1532 | # abort silently |
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1533 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1534 | |
8051
b78279548993
MicroPython: changed the handling of the download stuff and corrected/extended the Calliope mini path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8038
diff
changeset
|
1535 | if url: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1536 | ericApp().getObject("UserInterface").launchHelpViewer(url) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1537 | |
7328 | 1538 | @pyqtSlot() |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1539 | def __manageIgnored(self): |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1540 | """ |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1541 | Private slot to manage the list of ignored serial devices. |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1542 | """ |
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1543 | from .IgnoredDevicesDialog import IgnoredDevicesDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1544 | |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1545 | dlg = IgnoredDevicesDialog( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1546 | Preferences.getMicroPython("IgnoredUnknownDevices"), self |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1547 | ) |
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:
8139
diff
changeset
|
1548 | if dlg.exec() == QDialog.DialogCode.Accepted: |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1549 | ignoredDevices = dlg.getDevices() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1550 | Preferences.setMicroPython("IgnoredUnknownDevices", ignoredDevices) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1551 | |
7592
f79dc58bdf62
MicroPython: added a dialog zo ignore unknown serial devices and to manage this list.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7588
diff
changeset
|
1552 | @pyqtSlot() |
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:
7150
diff
changeset
|
1553 | def __configure(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:
7150
diff
changeset
|
1554 | """ |
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:
7150
diff
changeset
|
1555 | Private slot to open the MicroPython configuration page. |
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:
7150
diff
changeset
|
1556 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1557 | ericApp().getObject("UserInterface").showPreferences("microPythonPage") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1558 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1559 | @pyqtSlot() |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1560 | def __manageUnknownDevices(self): |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1561 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1562 | Private slot to manage manually added boards (i.e. those not in the |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1563 | list of supported boards). |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1564 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1565 | from .UnknownDevicesDialog import UnknownDevicesDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1566 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1567 | dlg = UnknownDevicesDialog() |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1568 | dlg.exec() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1569 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1570 | def __addUnknownDevices(self, devices): |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1571 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1572 | Private method to add devices to the list of manually added boards. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1573 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1574 | @param devices list of not ignored but unknown devices |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1575 | @type list of tuple of (int, int, str) |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1576 | """ |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1577 | from .AddEditDevicesDialog import AddEditDevicesDialog |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1578 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1579 | if len(devices) > 1: |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8343
diff
changeset
|
1580 | sdlg = EricListSelectionDialog( |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1581 | [d[2] for d in devices], |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1582 | title=self.tr("Add Unknown Devices"), |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1583 | message=self.tr("Select the devices to be added:"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1584 | checkBoxSelection=True, |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1585 | ) |
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:
8139
diff
changeset
|
1586 | if sdlg.exec() == QDialog.DialogCode.Accepted: |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1587 | selectedDevices = sdlg.getSelection() |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1588 | else: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1589 | selectedDevices = devices[0][2] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1590 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1591 | if selectedDevices: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1592 | manualDevices = Preferences.getMicroPython("ManualDevices") |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1593 | for vid, pid, description in devices: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1594 | if description in selectedDevices: |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1595 | dlg = AddEditDevicesDialog(vid, pid, description) |
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:
8139
diff
changeset
|
1596 | if dlg.exec() == QDialog.DialogCode.Accepted: |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1597 | manualDevices.append(dlg.getDeviceDict()) |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1598 | Preferences.setMicroPython("ManualDevices", manualDevices) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1599 | |
8079
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1600 | # rescan the ports |
331e717c458e
MicroPython: added capability to manually configure devices not yet known by eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8072
diff
changeset
|
1601 | self.__populateDeviceTypeComboBox() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1602 | |
8096 | 1603 | @pyqtSlot() |
1604 | def __flashUF2(self): | |
1605 | """ | |
1606 | Private slot to flash MicroPython/CircuitPython to a device | |
1607 | support the UF2 bootloader. | |
1608 | """ | |
1609 | dlg = UF2FlashDialog.UF2FlashDialog() | |
1610 | dlg.exec() | |
9748 | 1611 | |
1612 | @pyqtSlot() | |
9915 | 1613 | def __convertToUF2(self): |
1614 | """ | |
1615 | Private slot to convert a non-UF2 MicroPython firmware file to UF2. | |
1616 | """ | |
1617 | dlg = ConvertToUF2Dialog.ConvertToUF2Dialog() | |
1618 | dlg.exec() | |
1619 | ||
1620 | @pyqtSlot() | |
9748 | 1621 | def __showBuiltinModules(self): |
1622 | """ | |
1623 | Private slot to show a list of builtin modules. | |
1624 | """ | |
1625 | from .ShowModulesDialog import ShowModulesDialog | |
1626 | ||
1627 | if self.__connected: | |
9749 | 1628 | try: |
9765
6378da868bb0
Reorganized the MicroPython code even more.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9763
diff
changeset
|
1629 | moduleNames = self.__device.getModules() |
9749 | 1630 | dlg = ShowModulesDialog( |
1631 | moduleNames, | |
1632 | info=self.tr("Plus any modules on the filesystem."), | |
1633 | parent=self, | |
1634 | ) | |
1635 | dlg.show() | |
1636 | except Exception as exc: | |
9787
163511257f24
Continued implementing WiFi functionality for RP2040 based devices (show connected stations, save/remove credentials, boot script for Pico W).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9776
diff
changeset
|
1637 | self.showError("getModules()", str(exc)) |
9844 | 1638 | |
1639 | @pyqtSlot() | |
1640 | def __installPackage(self, method): | |
1641 | """ | |
1642 | Private slot to install packages using the given method. | |
1643 | ||
1644 | @param method package management method to be used (one of 'upip' or 'mip') | |
1645 | @type str | |
9847
d8c7ded575cb
Corrected some code style and formatting issues and regenerated the source documentation accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9844
diff
changeset
|
1646 | @exception ValueError raised to indicate an unsupported package management |
d8c7ded575cb
Corrected some code style and formatting issues and regenerated the source documentation accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9844
diff
changeset
|
1647 | method |
9844 | 1648 | """ |
9979 | 1649 | from .MipLocalInstaller import MipLocalInstaller |
9844 | 1650 | from .MipPackageDialog import MipPackageDialog |
1651 | ||
9979 | 1652 | if method not in ("local_mip", "mip", "upip"): |
9844 | 1653 | raise ValueError( |
9979 | 1654 | "Unsupported method given. Expected 'local_mip', 'mip' or 'upip' but" |
1655 | " got {0}." | |
9844 | 1656 | ).format(method) |
1657 | ||
9979 | 1658 | if method in ("local_mip", "mip"): |
9844 | 1659 | title = self.tr("Install Package") |
1660 | dlg = MipPackageDialog(self) | |
1661 | if dlg.exec() == QDialog.DialogCode.Accepted: | |
9979 | 1662 | package, version, mpy, target, index = dlg.getData() |
1663 | if method == "mip": | |
1664 | with EricOverrideCursor(): | |
1665 | out, err = self.__device.mipInstall( | |
1666 | package, | |
1667 | index=index, | |
1668 | target=target, | |
1669 | version=version, | |
1670 | mpy=mpy, | |
1671 | ) | |
1672 | else: | |
1673 | installer = MipLocalInstaller(self.__device) | |
1674 | with EricOverrideCursor(): | |
1675 | ok = installer.installPackage( | |
1676 | package, | |
1677 | index=index, | |
1678 | target=target, | |
1679 | version=version, | |
1680 | mpy=mpy, | |
1681 | ) | |
1682 | if ok: | |
1683 | out = ( | |
1684 | self.tr("Package '{0}' was installed successfully.") | |
1685 | .format(package) | |
1686 | .encode("utf-8") | |
1687 | ) | |
1688 | err = b"" | |
1689 | else: | |
1690 | out = b"" | |
1691 | err = installer.errorString().encode("utf-8") | |
9895 | 1692 | else: |
1693 | return | |
9844 | 1694 | elif method == "upip": |
1695 | title = self.tr("Install Packages") | |
1696 | packagesStr, ok = QInputDialog.getText( | |
1697 | self, | |
1698 | self.tr("Install Packages"), | |
1699 | self.tr("Enter the packages to be installed separated by whitespace:"), | |
1700 | QLineEdit.EchoMode.Normal, | |
1701 | ) | |
1702 | if ok and packagesStr: | |
1703 | packages = packagesStr.split() | |
1704 | with EricOverrideCursor(): | |
1705 | out, err = self.__device.upipInstall(packages) | |
1706 | else: | |
1707 | return | |
1708 | else: | |
1709 | return | |
1710 | ||
1711 | if err: | |
1712 | self.showError(title, err.decode("utf-8")) | |
1713 | if out: | |
1714 | dlg = EricPlainTextDialog( | |
1715 | title=title, text=out.decode("utf-8"), parent=self | |
1716 | ) | |
1717 | dlg.exec() |