eric6/MicroPython/MicrobitDevices.py

changeset 8117
aaa5e0eacd4e
parent 8096
5425a9072300
child 8143
2c730d5fd177
equal deleted inserted replaced
8116:ef415e4efd70 8117:aaa5e0eacd4e
37 @param deviceType type of the device 37 @param deviceType type of the device
38 @type str 38 @type str
39 @param parent reference to the parent object 39 @param parent reference to the parent object
40 @type QObject 40 @type QObject
41 """ 41 """
42 super(MicrobitDevice, self).__init__(microPythonWidget, parent) 42 super(MicrobitDevice, self).__init__(
43 43 microPythonWidget, deviceType, parent)
44 self.__deviceType = deviceType
45 44
46 def setButtons(self): 45 def setButtons(self):
47 """ 46 """
48 Public method to enable the supported action buttons. 47 Public method to enable the supported action buttons.
49 """ 48 """
66 Public method to get the name of the device. 65 Public method to get the name of the device.
67 66
68 @return name of the device 67 @return name of the device
69 @rtype str 68 @rtype str
70 """ 69 """
71 if self.__deviceType == "bbc_microbit": 70 if self.getDeviceType() == "bbc_microbit":
72 # BBC micro:bit 71 # BBC micro:bit
73 return self.tr("BBC micro:bit") 72 return self.tr("BBC micro:bit")
74 else: 73 else:
75 # Calliope mini 74 # Calliope mini
76 return self.tr("Calliope mini") 75 return self.tr("Calliope mini")
185 @type bool 184 @type bool
186 """ 185 """
187 # Attempts to find the path on the file system that represents the 186 # Attempts to find the path on the file system that represents the
188 # plugged in micro:bit board. To flash the DAPLink firmware, it must be 187 # plugged in micro:bit board. To flash the DAPLink firmware, it must be
189 # in maintenance mode, for MicroPython in standard mode. 188 # in maintenance mode, for MicroPython in standard mode.
190 if self.__deviceType == "bbc_microbit": 189 if self.getDeviceType() == "bbc_microbit":
191 # BBC micro:bit 190 # BBC micro:bit
192 if firmware: 191 if firmware:
193 deviceDirectories = Utilities.findVolume("MAINTENANCE", 192 deviceDirectories = Utilities.findVolume("MAINTENANCE",
194 findAll=True) 193 findAll=True)
195 else: 194 else:
202 findAll=True) 201 findAll=True)
203 else: 202 else:
204 deviceDirectories = Utilities.findVolume("MINI", 203 deviceDirectories = Utilities.findVolume("MINI",
205 findAll=True) 204 findAll=True)
206 if len(deviceDirectories) == 0: 205 if len(deviceDirectories) == 0:
207 if self.__deviceType == "bbc_microbit": 206 if self.getDeviceType() == "bbc_microbit":
208 # BBC micro:bit is not ready or not mounted 207 # BBC micro:bit is not ready or not mounted
209 if firmware: 208 if firmware:
210 E5MessageBox.critical( 209 E5MessageBox.critical(
211 self.microPython, 210 self.microPython,
212 self.tr("Flash MicroPython/Firmware"), 211 self.tr("Flash MicroPython/Firmware"),
364 @pyqtSlot() 363 @pyqtSlot()
365 def __resetDevice(self): 364 def __resetDevice(self):
366 """ 365 """
367 Private slot to reset the connected device. 366 Private slot to reset the connected device.
368 """ 367 """
369 if self.__deviceType == "bbc_microbit": 368 if self.getDeviceType() == "bbc_microbit":
370 # BBC micro:bit 369 # BBC micro:bit
371 self.microPython.commandsInterface().execute([ 370 self.microPython.commandsInterface().execute([
372 "import microbit", 371 "import microbit",
373 "microbit.reset()", 372 "microbit.reset()",
374 ]) 373 ])
384 Public method to get the device documentation URL. 383 Public method to get the device documentation URL.
385 384
386 @return documentation URL of the device 385 @return documentation URL of the device
387 @rtype str 386 @rtype str
388 """ 387 """
389 if self.__deviceType == "bbc_microbit": 388 if self.getDeviceType() == "bbc_microbit":
390 # BBC micro:bit 389 # BBC micro:bit
391 return Preferences.getMicroPython("MicrobitDocuUrl") 390 return Preferences.getMicroPython("MicrobitDocuUrl")
392 else: 391 else:
393 # Calliope mini 392 # Calliope mini
394 return Preferences.getMicroPython("CalliopeDocuUrl") 393 return Preferences.getMicroPython("CalliopeDocuUrl")
399 398
400 @return list of tuples with menu text and URL to be opened for each 399 @return list of tuples with menu text and URL to be opened for each
401 entry 400 entry
402 @rtype list of tuple of (str, str) 401 @rtype list of tuple of (str, str)
403 """ 402 """
404 if self.__deviceType == "bbc_microbit": 403 if self.getDeviceType() == "bbc_microbit":
405 return [ 404 return [
406 (self.tr("MicroPython Firmware for BBC micro:bit V1"), 405 (self.tr("MicroPython Firmware for BBC micro:bit V1"),
407 Preferences.getMicroPython("MicrobitMicroPythonUrl")), 406 Preferences.getMicroPython("MicrobitMicroPythonUrl")),
408 (self.tr("MicroPython Firmware for BBC micro:bit V2"), 407 (self.tr("MicroPython Firmware for BBC micro:bit V2"),
409 Preferences.getMicroPython("MicrobitV2MicroPythonUrl")), 408 Preferences.getMicroPython("MicrobitV2MicroPythonUrl")),

eric ide

mercurial