eric6/MicroPython/MicrobitDevices.py

changeset 7549
fcfbb9e94471
parent 7548
e1c6a2e32a38
child 7551
b159c55ea6dd
--- a/eric6/MicroPython/MicrobitDevices.py	Tue Apr 21 19:52:43 2020 +0200
+++ b/eric6/MicroPython/MicrobitDevices.py	Wed Apr 22 19:58:01 2020 +0200
@@ -4,7 +4,8 @@
 #
 
 """
-Module implementing the device interface class for BBC micro:bit boards.
+Module implementing the device interface class for BBC micro:bit and
+Calliope mini boards.
 """
 
 
@@ -26,18 +27,22 @@
 
 class MicrobitDevice(MicroPythonDevice):
     """
-    Class implementing the device for BBC micro:bit boards.
+    Class implementing the device for BBC micro:bit and Calliope mini boards.
     """
-    def __init__(self, microPythonWidget, parent=None):
+    def __init__(self, microPythonWidget, deviceType, parent=None):
         """
         Constructor
         
         @param microPythonWidget reference to the main MicroPython widget
         @type MicroPythonWidget
+        @param deviceType type of the device
+        @type str
         @param parent reference to the parent object
         @type QObject
         """
         super(MicrobitDevice, self).__init__(microPythonWidget, parent)
+        
+        self.__deviceType = deviceType
     
     def setButtons(self):
         """
@@ -64,6 +69,7 @@
         @return name of the device
         @rtype str
         """
+        # TODO: extend this to support Calliope mini
         return self.tr("BBC micro:bit")
     
     def canStartRepl(self):
@@ -123,6 +129,7 @@
         @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")
@@ -131,6 +138,7 @@
             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"),
@@ -186,6 +194,7 @@
         # 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,
@@ -293,6 +302,7 @@
         """
         Private slot to reset the connected device.
         """
+        # TODO: extend this to support Calliope mini
         self.microPython.commandsInterface().execute([
             "import microbit",
             "microbit.reset()",
@@ -305,7 +315,12 @@
         @return documentation URL of the device
         @rtype str
         """
-        return Preferences.getMicroPython("MicrobitDocuUrl")
+        if self.__deviceType == "bbc_microbit":
+            # BBC micro:bit
+            return Preferences.getMicroPython("MicrobitDocuUrl")
+        else:
+            # Calliope mini
+            return Preferences.getMicroPython("CalliopeDocuUrl")
     
     def getFirmwareUrl(self):
         """
@@ -314,4 +329,9 @@
         @return firmware download URL of the device
         @rtype str
         """
-        return Preferences.getMicroPython("MicrobitFirmwareUrl")
+        if self.__deviceType == "bbc_microbit":
+            # BBC micro:bit
+            return Preferences.getMicroPython("MicrobitFirmwareUrl")
+        else:
+            # Calliope mini
+            return Preferences.getMicroPython("CalliopeFirmwareUrl")

eric ide

mercurial