eric6/MicroPython/MicroPythonDevices.py

changeset 8082
2242a6a1d786
parent 8079
331e717c458e
child 8084
7742e0b96629
--- a/eric6/MicroPython/MicroPythonDevices.py	Sat Feb 06 19:18:22 2021 +0100
+++ b/eric6/MicroPython/MicroPythonDevices.py	Sat Feb 06 19:22:22 2021 +0100
@@ -60,8 +60,7 @@
             (0x1B4F, 0x0016),       # Sparkfun Thing Plus - SAMD51
             (0x1B4F, 0x8D22),       # SparkFun SAMD21 Mini Breakout
             (0x1B4F, 0x8D23),       # SparkFun SAMD21 Dev Breakout
-# TODO: re-enable after testing is done
-#            (0x1B4F, 0x8D24),       # SparkFun Qwiic Micro
+            (0x1B4F, 0x8D24),       # SparkFun Qwiic Micro
             (0x1D50, 0x60E8),       # PewPew Game Console
             (0x2341, 0x8057),       # Arduino Nano 33 IoT board
             (0x2886, 0x002F),       # Seeed XIAO
@@ -172,21 +171,27 @@
                         SupportedBoards[board]["port_description"]
                     ):
                         continue
-                foundDevices.append(
-                    (board,
-                     port.description(),
-                     SupportedBoards[board]["description"],
-                     port.portName()))
+                foundDevices.append((
+                    board,
+                    port.description(),
+                    SupportedBoards[board]["description"],
+                    port.portName(),
+                    vid,
+                    pid,
+                ))
                 supported = True
         if not supported:
             # check the locally added ones next
             if (vid, pid) in manualDevices:
                 board = manualDevices[(vid, pid)]["type"]
-                foundDevices.append(
-                    (board,
-                     port.description(),
-                     SupportedBoards[board]["description"],
-                     port.portName()))
+                foundDevices.append((
+                    board,
+                    port.description(),
+                    SupportedBoards[board]["description"],
+                    port.portName(),
+                    vid,
+                    pid,
+                ))
                 supported = True
         if not supported:
             if vid and pid and (vid, pid) not in IgnoredBoards:
@@ -221,7 +226,7 @@
         return UI.PixmapCache.getPixmap(iconName)
 
 
-def getDevice(deviceType, microPythonWidget):
+def getDevice(deviceType, microPythonWidget, vid, pid):
     """
     Public method to instantiate a specific MicroPython device interface.
     
@@ -229,10 +234,13 @@
     @type str
     @param microPythonWidget reference to the main MicroPython widget
     @type MicroPythonWidget
+    @param vid vendor ID (only used for deviceType 'generic')
+    @type int
+    @param pid product ID (only used for deviceType 'generic')
+    @type int
     @return instantiated device interface
     @rtype MicroPythonDevice
     """
-    # TODO: use vid, pid for 'generic' type
     if deviceType == "esp":
         from .EspDevices import EspDevice
         return EspDevice(microPythonWidget)
@@ -245,6 +253,9 @@
     elif deviceType == "pyboard":
         from .PyBoardDevices import PyBoardDevice
         return PyBoardDevice(microPythonWidget)
+    elif deviceType == "generic":
+        from .GenericMicroPythonDevices import GenericMicroPythonDevice
+        return GenericMicroPythonDevice(microPythonWidget, vid, pid)
     else:
         # nothing specific requested
         return MicroPythonDevice(microPythonWidget)
@@ -254,8 +265,6 @@
     """
     Base class for the more specific MicroPython devices.
     """
-    # TODO: use vid, pid for 'generic' type
-    # TODO: check, if this is a direct access device
     def __init__(self, microPythonWidget, parent=None):
         """
         Constructor
@@ -380,7 +389,6 @@
         @return flag indicating file access via local directory
         @rtype bool
         """
-        # TODO: check 'unknown devices' with type 'generic'
         return False        # default
     
     def getWorkspace(self):
@@ -390,7 +398,6 @@
         @return workspace directory used for saving files
         @rtype str
         """
-        # TODO: check 'unknown devices' with type 'generic'
         return (
             Preferences.getMicroPython("MpyWorkspace") or
             Preferences.getMultiProject("Workspace") or

eric ide

mercurial