eric6/MicroPython/MicroPythonDevices.py

changeset 8079
331e717c458e
parent 8072
58491f4c99d6
child 8082
2242a6a1d786
--- a/eric6/MicroPython/MicroPythonDevices.py	Sat Feb 06 11:45:58 2021 +0100
+++ b/eric6/MicroPython/MicroPythonDevices.py	Sat Feb 06 16:05:27 2021 +0100
@@ -11,7 +11,7 @@
 import logging
 import os
 
-from PyQt5.QtCore import pyqtSlot, QObject
+from PyQt5.QtCore import pyqtSlot, QObject, QCoreApplication
 from PyQt5.QtWidgets import QInputDialog
 
 from E5Gui.E5Application import e5App
@@ -33,7 +33,7 @@
             (0x10C4, 0xEA60),       # CP210x
             (0x1A86, 0x7523),       # HL-340
         ],
-        "description": "ESP8266, ESP32",
+        "description": "ESP32, ESP8266",
         "icon": "esp32Device",
         "port_description": "",
     },
@@ -60,6 +60,8 @@
             (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
             (0x1D50, 0x60E8),       # PewPew Game Console
             (0x2341, 0x8057),       # Arduino Nano 33 IoT board
             (0x2886, 0x002F),       # Seeed XIAO
@@ -104,6 +106,15 @@
         "icon": "micropython48",
         "port_description": "",
     },
+    
+    "generic": {
+        # only manually configured devices use this
+        "ids": [],
+        "description": QCoreApplication.translate(
+            "MicroPythonDevice", "Generic Board"),
+        "icon": "micropython48",
+        "port_description": "",
+    },
 }
 
 IgnoredBoards = (
@@ -141,6 +152,10 @@
     foundDevices = []
     unknownDevices = []
     
+    manualDevices = {}
+    for deviceDict in Preferences.getMicroPython("ManualDevices"):
+        manualDevices[(deviceDict["vid"], deviceDict["pid"])] = deviceDict
+    
     availablePorts = QSerialPortInfo.availablePorts()
     for port in availablePorts:
         supported = False
@@ -164,6 +179,16 @@
                      port.portName()))
                 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()))
+                supported = True
+        if not supported:
             if vid and pid and (vid, pid) not in IgnoredBoards:
                 unknownDevices.append((vid, pid, port.description()))
                 logging.debug("Unknown device: (0x%04x:0x%04x %s)",
@@ -207,6 +232,7 @@
     @return instantiated device interface
     @rtype MicroPythonDevice
     """
+    # TODO: use vid, pid for 'generic' type
     if deviceType == "esp":
         from .EspDevices import EspDevice
         return EspDevice(microPythonWidget)
@@ -228,6 +254,8 @@
     """
     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
@@ -352,6 +380,7 @@
         @return flag indicating file access via local directory
         @rtype bool
         """
+        # TODO: check 'unknown devices' with type 'generic'
         return False        # default
     
     def getWorkspace(self):
@@ -361,6 +390,7 @@
         @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