37 Class implementing the device for CircuitPython boards. |
37 Class implementing the device for CircuitPython boards. |
38 """ |
38 """ |
39 |
39 |
40 DeviceVolumeName = "CIRCUITPY" |
40 DeviceVolumeName = "CIRCUITPY" |
41 |
41 |
42 def __init__(self, microPythonWidget, deviceType, boardName, parent=None): |
42 def __init__( |
|
43 self, microPythonWidget, deviceType, boardName, hasWorkspace=True, parent=None |
|
44 ): |
43 """ |
45 """ |
44 Constructor |
46 Constructor |
45 |
47 |
46 @param microPythonWidget reference to the main MicroPython widget |
48 @param microPythonWidget reference to the main MicroPython widget |
47 @type MicroPythonWidget |
49 @type MicroPythonWidget |
48 @param deviceType device type assigned to this device interface |
50 @param deviceType device type assigned to this device interface |
49 @type str |
51 @type str |
50 @param boardName name of the board |
52 @param boardName name of the board |
51 @type str |
53 @type str |
|
54 @param hasWorkspace flag indicating that the devices supports access via |
|
55 a mounted volume (defaults to True) |
|
56 @type bool (optional) |
52 @param parent reference to the parent object |
57 @param parent reference to the parent object |
53 @type QObject |
58 @type QObject |
54 """ |
59 """ |
55 super().__init__(microPythonWidget, deviceType, parent) |
60 super().__init__(microPythonWidget, deviceType, parent) |
56 |
61 |
57 self._submitMode = "paste" # use 'paste' mode to avoid loosing state |
62 self._submitMode = "paste" # use 'paste' mode to avoid loosing state |
58 |
63 |
59 self.__boardName = boardName |
64 self.__boardName = boardName |
60 self.__workspace = self.__findWorkspace() |
65 |
|
66 self.__workspace = ( |
|
67 self.__findWorkspace() if hasWorkspace else None |
|
68 ) |
61 |
69 |
62 self.__updater = CircuitPythonUpdaterInterface(self) |
70 self.__updater = CircuitPythonUpdaterInterface(self) |
63 |
71 |
64 self.__createCPyMenu() |
72 self.__createCPyMenu() |
65 |
73 |
298 |
306 |
299 self.__flashMenu = self.__createFlashMenus() |
307 self.__flashMenu = self.__createFlashMenus() |
300 |
308 |
301 self.__cpyMenu = QMenu(self.tr("CircuitPython Functions")) |
309 self.__cpyMenu = QMenu(self.tr("CircuitPython Functions")) |
302 self.__cpyMenu.addAction( |
310 self.__cpyMenu.addAction( |
303 self.tr("Show CircuitPython Versions"), self.__showCircuitPythonVersions |
311 self.tr("Show CircuitPython Versions"), self.showCircuitPythonVersions |
304 ) |
312 ) |
305 self.__cpyMenu.addSeparator() |
313 self.__cpyMenu.addSeparator() |
306 self.__flashCpyAct = self.__cpyMenu.addMenu(self.__flashMenu) |
314 self.__flashCpyAct = self.__cpyMenu.addMenu(self.__flashMenu) |
307 self.__cpyMenu.addSeparator() |
315 self.__cpyMenu.addSeparator() |
308 self.__cpyMenu.addMenu(self.__libraryMenu) |
316 self.__cpyMenu.addMenu(self.__libraryMenu) |
471 from .EspDevices import flashAddonFirmware |
479 from .EspDevices import flashAddonFirmware |
472 |
480 |
473 flashAddonFirmware(self.microPython.getCurrentPort()) |
481 flashAddonFirmware(self.microPython.getCurrentPort()) |
474 |
482 |
475 @pyqtSlot() |
483 @pyqtSlot() |
476 def __showCircuitPythonVersions(self): |
484 def showCircuitPythonVersions(self): |
477 """ |
485 """ |
478 Private slot to show the CircuitPython version of a connected device and |
486 Public slot to show the CircuitPython version of a connected device and |
479 the latest available one (from Github). |
487 the latest available one (from Github). |
480 """ |
488 """ |
481 ui = ericApp().getObject("UserInterface") |
489 ui = ericApp().getObject("UserInterface") |
482 request = QNetworkRequest(QUrl(FirmwareGithubUrls["circuitpython"])) |
490 request = QNetworkRequest(QUrl(FirmwareGithubUrls["circuitpython"])) |
483 reply = ui.networkAccessManager().head(request) |
491 reply = ui.networkAccessManager().head(request) |