--- a/eric6/MicroPython/MicrobitDevices.py Thu Apr 23 18:50:54 2020 +0200 +++ b/eric6/MicroPython/MicrobitDevices.py Thu Apr 23 19:48:12 2020 +0200 @@ -69,8 +69,12 @@ @return name of the device @rtype str """ - # TODO: extend this to support Calliope mini - return self.tr("BBC micro:bit") + if self.__deviceType == "bbc_microbit": + # BBC micro:bit + return self.tr("BBC micro:bit") + else: + # Calliope mini + return self.tr("Calliope mini") def canStartRepl(self): """ @@ -129,22 +133,25 @@ @return workspace directory used for saving files @rtype str """ - # TODO: extend this to support Calliope mini # Attempts to find the path on the filesystem that represents the - # plugged in MICROBIT board. - deviceDirectory = Utilities.findVolume("MICROBIT") + # plugged in MICROBIT or MINI board. + if self.__deviceType == "bbc_microbit": + # BBC micro:bit + deviceDirectory = Utilities.findVolume("MICROBIT") + else: + # Calliope mini + deviceDirectory = Utilities.findVolume("MINI") if deviceDirectory: return deviceDirectory else: # return the default workspace and give the user a warning - # TODO: extend this to support Calliope mini E5MessageBox.warning( self.microPython, self.tr("Workspace Directory"), - self.tr("Could not find an attached BBC micro:bit.\n\n" + self.tr("Could not find an attached {0}.\n\n" "Please make sure the device is plugged " - "into this computer.")) + "into this computer.").format(self.deviceName())) return super(MicrobitDevice, self).getWorkspace() @@ -194,23 +201,41 @@ # plugged in micro:bit board in maintenance mode. deviceDirectory = Utilities.findVolume("MAINTENANCE") if not deviceDirectory: - # TODO: extend this to support Calliope mini - # BBC micro:bit is not ready or not mounted - E5MessageBox.critical( - self.microPython, - self.tr("Flash MicroPython Firmware"), - self.tr( - '<p>The BBC micro:bit is not ready for flashing. Follow' - ' these instructions.</p>' - '<ul>' - '<li>unplug USB cable and any batteries</li>' - '<li>keep RESET pressed an plug USB cable back in</li>' - '<li>a drive called MAINTENANCE should be available</li>' - '</ul>' - '<p>See the ' - '<a href="https://microbit.org/guide/firmware/">' - 'micro:bit web site</a> for details.</p>' - )) + if self.__deviceType == "bbc_microbit": + # BBC micro:bit is not ready or not mounted + E5MessageBox.critical( + self.microPython, + self.tr("Flash MicroPython Firmware"), + self.tr( + '<p>The BBC micro:bit is not ready for flashing.' + ' Follow these instructions.</p>' + '<ul>' + '<li>unplug USB cable and any batteries</li>' + '<li>keep RESET button pressed an plug USB cable back' + ' in</li>' + '<li>a drive called MAINTENANCE should be available' + '</li>' + '</ul>' + '<p>See the ' + '<a href="https://microbit.org/guide/firmware/">' + 'micro:bit web site</a> for details.</p>' + )) + else: + # Calliope mini is not ready or not mounted + E5MessageBox.critical( + self.microPython, + self.tr("Flash MicroPython Firmware"), + self.tr( + '<p>The Calliope mini is not ready for flashing.' + ' Follow these instructions.</p>' + '<ul>' + '<li>unplug USB cable and any batteries</li>' + '<li>keep RESET button pressed an plug USB cable back' + ' in</li>' + '<li>a drive called MAINTENANCE should be available' + '</li>' + '</ul>' + )) else: downloadsPath = QStandardPaths.standardLocations( QStandardPaths.DownloadLocation)[0] @@ -302,11 +327,19 @@ """ Private slot to reset the connected device. """ - # TODO: extend this to support Calliope mini - self.microPython.commandsInterface().execute([ - "import microbit", - "microbit.reset()", - ]) + if self.__deviceType == "bbc_microbit": + # BBC micro:bit + self.microPython.commandsInterface().execute([ + "import microbit", + "microbit.reset()", + ]) + else: + # TODO: try this branch with a Calliope mini + # Calliope mini + self.microPython.commandsInterface().execute([ + "import calliope_mini", + "calliope_mini.reset()", + ]) def getDocumentationUrl(self): """