31 (0x0403, 0x6015), # Sparkfun ESP32 |
31 (0x0403, 0x6015), # Sparkfun ESP32 |
32 (0x0403, 0x601C), # FT4222H |
32 (0x0403, 0x601C), # FT4222H |
33 (0x10C4, 0xEA60), # CP210x |
33 (0x10C4, 0xEA60), # CP210x |
34 (0x1A86, 0x7523), # HL-340 |
34 (0x1A86, 0x7523), # HL-340 |
35 ], |
35 ], |
36 "description": "ESP8266, ESP32", |
36 "description": "ESP32, ESP8266", |
37 "icon": "esp32Device", |
37 "icon": "esp32Device", |
38 "port_description": "", |
38 "port_description": "", |
39 }, |
39 }, |
40 |
40 |
41 "circuitpython": { |
41 "circuitpython": { |
58 (0x1209, 0xBAB6), # Electronic Cats Escornabot Makech |
58 (0x1209, 0xBAB6), # Electronic Cats Escornabot Makech |
59 (0x16C0, 0x0486), # PJRC Teensy 4.1 |
59 (0x16C0, 0x0486), # PJRC Teensy 4.1 |
60 (0x1B4F, 0x0016), # Sparkfun Thing Plus - SAMD51 |
60 (0x1B4F, 0x0016), # Sparkfun Thing Plus - SAMD51 |
61 (0x1B4F, 0x8D22), # SparkFun SAMD21 Mini Breakout |
61 (0x1B4F, 0x8D22), # SparkFun SAMD21 Mini Breakout |
62 (0x1B4F, 0x8D23), # SparkFun SAMD21 Dev Breakout |
62 (0x1B4F, 0x8D23), # SparkFun SAMD21 Dev Breakout |
|
63 # TODO: re-enable after testing is done |
|
64 # (0x1B4F, 0x8D24), # SparkFun Qwiic Micro |
63 (0x1D50, 0x60E8), # PewPew Game Console |
65 (0x1D50, 0x60E8), # PewPew Game Console |
64 (0x2341, 0x8057), # Arduino Nano 33 IoT board |
66 (0x2341, 0x8057), # Arduino Nano 33 IoT board |
65 (0x2886, 0x002F), # Seeed XIAO |
67 (0x2886, 0x002F), # Seeed XIAO |
66 (0x2886, 0x802D), # Seeed Wio Terminal |
68 (0x2886, 0x802D), # Seeed Wio Terminal |
67 (0x2886, 0x802F), # Seeed XIAO |
69 (0x2886, 0x802F), # Seeed XIAO |
102 ], |
104 ], |
103 "description": "PyBoard", |
105 "description": "PyBoard", |
104 "icon": "micropython48", |
106 "icon": "micropython48", |
105 "port_description": "", |
107 "port_description": "", |
106 }, |
108 }, |
|
109 |
|
110 "generic": { |
|
111 # only manually configured devices use this |
|
112 "ids": [], |
|
113 "description": QCoreApplication.translate( |
|
114 "MicroPythonDevice", "Generic Board"), |
|
115 "icon": "micropython48", |
|
116 "port_description": "", |
|
117 }, |
107 } |
118 } |
108 |
119 |
109 IgnoredBoards = ( |
120 IgnoredBoards = ( |
110 (0x8086, 0x9c3d), |
121 (0x8086, 0x9c3d), |
111 ) |
122 ) |
138 """ |
149 """ |
139 from PyQt5.QtSerialPort import QSerialPortInfo |
150 from PyQt5.QtSerialPort import QSerialPortInfo |
140 |
151 |
141 foundDevices = [] |
152 foundDevices = [] |
142 unknownDevices = [] |
153 unknownDevices = [] |
|
154 |
|
155 manualDevices = {} |
|
156 for deviceDict in Preferences.getMicroPython("ManualDevices"): |
|
157 manualDevices[(deviceDict["vid"], deviceDict["pid"])] = deviceDict |
143 |
158 |
144 availablePorts = QSerialPortInfo.availablePorts() |
159 availablePorts = QSerialPortInfo.availablePorts() |
145 for port in availablePorts: |
160 for port in availablePorts: |
146 supported = False |
161 supported = False |
147 vid = port.vendorIdentifier() |
162 vid = port.vendorIdentifier() |
162 port.description(), |
177 port.description(), |
163 SupportedBoards[board]["description"], |
178 SupportedBoards[board]["description"], |
164 port.portName())) |
179 port.portName())) |
165 supported = True |
180 supported = True |
166 if not supported: |
181 if not supported: |
|
182 # check the locally added ones next |
|
183 if (vid, pid) in manualDevices: |
|
184 board = manualDevices[(vid, pid)]["type"] |
|
185 foundDevices.append( |
|
186 (board, |
|
187 port.description(), |
|
188 SupportedBoards[board]["description"], |
|
189 port.portName())) |
|
190 supported = True |
|
191 if not supported: |
167 if vid and pid and (vid, pid) not in IgnoredBoards: |
192 if vid and pid and (vid, pid) not in IgnoredBoards: |
168 unknownDevices.append((vid, pid, port.description())) |
193 unknownDevices.append((vid, pid, port.description())) |
169 logging.debug("Unknown device: (0x%04x:0x%04x %s)", |
194 logging.debug("Unknown device: (0x%04x:0x%04x %s)", |
170 vid, pid, port.description()) |
195 vid, pid, port.description()) |
171 |
196 |
205 @param microPythonWidget reference to the main MicroPython widget |
230 @param microPythonWidget reference to the main MicroPython widget |
206 @type MicroPythonWidget |
231 @type MicroPythonWidget |
207 @return instantiated device interface |
232 @return instantiated device interface |
208 @rtype MicroPythonDevice |
233 @rtype MicroPythonDevice |
209 """ |
234 """ |
|
235 # TODO: use vid, pid for 'generic' type |
210 if deviceType == "esp": |
236 if deviceType == "esp": |
211 from .EspDevices import EspDevice |
237 from .EspDevices import EspDevice |
212 return EspDevice(microPythonWidget) |
238 return EspDevice(microPythonWidget) |
213 elif deviceType == "circuitpython": |
239 elif deviceType == "circuitpython": |
214 from .CircuitPythonDevices import CircuitPythonDevice |
240 from .CircuitPythonDevices import CircuitPythonDevice |
226 |
252 |
227 class MicroPythonDevice(QObject): |
253 class MicroPythonDevice(QObject): |
228 """ |
254 """ |
229 Base class for the more specific MicroPython devices. |
255 Base class for the more specific MicroPython devices. |
230 """ |
256 """ |
|
257 # TODO: use vid, pid for 'generic' type |
|
258 # TODO: check, if this is a direct access device |
231 def __init__(self, microPythonWidget, parent=None): |
259 def __init__(self, microPythonWidget, parent=None): |
232 """ |
260 """ |
233 Constructor |
261 Constructor |
234 |
262 |
235 @param microPythonWidget reference to the main MicroPython widget |
263 @param microPythonWidget reference to the main MicroPython widget |
350 Public method to indicate file access via a local directory. |
378 Public method to indicate file access via a local directory. |
351 |
379 |
352 @return flag indicating file access via local directory |
380 @return flag indicating file access via local directory |
353 @rtype bool |
381 @rtype bool |
354 """ |
382 """ |
|
383 # TODO: check 'unknown devices' with type 'generic' |
355 return False # default |
384 return False # default |
356 |
385 |
357 def getWorkspace(self): |
386 def getWorkspace(self): |
358 """ |
387 """ |
359 Public method to get the workspace directory. |
388 Public method to get the workspace directory. |
360 |
389 |
361 @return workspace directory used for saving files |
390 @return workspace directory used for saving files |
362 @rtype str |
391 @rtype str |
363 """ |
392 """ |
|
393 # TODO: check 'unknown devices' with type 'generic' |
364 return ( |
394 return ( |
365 Preferences.getMicroPython("MpyWorkspace") or |
395 Preferences.getMicroPython("MpyWorkspace") or |
366 Preferences.getMultiProject("Workspace") or |
396 Preferences.getMultiProject("Workspace") or |
367 os.path.expanduser("~") |
397 os.path.expanduser("~") |
368 ) |
398 ) |