eric6/MicroPython/MicrobitDevices.py

changeset 8038
73ec029d4107
parent 8032
76375aa6bc04
child 8051
b78279548993
equal deleted inserted replaced
8037:cf0e5b8cd23a 8038:73ec029d4107
10 10
11 import os 11 import os
12 import shutil 12 import shutil
13 13
14 from PyQt5.QtCore import pyqtSlot, QStandardPaths 14 from PyQt5.QtCore import pyqtSlot, QStandardPaths
15 from PyQt5.QtWidgets import QInputDialog, QLineEdit 15 from PyQt5.QtWidgets import QInputDialog, QLineEdit, QDialog
16 16
17 from .MicroPythonDevices import MicroPythonDevice 17 from .MicroPythonDevices import MicroPythonDevice
18 from .MicroPythonWidget import HAS_QTCHART 18 from .MicroPythonWidget import HAS_QTCHART
19 19
20 from E5Gui import E5MessageBox, E5FileDialog 20 from E5Gui import E5MessageBox, E5FileDialog
375 return Preferences.getMicroPython("MicrobitDocuUrl") 375 return Preferences.getMicroPython("MicrobitDocuUrl")
376 else: 376 else:
377 # Calliope mini 377 # Calliope mini
378 return Preferences.getMicroPython("CalliopeDocuUrl") 378 return Preferences.getMicroPython("CalliopeDocuUrl")
379 379
380 def getFirmwareUrl(self): 380 def getFirmwareUrl(self, fwtype="mpy"):
381 """ 381 """
382 Public method to get the device firmware download URL. 382 Public method to get the device firmware download URL.
383 383
384 @param fwtype type of firmware to download
385 (valid values are "mpy" and "dap"; defaults to "mpy")
386 @type str (optional)
384 @return firmware download URL of the device 387 @return firmware download URL of the device
385 @rtype str 388 @rtype str
386 """ 389 """
387 if self.__deviceType == "bbc_microbit": 390 if self.__deviceType == "bbc_microbit":
388 # BBC micro:bit 391 # BBC micro:bit V1
389 return Preferences.getMicroPython("MicrobitFirmwareUrl") 392 if fwtype == "mpy":
393 return Preferences.getMicroPython("MicrobitMicroPythonUrl")
394 elif fwtype == "dap":
395 return Preferences.getMicroPython("MicrobitFirmwareUrl")
396 else:
397 return ""
390 else: 398 else:
391 # Calliope mini 399 # Calliope mini
392 return Preferences.getMicroPython("CalliopeFirmwareUrl") 400 return Preferences.getMicroPython("CalliopeFirmwareUrl")
401
402 def downloadFirmware(self):
403 """
404 Public method to download the device firmware.
405 """
406 fwtype = ""
407 if self.__deviceType == "bbc_microbit":
408 # BBC micro:bit
409 from E5Gui.E5ComboSelectionDialog import E5ComboSelectionDialog
410 dlg = E5ComboSelectionDialog(
411 [(self.tr("MicroPython"), "mpy"), (self.tr("DAPLink"), "dap")],
412 title=self.tr("Firmware Type"),
413 message=self.tr("Select the firmware type to download from"
414 " the list below:")
415 )
416 if dlg.exec() == QDialog.Accepted:
417 fwtype = dlg.getSelection()[1]
418 else:
419 # user cancelled
420 return
421
422 url = self.getFirmwareUrl(fwtype)
423 if url:
424 e5App().getObject("UserInterface").launchHelpViewer(url)

eric ide

mercurial