eric6/MicroPython/PyBoardDevices.py

Wed, 27 Jan 2021 18:27:52 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 27 Jan 2021 18:27:52 +0100
branch
jsonfiles
changeset 8011
630a173cb137
parent 7923
91e843545d9a
child 8062
8dc5acb30a8b
permissions
-rw-r--r--

Implemented the JSON based tasks files.

7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7759
diff changeset
3 # Copyright (c) 2019 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the device interface class for PyBoard boards.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
10 import os
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
11
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
12 from PyQt5.QtCore import pyqtSlot, QStandardPaths
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
13
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
14 from E5Gui import E5MessageBox, E5FileDialog
7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from E5Gui.E5Application import e5App
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
16 from E5Gui.E5ProcessDialog import E5ProcessDialog
7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .MicroPythonDevices import MicroPythonDevice
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .MicroPythonWidget import HAS_QTCHART
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import Utilities
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Preferences
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class PyBoardDevice(MicroPythonDevice):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing the device for PyBoard boards.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 DeviceVolumeName = "PYBFLASH"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 FlashInstructionsURL = (
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 "https://github.com/micropython/micropython/wiki/"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 "Pyboard-Firmware-Update"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 )
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 def __init__(self, microPythonWidget, parent=None):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 Constructor
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @param microPythonWidget reference to the main MicroPython widget
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @type MicroPythonWidget
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @param parent reference to the parent object
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @type QObject
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 super(PyBoardDevice, self).__init__(microPythonWidget, parent)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def setButtons(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Public method to enable the supported action buttons.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 super(PyBoardDevice, self).setButtons()
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.microPython.setActionButtons(
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 run=True, repl=True, files=True, chart=HAS_QTCHART)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 if self.__deviceVolumeMounted():
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.microPython.setActionButtons(open=True, save=True)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 def forceInterrupt(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Public method to determine the need for an interrupt when opening the
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 serial connection.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 @return flag indicating an interrupt is needed
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @rtype bool
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 return False
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 def deviceName(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 Public method to get the name of the device.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 @return name of the device
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @rtype str
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 return self.tr("PyBoard")
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def canStartRepl(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Public method to determine, if a REPL can be started.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @return tuple containing a flag indicating it is safe to start a REPL
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 and a reason why it cannot.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 @rtype tuple of (bool, str)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 return True, ""
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 def canStartPlotter(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 Public method to determine, if a Plotter can be started.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 @return tuple containing a flag indicating it is safe to start a
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 Plotter and a reason why it cannot.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 @rtype tuple of (bool, str)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 return True, ""
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 def canRunScript(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 Public method to determine, if a script can be executed.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @return tuple containing a flag indicating it is safe to start a
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 Plotter and a reason why it cannot.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 @rtype tuple of (bool, str)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 return True, ""
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 def runScript(self, script):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 Public method to run the given Python script.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 @param script script to be executed
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 @type str
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 pythonScript = script.split("\n")
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 self.sendCommands(pythonScript)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 def canStartFileManager(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 Public method to determine, if a File Manager can be started.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 @return tuple containing a flag indicating it is safe to start a
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 File Manager and a reason why it cannot.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 @rtype tuple of (bool, str)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 return True, ""
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 def supportsLocalFileAccess(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 Public method to indicate file access via a local directory.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 @return flag indicating file access via local directory
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @rtype bool
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 return self.__deviceVolumeMounted()
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 def __deviceVolumeMounted(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 Private method to check, if the device volume is mounted.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 @return flag indicated a mounted device
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 @rtype bool
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 return self.getWorkspace(silent=True).endswith(self.DeviceVolumeName)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 def getWorkspace(self, silent=False):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 Public method to get the workspace directory.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @param silent flag indicating silent operations
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 @type bool
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 @return workspace directory used for saving files
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 @rtype str
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 # Attempts to find the path on the filesystem that represents the
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 # plugged in PyBoard board.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 deviceDirectory = Utilities.findVolume(self.DeviceVolumeName)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 if deviceDirectory:
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 return deviceDirectory
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 else:
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 # return the default workspace and give the user a warning (unless
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 # silent mode is selected)
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 if not silent:
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 E5MessageBox.warning(
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 self.microPython,
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 self.tr("Workspace Directory"),
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 self.tr("Python files for PyBoard devices are stored"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 " on the device. Therefore, to edit these files"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 " you need to have the device plugged in. Until"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 " you plug in a device, the standard directory"
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 " will be used."))
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 return super(PyBoardDevice, self).getWorkspace()
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 def getDocumentationUrl(self):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 Public method to get the device documentation URL.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 @return documentation URL of the device
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @rtype str
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 return Preferences.getMicroPython("MicroPythonDocuUrl")
7328
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
183
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
184 def getFirmwareUrl(self):
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
185 """
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
186 Public method to get the device firmware download URL.
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
187
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
188 @return firmware download URL of the device
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
189 @rtype str
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
190 """
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
191 return Preferences.getMicroPython("MicroPythonFirmwareUrl")
e2d85ef3fadb MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7327
diff changeset
192
7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 def addDeviceMenuEntries(self, menu):
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 Public method to add device specific entries to the given menu.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @param menu reference to the context menu
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @type QMenu
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
200 connected = self.microPython.isConnected()
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
201
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
202 act = menu.addAction(self.tr("List DFU-capable Devices"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
203 self.__listDfuCapableDevices)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
204 act.setEnabled(not connected)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
205 act = menu.addAction(self.tr("Flash MicroPython Firmware"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
206 self.__flashMicroPython)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
207 act.setEnabled(not connected)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
208 menu.addSeparator()
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
209 menu.addAction(self.tr("MicroPython Flash Instructions"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
210 self.__showFlashInstructions)
7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
212 @pyqtSlot()
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
213 def __showFlashInstructions(self):
7295
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 Private slot to open the URL containing instructions for installing
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 MicroPython on the pyboard.
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 e5App().getObject("UserInterface").launchHelpViewer(
cf50045a7c0f MicroPython: added support for PyBoard.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 PyBoardDevice.FlashInstructionsURL)
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
220
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
221 def __dfuUtilAvailable(self):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
222 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
223 Private method to check the availability of dfu-util.
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
224
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
225 @return flag indicating the availability of dfu-util
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
226 @rtype bool
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
227 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
228 available = False
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
229 program = Preferences.getMicroPython("DfuUtilPath")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
230 if not program:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
231 program = "dfu-util"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
232 if Utilities.isinpath(program):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
233 available = True
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
234 else:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
235 if Utilities.isExecutable(program):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
236 available = True
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
237
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
238 if not available:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
239 E5MessageBox.critical(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
240 self.microPython,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
241 self.tr("dfu-util not available"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
242 self.tr("""The dfu-util firmware flashing tool"""
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
243 """ <b>dfu-util</b> cannot be found or is not"""
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
244 """ executable. Ensure it is in the search path"""
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
245 """ or configure it on the MicroPython"""
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
246 """ configuration page.""")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
247 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
248
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
249 return available
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
250
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
251 def __showDfuEnableInstructions(self, flash=True):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
252 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
253 Private method to show some instructions to enable the DFU mode.
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
254
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
255 @param flash flag indicating to show a warning message for flashing
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
256 @type bool
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
257 @return flag indicating OK to continue or abort
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
258 @rtype bool
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
259 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
260 msg = self.tr(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
261 "<h3>Enable DFU Mode</h3>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
262 "<p>1. Disconnect everything from your board</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
263 "<p>2. Disconnect your board</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
264 "<p>3. Connect the DFU/BOOT0 pin with a 3.3V pin</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
265 "<p>4. Re-connect your board</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
266 "<hr />"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
267 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
268
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
269 if flash:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
270 msg += self.tr(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
271 "<p><b>Warning:</b> Make sure that all other DFU capable"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
272 " devices except your PyBoard are disconnected."
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
273 "<hr />"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
274 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
275
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
276 msg += self.tr(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
277 "<p>Press <b>OK</b> to continue...</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
278 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
279 res = E5MessageBox.information(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
280 self.microPython,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
281 self.tr("Enable DFU mode"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
282 msg,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
283 E5MessageBox.StandardButtons(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
284 E5MessageBox.Abort |
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
285 E5MessageBox.Ok))
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
286
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
287 return res == E5MessageBox.Ok
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
288
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
289 def __showDfuDisableInstructions(self):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
290 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
291 Private method to show some instructions to disable the DFU mode.
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
292 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
293 msg = self.tr(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
294 "<h3>Disable DFU Mode</h3>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
295 "<p>1. Disconnect your board</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
296 "<p>2. Remove the DFU jumper</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
297 "<p>3. Re-connect your board</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
298 "<hr />"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
299 "<p>Press <b>OK</b> to continue...</p>"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
300 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
301 E5MessageBox.information(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
302 self.microPython,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
303 self.tr("Disable DFU mode"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
304 msg
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
305 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
306
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
307 @pyqtSlot()
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
308 def __listDfuCapableDevices(self):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
309 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
310 Private slot to list all DFU-capable devices.
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
311 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
312 if self.__dfuUtilAvailable():
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
313 ok2continue = self.__showDfuEnableInstructions(flash=False)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
314 if ok2continue:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
315 program = Preferences.getMicroPython("DfuUtilPath")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
316 if not program:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
317 program = "dfu-util"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
318
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
319 args = [
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
320 "--list",
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
321 ]
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
322 dlg = E5ProcessDialog(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
323 self.tr("'dfu-util' Output"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
324 self.tr("List DFU capable Devices")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
325 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
326 res = dlg.startProcess(program, args)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
327 if res:
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
328 dlg.exec()
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
329
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
330 @pyqtSlot()
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
331 def __flashMicroPython(self):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
332 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
333 Private slot to flash a MicroPython firmware.
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
334 """
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
335 if self.__dfuUtilAvailable():
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
336 ok2continue = self.__showDfuEnableInstructions()
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
337 if ok2continue:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
338 program = Preferences.getMicroPython("DfuUtilPath")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
339 if not program:
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
340 program = "dfu-util"
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
341
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
342 downloadsPath = QStandardPaths.standardLocations(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
343 QStandardPaths.DownloadLocation)[0]
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
344 firmware = E5FileDialog.getOpenFileName(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
345 self.microPython,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
346 self.tr("Flash MicroPython Firmware"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
347 downloadsPath,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
348 self.tr(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
349 "MicroPython Firmware Files (*.dfu);;All Files (*)")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
350 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
351 if firmware and os.path.exists(firmware):
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
352 args = [
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
353 "--alt", "0",
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
354 "--download", firmware,
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
355 ]
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
356 dlg = E5ProcessDialog(
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
357 self.tr("'dfu-util' Output"),
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
358 self.tr("Flash MicroPython Firmware")
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
359 )
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
360 res = dlg.startProcess(program, args)
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
361 if res:
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
362 dlg.exec()
7327
71883ddcb762 MicroPython:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7321
diff changeset
363 self.__showDfuDisableInstructions()

eric ide

mercurial