Skip to content

Commit f5f999c

Browse files
Documentation improvements. (#63)
1 parent 199740f commit f5f999c

File tree

1 file changed

+72
-40
lines changed

1 file changed

+72
-40
lines changed

README.md

Lines changed: 72 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,38 @@
11
# MicroPython-micro:bit simulator
22

3-
This is a variant of codal_port which is compiled with Emscripten. It
4-
provides a simulated micro:bit REPL in the browser.
3+
## Try it out
54

6-
To build, first fetch the submodules (don't use recursive fetch):
7-
8-
$ git submodule update --init lib/micropython-microbit-v2
9-
$ git -C lib/micropython-microbit-v2 submodule update --init lib/micropython
10-
11-
Then run (from this top-level directory):
12-
13-
$ make
14-
15-
Once it is build the webpage in src/ needs to be served, eg via:
16-
17-
$ (cd build && python -m http.server)
18-
19-
Then browse to http://localhost:8000/demo.html
20-
21-
## Deployments
22-
23-
The main branch is deployed to https://stage-python-simulator.microbit.org/ by CircleCI.
24-
25-
Other branches are deployed to https://review-python-simulator.microbit.org/{branchName} by CircleCI.
5+
To try the simulator use the [micro:bit Python Editor beta](https://python.microbit.org/v/beta).
266

27-
There is currently no stable deployment. The URLs above are under active development
28-
and are subject to change.
29-
30-
There is also a Netlify based build for development purposes only.
31-
Netlify's GitHub integration will comment on PRs with deployment details.
7+
The rest of this page explains how to embed the simulator in an application
8+
and develop the simulator software.
329

3310
## Embedding
3411

3512
The simulator is designed to be embedded into other web applications
36-
via an iframe.
13+
as an iframe. The embedding API and URLs are not yet stable and are
14+
subject to change. If you are interested in embedding the simulator
15+
in your application please [get in touch](mailto:[email protected]).
3716

38-
The page to embed is http://localhost:8000/simulator.html
17+
The URL to embed is https://stage-python-simulator.microbit.org/simulator.html (subject to change, still under development).
3918

4019
The iframe provides the micro:bit board user interface and some limited
41-
interactions. It does not provide a terminal for serial output or the
42-
REPL or any UI for the sensors. A value for color can be passed to the simulator
43-
via a query string and is used to style the play button. E.g., http://localhost:8000/simulator.html?color=blue
20+
interactions. It does not provide a terminal for serial/the REPL or any UI to change the board sensor state.
21+
22+
A value for a brand color can be passed to the simulator via a query
23+
string and is used to style the play button. E.g., https://stage-python-simulator.microbit.org/simulator.html?color=blue
4424

4525
[demo.html](./src/demo.html) is an example of embedding the simulator.
4626
It connects the iframe to a terminal and provides a simple interface for
4727
sensors.
4828

49-
The following sections documents the messages supported via postMessage.
29+
The following sections document the messages supported by the iframe embed
30+
via postMessage.
31+
32+
### Messages sent to parent window from iframe
5033

51-
## Messages sent to parent window from iframe
34+
These messages are sent as the result of user interactions or actions taken
35+
by the running program. The simulator starts stopped with no program flashed.
5236

5337
<table>
5438
<thead>
@@ -166,7 +150,7 @@ If you send string data from the program then it will be prepended with the thre
166150

167151
</table>
168152

169-
## Messages supported by the iframe
153+
### Messages you can send to the iframe from the embedding app
170154

171155
<table>
172156
<thead>
@@ -190,7 +174,7 @@ If you send string data from the program then it will be prepended with the thre
190174
}
191175
```
192176

193-
<td>Update the micro:bit filesystem and restart the program.
177+
<td>Update the micro:bit filesystem and restart the program. You must send this in response to the request_flash message.
194178

195179
<tr>
196180
<td>stop
@@ -283,19 +267,67 @@ Otherwise, the user will need to use <code>radio.receive_bytes</code> or <code>r
283267

284268
</table>
285269

286-
## Upgrading micropython-microbit-v2
270+
## Developing the simulator
271+
272+
### Build steps
273+
274+
The simulator is a variant of the MicroPython codal_port which is compiled with
275+
Emscripten. It provides a simulated micro:bit (including REPL) in the browser.
276+
277+
To build, first fetch the submodules (don't use recursive fetch):
278+
279+
$ git submodule update --init lib/micropython-microbit-v2
280+
$ git -C lib/micropython-microbit-v2 submodule update --init lib/micropython
281+
282+
Then run (from this top-level directory):
283+
284+
$ make
285+
286+
Once it is built the pages in build/ need to be served, e.g. via:
287+
288+
$ npx serve build
289+
290+
View at http://localhost:3000/demo.html
291+
292+
$ (cd build && python -m http.server)
293+
294+
View at http://localhost:8000/demo.html
295+
296+
### Branch deployments
297+
298+
There is a Netlify based build for development purposes. Do not embed
299+
the simulator via this URL. Netlify's GitHub integration will comment
300+
on PRs with deployment details.
301+
302+
Branches in this repository are also deployed via CircleCI to https://review-python-simulator.microbit.org/{branchName}/. This requires the user pushing code to have
303+
permissions for the relevant Micro:bit Educational Foundation infrastructure.
304+
305+
### Upgrading micropython-microbit-v2
287306

288307
1. Update the lib/micropython-microbit-v2 to the relevant hash. Make sure that its lib/micropython submodule is updated (see checkout instructions above).
289308
2. Review the full diff for micropython-microbit-v2. In particular, note changes to:
290309
1. main.c, src/Makefile and mpconfigport.h all which have simulator versions that may need updates
291310
2. the HAL, which may require implementing in the simulator
292311
3. the filesystem, which has a JavaScript implementation.
293312

294-
## Web Assembly debugging
313+
### Web Assembly debugging
295314

296315
Steps for WASM debugging in Chrome:
297316

298-
- Add the source folder
317+
- Add the source folder in dev tools
299318
- Install the C/C++ debug extension: https://helpgoo.gle/wasm-debugging-extension
300-
- Enable "WebAssembly Debugging: Enable DWARF support" in DevTools Experiments.
319+
- Enable "WebAssembly Debugging: Enable DWARF support" in DevTools Experiments
301320
- DEBUG=1 make
321+
322+
## Code of Conduct
323+
324+
Trust, partnership, simplicity and passion are our core values we live and
325+
breathe in our daily work life and within our projects. Our open-source
326+
projects are no exception. We have an active community which spans the globe
327+
and we welcome and encourage participation and contributions to our projects
328+
by everyone. We work to foster a positive, open, inclusive and supportive
329+
environment and trust that our community respects the micro:bit code of
330+
conduct. Please see our [code of conduct](https://microbit.org/safeguarding/)
331+
which outlines our expectations for all those that participate in our
332+
community and details on how to report any concerns and what would happen
333+
should breaches occur.

0 commit comments

Comments
 (0)