Sun, 26 Feb 2023 14:25:39 +0100
MicroPython
- added a 'reset' function to the CircuitPython devices interface
src/eric7/MicroPython/Devices/CircuitPythonDevices.py | file | annotate | diff | comparison | revisions |
--- a/src/eric7/MicroPython/Devices/CircuitPythonDevices.py Sun Feb 26 12:44:03 2023 +0100 +++ b/src/eric7/MicroPython/Devices/CircuitPythonDevices.py Sun Feb 26 14:25:39 2023 +0100 @@ -291,6 +291,10 @@ ) self.__cpyMenu.addSeparator() self.__cpyMenu.addMenu(self.__libraryMenu) + self.__cpyMenu.addSeparator() + self.__resetAct = self.__cpyMenu.addAction( + self.tr("Reset Device"), self.__resetDevice + ) def addDeviceMenuEntries(self, menu): """ @@ -299,9 +303,11 @@ @param menu reference to the context menu @type QMenu """ + connected = self.microPython.isConnected() linkConnected = self.microPython.isLinkConnected() self.__flashCpyAct.setEnabled(not linkConnected) + self.__resetAct.setEnabled(connected) menu.addMenu(self.__cpyMenu) @@ -330,6 +336,16 @@ self.__updater.installCircup, ) + @pyqtSlot() + def __resetDevice(self): + """ + Private slot to reset the connected device. + """ + if self.microPython.isConnected(): + self.microPython.deviceInterface().execute( + "import microcontroller\nmicrocontroller.reset()\n" + ) + def hasFlashMenuEntry(self): """ Public method to check, if the device has its own flash menu entry.