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