diff -r fb84d8489bc1 -r bdd583f96e96 eric6/MicroPython/MicroPythonDevices.py --- a/eric6/MicroPython/MicroPythonDevices.py Sun Jul 07 18:48:17 2019 +0200 +++ b/eric6/MicroPython/MicroPythonDevices.py Tue Jul 09 19:49:41 2019 +0200 @@ -23,51 +23,33 @@ "ids": [ (0x1A86, 0x7523), # HL-340 (0x10C4, 0xEA60), # CP210x - (0x0403, 0x6015), # Sparkfun ESP32 VID, PID + (0x0403, 0x6015), # Sparkfun ESP32 ], "description": "ESP8266, ESP32", "icon": "esp32Device", }, - "adafruit": { + "circuitpython": { "ids": [ - (0x239A, 0x8015), # Adafruit Feather M0 CircuitPython - (0x239A, 0x8023), # Adafruit Feather M0 Express CircuitPython - (0x239A, 0x801B), # Adafruit Feather M0 Express CircuitPython - (0x239A, 0x8014), # Adafruit Metro M0 CircuitPython - (0x239A, 0x8019), # Adafruit CircuitPlayground - # Express CircuitPython - (0x239A, 0x801D), # Adafruit Gemma M0 - (0x239A, 0x801F), # Adafruit Trinket M0 - (0x239A, 0x8012), # Adafruit ItsyBitsy M0 - (0x239A, 0x8021), # Adafruit Metro M4 - (0x239A, 0x8025), # Adafruit Feather RadioFruit - (0x239A, 0x8026), # Adafruit Feather M4 - (0x239A, 0x8028), # Adafruit pIRKey M0 - (0x239A, 0x802A), # Adafruit Feather 52840 - (0x239A, 0x802C), # Adafruit Itsy M4 - (0x239A, 0x802E), # Adafruit CRICKit M0 - (0x239A, 0xD1ED), # Adafruit HalloWing M0 - (0x239A, 0x8030), # Adafruit NeoTrellis M4 - (0x239A, 0x8032), # Grand Central (0x2B04, 0xC00C), # Particle Argon (0x2B04, 0xC00D), # Particle Boron (0x2B04, 0xC00E), # Particle Xenon - (0x239A, 0x8034), # future board - (0x239A, 0x8036), # future board - (0x239A, 0x8038), # future board - (0x239A, 0x803A), # future board - (0x239A, 0x803C), # future board - (0x239A, 0x803E), # future board (0x239A, None), # Any Adafruit Boards + (0x1209, 0xBAB1), # Electronic Cats Meow Meow + (0x1209, 0xBAB2), # Electronic Cats CatWAN USBStick + (0x1209, 0xBAB3), # Electronic Cats Bast Pro Mini M0 + (0x1B4F, 0x8D22), # SparkFun SAMD21 Mini Breakout + (0x1B4F, 0x8D23), # SparkFun SAMD21 Dev Breakout + (0x1209, 0x2017), # Mini SAM M4 + (0x1209, 0x7102), # Mini SAM M0 ], - "description": "Adafruit CircuitPython", + "description": "CircuitPython Boards", "icon": "adafruitDevice", }, "bbc_microbit": { "ids": [ - (0x0D28, 0x0204), # micro:bit USB VID, PID + (0x0D28, 0x0204), # micro:bit ], "description": "BBC micro:bit", "icon": "microbitDevice", @@ -142,79 +124,120 @@ return UI.PixmapCache.getPixmap(iconName) -def getDevice(deviceType): +def getDevice(deviceType, microPythonWidget): """ Public method to instantiate a specific MicroPython device interface. @param deviceType type of the device interface @type str + @param microPythonWidget reference to the main MicroPython widget + @type MicroPythonReplWidget @return instantiated device interface @rtype MicroPythonDevice """ # TODO: not implemented yet - return None + return MicroPythonDevice(microPythonWidget) class MicroPythonDevice(QObject): """ Base class for the more specific MicroPython devices. """ - def __init__(self, parent=None): + def __init__(self, microPythonWidget, parent=None): """ Constructor + @param microPythonWidget reference to the main MicroPython widget + @type MicroPythonReplWidget @param parent reference to the parent object @type QObject """ super(MicroPythonDevice, self).__init__(parent) + + self.__microPython = microPythonWidget - def supportedActions(self): + def setButtons(self): """ - Public method to get the names of the supported actions. - - @return tuple of supported actions out of "repl", "run", "files", - "chart" - @rtype tuple of str + Public method to enable the supported action buttons. """ - return tuple() + self.__microPython.setActionButtons( + run=False, repl=False, files=False, chart=False) - def findDevice(self, deviceType): + def forceInterrupt(self): """ - Public method to find the first device of a specific type. + Public method to determine the need for an interrupt when opening the + serial connection. - @param deviceType device type - @type str - @return tuple containing the port the device is connected to and its - serial number - @rtype tuple of (str, str) + @return flag indicating an interrupt is needed + @rtype bool + """ + return True + + def canStartRepl(self): """ - from PyQt5.QtSerialPort import QSerialPortInfo + Public method to determine, if a REPL can be started. + + @return tuple containing a flag indicating it is safe to start a REPL + and a reason why it cannot. + """ + return False, self.tr("Not implemented") + + def setRepl(self, on): + """ + Public method to set the REPL status and dependent status. - availablePorts = QSerialPortInfo.availablePorts() - for port in availablePorts: - vid = port.vendorIdentifier() - pid = port.productIdentifier() - for board in SupportedBoards: - if ((vid, pid) in SupportedBoards[board] or - (vid, None) in SupportedBoards[board]): - portName = port.portName() - serialNumber = port.serialNumber() - return (self.__portPath(portName), serialNumber) + @param on flag indicating the active status + @type bool + """ + return + + def getWorkspace(self): + """ + Public method to get the workspace directory. - return (None, None) - - def __portPath(self, portName): - """ - Private method to get the full path of a given port. - - @param portName name of the port the path shall be determined for - @type str - @return full port path + @return workspace directory used for saving files @rtype str """ - if Globals.isWindowsPlatform(): - # return name unchanged - return portName - else: - # assume Posix system (Linux or macOS) - return "/dev/{0}".format(portName) + return "" + + # TODO: are these needed? +## def findDevice(self, deviceType): +## """ +## Public method to find the first device of a specific type. +## +## @param deviceType device type +## @type str +## @return tuple containing the port the device is connected to and its +## serial number +## @rtype tuple of (str, str) +## """ +## from PyQt5.QtSerialPort import QSerialPortInfo +## +## availablePorts = QSerialPortInfo.availablePorts() +## for port in availablePorts: +## vid = port.vendorIdentifier() +## pid = port.productIdentifier() +## for board in SupportedBoards: +## if ((vid, pid) in SupportedBoards[board] or +## (vid, None) in SupportedBoards[board]): +## portName = port.portName() +## serialNumber = port.serialNumber() +## return (self.__portPath(portName), serialNumber) +## +## return (None, None) +## +## def __portPath(self, portName): +## """ +## Private method to get the full path of a given port. +## +## @param portName name of the port the path shall be determined for +## @type str +## @return full port path +## @rtype str +## """ +## if Globals.isWindowsPlatform(): +## # return name unchanged +## return portName +## else: +## # assume Posix system (Linux or macOS) +## return "/dev/{0}".format(portName)