eric6/MicroPython/MicroPythonDevices.py

changeset 8117
aaa5e0eacd4e
parent 8096
5425a9072300
child 8122
eb85ced7844c
equal deleted inserted replaced
8116:ef415e4efd70 8117:aaa5e0eacd4e
135 "description": "PyBoard", 135 "description": "PyBoard",
136 "icon": "micropython48", 136 "icon": "micropython48",
137 "port_description": "", 137 "port_description": "",
138 }, 138 },
139 139
140 # TODO: add RP2040 boards (VID: 0x2e8a, PID: 0x0005)
140 "generic": { 141 "generic": {
141 # only manually configured devices use this 142 # only manually configured devices use this
142 "ids": [], 143 "ids": [],
143 "description": QCoreApplication.translate( 144 "description": QCoreApplication.translate(
144 "MicroPythonDevice", "Generic Board"), 145 "MicroPythonDevice", "Generic Board"),
277 @return instantiated device interface 278 @return instantiated device interface
278 @rtype MicroPythonDevice 279 @rtype MicroPythonDevice
279 """ 280 """
280 if deviceType == "esp": 281 if deviceType == "esp":
281 from .EspDevices import EspDevice 282 from .EspDevices import EspDevice
282 return EspDevice(microPythonWidget) 283 return EspDevice(microPythonWidget, deviceType)
283 elif deviceType == "circuitpython": 284 elif deviceType == "circuitpython":
284 from .CircuitPythonDevices import CircuitPythonDevice 285 from .CircuitPythonDevices import CircuitPythonDevice
285 return CircuitPythonDevice(microPythonWidget) 286 return CircuitPythonDevice(microPythonWidget, deviceType)
286 elif deviceType in ("bbc_microbit", "calliope"): 287 elif deviceType in ("bbc_microbit", "calliope"):
287 from .MicrobitDevices import MicrobitDevice 288 from .MicrobitDevices import MicrobitDevice
288 return MicrobitDevice(microPythonWidget, deviceType) 289 return MicrobitDevice(microPythonWidget, deviceType)
289 elif deviceType == "pyboard": 290 elif deviceType == "pyboard":
290 from .PyBoardDevices import PyBoardDevice 291 from .PyBoardDevices import PyBoardDevice
291 return PyBoardDevice(microPythonWidget) 292 return PyBoardDevice(microPythonWidget, deviceType)
293 # TODO: add RP2040 boards (VID: 0x2e8a, PID: 0x0005)
292 elif deviceType == "generic": 294 elif deviceType == "generic":
293 from .GenericMicroPythonDevices import GenericMicroPythonDevice 295 from .GenericMicroPythonDevices import GenericMicroPythonDevice
294 return GenericMicroPythonDevice(microPythonWidget, vid, pid) 296 return GenericMicroPythonDevice(microPythonWidget, deviceType,
297 vid, pid)
295 else: 298 else:
296 # nothing specific requested 299 # nothing specific requested
297 return MicroPythonDevice(microPythonWidget) 300 return MicroPythonDevice(microPythonWidget, deviceType)
298 301
299 302
300 class MicroPythonDevice(QObject): 303 class MicroPythonDevice(QObject):
301 """ 304 """
302 Base class for the more specific MicroPython devices. 305 Base class for the more specific MicroPython devices.
303 """ 306 """
304 def __init__(self, microPythonWidget, parent=None): 307 def __init__(self, microPythonWidget, deviceType, parent=None):
305 """ 308 """
306 Constructor 309 Constructor
307 310
308 @param microPythonWidget reference to the main MicroPython widget 311 @param microPythonWidget reference to the main MicroPython widget
309 @type MicroPythonWidget 312 @type MicroPythonWidget
313 @param deviceType device type assigned to this device interface
314 @type str
310 @param parent reference to the parent object 315 @param parent reference to the parent object
311 @type QObject 316 @type QObject
312 """ 317 """
313 super(MicroPythonDevice, self).__init__(parent) 318 super(MicroPythonDevice, self).__init__(parent)
314 319
320 self._deviceType = deviceType
315 self.microPython = microPythonWidget 321 self.microPython = microPythonWidget
322
323 def getDeviceType(self):
324 """
325 Public method to get the device type.
326
327 @return type of the device
328 @rtype str
329 """
330 return self._deviceType
316 331
317 def setButtons(self): 332 def setButtons(self):
318 """ 333 """
319 Public method to enable the supported action buttons. 334 Public method to enable the supported action buttons.
320 """ 335 """

eric ide

mercurial