|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.MicroPython.MicrobitDevices</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.MicroPython.MicrobitDevices</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing the device interface class for BBC micro:bit and |
|
13 Calliope mini boards. |
|
14 </p> |
|
15 <h3>Global Attributes</h3> |
|
16 |
|
17 <table> |
|
18 <tr><td>None</td></tr> |
|
19 </table> |
|
20 <h3>Classes</h3> |
|
21 |
|
22 <table> |
|
23 |
|
24 <tr> |
|
25 <td><a href="#MicrobitDevice">MicrobitDevice</a></td> |
|
26 <td>Class implementing the device for BBC micro:bit and Calliope mini boards.</td> |
|
27 </tr> |
|
28 </table> |
|
29 <h3>Functions</h3> |
|
30 |
|
31 <table> |
|
32 <tr><td>None</td></tr> |
|
33 </table> |
|
34 <hr /> |
|
35 <hr /> |
|
36 <a NAME="MicrobitDevice" ID="MicrobitDevice"></a> |
|
37 <h2>MicrobitDevice</h2> |
|
38 |
|
39 <p> |
|
40 Class implementing the device for BBC micro:bit and Calliope mini boards. |
|
41 </p> |
|
42 <h3>Derived from</h3> |
|
43 MicroPythonDevice |
|
44 <h3>Class Attributes</h3> |
|
45 |
|
46 <table> |
|
47 <tr><td>None</td></tr> |
|
48 </table> |
|
49 <h3>Class Methods</h3> |
|
50 |
|
51 <table> |
|
52 <tr><td>None</td></tr> |
|
53 </table> |
|
54 <h3>Methods</h3> |
|
55 |
|
56 <table> |
|
57 |
|
58 <tr> |
|
59 <td><a href="#MicrobitDevice.__init__">MicrobitDevice</a></td> |
|
60 <td>Constructor</td> |
|
61 </tr> |
|
62 <tr> |
|
63 <td><a href="#MicrobitDevice.__flashMicroPython">__flashMicroPython</a></td> |
|
64 <td>Private slot to flash MicroPython or the DAPLink firmware to the device.</td> |
|
65 </tr> |
|
66 <tr> |
|
67 <td><a href="#MicrobitDevice.__resetDevice">__resetDevice</a></td> |
|
68 <td>Private slot to reset the connected device.</td> |
|
69 </tr> |
|
70 <tr> |
|
71 <td><a href="#MicrobitDevice.__saveMain">__saveMain</a></td> |
|
72 <td>Private slot to copy the current script as 'main.py' onto the connected device.</td> |
|
73 </tr> |
|
74 <tr> |
|
75 <td><a href="#MicrobitDevice.__saveScriptToDevice">__saveScriptToDevice</a></td> |
|
76 <td>Private method to save the current script onto the connected device.</td> |
|
77 </tr> |
|
78 <tr> |
|
79 <td><a href="#MicrobitDevice.addDeviceMenuEntries">addDeviceMenuEntries</a></td> |
|
80 <td>Public method to add device specific entries to the given menu.</td> |
|
81 </tr> |
|
82 <tr> |
|
83 <td><a href="#MicrobitDevice.canRunScript">canRunScript</a></td> |
|
84 <td>Public method to determine, if a script can be executed.</td> |
|
85 </tr> |
|
86 <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> |
|
90 <tr> |
|
91 <td><a href="#MicrobitDevice.canStartPlotter">canStartPlotter</a></td> |
|
92 <td>Public method to determine, if a Plotter can be started.</td> |
|
93 </tr> |
|
94 <tr> |
|
95 <td><a href="#MicrobitDevice.canStartRepl">canStartRepl</a></td> |
|
96 <td>Public method to determine, if a REPL can be started.</td> |
|
97 </tr> |
|
98 <tr> |
|
99 <td><a href="#MicrobitDevice.deviceName">deviceName</a></td> |
|
100 <td>Public method to get the name of the device.</td> |
|
101 </tr> |
|
102 <tr> |
|
103 <td><a href="#MicrobitDevice.forceInterrupt">forceInterrupt</a></td> |
|
104 <td>Public method to determine the need for an interrupt when opening the serial connection.</td> |
|
105 </tr> |
|
106 <tr> |
|
107 <td><a href="#MicrobitDevice.getDocumentationUrl">getDocumentationUrl</a></td> |
|
108 <td>Public method to get the device documentation URL.</td> |
|
109 </tr> |
|
110 <tr> |
|
111 <td><a href="#MicrobitDevice.getDownloadMenuEntries">getDownloadMenuEntries</a></td> |
|
112 <td>Public method to retrieve the entries for the downloads menu.</td> |
|
113 </tr> |
|
114 <tr> |
|
115 <td><a href="#MicrobitDevice.hasFlashMenuEntry">hasFlashMenuEntry</a></td> |
|
116 <td>Public method to check, if the device has its own flash menu entry.</td> |
|
117 </tr> |
|
118 <tr> |
|
119 <td><a href="#MicrobitDevice.hasTimeCommands">hasTimeCommands</a></td> |
|
120 <td>Public method to check, if the device supports time commands.</td> |
|
121 </tr> |
|
122 <tr> |
|
123 <td><a href="#MicrobitDevice.runScript">runScript</a></td> |
|
124 <td>Public method to run the given Python script.</td> |
|
125 </tr> |
|
126 <tr> |
|
127 <td><a href="#MicrobitDevice.setButtons">setButtons</a></td> |
|
128 <td>Public method to enable the supported action buttons.</td> |
|
129 </tr> |
|
130 </table> |
|
131 <h3>Static Methods</h3> |
|
132 |
|
133 <table> |
|
134 <tr><td>None</td></tr> |
|
135 </table> |
|
136 |
|
137 <a NAME="MicrobitDevice.__init__" ID="MicrobitDevice.__init__"></a> |
|
138 <h4>MicrobitDevice (Constructor)</h4> |
|
139 <b>MicrobitDevice</b>(<i>microPythonWidget, deviceType, parent=None</i>) |
|
140 |
|
141 <p> |
|
142 Constructor |
|
143 </p> |
|
144 <dl> |
|
145 |
|
146 <dt><i>microPythonWidget</i> (MicroPythonWidget)</dt> |
|
147 <dd> |
|
148 reference to the main MicroPython widget |
|
149 </dd> |
|
150 <dt><i>deviceType</i> (str)</dt> |
|
151 <dd> |
|
152 type of the device |
|
153 </dd> |
|
154 <dt><i>parent</i> (QObject)</dt> |
|
155 <dd> |
|
156 reference to the parent object |
|
157 </dd> |
|
158 </dl> |
|
159 <a NAME="MicrobitDevice.__flashMicroPython" ID="MicrobitDevice.__flashMicroPython"></a> |
|
160 <h4>MicrobitDevice.__flashMicroPython</h4> |
|
161 <b>__flashMicroPython</b>(<i>firmware=False</i>) |
|
162 |
|
163 <p> |
|
164 Private slot to flash MicroPython or the DAPLink firmware to the |
|
165 device. |
|
166 </p> |
|
167 <dl> |
|
168 |
|
169 <dt><i>firmware</i> (bool)</dt> |
|
170 <dd> |
|
171 flag indicating to flash the DAPLink firmware |
|
172 </dd> |
|
173 </dl> |
|
174 <a NAME="MicrobitDevice.__resetDevice" ID="MicrobitDevice.__resetDevice"></a> |
|
175 <h4>MicrobitDevice.__resetDevice</h4> |
|
176 <b>__resetDevice</b>(<i></i>) |
|
177 |
|
178 <p> |
|
179 Private slot to reset the connected device. |
|
180 </p> |
|
181 <a NAME="MicrobitDevice.__saveMain" ID="MicrobitDevice.__saveMain"></a> |
|
182 <h4>MicrobitDevice.__saveMain</h4> |
|
183 <b>__saveMain</b>(<i></i>) |
|
184 |
|
185 <p> |
|
186 Private slot to copy the current script as 'main.py' onto the |
|
187 connected device. |
|
188 </p> |
|
189 <a NAME="MicrobitDevice.__saveScriptToDevice" ID="MicrobitDevice.__saveScriptToDevice"></a> |
|
190 <h4>MicrobitDevice.__saveScriptToDevice</h4> |
|
191 <b>__saveScriptToDevice</b>(<i>scriptName=""</i>) |
|
192 |
|
193 <p> |
|
194 Private method to save the current script onto the connected |
|
195 device. |
|
196 </p> |
|
197 <dl> |
|
198 |
|
199 <dt><i>scriptName</i> (str)</dt> |
|
200 <dd> |
|
201 name of the file on the device |
|
202 </dd> |
|
203 </dl> |
|
204 <a NAME="MicrobitDevice.addDeviceMenuEntries" ID="MicrobitDevice.addDeviceMenuEntries"></a> |
|
205 <h4>MicrobitDevice.addDeviceMenuEntries</h4> |
|
206 <b>addDeviceMenuEntries</b>(<i>menu</i>) |
|
207 |
|
208 <p> |
|
209 Public method to add device specific entries to the given menu. |
|
210 </p> |
|
211 <dl> |
|
212 |
|
213 <dt><i>menu</i> (QMenu)</dt> |
|
214 <dd> |
|
215 reference to the context menu |
|
216 </dd> |
|
217 </dl> |
|
218 <a NAME="MicrobitDevice.canRunScript" ID="MicrobitDevice.canRunScript"></a> |
|
219 <h4>MicrobitDevice.canRunScript</h4> |
|
220 <b>canRunScript</b>(<i></i>) |
|
221 |
|
222 <p> |
|
223 Public method to determine, if a script can be executed. |
|
224 </p> |
|
225 <dl> |
|
226 <dt>Return:</dt> |
|
227 <dd> |
|
228 tuple containing a flag indicating it is safe to start a |
|
229 Plotter and a reason why it cannot. |
|
230 </dd> |
|
231 </dl> |
|
232 <dl> |
|
233 <dt>Return Type:</dt> |
|
234 <dd> |
|
235 tuple of (bool, str) |
|
236 </dd> |
|
237 </dl> |
|
238 <a NAME="MicrobitDevice.canStartFileManager" ID="MicrobitDevice.canStartFileManager"></a> |
|
239 <h4>MicrobitDevice.canStartFileManager</h4> |
|
240 <b>canStartFileManager</b>(<i></i>) |
|
241 |
|
242 <p> |
|
243 Public method to determine, if a File Manager can be started. |
|
244 </p> |
|
245 <dl> |
|
246 <dt>Return:</dt> |
|
247 <dd> |
|
248 tuple containing a flag indicating it is safe to start a |
|
249 File Manager and a reason why it cannot. |
|
250 </dd> |
|
251 </dl> |
|
252 <dl> |
|
253 <dt>Return Type:</dt> |
|
254 <dd> |
|
255 tuple of (bool, str) |
|
256 </dd> |
|
257 </dl> |
|
258 <a NAME="MicrobitDevice.canStartPlotter" ID="MicrobitDevice.canStartPlotter"></a> |
|
259 <h4>MicrobitDevice.canStartPlotter</h4> |
|
260 <b>canStartPlotter</b>(<i></i>) |
|
261 |
|
262 <p> |
|
263 Public method to determine, if a Plotter can be started. |
|
264 </p> |
|
265 <dl> |
|
266 <dt>Return:</dt> |
|
267 <dd> |
|
268 tuple containing a flag indicating it is safe to start a |
|
269 Plotter and a reason why it cannot. |
|
270 </dd> |
|
271 </dl> |
|
272 <dl> |
|
273 <dt>Return Type:</dt> |
|
274 <dd> |
|
275 tuple of (bool, str) |
|
276 </dd> |
|
277 </dl> |
|
278 <a NAME="MicrobitDevice.canStartRepl" ID="MicrobitDevice.canStartRepl"></a> |
|
279 <h4>MicrobitDevice.canStartRepl</h4> |
|
280 <b>canStartRepl</b>(<i></i>) |
|
281 |
|
282 <p> |
|
283 Public method to determine, if a REPL can be started. |
|
284 </p> |
|
285 <dl> |
|
286 <dt>Return:</dt> |
|
287 <dd> |
|
288 tuple containing a flag indicating it is safe to start a REPL |
|
289 and a reason why it cannot. |
|
290 </dd> |
|
291 </dl> |
|
292 <dl> |
|
293 <dt>Return Type:</dt> |
|
294 <dd> |
|
295 tuple of (bool, str) |
|
296 </dd> |
|
297 </dl> |
|
298 <a NAME="MicrobitDevice.deviceName" ID="MicrobitDevice.deviceName"></a> |
|
299 <h4>MicrobitDevice.deviceName</h4> |
|
300 <b>deviceName</b>(<i></i>) |
|
301 |
|
302 <p> |
|
303 Public method to get the name of the device. |
|
304 </p> |
|
305 <dl> |
|
306 <dt>Return:</dt> |
|
307 <dd> |
|
308 name of the device |
|
309 </dd> |
|
310 </dl> |
|
311 <dl> |
|
312 <dt>Return Type:</dt> |
|
313 <dd> |
|
314 str |
|
315 </dd> |
|
316 </dl> |
|
317 <a NAME="MicrobitDevice.forceInterrupt" ID="MicrobitDevice.forceInterrupt"></a> |
|
318 <h4>MicrobitDevice.forceInterrupt</h4> |
|
319 <b>forceInterrupt</b>(<i></i>) |
|
320 |
|
321 <p> |
|
322 Public method to determine the need for an interrupt when opening the |
|
323 serial connection. |
|
324 </p> |
|
325 <dl> |
|
326 <dt>Return:</dt> |
|
327 <dd> |
|
328 flag indicating an interrupt is needed |
|
329 </dd> |
|
330 </dl> |
|
331 <dl> |
|
332 <dt>Return Type:</dt> |
|
333 <dd> |
|
334 bool |
|
335 </dd> |
|
336 </dl> |
|
337 <a NAME="MicrobitDevice.getDocumentationUrl" ID="MicrobitDevice.getDocumentationUrl"></a> |
|
338 <h4>MicrobitDevice.getDocumentationUrl</h4> |
|
339 <b>getDocumentationUrl</b>(<i></i>) |
|
340 |
|
341 <p> |
|
342 Public method to get the device documentation URL. |
|
343 </p> |
|
344 <dl> |
|
345 <dt>Return:</dt> |
|
346 <dd> |
|
347 documentation URL of the device |
|
348 </dd> |
|
349 </dl> |
|
350 <dl> |
|
351 <dt>Return Type:</dt> |
|
352 <dd> |
|
353 str |
|
354 </dd> |
|
355 </dl> |
|
356 <a NAME="MicrobitDevice.getDownloadMenuEntries" ID="MicrobitDevice.getDownloadMenuEntries"></a> |
|
357 <h4>MicrobitDevice.getDownloadMenuEntries</h4> |
|
358 <b>getDownloadMenuEntries</b>(<i></i>) |
|
359 |
|
360 <p> |
|
361 Public method to retrieve the entries for the downloads menu. |
|
362 </p> |
|
363 <dl> |
|
364 <dt>Return:</dt> |
|
365 <dd> |
|
366 list of tuples with menu text and URL to be opened for each |
|
367 entry |
|
368 </dd> |
|
369 </dl> |
|
370 <dl> |
|
371 <dt>Return Type:</dt> |
|
372 <dd> |
|
373 list of tuple of (str, str) |
|
374 </dd> |
|
375 </dl> |
|
376 <a NAME="MicrobitDevice.hasFlashMenuEntry" ID="MicrobitDevice.hasFlashMenuEntry"></a> |
|
377 <h4>MicrobitDevice.hasFlashMenuEntry</h4> |
|
378 <b>hasFlashMenuEntry</b>(<i></i>) |
|
379 |
|
380 <p> |
|
381 Public method to check, if the device has its own flash menu entry. |
|
382 </p> |
|
383 <dl> |
|
384 <dt>Return:</dt> |
|
385 <dd> |
|
386 flag indicating a specific flash menu entry |
|
387 </dd> |
|
388 </dl> |
|
389 <dl> |
|
390 <dt>Return Type:</dt> |
|
391 <dd> |
|
392 bool |
|
393 </dd> |
|
394 </dl> |
|
395 <a NAME="MicrobitDevice.hasTimeCommands" ID="MicrobitDevice.hasTimeCommands"></a> |
|
396 <h4>MicrobitDevice.hasTimeCommands</h4> |
|
397 <b>hasTimeCommands</b>(<i></i>) |
|
398 |
|
399 <p> |
|
400 Public method to check, if the device supports time commands. |
|
401 </p> |
|
402 <p> |
|
403 The default returns True. |
|
404 </p> |
|
405 <dl> |
|
406 <dt>Return:</dt> |
|
407 <dd> |
|
408 flag indicating support for time commands |
|
409 </dd> |
|
410 </dl> |
|
411 <dl> |
|
412 <dt>Return Type:</dt> |
|
413 <dd> |
|
414 bool |
|
415 </dd> |
|
416 </dl> |
|
417 <a NAME="MicrobitDevice.runScript" ID="MicrobitDevice.runScript"></a> |
|
418 <h4>MicrobitDevice.runScript</h4> |
|
419 <b>runScript</b>(<i>script</i>) |
|
420 |
|
421 <p> |
|
422 Public method to run the given Python script. |
|
423 </p> |
|
424 <dl> |
|
425 |
|
426 <dt><i>script</i> (str)</dt> |
|
427 <dd> |
|
428 script to be executed |
|
429 </dd> |
|
430 </dl> |
|
431 <a NAME="MicrobitDevice.setButtons" ID="MicrobitDevice.setButtons"></a> |
|
432 <h4>MicrobitDevice.setButtons</h4> |
|
433 <b>setButtons</b>(<i></i>) |
|
434 |
|
435 <p> |
|
436 Public method to enable the supported action buttons. |
|
437 </p> |
|
438 <div align="right"><a href="#top">Up</a></div> |
|
439 <hr /> |
|
440 </body></html> |