256 self.__currentZoom = 0 |
256 self.__currentZoom = 0 |
257 |
257 |
258 self.__fileManagerWidget = None |
258 self.__fileManagerWidget = None |
259 self.__chartWidget = None |
259 self.__chartWidget = None |
260 |
260 |
|
261 self.__unknownPorts = [] |
|
262 self.__lastPort = None |
|
263 self.__lastDeviceType = None |
|
264 |
261 if HAS_QTSERIALPORT: |
265 if HAS_QTSERIALPORT: |
262 self.__interface = MicroPythonCommandsInterface(self) |
266 self.__interface = MicroPythonCommandsInterface(self) |
263 else: |
267 else: |
264 self.__interface = None |
268 self.__interface = None |
265 self.__device = None |
269 self.__device = None |
303 |
307 |
304 self.deviceTypeComboBox.clear() |
308 self.deviceTypeComboBox.clear() |
305 self.deviceInfoLabel.clear() |
309 self.deviceInfoLabel.clear() |
306 |
310 |
307 self.deviceTypeComboBox.addItem("", "") |
311 self.deviceTypeComboBox.addItem("", "") |
308 devices, unknownDevices = MicroPythonDevices.getFoundDevices() |
312 devices, unknownDevices, unknownPorts = ( |
|
313 MicroPythonDevices.getFoundDevices() |
|
314 ) |
309 if devices: |
315 if devices: |
310 self.deviceInfoLabel.setText( |
316 self.deviceInfoLabel.setText( |
311 self.tr("%n supported device(s) detected.", "", len(devices))) |
317 self.tr("%n supported device(s) detected.", "", len(devices))) |
312 |
318 |
313 for index, (boardType, boardName, description, portName, |
319 for index, (boardType, boardName, description, portName, |
389 self.tr("""Would you like to add them to the list of""" |
395 self.tr("""Would you like to add them to the list of""" |
390 """ manually configured devices?"""), |
396 """ manually configured devices?"""), |
391 yesDefault=True) |
397 yesDefault=True) |
392 if yes: |
398 if yes: |
393 self.__addUnknownDevices(list(newUnknownDevices)) |
399 self.__addUnknownDevices(list(newUnknownDevices)) |
|
400 |
|
401 self.__unknownPorts = unknownPorts |
|
402 if self.__unknownPorts: |
|
403 self.connectButton.setEnabled(True) |
394 |
404 |
395 def __handlePreferencesChanged(self): |
405 def __handlePreferencesChanged(self): |
396 """ |
406 """ |
397 Private slot to handle a change in preferences. |
407 Private slot to handle a change in preferences. |
398 """ |
408 """ |
455 |
465 |
456 self.__device = MicroPythonDevices.getDevice(deviceType, self, |
466 self.__device = MicroPythonDevices.getDevice(deviceType, self, |
457 vid, pid) |
467 vid, pid) |
458 self.__device.setButtons() |
468 self.__device.setButtons() |
459 |
469 |
460 self.connectButton.setEnabled(bool(deviceType)) |
470 self.connectButton.setEnabled(bool(deviceType) or |
|
471 bool(self.__unknownPorts)) |
461 |
472 |
462 @pyqtSlot() |
473 @pyqtSlot() |
463 def on_checkButton_clicked(self): |
474 def on_checkButton_clicked(self): |
464 """ |
475 """ |
465 Private slot to check for connected devices. |
476 Private slot to check for connected devices. |
957 |
968 |
958 @return path of the port of the selected device |
969 @return path of the port of the selected device |
959 @rtype str |
970 @rtype str |
960 """ |
971 """ |
961 portName = self.deviceTypeComboBox.currentData(self.DevicePortRole) |
972 portName = self.deviceTypeComboBox.currentData(self.DevicePortRole) |
962 |
973 if portName: |
963 if Globals.isWindowsPlatform(): |
974 if Globals.isWindowsPlatform(): |
964 # return it unchanged |
975 # return it unchanged |
965 return portName |
976 return portName |
|
977 else: |
|
978 # return with device path prepended |
|
979 return "/dev/{0}".format(portName) |
966 else: |
980 else: |
967 # return with device path prepended |
981 return "" |
968 return "/dev/{0}".format(portName) |
|
969 |
982 |
970 def getCurrentBoard(self): |
983 def getCurrentBoard(self): |
971 """ |
984 """ |
972 Public method to get the board name of the selected device. |
985 Public method to get the board name of the selected device. |
973 |
986 |
992 def __connectToDevice(self): |
1005 def __connectToDevice(self): |
993 """ |
1006 """ |
994 Private method to connect to the selected device. |
1007 Private method to connect to the selected device. |
995 """ |
1008 """ |
996 port = self.getCurrentPort() |
1009 port = self.getCurrentPort() |
|
1010 if not port: |
|
1011 # TODO: implement port and device selection dialog |
|
1012 deviceType = "circuitpython" |
|
1013 port = "ttyACM0" |
|
1014 vid = 0 |
|
1015 pid = 0 |
|
1016 |
|
1017 self.deviceIconLabel.setPixmap(MicroPythonDevices.getDeviceIcon( |
|
1018 deviceType, False)) |
|
1019 self.__device = MicroPythonDevices.getDevice(deviceType, self, |
|
1020 vid, pid) |
|
1021 self.__device.setButtons() |
|
1022 |
997 if self.__interface.connectToDevice(port): |
1023 if self.__interface.connectToDevice(port): |
998 self.__setConnected(True) |
1024 self.__setConnected(True) |
999 |
1025 |
1000 if (Preferences.getMicroPython("SyncTimeAfterConnect") and |
1026 if (Preferences.getMicroPython("SyncTimeAfterConnect") and |
1001 self.__device.hasTimeCommands()): |
1027 self.__device.hasTimeCommands()): |
1003 else: |
1029 else: |
1004 with E5OverridenCursor(): |
1030 with E5OverridenCursor(): |
1005 E5MessageBox.warning( |
1031 E5MessageBox.warning( |
1006 self, |
1032 self, |
1007 self.tr("Serial Device Connect"), |
1033 self.tr("Serial Device Connect"), |
1008 self.tr("""<p>Cannot connect to device at serial port""" |
1034 self.tr("""<p>Cannot connect to device at serial""" |
1009 """ <b>{0}</b>.</p>""").format(port)) |
1035 """ port <b>{0}</b>.</p>""").format(port)) |
1010 |
1036 |
1011 def __disconnectFromDevice(self): |
1037 def __disconnectFromDevice(self): |
1012 """ |
1038 """ |
1013 Private method to disconnect from the device. |
1039 Private method to disconnect from the device. |
1014 """ |
1040 """ |