src/eric7/Documentation/Source/eric7.MicroPython.Devices.MicrobitDevices.html

branch
eric7
changeset 9756
9854647c8c5c
child 9765
6378da868bb0
equal deleted inserted replaced
9755:1a09700229e7 9756:9854647c8c5c
1 <!DOCTYPE html>
2 <html><head>
3 <title>eric7.MicroPython.Devices.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.Devices.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
33 <tr>
34 <td><a href="#createDevice">createDevice</a></td>
35 <td>Function to instantiate a MicroPython device object.</td>
36 </tr>
37 </table>
38 <hr />
39 <hr />
40 <a NAME="MicrobitDevice" ID="MicrobitDevice"></a>
41 <h2>MicrobitDevice</h2>
42
43 <p>
44 Class implementing the device for BBC micro:bit and Calliope mini boards.
45 </p>
46 <h3>Derived from</h3>
47 BaseDevice
48 <h3>Class Attributes</h3>
49
50 <table>
51 <tr><td>None</td></tr>
52 </table>
53 <h3>Class Methods</h3>
54
55 <table>
56 <tr><td>None</td></tr>
57 </table>
58 <h3>Methods</h3>
59
60 <table>
61
62 <tr>
63 <td><a href="#MicrobitDevice.__init__">MicrobitDevice</a></td>
64 <td>Constructor</td>
65 </tr>
66 <tr>
67 <td><a href="#MicrobitDevice.__createMicrobitMenu">__createMicrobitMenu</a></td>
68 <td>Private method to create the microbit submenu.</td>
69 </tr>
70 <tr>
71 <td><a href="#MicrobitDevice.__firmwareVersionResponse">__firmwareVersionResponse</a></td>
72 <td>Private method handling the response of the latest version request.</td>
73 </tr>
74 <tr>
75 <td><a href="#MicrobitDevice.__flashMicroPython">__flashMicroPython</a></td>
76 <td>Private slot to flash MicroPython or the DAPLink firmware to the device.</td>
77 </tr>
78 <tr>
79 <td><a href="#MicrobitDevice.__isCalliope">__isCalliope</a></td>
80 <td>Private method to check, if the device is a Calliope mini.</td>
81 </tr>
82 <tr>
83 <td><a href="#MicrobitDevice.__isMicroBitV1">__isMicroBitV1</a></td>
84 <td>Private method to check, if the device is a BBC micro:bit v1.</td>
85 </tr>
86 <tr>
87 <td><a href="#MicrobitDevice.__isMicroBitV2">__isMicroBitV2</a></td>
88 <td>Private method to check, if the device is a BBC micro:bit v2.</td>
89 </tr>
90 <tr>
91 <td><a href="#MicrobitDevice.__resetDevice">__resetDevice</a></td>
92 <td>Private slot to reset the connected device.</td>
93 </tr>
94 <tr>
95 <td><a href="#MicrobitDevice.__saveMain">__saveMain</a></td>
96 <td>Private slot to copy the current script as 'main.py' onto the connected device.</td>
97 </tr>
98 <tr>
99 <td><a href="#MicrobitDevice.__saveScriptToDevice">__saveScriptToDevice</a></td>
100 <td>Private method to save the current script onto the connected device.</td>
101 </tr>
102 <tr>
103 <td><a href="#MicrobitDevice.__showFirmwareVersions">__showFirmwareVersions</a></td>
104 <td>Private slot to show the firmware version of the connected device and the available firmware version.</td>
105 </tr>
106 <tr>
107 <td><a href="#MicrobitDevice.addDeviceMenuEntries">addDeviceMenuEntries</a></td>
108 <td>Public method to add device specific entries to the given menu.</td>
109 </tr>
110 <tr>
111 <td><a href="#MicrobitDevice.canRunScript">canRunScript</a></td>
112 <td>Public method to determine, if a script can be executed.</td>
113 </tr>
114 <tr>
115 <td><a href="#MicrobitDevice.canStartFileManager">canStartFileManager</a></td>
116 <td>Public method to determine, if a File Manager can be started.</td>
117 </tr>
118 <tr>
119 <td><a href="#MicrobitDevice.canStartPlotter">canStartPlotter</a></td>
120 <td>Public method to determine, if a Plotter can be started.</td>
121 </tr>
122 <tr>
123 <td><a href="#MicrobitDevice.canStartRepl">canStartRepl</a></td>
124 <td>Public method to determine, if a REPL can be started.</td>
125 </tr>
126 <tr>
127 <td><a href="#MicrobitDevice.deviceName">deviceName</a></td>
128 <td>Public method to get the name of the device.</td>
129 </tr>
130 <tr>
131 <td><a href="#MicrobitDevice.forceInterrupt">forceInterrupt</a></td>
132 <td>Public method to determine the need for an interrupt when opening the serial connection.</td>
133 </tr>
134 <tr>
135 <td><a href="#MicrobitDevice.getDocumentationUrl">getDocumentationUrl</a></td>
136 <td>Public method to get the device documentation URL.</td>
137 </tr>
138 <tr>
139 <td><a href="#MicrobitDevice.getDownloadMenuEntries">getDownloadMenuEntries</a></td>
140 <td>Public method to retrieve the entries for the downloads menu.</td>
141 </tr>
142 <tr>
143 <td><a href="#MicrobitDevice.hasFlashMenuEntry">hasFlashMenuEntry</a></td>
144 <td>Public method to check, if the device has its own flash menu entry.</td>
145 </tr>
146 <tr>
147 <td><a href="#MicrobitDevice.hasTimeCommands">hasTimeCommands</a></td>
148 <td>Public method to check, if the device supports time commands.</td>
149 </tr>
150 <tr>
151 <td><a href="#MicrobitDevice.runScript">runScript</a></td>
152 <td>Public method to run the given Python script.</td>
153 </tr>
154 <tr>
155 <td><a href="#MicrobitDevice.setButtons">setButtons</a></td>
156 <td>Public method to enable the supported action buttons.</td>
157 </tr>
158 </table>
159 <h3>Static Methods</h3>
160
161 <table>
162 <tr><td>None</td></tr>
163 </table>
164
165 <a NAME="MicrobitDevice.__init__" ID="MicrobitDevice.__init__"></a>
166 <h4>MicrobitDevice (Constructor)</h4>
167 <b>MicrobitDevice</b>(<i>microPythonWidget, deviceType, serialNumber, parent=None</i>)
168
169 <p>
170 Constructor
171 </p>
172 <dl>
173
174 <dt><i>microPythonWidget</i> (MicroPythonWidget)</dt>
175 <dd>
176 reference to the main MicroPython widget
177 </dd>
178 <dt><i>deviceType</i> (str)</dt>
179 <dd>
180 type of the device
181 </dd>
182 <dt><i>serialNumber</i> (str)</dt>
183 <dd>
184 serial number of the board
185 </dd>
186 <dt><i>parent</i> (QObject)</dt>
187 <dd>
188 reference to the parent object
189 </dd>
190 </dl>
191 <a NAME="MicrobitDevice.__createMicrobitMenu" ID="MicrobitDevice.__createMicrobitMenu"></a>
192 <h4>MicrobitDevice.__createMicrobitMenu</h4>
193 <b>__createMicrobitMenu</b>(<i></i>)
194
195 <p>
196 Private method to create the microbit submenu.
197 </p>
198 <a NAME="MicrobitDevice.__firmwareVersionResponse" ID="MicrobitDevice.__firmwareVersionResponse"></a>
199 <h4>MicrobitDevice.__firmwareVersionResponse</h4>
200 <b>__firmwareVersionResponse</b>(<i>reply</i>)
201
202 <p>
203 Private method handling the response of the latest version request.
204 </p>
205 <dl>
206
207 <dt><i>reply</i> (QNetworkReply)</dt>
208 <dd>
209 reference to the reply object
210 </dd>
211 </dl>
212 <a NAME="MicrobitDevice.__flashMicroPython" ID="MicrobitDevice.__flashMicroPython"></a>
213 <h4>MicrobitDevice.__flashMicroPython</h4>
214 <b>__flashMicroPython</b>(<i>firmware=False</i>)
215
216 <p>
217 Private slot to flash MicroPython or the DAPLink firmware to the
218 device.
219 </p>
220 <dl>
221
222 <dt><i>firmware</i> (bool)</dt>
223 <dd>
224 flag indicating to flash the DAPLink firmware
225 </dd>
226 </dl>
227 <a NAME="MicrobitDevice.__isCalliope" ID="MicrobitDevice.__isCalliope"></a>
228 <h4>MicrobitDevice.__isCalliope</h4>
229 <b>__isCalliope</b>(<i></i>)
230
231 <p>
232 Private method to check, if the device is a Calliope mini.
233 </p>
234 <dl>
235 <dt>Return:</dt>
236 <dd>
237 flag indicating a Calliope mini
238 </dd>
239 </dl>
240 <dl>
241 <dt>Return Type:</dt>
242 <dd>
243 bool
244 </dd>
245 </dl>
246 <a NAME="MicrobitDevice.__isMicroBitV1" ID="MicrobitDevice.__isMicroBitV1"></a>
247 <h4>MicrobitDevice.__isMicroBitV1</h4>
248 <b>__isMicroBitV1</b>(<i></i>)
249
250 <p>
251 Private method to check, if the device is a BBC micro:bit v1.
252 </p>
253 <dl>
254 <dt>Return:</dt>
255 <dd>
256 falg indicating a BBC micro:bit v1
257 </dd>
258 </dl>
259 <dl>
260 <dt>Return Type:</dt>
261 <dd>
262 bool
263 </dd>
264 </dl>
265 <a NAME="MicrobitDevice.__isMicroBitV2" ID="MicrobitDevice.__isMicroBitV2"></a>
266 <h4>MicrobitDevice.__isMicroBitV2</h4>
267 <b>__isMicroBitV2</b>(<i></i>)
268
269 <p>
270 Private method to check, if the device is a BBC micro:bit v2.
271 </p>
272 <dl>
273 <dt>Return:</dt>
274 <dd>
275 falg indicating a BBC micro:bit v2
276 </dd>
277 </dl>
278 <dl>
279 <dt>Return Type:</dt>
280 <dd>
281 bool
282 </dd>
283 </dl>
284 <a NAME="MicrobitDevice.__resetDevice" ID="MicrobitDevice.__resetDevice"></a>
285 <h4>MicrobitDevice.__resetDevice</h4>
286 <b>__resetDevice</b>(<i></i>)
287
288 <p>
289 Private slot to reset the connected device.
290 </p>
291 <a NAME="MicrobitDevice.__saveMain" ID="MicrobitDevice.__saveMain"></a>
292 <h4>MicrobitDevice.__saveMain</h4>
293 <b>__saveMain</b>(<i></i>)
294
295 <p>
296 Private slot to copy the current script as 'main.py' onto the
297 connected device.
298 </p>
299 <a NAME="MicrobitDevice.__saveScriptToDevice" ID="MicrobitDevice.__saveScriptToDevice"></a>
300 <h4>MicrobitDevice.__saveScriptToDevice</h4>
301 <b>__saveScriptToDevice</b>(<i>scriptName=""</i>)
302
303 <p>
304 Private method to save the current script onto the connected
305 device.
306 </p>
307 <dl>
308
309 <dt><i>scriptName</i> (str)</dt>
310 <dd>
311 name of the file on the device
312 </dd>
313 </dl>
314 <a NAME="MicrobitDevice.__showFirmwareVersions" ID="MicrobitDevice.__showFirmwareVersions"></a>
315 <h4>MicrobitDevice.__showFirmwareVersions</h4>
316 <b>__showFirmwareVersions</b>(<i></i>)
317
318 <p>
319 Private slot to show the firmware version of the connected device and the
320 available firmware version.
321 </p>
322 <a NAME="MicrobitDevice.addDeviceMenuEntries" ID="MicrobitDevice.addDeviceMenuEntries"></a>
323 <h4>MicrobitDevice.addDeviceMenuEntries</h4>
324 <b>addDeviceMenuEntries</b>(<i>menu</i>)
325
326 <p>
327 Public method to add device specific entries to the given menu.
328 </p>
329 <dl>
330
331 <dt><i>menu</i> (QMenu)</dt>
332 <dd>
333 reference to the context menu
334 </dd>
335 </dl>
336 <a NAME="MicrobitDevice.canRunScript" ID="MicrobitDevice.canRunScript"></a>
337 <h4>MicrobitDevice.canRunScript</h4>
338 <b>canRunScript</b>(<i></i>)
339
340 <p>
341 Public method to determine, if a script can be executed.
342 </p>
343 <dl>
344 <dt>Return:</dt>
345 <dd>
346 tuple containing a flag indicating it is safe to start a
347 Plotter and a reason why it cannot.
348 </dd>
349 </dl>
350 <dl>
351 <dt>Return Type:</dt>
352 <dd>
353 tuple of (bool, str)
354 </dd>
355 </dl>
356 <a NAME="MicrobitDevice.canStartFileManager" ID="MicrobitDevice.canStartFileManager"></a>
357 <h4>MicrobitDevice.canStartFileManager</h4>
358 <b>canStartFileManager</b>(<i></i>)
359
360 <p>
361 Public method to determine, if a File Manager can be started.
362 </p>
363 <dl>
364 <dt>Return:</dt>
365 <dd>
366 tuple containing a flag indicating it is safe to start a
367 File Manager and a reason why it cannot.
368 </dd>
369 </dl>
370 <dl>
371 <dt>Return Type:</dt>
372 <dd>
373 tuple of (bool, str)
374 </dd>
375 </dl>
376 <a NAME="MicrobitDevice.canStartPlotter" ID="MicrobitDevice.canStartPlotter"></a>
377 <h4>MicrobitDevice.canStartPlotter</h4>
378 <b>canStartPlotter</b>(<i></i>)
379
380 <p>
381 Public method to determine, if a Plotter can be started.
382 </p>
383 <dl>
384 <dt>Return:</dt>
385 <dd>
386 tuple containing a flag indicating it is safe to start a
387 Plotter and a reason why it cannot.
388 </dd>
389 </dl>
390 <dl>
391 <dt>Return Type:</dt>
392 <dd>
393 tuple of (bool, str)
394 </dd>
395 </dl>
396 <a NAME="MicrobitDevice.canStartRepl" ID="MicrobitDevice.canStartRepl"></a>
397 <h4>MicrobitDevice.canStartRepl</h4>
398 <b>canStartRepl</b>(<i></i>)
399
400 <p>
401 Public method to determine, if a REPL can be started.
402 </p>
403 <dl>
404 <dt>Return:</dt>
405 <dd>
406 tuple containing a flag indicating it is safe to start a REPL
407 and a reason why it cannot.
408 </dd>
409 </dl>
410 <dl>
411 <dt>Return Type:</dt>
412 <dd>
413 tuple of (bool, str)
414 </dd>
415 </dl>
416 <a NAME="MicrobitDevice.deviceName" ID="MicrobitDevice.deviceName"></a>
417 <h4>MicrobitDevice.deviceName</h4>
418 <b>deviceName</b>(<i></i>)
419
420 <p>
421 Public method to get the name of the device.
422 </p>
423 <dl>
424 <dt>Return:</dt>
425 <dd>
426 name of the device
427 </dd>
428 </dl>
429 <dl>
430 <dt>Return Type:</dt>
431 <dd>
432 str
433 </dd>
434 </dl>
435 <a NAME="MicrobitDevice.forceInterrupt" ID="MicrobitDevice.forceInterrupt"></a>
436 <h4>MicrobitDevice.forceInterrupt</h4>
437 <b>forceInterrupt</b>(<i></i>)
438
439 <p>
440 Public method to determine the need for an interrupt when opening the
441 serial connection.
442 </p>
443 <dl>
444 <dt>Return:</dt>
445 <dd>
446 flag indicating an interrupt is needed
447 </dd>
448 </dl>
449 <dl>
450 <dt>Return Type:</dt>
451 <dd>
452 bool
453 </dd>
454 </dl>
455 <a NAME="MicrobitDevice.getDocumentationUrl" ID="MicrobitDevice.getDocumentationUrl"></a>
456 <h4>MicrobitDevice.getDocumentationUrl</h4>
457 <b>getDocumentationUrl</b>(<i></i>)
458
459 <p>
460 Public method to get the device documentation URL.
461 </p>
462 <dl>
463 <dt>Return:</dt>
464 <dd>
465 documentation URL of the device
466 </dd>
467 </dl>
468 <dl>
469 <dt>Return Type:</dt>
470 <dd>
471 str
472 </dd>
473 </dl>
474 <a NAME="MicrobitDevice.getDownloadMenuEntries" ID="MicrobitDevice.getDownloadMenuEntries"></a>
475 <h4>MicrobitDevice.getDownloadMenuEntries</h4>
476 <b>getDownloadMenuEntries</b>(<i></i>)
477
478 <p>
479 Public method to retrieve the entries for the downloads menu.
480 </p>
481 <dl>
482 <dt>Return:</dt>
483 <dd>
484 list of tuples with menu text and URL to be opened for each
485 entry
486 </dd>
487 </dl>
488 <dl>
489 <dt>Return Type:</dt>
490 <dd>
491 list of tuple of (str, str)
492 </dd>
493 </dl>
494 <a NAME="MicrobitDevice.hasFlashMenuEntry" ID="MicrobitDevice.hasFlashMenuEntry"></a>
495 <h4>MicrobitDevice.hasFlashMenuEntry</h4>
496 <b>hasFlashMenuEntry</b>(<i></i>)
497
498 <p>
499 Public method to check, if the device has its own flash menu entry.
500 </p>
501 <dl>
502 <dt>Return:</dt>
503 <dd>
504 flag indicating a specific flash menu entry
505 </dd>
506 </dl>
507 <dl>
508 <dt>Return Type:</dt>
509 <dd>
510 bool
511 </dd>
512 </dl>
513 <a NAME="MicrobitDevice.hasTimeCommands" ID="MicrobitDevice.hasTimeCommands"></a>
514 <h4>MicrobitDevice.hasTimeCommands</h4>
515 <b>hasTimeCommands</b>(<i></i>)
516
517 <p>
518 Public method to check, if the device supports time commands.
519 </p>
520 <p>
521 The default returns True.
522 </p>
523 <dl>
524 <dt>Return:</dt>
525 <dd>
526 flag indicating support for time commands
527 </dd>
528 </dl>
529 <dl>
530 <dt>Return Type:</dt>
531 <dd>
532 bool
533 </dd>
534 </dl>
535 <a NAME="MicrobitDevice.runScript" ID="MicrobitDevice.runScript"></a>
536 <h4>MicrobitDevice.runScript</h4>
537 <b>runScript</b>(<i>script</i>)
538
539 <p>
540 Public method to run the given Python script.
541 </p>
542 <dl>
543
544 <dt><i>script</i> (str)</dt>
545 <dd>
546 script to be executed
547 </dd>
548 </dl>
549 <a NAME="MicrobitDevice.setButtons" ID="MicrobitDevice.setButtons"></a>
550 <h4>MicrobitDevice.setButtons</h4>
551 <b>setButtons</b>(<i></i>)
552
553 <p>
554 Public method to enable the supported action buttons.
555 </p>
556 <div align="right"><a href="#top">Up</a></div>
557 <hr />
558 <hr />
559 <a NAME="createDevice" ID="createDevice"></a>
560 <h2>createDevice</h2>
561 <b>createDevice</b>(<i>microPythonWidget, deviceType, vid, pid, boardName, serialNumber</i>)
562
563 <p>
564 Function to instantiate a MicroPython device object.
565 </p>
566 <dl>
567
568 <dt><i>microPythonWidget</i> (MicroPythonWidget)</dt>
569 <dd>
570 reference to the main MicroPython widget
571 </dd>
572 <dt><i>deviceType</i> (str)</dt>
573 <dd>
574 device type assigned to this device interface
575 </dd>
576 <dt><i>vid</i> (int)</dt>
577 <dd>
578 vendor ID
579 </dd>
580 <dt><i>pid</i> (int)</dt>
581 <dd>
582 product ID
583 </dd>
584 <dt><i>boardName</i> (str)</dt>
585 <dd>
586 name of the board
587 </dd>
588 <dt><i>serialNumber</i> (str)</dt>
589 <dd>
590 serial number of the board
591 </dd>
592 </dl>
593 <dl>
594 <dt>Return:</dt>
595 <dd>
596 reference to the instantiated device object
597 </dd>
598 </dl>
599 <dl>
600 <dt>Return Type:</dt>
601 <dd>
602 MicrobitDevice
603 </dd>
604 </dl>
605 <div align="right"><a href="#top">Up</a></div>
606 <hr />
607 </body></html>

eric ide

mercurial