Mon, 16 Aug 2021 19:44:48 +0200
MicroPython: changed the code slightly to get rid of obsolete methods.
eric6/MicroPython/MicroPythonDevices.py | file | annotate | diff | comparison | revisions | |
eric6/MicroPython/MicroPythonGraphWidget.py | file | annotate | diff | comparison | revisions |
--- a/eric6/MicroPython/MicroPythonDevices.py Fri Jul 30 17:40:58 2021 +0200 +++ b/eric6/MicroPython/MicroPythonDevices.py Mon Aug 16 19:44:48 2021 +0200 @@ -223,27 +223,36 @@ availablePorts = QSerialPortInfo.availablePorts() for port in availablePorts: - supported = False - vid = port.vendorIdentifier() - pid = port.productIdentifier() - - if not port.isValid(): - # no device detected at port - continue - - for board in SupportedBoards: - if ( - (vid, pid) in SupportedBoards[board]["ids"] or - (vid, None) in SupportedBoards[board]["ids"] - ): + if port.hasVendorIdentifier() and port.hasProductIdentifier(): + supported = False + vid = port.vendorIdentifier() + pid = port.productIdentifier() + + for board in SupportedBoards: if ( - board in ("bbc_microbit", "calliope") and - (port.description().strip() != - SupportedBoards[board]["port_description"]) + (vid, pid) in SupportedBoards[board]["ids"] or + (vid, None) in SupportedBoards[board]["ids"] ): - # both boards have the same VID and PID - # try to differentiate based on port description - continue + if ( + board in ("bbc_microbit", "calliope") and + (port.description().strip() != + SupportedBoards[board]["port_description"]) + ): + # both boards have the same VID and PID + # try to differentiate based on port description + continue + foundDevices.append(( + board, + port.description(), + SupportedBoards[board]["description"], + port.portName(), + vid, + pid, + )) + supported = True + if not supported and (vid, pid) in manualDevices: + # check the locally added ones next + board = manualDevices[(vid, pid)]["type"] foundDevices.append(( board, port.description(), @@ -253,31 +262,19 @@ pid, )) supported = True - if not supported and (vid, pid) in manualDevices: - # check the locally added ones next - board = manualDevices[(vid, pid)]["type"] - foundDevices.append(( - board, - port.description(), - SupportedBoards[board]["description"], - port.portName(), - vid, - pid, - )) - supported = True - if not supported: - if vid and pid: - if (vid, pid) not in IgnoredBoards: - unknownDevices.append((vid, pid, port.description())) - logging.debug("Unknown device: (0x%04x:0x%04x %s)", - vid, pid, port.description()) - else: - # either VID or PID or both not detected - desc = port.description() - if not desc: - desc = QCoreApplication.translate("MicroPythonDevice", - "Unknown Device") - unknownPorts.append((vid, pid, desc, port.portName())) + if not supported: + if vid and pid: + if (vid, pid) not in IgnoredBoards: + unknownDevices.append((vid, pid, port.description())) + logging.debug("Unknown device: (0x%04x:0x%04x %s)", + vid, pid, port.description()) + else: + # either VID or PID or both not detected + desc = port.description() + if not desc: + desc = QCoreApplication.translate("MicroPythonDevice", + "Unknown Device") + unknownPorts.append((vid, pid, desc, port.portName())) return foundDevices, unknownDevices, unknownPorts
--- a/eric6/MicroPython/MicroPythonGraphWidget.py Fri Jul 30 17:40:58 2021 +0200 +++ b/eric6/MicroPython/MicroPythonGraphWidget.py Mon Aug 16 19:44:48 2021 +0200 @@ -106,14 +106,19 @@ self.__chart = QChart() self.__chart.legend().hide() self.__chart.addSeries(self.__series[0]) + self.__axisX = QValueAxis() + self.__axisX.setLabelFormat("time") + self.__chart.addAxis(self.__axisX, Qt.AlignmentFlag.AlignBottom) + self.__series[0].attachAxis(self.__axisX) self.__axisX.setRange(0, self.__maxX) - self.__axisX.setLabelFormat("time") + self.__axisY = QValueAxis() + self.__axisY.setLabelFormat("%d") + self.__chart.addAxis(self.__axisY, Qt.AlignmentFlag.AlignLeft) + self.__series[0].attachAxis(self.__axisY) self.__axisY.setRange(-self.__maxY, self.__maxY) - self.__axisY.setLabelFormat("%d") - self.__chart.setAxisX(self.__axisX, self.__series[0]) - self.__chart.setAxisY(self.__axisY, self.__series[0]) + self.__chartView.setChart(self.__chart) self.__chartView.setRenderHint(QPainter.RenderHint.Antialiasing) self.preferencesChanged() @@ -223,12 +228,12 @@ valuesLen = len(values) seriesLen = len(self.__series) if valuesLen > seriesLen: - # add a nwe line series + # add a new line series for _index in range(valuesLen - seriesLen): newSeries = QLineSeries() self.__chart.addSeries(newSeries) - self.__chart.setAxisX(self.__axisX, newSeries) - self.__chart.setAxisY(self.__axisY, newSeries) + newSeries.attachAxis(self.__axisX) + newSeries.attachAxis(self.__axisY) self.__series.append(newSeries) self.__data.append(deque([0] * self.__maxX)) else: