26 from E5Gui.E5OverrideCursor import E5OverrideCursor, E5OverridenCursor |
26 from E5Gui.E5OverrideCursor import E5OverrideCursor, E5OverridenCursor |
27 |
27 |
28 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
28 from .Ui_MicroPythonWidget import Ui_MicroPythonWidget |
29 |
29 |
30 from . import MicroPythonDevices |
30 from . import MicroPythonDevices |
|
31 from . import UF2FlashDialog |
31 try: |
32 try: |
32 from .MicroPythonGraphWidget import MicroPythonGraphWidget |
33 from .MicroPythonGraphWidget import MicroPythonGraphWidget |
33 HAS_QTCHART = True |
34 HAS_QTCHART = True |
34 except ImportError: |
35 except ImportError: |
35 HAS_QTCHART = False |
36 HAS_QTCHART = False |
176 17: QBrush(QColor(255, 255, 255)), |
177 17: QBrush(QColor(255, 255, 255)), |
177 }, |
178 }, |
178 } |
179 } |
179 |
180 |
180 |
181 |
181 # TODO: extract UF2 flashing support into a general MPy functionality with own |
|
182 # vid/pid list |
|
183 class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
182 class MicroPythonWidget(QWidget, Ui_MicroPythonWidget): |
184 """ |
183 """ |
185 Class implementing the MicroPython REPL widget. |
184 Class implementing the MicroPython REPL widget. |
186 |
185 |
187 @signal dataReceived(data) emitted to send data received via the serial |
186 @signal dataReceived(data) emitted to send data received via the serial |
345 if unknownDevices: |
344 if unknownDevices: |
346 ignoredUnknown = { |
345 ignoredUnknown = { |
347 tuple(d) |
346 tuple(d) |
348 for d in Preferences.getMicroPython("IgnoredUnknownDevices") |
347 for d in Preferences.getMicroPython("IgnoredUnknownDevices") |
349 } |
348 } |
350 newUnknownDevices = set(unknownDevices) - ignoredUnknown |
349 uf2Devices = {(*x[2], x[1]) for x in UF2FlashDialog.getFoundDevices()} |
|
350 newUnknownDevices = ( |
|
351 set(unknownDevices) - ignoredUnknown - uf2Devices |
|
352 ) |
351 if newUnknownDevices: |
353 if newUnknownDevices: |
352 button = E5MessageBox.information( |
354 button = E5MessageBox.information( |
353 self, |
355 self, |
354 self.tr("Unknown MicroPython Device"), |
356 self.tr("Unknown MicroPython Device"), |
355 self.tr( |
357 self.tr( |
1280 self.__superMenu.addMenu(downloadMenu) |
1282 self.__superMenu.addMenu(downloadMenu) |
1281 self.__superMenu.addSeparator() |
1283 self.__superMenu.addSeparator() |
1282 act = self.__superMenu.addAction( |
1284 act = self.__superMenu.addAction( |
1283 self.tr("Show Documentation"), self.__showDocumentation) |
1285 self.tr("Show Documentation"), self.__showDocumentation) |
1284 act.setEnabled(self.__device.hasDocumentationUrl()) |
1286 act.setEnabled(self.__device.hasDocumentationUrl()) |
1285 self.__superMenu.addSeparator() |
1287 self.__superMenu.addSeparator() |
|
1288 if not self.__device.hasFlashMenuEntry(): |
|
1289 self.__superMenu.addAction(self.tr("Flash UF2 Device"), |
|
1290 self.__flashUF2) |
|
1291 self.__superMenu.addSeparator() |
1286 self.__superMenu.addAction(self.tr("Manage Unknown Devices"), |
1292 self.__superMenu.addAction(self.tr("Manage Unknown Devices"), |
1287 self.__manageUnknownDevices) |
1293 self.__manageUnknownDevices) |
1288 self.__superMenu.addAction(self.tr("Ignored Serial Devices"), |
1294 self.__superMenu.addAction(self.tr("Ignored Serial Devices"), |
1289 self.__manageIgnored) |
1295 self.__manageIgnored) |
1290 self.__superMenu.addSeparator() |
1296 self.__superMenu.addSeparator() |
1704 manualDevices.append(dlg.getDeviceDict()) |
1710 manualDevices.append(dlg.getDeviceDict()) |
1705 Preferences.setMicroPython("ManualDevices", manualDevices) |
1711 Preferences.setMicroPython("ManualDevices", manualDevices) |
1706 |
1712 |
1707 # rescan the ports |
1713 # rescan the ports |
1708 self.__populateDeviceTypeComboBox() |
1714 self.__populateDeviceTypeComboBox() |
|
1715 |
|
1716 @pyqtSlot() |
|
1717 def __flashUF2(self): |
|
1718 """ |
|
1719 Private slot to flash MicroPython/CircuitPython to a device |
|
1720 support the UF2 bootloader. |
|
1721 """ |
|
1722 dlg = UF2FlashDialog.UF2FlashDialog() |
|
1723 dlg.exec() |