|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.MicroPython.MicrobitDevices</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.MicroPython.MicrobitDevices</h1> |
|
23 <p> |
|
24 Module implementing the device interface class for BBC micro:bit boards. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>None</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#MicrobitDevice">MicrobitDevice</a></td> |
|
34 <td>Class implementing the device for BBC micro:bit boards.</td> |
|
35 </tr> |
|
36 </table> |
|
37 <h3>Functions</h3> |
|
38 <table> |
|
39 <tr><td>None</td></tr> |
|
40 </table> |
|
41 <hr /><hr /> |
|
42 <a NAME="MicrobitDevice" ID="MicrobitDevice"></a> |
|
43 <h2>MicrobitDevice</h2> |
|
44 <p> |
|
45 Class implementing the device for BBC micro:bit boards. |
|
46 </p> |
|
47 <h3>Derived from</h3> |
|
48 MicroPythonDevice |
|
49 <h3>Class Attributes</h3> |
|
50 <table> |
|
51 <tr><td>None</td></tr> |
|
52 </table> |
|
53 <h3>Class Methods</h3> |
|
54 <table> |
|
55 <tr><td>None</td></tr> |
|
56 </table> |
|
57 <h3>Methods</h3> |
|
58 <table> |
|
59 <tr> |
|
60 <td><a href="#MicrobitDevice.__init__">MicrobitDevice</a></td> |
|
61 <td>Constructor</td> |
|
62 </tr><tr> |
|
63 <td><a href="#MicrobitDevice.__flashCustomMicroPython">__flashCustomMicroPython</a></td> |
|
64 <td>Private slot to flash a custom MicroPython firmware to the device.</td> |
|
65 </tr><tr> |
|
66 <td><a href="#MicrobitDevice.__flashMicroPython">__flashMicroPython</a></td> |
|
67 <td>Private slot to flash the default MicroPython firmware to the device.</td> |
|
68 </tr><tr> |
|
69 <td><a href="#MicrobitDevice.__flashScript">__flashScript</a></td> |
|
70 <td>Private slot to flash the current script onto the selected device.</td> |
|
71 </tr><tr> |
|
72 <td><a href="#MicrobitDevice.__installUflashTool">__installUflashTool</a></td> |
|
73 <td>Private slot to install the uflash package via pip.</td> |
|
74 </tr><tr> |
|
75 <td><a href="#MicrobitDevice.__resetDevice">__resetDevice</a></td> |
|
76 <td>Private slot to reset the connected device.</td> |
|
77 </tr><tr> |
|
78 <td><a href="#MicrobitDevice.__saveMain">__saveMain</a></td> |
|
79 <td>Private slot to copy the current script as 'main.py' onto the connected device.</td> |
|
80 </tr><tr> |
|
81 <td><a href="#MicrobitDevice.addDeviceMenuEntries">addDeviceMenuEntries</a></td> |
|
82 <td>Public method to add device specific entries to the given menu.</td> |
|
83 </tr><tr> |
|
84 <td><a href="#MicrobitDevice.canRunScript">canRunScript</a></td> |
|
85 <td>Public method to determine, if a script can be executed.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#MicrobitDevice.canStartFileManager">canStartFileManager</a></td> |
|
88 <td>Public method to determine, if a File Manager can be started.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#MicrobitDevice.canStartPlotter">canStartPlotter</a></td> |
|
91 <td>Public method to determine, if a Plotter can be started.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#MicrobitDevice.canStartRepl">canStartRepl</a></td> |
|
94 <td>Public method to determine, if a REPL can be started.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#MicrobitDevice.deviceName">deviceName</a></td> |
|
97 <td>Public method to get the name of the device.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#MicrobitDevice.forceInterrupt">forceInterrupt</a></td> |
|
100 <td>Public method to determine the need for an interrupt when opening the serial connection.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#MicrobitDevice.getWorkspace">getWorkspace</a></td> |
|
103 <td>Public method to get the workspace directory.</td> |
|
104 </tr><tr> |
|
105 <td><a href="#MicrobitDevice.hasTimeCommands">hasTimeCommands</a></td> |
|
106 <td>Public method to check, if the device supports time commands.</td> |
|
107 </tr><tr> |
|
108 <td><a href="#MicrobitDevice.runScript">runScript</a></td> |
|
109 <td>Public method to run the given Python script.</td> |
|
110 </tr><tr> |
|
111 <td><a href="#MicrobitDevice.setButtons">setButtons</a></td> |
|
112 <td>Public method to enable the supported action buttons.</td> |
|
113 </tr> |
|
114 </table> |
|
115 <h3>Static Methods</h3> |
|
116 <table> |
|
117 <tr><td>None</td></tr> |
|
118 </table> |
|
119 <a NAME="MicrobitDevice.__init__" ID="MicrobitDevice.__init__"></a> |
|
120 <h4>MicrobitDevice (Constructor)</h4> |
|
121 <b>MicrobitDevice</b>(<i>microPythonWidget, parent=None</i>) |
|
122 <p> |
|
123 Constructor |
|
124 </p><dl> |
|
125 <dt><i>microPythonWidget</i> (MicroPythonWidget)</dt> |
|
126 <dd> |
|
127 reference to the main MicroPython widget |
|
128 </dd><dt><i>parent</i> (QObject)</dt> |
|
129 <dd> |
|
130 reference to the parent object |
|
131 </dd> |
|
132 </dl><a NAME="MicrobitDevice.__flashCustomMicroPython" ID="MicrobitDevice.__flashCustomMicroPython"></a> |
|
133 <h4>MicrobitDevice.__flashCustomMicroPython</h4> |
|
134 <b>__flashCustomMicroPython</b>(<i></i>) |
|
135 <p> |
|
136 Private slot to flash a custom MicroPython firmware to the device. |
|
137 </p><a NAME="MicrobitDevice.__flashMicroPython" ID="MicrobitDevice.__flashMicroPython"></a> |
|
138 <h4>MicrobitDevice.__flashMicroPython</h4> |
|
139 <b>__flashMicroPython</b>(<i></i>) |
|
140 <p> |
|
141 Private slot to flash the default MicroPython firmware to the device. |
|
142 </p><a NAME="MicrobitDevice.__flashScript" ID="MicrobitDevice.__flashScript"></a> |
|
143 <h4>MicrobitDevice.__flashScript</h4> |
|
144 <b>__flashScript</b>(<i></i>) |
|
145 <p> |
|
146 Private slot to flash the current script onto the selected device. |
|
147 </p><a NAME="MicrobitDevice.__installUflashTool" ID="MicrobitDevice.__installUflashTool"></a> |
|
148 <h4>MicrobitDevice.__installUflashTool</h4> |
|
149 <b>__installUflashTool</b>(<i></i>) |
|
150 <p> |
|
151 Private slot to install the uflash package via pip. |
|
152 </p><a NAME="MicrobitDevice.__resetDevice" ID="MicrobitDevice.__resetDevice"></a> |
|
153 <h4>MicrobitDevice.__resetDevice</h4> |
|
154 <b>__resetDevice</b>(<i></i>) |
|
155 <p> |
|
156 Private slot to reset the connected device. |
|
157 </p><a NAME="MicrobitDevice.__saveMain" ID="MicrobitDevice.__saveMain"></a> |
|
158 <h4>MicrobitDevice.__saveMain</h4> |
|
159 <b>__saveMain</b>(<i></i>) |
|
160 <p> |
|
161 Private slot to copy the current script as 'main.py' onto the |
|
162 connected device. |
|
163 </p><a NAME="MicrobitDevice.addDeviceMenuEntries" ID="MicrobitDevice.addDeviceMenuEntries"></a> |
|
164 <h4>MicrobitDevice.addDeviceMenuEntries</h4> |
|
165 <b>addDeviceMenuEntries</b>(<i>menu</i>) |
|
166 <p> |
|
167 Public method to add device specific entries to the given menu. |
|
168 </p><dl> |
|
169 <dt><i>menu</i> (QMenu)</dt> |
|
170 <dd> |
|
171 reference to the context menu |
|
172 </dd> |
|
173 </dl><a NAME="MicrobitDevice.canRunScript" ID="MicrobitDevice.canRunScript"></a> |
|
174 <h4>MicrobitDevice.canRunScript</h4> |
|
175 <b>canRunScript</b>(<i></i>) |
|
176 <p> |
|
177 Public method to determine, if a script can be executed. |
|
178 </p><dl> |
|
179 <dt>Returns:</dt> |
|
180 <dd> |
|
181 tuple containing a flag indicating it is safe to start a |
|
182 Plotter and a reason why it cannot. |
|
183 </dd> |
|
184 </dl><dl> |
|
185 <dt>Return Type:</dt> |
|
186 <dd> |
|
187 tuple of (bool, str) |
|
188 </dd> |
|
189 </dl><a NAME="MicrobitDevice.canStartFileManager" ID="MicrobitDevice.canStartFileManager"></a> |
|
190 <h4>MicrobitDevice.canStartFileManager</h4> |
|
191 <b>canStartFileManager</b>(<i></i>) |
|
192 <p> |
|
193 Public method to determine, if a File Manager can be started. |
|
194 </p><dl> |
|
195 <dt>Returns:</dt> |
|
196 <dd> |
|
197 tuple containing a flag indicating it is safe to start a |
|
198 File Manager and a reason why it cannot. |
|
199 </dd> |
|
200 </dl><dl> |
|
201 <dt>Return Type:</dt> |
|
202 <dd> |
|
203 tuple of (bool, str) |
|
204 </dd> |
|
205 </dl><a NAME="MicrobitDevice.canStartPlotter" ID="MicrobitDevice.canStartPlotter"></a> |
|
206 <h4>MicrobitDevice.canStartPlotter</h4> |
|
207 <b>canStartPlotter</b>(<i></i>) |
|
208 <p> |
|
209 Public method to determine, if a Plotter can be started. |
|
210 </p><dl> |
|
211 <dt>Returns:</dt> |
|
212 <dd> |
|
213 tuple containing a flag indicating it is safe to start a |
|
214 Plotter and a reason why it cannot. |
|
215 </dd> |
|
216 </dl><dl> |
|
217 <dt>Return Type:</dt> |
|
218 <dd> |
|
219 tuple of (bool, str) |
|
220 </dd> |
|
221 </dl><a NAME="MicrobitDevice.canStartRepl" ID="MicrobitDevice.canStartRepl"></a> |
|
222 <h4>MicrobitDevice.canStartRepl</h4> |
|
223 <b>canStartRepl</b>(<i></i>) |
|
224 <p> |
|
225 Public method to determine, if a REPL can be started. |
|
226 </p><dl> |
|
227 <dt>Returns:</dt> |
|
228 <dd> |
|
229 tuple containing a flag indicating it is safe to start a REPL |
|
230 and a reason why it cannot. |
|
231 </dd> |
|
232 </dl><dl> |
|
233 <dt>Return Type:</dt> |
|
234 <dd> |
|
235 tuple of (bool, str) |
|
236 </dd> |
|
237 </dl><a NAME="MicrobitDevice.deviceName" ID="MicrobitDevice.deviceName"></a> |
|
238 <h4>MicrobitDevice.deviceName</h4> |
|
239 <b>deviceName</b>(<i></i>) |
|
240 <p> |
|
241 Public method to get the name of the device. |
|
242 </p><dl> |
|
243 <dt>Returns:</dt> |
|
244 <dd> |
|
245 name of the device |
|
246 </dd> |
|
247 </dl><dl> |
|
248 <dt>Return Type:</dt> |
|
249 <dd> |
|
250 str |
|
251 </dd> |
|
252 </dl><a NAME="MicrobitDevice.forceInterrupt" ID="MicrobitDevice.forceInterrupt"></a> |
|
253 <h4>MicrobitDevice.forceInterrupt</h4> |
|
254 <b>forceInterrupt</b>(<i></i>) |
|
255 <p> |
|
256 Public method to determine the need for an interrupt when opening the |
|
257 serial connection. |
|
258 </p><dl> |
|
259 <dt>Returns:</dt> |
|
260 <dd> |
|
261 flag indicating an interrupt is needed |
|
262 </dd> |
|
263 </dl><dl> |
|
264 <dt>Return Type:</dt> |
|
265 <dd> |
|
266 bool |
|
267 </dd> |
|
268 </dl><a NAME="MicrobitDevice.getWorkspace" ID="MicrobitDevice.getWorkspace"></a> |
|
269 <h4>MicrobitDevice.getWorkspace</h4> |
|
270 <b>getWorkspace</b>(<i></i>) |
|
271 <p> |
|
272 Public method to get the workspace directory. |
|
273 </p><dl> |
|
274 <dt>Returns:</dt> |
|
275 <dd> |
|
276 workspace directory used for saving files |
|
277 </dd> |
|
278 </dl><dl> |
|
279 <dt>Return Type:</dt> |
|
280 <dd> |
|
281 str |
|
282 </dd> |
|
283 </dl><a NAME="MicrobitDevice.hasTimeCommands" ID="MicrobitDevice.hasTimeCommands"></a> |
|
284 <h4>MicrobitDevice.hasTimeCommands</h4> |
|
285 <b>hasTimeCommands</b>(<i></i>) |
|
286 <p> |
|
287 Public method to check, if the device supports time commands. |
|
288 </p><p> |
|
289 The default returns True. |
|
290 </p><dl> |
|
291 <dt>Returns:</dt> |
|
292 <dd> |
|
293 flag indicating support for time commands |
|
294 </dd> |
|
295 </dl><dl> |
|
296 <dt>Return Type:</dt> |
|
297 <dd> |
|
298 bool |
|
299 </dd> |
|
300 </dl><a NAME="MicrobitDevice.runScript" ID="MicrobitDevice.runScript"></a> |
|
301 <h4>MicrobitDevice.runScript</h4> |
|
302 <b>runScript</b>(<i>script</i>) |
|
303 <p> |
|
304 Public method to run the given Python script. |
|
305 </p><dl> |
|
306 <dt><i>script</i> (str)</dt> |
|
307 <dd> |
|
308 script to be executed |
|
309 </dd> |
|
310 </dl><a NAME="MicrobitDevice.setButtons" ID="MicrobitDevice.setButtons"></a> |
|
311 <h4>MicrobitDevice.setButtons</h4> |
|
312 <b>setButtons</b>(<i></i>) |
|
313 <p> |
|
314 Public method to enable the supported action buttons. |
|
315 </p> |
|
316 <div align="right"><a href="#top">Up</a></div> |
|
317 <hr /> |
|
318 </body></html> |