421 return EricPixmapCache.getIcon(iconName) |
421 return EricPixmapCache.getIcon(iconName) |
422 else: |
422 else: |
423 return EricPixmapCache.getPixmap(iconName) |
423 return EricPixmapCache.getPixmap(iconName) |
424 |
424 |
425 |
425 |
426 def getDevice(deviceType, microPythonWidget, vid, pid): |
426 def getDevice(deviceType, microPythonWidget, vid, pid, boardName=""): |
427 """ |
427 """ |
428 Public method to instantiate a specific MicroPython device interface. |
428 Public method to instantiate a specific MicroPython device interface. |
429 |
429 |
430 @param deviceType type of the device interface |
430 @param deviceType type of the device interface |
431 @type str |
431 @type str |
433 @type MicroPythonWidget |
433 @type MicroPythonWidget |
434 @param vid vendor ID (only used for deviceType 'generic') |
434 @param vid vendor ID (only used for deviceType 'generic') |
435 @type int |
435 @type int |
436 @param pid product ID (only used for deviceType 'generic') |
436 @param pid product ID (only used for deviceType 'generic') |
437 @type int |
437 @type int |
|
438 @param boardName name of the board (defaults to "") |
|
439 @type str (optional) |
438 @return instantiated device interface |
440 @return instantiated device interface |
439 @rtype MicroPythonDevice |
441 @rtype MicroPythonDevice |
440 """ |
442 """ |
441 deviceMapping = { |
443 deviceMapping = { |
442 "bbc_microbit": ".MicrobitDevices", |
444 "bbc_microbit": ".MicrobitDevices", |
449 } |
451 } |
450 |
452 |
451 with contextlib.suppress(KeyError): |
453 with contextlib.suppress(KeyError): |
452 mod = importlib.import_module(deviceMapping[deviceType], __package__) |
454 mod = importlib.import_module(deviceMapping[deviceType], __package__) |
453 if mod: |
455 if mod: |
454 return mod.createDevice(microPythonWidget, deviceType, vid, pid) |
456 return mod.createDevice(microPythonWidget, deviceType, vid, pid, boardName) |
455 |
457 |
456 # nothing specific requested or specific one failed or is not supported yet |
458 # nothing specific requested or specific one failed or is not supported yet |
457 return MicroPythonDevice(microPythonWidget, deviceType) |
459 return MicroPythonDevice(microPythonWidget, deviceType) |
458 |
460 |
459 |
461 |