31 FlashInstructionsURL = ( |
31 FlashInstructionsURL = ( |
32 "https://github.com/micropython/micropython/wiki/" |
32 "https://github.com/micropython/micropython/wiki/" |
33 "Pyboard-Firmware-Update" |
33 "Pyboard-Firmware-Update" |
34 ) |
34 ) |
35 |
35 |
36 def __init__(self, microPythonWidget, parent=None): |
36 def __init__(self, microPythonWidget, deviceType, parent=None): |
37 """ |
37 """ |
38 Constructor |
38 Constructor |
39 |
39 |
40 @param microPythonWidget reference to the main MicroPython widget |
40 @param microPythonWidget reference to the main MicroPython widget |
41 @type MicroPythonWidget |
41 @type MicroPythonWidget |
|
42 @param deviceType device type assigned to this device interface |
|
43 @type str |
42 @param parent reference to the parent object |
44 @param parent reference to the parent object |
43 @type QObject |
45 @type QObject |
44 """ |
46 """ |
45 super(PyBoardDevice, self).__init__(microPythonWidget, parent) |
47 super(PyBoardDevice, self).__init__(microPythonWidget, deviceType, |
|
48 parent) |
46 |
49 |
47 self.__workspace = self.__findWorkspace() |
50 self.__workspace = self.__findWorkspace() |
48 |
51 |
49 def setButtons(self): |
52 def setButtons(self): |
50 """ |
53 """ |
223 @param menu reference to the context menu |
226 @param menu reference to the context menu |
224 @type QMenu |
227 @type QMenu |
225 """ |
228 """ |
226 connected = self.microPython.isConnected() |
229 connected = self.microPython.isConnected() |
227 |
230 |
|
231 act = menu.addAction(self.tr("Activate Bootloader"), |
|
232 self.__activateBootloader) |
|
233 act.setEnabled(connected) |
228 act = menu.addAction(self.tr("List DFU-capable Devices"), |
234 act = menu.addAction(self.tr("List DFU-capable Devices"), |
229 self.__listDfuCapableDevices) |
235 self.__listDfuCapableDevices) |
230 act.setEnabled(not connected) |
236 act.setEnabled(not connected) |
231 act = menu.addAction(self.tr("Flash MicroPython Firmware"), |
237 act = menu.addAction(self.tr("Flash MicroPython Firmware"), |
232 self.__flashMicroPython) |
238 self.__flashMicroPython) |
394 ) |
400 ) |
395 res = dlg.startProcess(program, args) |
401 res = dlg.startProcess(program, args) |
396 if res: |
402 if res: |
397 dlg.exec() |
403 dlg.exec() |
398 self.__showDfuDisableInstructions() |
404 self.__showDfuDisableInstructions() |
|
405 |
|
406 @pyqtSlot() |
|
407 def __activateBootloader(self): |
|
408 """ |
|
409 Private slot to activate the bootloader and disconnect. |
|
410 """ |
|
411 if self.microPython.isConnected(): |
|
412 self.microPython.commandsInterface().execute([ |
|
413 "import pyb", |
|
414 "pyb.bootloader()", |
|
415 ]) |
|
416 # simulate pressing the disconnect button |
|
417 self.microPython.on_connectButton_clicked() |