MicroPython: continued implementing support for the "Calliope mini".

Wed, 22 Apr 2020 19:58:01 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 22 Apr 2020 19:58:01 +0200
changeset 7549
fcfbb9e94471
parent 7548
e1c6a2e32a38
child 7550
e91462fd0838

MicroPython: continued implementing support for the "Calliope mini".

eric6/MicroPython/MicroPythonDevices.py file | annotate | diff | comparison | revisions
eric6/MicroPython/MicrobitDevices.py file | annotate | diff | comparison | revisions
--- a/eric6/MicroPython/MicroPythonDevices.py	Tue Apr 21 19:52:43 2020 +0200
+++ b/eric6/MicroPython/MicroPythonDevices.py	Wed Apr 22 19:58:01 2020 +0200
@@ -55,6 +55,14 @@
         "icon": "microbitDevice",
     },
     
+    "calliope": {
+        "ids": [
+            (0x0D28, 0x0204),       # Calliope mini
+        ],
+        "description": "Calliope mini",
+        "icon": "calliope_mini",
+    },
+    
     "pyboard": {
         "ids": [
             (0xF055, 0x9800),       # Pyboard in CDC mode
@@ -63,7 +71,7 @@
         ],
         "description": "PyBoard",
         "icon": "micropython48",
-    }
+    },
 }
 
 
@@ -103,7 +111,6 @@
                 foundDevices.append(
                     (board, SupportedBoards[board]["description"],
                      port.portName()))
-                break
         else:
             logging.debug("Unknown device: (0x%04x:0x%04x)", vid, pid)
     
@@ -151,9 +158,9 @@
     elif deviceType == "circuitpython":
         from .CircuitPythonDevices import CircuitPythonDevice
         return CircuitPythonDevice(microPythonWidget)
-    elif deviceType == "bbc_microbit":
+    elif deviceType in ("bbc_microbit", "calliope"):
         from .MicrobitDevices import MicrobitDevice
-        return MicrobitDevice(microPythonWidget)
+        return MicrobitDevice(microPythonWidget, deviceType)
     elif deviceType == "pyboard":
         from .PyBoardDevices import PyBoardDevice
         return PyBoardDevice(microPythonWidget)
--- 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