Compare commits
663 Commits
Author | SHA1 | Date | |
---|---|---|---|
c6b16279b8 | |||
d858bd0fe8 | |||
4c62df1112 | |||
ad2acb244a | |||
24c240c7de | |||
c9dde9d99f | |||
df5ec40bd7 | |||
ada5a5898b | |||
72d3cb64eb | |||
735cdc743c | |||
f8a5244146 | |||
b5c1acd363 | |||
29fc2c6681 | |||
a7534b0680 | |||
2a2f31d71c | |||
1ec778276d | |||
186ecb6493 | |||
623269e239 | |||
6264e32223 | |||
bc8b97faba | |||
df64034519 | |||
3ef7fe6a5a | |||
2b4d71ac8b | |||
aec1cf2ca6 | |||
d1d6abebb4 | |||
df04e9f0d1 | |||
a1b0b5153c | |||
00b4e8dc01 | |||
7a8f540b27 | |||
f04222fecb | |||
ede7c8b29b | |||
3dffd14abb | |||
fbf653834e | |||
166014bd92 | |||
3811461274 | |||
dbd3837dba | |||
db79634446 | |||
7f710c7d78 | |||
ce8bd38cb7 | |||
56dc85e6ff | |||
60f921c173 | |||
28fc309a64 | |||
e28cd3c3c6 | |||
4d2981489d | |||
f7f9a29e55 | |||
be88603d57 | |||
0dc9f53e30 | |||
9cb426e060 | |||
38c60710d1 | |||
5c62e5d697 | |||
63268c61a8 | |||
0c0c1cdd73 | |||
3d70526d05 | |||
cf1b85f85b | |||
1f7ad1f114 | |||
b1d8ab0206 | |||
8bfa79fd15 | |||
991aa40f19 | |||
279f72c800 | |||
2420a7c781 | |||
7f134f330d | |||
a91c28bd56 | |||
a5aca0dfcf | |||
b1fd48882c | |||
a34004c14a | |||
9db0335844 | |||
ae8cb2dc53 | |||
3fb21e590c | |||
4376d3cefe | |||
b31d6188f9 | |||
7a741622a9 | |||
a1104010e4 | |||
a39067a0f4 | |||
f2ccad6c26 | |||
8fe328b2e8 | |||
b984af2130 | |||
fcfcf901aa | |||
969ecee5b5 | |||
cd5e5d55bc | |||
7730b7c18f | |||
254a979086 | |||
a846685d26 | |||
1a7667724d | |||
1d49ba4cf0 | |||
70dd486320 | |||
9e60666b66 | |||
0de9102f96 | |||
53dd4206a0 | |||
9b2fdabdcc | |||
3af4d8cf18 | |||
9f2368b59e | |||
08f79ee743 | |||
5ec4a3118a | |||
352e59bfad | |||
143c703bf2 | |||
37eb855df6 | |||
47dac2a175 | |||
211ec7a65d | |||
d4220593b0 | |||
5d861e1e6d | |||
64aa0fd6f5 | |||
5be188d6e7 | |||
502cca6cc0 | |||
703a876a84 | |||
ca1e3e7231 | |||
a0e971d49f | |||
750faf42e4 | |||
b359411058 | |||
9c140a5e6f | |||
fad68499e5 | |||
c861fd6c65 | |||
db961f78a5 | |||
975b995f09 | |||
167ba57d2b | |||
d40c0763f1 | |||
8c2ecdd42e | |||
9d58ea8b1c | |||
22864af73d | |||
53bb4ec7e9 | |||
8e3694661a | |||
2ba1b0c262 | |||
a61e6f539e | |||
cc3c966427 | |||
ef5bee5a21 | |||
800682e8cc | |||
291ea7169f | |||
ef6c3a6617 | |||
734e81f4be | |||
8e1acfc7df | |||
01c56e1111 | |||
dfbf06fc0e | |||
d1902a83ca | |||
aeff3d9f45 | |||
6530bc26ae | |||
8ea9f1fb26 | |||
1e94e04104 | |||
e95d29286a | |||
14d50810cb | |||
250e21b5c9 | |||
98eab3672f | |||
360e2b7ba6 | |||
f255e1a903 | |||
d4762cc5b5 | |||
749b5266cb | |||
bbd23f6d26 | |||
4bef7d50bd | |||
bf423ca037 | |||
7556796eb6 | |||
0a380a70d1 | |||
5c57e0faa4 | |||
41abeb62c3 | |||
b6eeeef4d5 | |||
b5b7edb978 | |||
a65fe1343c | |||
3165fb3749 | |||
2789887f3b | |||
d230fdd2fb | |||
88c9ef5b22 | |||
154115cc66 | |||
145dbaeb8f | |||
1c8ceaef17 | |||
e30c6f7149 | |||
e69174ed0f | |||
303d37ac9b | |||
69e2b41c40 | |||
8f04c8c20a | |||
7661df09c8 | |||
62cbacc8ba | |||
a9fd336093 | |||
d800f5fcb9 | |||
29e6f51798 | |||
ffb671d6b1 | |||
8eb4200b46 | |||
dfc7a1ddb9 | |||
5e2ea5056b | |||
c417f0ed93 | |||
ce85907019 | |||
8cf0984a3f | |||
8eb1b98cd4 | |||
53f55c031c | |||
61b1150b8f | |||
f574b91098 | |||
4a52f93367 | |||
fd0193e983 | |||
566326ea17 | |||
d7e1ec41b8 | |||
620297b95e | |||
e9862751ba | |||
5df83bb079 | |||
903c0ec6bd | |||
4be57eee9a | |||
89a2178ff5 | |||
b3ffabba41 | |||
c98e65a68c | |||
2c70784251 | |||
00333b0257 | |||
d01c801f63 | |||
05828ddcd9 | |||
f473835604 | |||
d82da1f877 | |||
94706adc40 | |||
79fb4e4ff7 | |||
dae84afded | |||
82d93a2b91 | |||
45cbbd342b | |||
5c7779927c | |||
df3d3b41ab | |||
d691ebfd52 | |||
a7bd9f6708 | |||
c3d3747cd8 | |||
7bc5488f25 | |||
f27aa28f8e | |||
12ccf21e28 | |||
c557929fb2 | |||
2e58a31b07 | |||
081a56550d | |||
3d665d5505 | |||
f991733e04 | |||
020b7e9bbe | |||
f3bf46f691 | |||
c3bb56da0c | |||
1f98257984 | |||
1cec654342 | |||
bb027ec75a | |||
ceeb366be5 | |||
d6cc95112c | |||
ce24e9d923 | |||
7ee5b4112b | |||
d903901de2 | |||
c1025b8658 | |||
cdb9682a8b | |||
9d589971f5 | |||
c6807d67d8 | |||
05ff9282ac | |||
2825d09eae | |||
15d4a594ae | |||
a0b426bdf0 | |||
580f1bf24e | |||
29cc6eaded | |||
6671d1864c | |||
42d21dea28 | |||
c4e427c090 | |||
d01ca8d565 | |||
9c3236de80 | |||
51e64bd82d | |||
572b4a74e4 | |||
9774c9306a | |||
1e2066726a | |||
0b144539f3 | |||
3a8bbfbd91 | |||
0b457d6a50 | |||
b6b18b7ceb | |||
6de8e604f7 | |||
4f960f5585 | |||
5e62d5c30d | |||
e701d83dc5 | |||
f666d3375e | |||
4aa2d129e9 | |||
09f4001c7a | |||
eae2f0436d | |||
287c9da3bd | |||
056ec1bc96 | |||
16439bfca3 | |||
7117ba771e | |||
633522c800 | |||
3f94033c7d | |||
1bc00f476c | |||
0269ffa5ae | |||
981910fb0a | |||
baa9a262fb | |||
fe1de4a423 | |||
8537061e79 | |||
c64225982e | |||
f6b7467324 | |||
36755400fd | |||
29eef560b0 | |||
90e191c4ca | |||
efd310f0b4 | |||
0a5c2e4df9 | |||
1d6eaf0370 | |||
b4b789422e | |||
cf982d7c52 | |||
2dafe5d253 | |||
63422bf696 | |||
56dc8571b7 | |||
d9190369b7 | |||
4cf7ec2da1 | |||
4b8e9f5715 | |||
ea4bc7f4e8 | |||
7aa136d01c | |||
4eeae7e239 | |||
11b6ba0862 | |||
349a385f97 | |||
48afb52ef1 | |||
e5dc046fcc | |||
7f7aa1c60b | |||
584aaf8c6d | |||
029b5cda2b | |||
ed2f6d05ad | |||
26e20d75a4 | |||
31f5db32d1 | |||
107fe2aefa | |||
171f578b0b | |||
90756557f2 | |||
1e89d142ec | |||
002f08ca37 | |||
054501ace0 | |||
0e99bf0d9e | |||
69bf34f773 | |||
980fbc9c1e | |||
dab48cf42d | |||
652abe0892 | |||
781472e7ce | |||
1e4197b4fa | |||
6ba50b6c17 | |||
ab5b6baf46 | |||
8ec20b87d7 | |||
dc3f6cf885 | |||
3a6e132c7f | |||
3533e57cc3 | |||
c03fac2162 | |||
2138725a44 | |||
e10bb1ce1d | |||
3bb03dcc1d | |||
a45bf54cff | |||
75e53ddd61 | |||
0590e74cc0 | |||
76edc1290c | |||
3b66827d8a | |||
83bd1ed3e1 | |||
41c7e88928 | |||
19f757e159 | |||
fb222fd732 | |||
07b07a5a3f | |||
f46c23fb92 | |||
937bcc61ad | |||
7d61e5fe7c | |||
773dae8fc8 | |||
511f399d90 | |||
633ce491af | |||
8193c4790f | |||
21e64d01e3 | |||
641d8fcb9b | |||
84736554b9 | |||
e2c7579dd4 | |||
2e9ad0ad92 | |||
68cbb963fc | |||
1c1e960252 | |||
077ecaab87 | |||
3111960ecf | |||
2f203d68d1 | |||
aeb3b6f864 | |||
e0cf776591 | |||
da38ca2234 | |||
682ae92a08 | |||
ed8aaf8bda | |||
f5f36d9cca | |||
19775e307a | |||
89406330cf | |||
9bc1e38345 | |||
85d5073fbb | |||
d76d92e041 | |||
6799721c9b | |||
c191cdf7ec | |||
16cf45aa7c | |||
94e72784b9 | |||
4963bf776a | |||
237c5c019b | |||
cf37baa337 | |||
67eb1d3b19 | |||
6a13b9737e | |||
1ec7e67fb0 | |||
c3253e24fc | |||
326cd7d0c3 | |||
804cc8c091 | |||
64ff568597 | |||
4196ba6632 | |||
26626d2a2a | |||
b70a2fc096 | |||
9791a02c7e | |||
89ceeefc32 | |||
91235d2377 | |||
a805d7b8a8 | |||
89fdbcdc4f | |||
7303a1235f | |||
38ee5efdd4 | |||
474d5bb762 | |||
f045942297 | |||
92d1d2ffc3 | |||
82c9af836f | |||
da90401fe6 | |||
315a12dd8b | |||
7936517a03 | |||
ee60396e35 | |||
72ec2d617e | |||
4d9ae63831 | |||
3eab21cff1 | |||
5a37385d14 | |||
9fa412ff6f | |||
307d25ce7d | |||
ec48474231 | |||
3f7fbb70ba | |||
524bcee5ed | |||
20189a709b | |||
111b321722 | |||
b8fe8f9294 | |||
83cfd5738f | |||
83b8ba1102 | |||
2169cb044c | |||
7b478c4c38 | |||
a68e1a611d | |||
b3b2944b46 | |||
76adc3c00a | |||
c809ee4fdf | |||
8e67e69602 | |||
c6e38bd7a9 | |||
c60a4cb359 | |||
0b508e37b1 | |||
e1a3aca9f8 | |||
bbe93ae9a2 | |||
6fd18b4f4c | |||
b511537348 | |||
749ba6b984 | |||
298382c19f | |||
ef849b645b | |||
78e8c9f176 | |||
57aadd0b27 | |||
e60c163b08 | |||
95e4c609a4 | |||
e571bec213 | |||
1ad90eda81 | |||
0c604498d3 | |||
a8ec408f96 | |||
40fe1b4616 | |||
30fd978064 | |||
0c26d74c05 | |||
0e4d555eb2 | |||
34c608ba75 | |||
007cf55d7f | |||
d3b10aa89e | |||
5dc99388b3 | |||
cbe25da154 | |||
e52da19925 | |||
d558f70118 | |||
8fca50e907 | |||
8c4abe979b | |||
f2e1bc0168 | |||
5c818980ed | |||
172aa6a4d7 | |||
d4fa9dab1b | |||
955b67b6b8 | |||
abf7d48bfd | |||
96d5dc2064 | |||
e0735188fa | |||
c5b9d0876a | |||
4716d06fe6 | |||
a2aaed2923 | |||
38aa6439a2 | |||
a4ba24d6ef | |||
d6d64f3edb | |||
f078d59bb5 | |||
dffbe5dcb4 | |||
d0821710f6 | |||
2291f8b899 | |||
2bc5db517e | |||
f191d9033d | |||
739be09ac9 | |||
7d912110f4 | |||
5877adc595 | |||
0380f4f0d0 | |||
ae882a0107 | |||
367e80cb77 | |||
c3865afe8c | |||
6b9b636ae6 | |||
9a20841c6e | |||
9e95f1a442 | |||
c6ce36065e | |||
13a4b03e9a | |||
4b21d51769 | |||
e7aed1d162 | |||
27f28032fb | |||
2dc9cffa99 | |||
376512f704 | |||
3813fba899 | |||
60e71e3e35 | |||
b003d89061 | |||
84816f4f39 | |||
2b095dfe21 | |||
2e3cdee2a2 | |||
ec404e5887 | |||
ba69563bf4 | |||
a5eb93d3e1 | |||
224cb446e4 | |||
62b3d7504f | |||
cc6594921f | |||
bf1269b82e | |||
c937cba17e | |||
79c89b832a | |||
0765159633 | |||
b14a025b14 | |||
3ccc8b7db3 | |||
7c8bae3cf0 | |||
000f784011 | |||
d85446d34d | |||
74f8cc7b2e | |||
cf778686c3 | |||
99bee9e796 | |||
cb61c1a712 | |||
fdf3d1b66c | |||
25ddbf9ffd | |||
578f971d26 | |||
06641d4e5c | |||
a705c4882b | |||
b36ffaf29c | |||
bff088fced | |||
784565b24e | |||
b59e4effff | |||
2db2741b08 | |||
66a46e4046 | |||
2f11d603e7 | |||
8089fe262e | |||
7d7d13f3ab | |||
bd1536132d | |||
fcefe1ed36 | |||
748581d76d | |||
f21f9e6e88 | |||
3f1817037e | |||
4bcba9b9e5 | |||
b3b836d77c | |||
a2cb2c2ed0 | |||
44e2ffc874 | |||
64b68c7439 | |||
198b24c6a4 | |||
a90a43d719 | |||
f9d138cb42 | |||
f2c87db3ed | |||
13089f92a8 | |||
0b1b312e76 | |||
958ff2ef40 | |||
eaf982903f | |||
8c15af11db | |||
35e414764f | |||
333659c320 | |||
8c161583eb | |||
b20e185bf2 | |||
299b595581 | |||
65433216e6 | |||
cbfbcd080a | |||
9c389e290e | |||
4dd26f854c | |||
66444b886c | |||
9ea2081e89 | |||
808e5fa17b | |||
20d967a230 | |||
c1e5419e45 | |||
0c01fdb30b | |||
75c2ccdea9 | |||
2dff5c1140 | |||
0ab28076f3 | |||
27f5411404 | |||
f53eab0539 | |||
8030f27fb7 | |||
33c4b2b9b7 | |||
2463faf8d6 | |||
6db78761c4 | |||
a0893cdaff | |||
c6fa997f02 | |||
76d236e4d9 | |||
445fe12629 | |||
ddd6e90c6d | |||
fd14ba6ff1 | |||
28a8f21d40 | |||
0f7323f2da | |||
23d30484d4 | |||
6ad59e04a6 | |||
ae5d5c74a7 | |||
3f626105cd | |||
d9ff9c4800 | |||
75baca4a97 | |||
58ae4945cb | |||
fba37d96b2 | |||
31998fec05 | |||
342aa3ca32 | |||
5eb8704382 | |||
81b66664ef | |||
135aaf4855 | |||
9b599b6242 | |||
e5e63c548f | |||
f3eb9a988f | |||
e7e2ff7752 | |||
f10ac93268 | |||
47f46553e0 | |||
3158e95cde | |||
854029fe33 | |||
1b379bddd0 | |||
9495da9a53 | |||
128b3f2f51 | |||
1fbf257619 | |||
932c01f394 | |||
c3b2b99d7c | |||
ec910cb10f | |||
a19d1c848b | |||
a331a017b8 | |||
790b9f557a | |||
0b469f69b6 | |||
5cce86ec7e | |||
65e01dc0df | |||
1a3c31c9f3 | |||
7aeb216462 | |||
543659b0e8 | |||
a2b5ff68af | |||
b968d3b1de | |||
4dbebe3e15 | |||
3b95fede48 | |||
5d4bd77bf4 | |||
c83d7e9f07 | |||
971faed80a | |||
02a58caf7a | |||
912e2e6159 | |||
efee05c7f5 | |||
cc9ab86181 | |||
e834ae0656 | |||
175923fcb9 | |||
42ebdde3df | |||
20c63359af | |||
841f3dc7d6 | |||
f7377f6a21 | |||
1104ab5b33 | |||
e2fe660012 | |||
7d4b800637 | |||
ef8d7185ee | |||
b0392da8b1 | |||
c817f9e3ff | |||
746728759d | |||
3d3b9e2718 | |||
0459cd693d | |||
9c43714126 | |||
9bf7459628 | |||
b52432e103 | |||
3ac0a060dd | |||
85ebbb28e3 | |||
f69db3faf7 | |||
5f78f98f94 | |||
395b6184b9 | |||
4fc514e643 | |||
7c2512e56b | |||
d9eebf4a9f | |||
8af383ec56 | |||
573d7aff40 | |||
f73274803c | |||
63556ef14a | |||
9607183587 | |||
4cca961e52 | |||
c2a1668d55 | |||
7102eddc0b | |||
b34884fe00 | |||
e768a4dc97 | |||
8b1b1bb869 | |||
57deb1749f | |||
3274964a11 | |||
f5e8b35df4 | |||
996073728c | |||
1e964ba1ea |
7
.gitignore
vendored
@ -16,6 +16,7 @@ clients/win10/*.opendb
|
||||
clients/**/bin/**
|
||||
clients/**/obj/**
|
||||
clients/electron/projects
|
||||
hexcache
|
||||
|
||||
*.user
|
||||
*.sw?
|
||||
@ -24,3 +25,9 @@ clients/electron/projects
|
||||
*.db
|
||||
*.suo
|
||||
*.log
|
||||
|
||||
.DS_Store
|
||||
.idea
|
||||
*.iml
|
||||
.vscode/.BROWSE.VC.DB-shm
|
||||
.vscode/.BROWSE.VC.DB-wal
|
||||
|
@ -4,7 +4,6 @@ node_js:
|
||||
script:
|
||||
- "node node_modules/pxt-core/built/pxt.js travis"
|
||||
- "node node_modules/pxt-core/built/pxt.js testdir tests"
|
||||
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
|
||||
sudo: false
|
||||
notifications:
|
||||
email:
|
||||
|
26
CONTRIBUTING.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Contributing Code
|
||||
|
||||
PXT accepts bug fix pull requests. For a bug fix PR to be accepted, it must first have a tracking issue that has been marked approved. Your PR should link to the bug you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort.
|
||||
|
||||
PXT also accepts new feature pull requests. For a feature-level PR to be accepted, it first needs to have design discussion. Design discussion can take one of two forms a) a feature request in the issue tracker that has been marked as approved or b) the PR must be accompanied by a full design spec and this spec is later approved in the open design discussion. Features are evaluated against their complexity, impact on other features, roadmap alignment, and maintainability.
|
||||
|
||||
These two blogs posts on contributing code to open source projects are a good reference: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik.
|
||||
|
||||
## Security
|
||||
|
||||
If you believe you have found a security issue in PXT, please share it with us privately following the guidance at the Microsoft [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094). Reporting it via this channel helps minimize risk to projects built with PXT.
|
||||
|
||||
## Legal
|
||||
|
||||
You will need to complete a Contributor License Agreement (CLA) before your pull request can be accepted. This agreement testifies that you are granting us permission to use the source code you are submitting, and that this work is being submitted under appropriate license that we can use it.
|
||||
|
||||
You can complete the CLA by going through the steps at https://cla.microsoft.com. Once we have received the signed CLA, we'll review the request. You will only need to do this once.
|
||||
|
||||
## Housekeeping
|
||||
|
||||
Your pull request should:
|
||||
* Include a description of what your change intends to do
|
||||
* Be a child commit of a reasonably recent commit in the master branch
|
||||
* Pass all unit tests
|
||||
* Have a clear commit message
|
||||
* Include adequate tests
|
25
LICENSE.txt
Normal file
@ -0,0 +1,25 @@
|
||||
PXT - Programming Experience Toolkit
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Microsoft Corporation
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
25
README.md
@ -1,11 +1,11 @@
|
||||
# micro:bit target for PXT
|
||||
# Calliope target for PXT
|
||||
|
||||
This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using
|
||||
This target allow to program a [Calliope](http://calliope.cc/) using
|
||||
PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)).
|
||||
|
||||
* [Try it live](https://codethemicrobit.com)
|
||||
[](https://travis-ci.org/Microsoft/pxt-calliope)
|
||||
|
||||
[](https://travis-ci.org/Microsoft/pxt-microbit)
|
||||

|
||||
|
||||
## Local server
|
||||
|
||||
@ -15,11 +15,11 @@ The local server allows to run the editor and the documentation from your comput
|
||||
|
||||
The following commands are a 1-time setup after synching the repo on your machine.
|
||||
|
||||
* if not yet installed, install [Node.js 4.4.5 or higher](https://nodejs.org/en/download/)
|
||||
* See requirements for [pxt](https://github.com/Microsoft/pxt)
|
||||
* [clone this repo](https://help.github.com/articles/cloning-a-repository/) to your computer and go in the project folder
|
||||
```
|
||||
git clone https://github.com/microsoft/pxt-microbit
|
||||
cd pxt-microbit
|
||||
git clone https://github.com/microsoft/pxt-calliope
|
||||
cd pxt-calliope
|
||||
```
|
||||
* install the PXT command line (add ``sudo`` for Mac/Linux shells).
|
||||
```
|
||||
@ -32,14 +32,15 @@ npm install
|
||||
|
||||
### Running
|
||||
|
||||
Run this command to open a local web server (add ``sudo`` for Mac/Linux shells)
|
||||
Run this command to open a local web server (add ``sudo`` for Mac/Linux shells).
|
||||
```
|
||||
pxt serve
|
||||
```
|
||||
If the local server opens in the wrong browser, make sure to copy the URL containing the local token.
|
||||
Otherwise, the editor will not be able to load the projects.
|
||||
|
||||
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo`` for Mac/Linux shells):
|
||||
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo`` for Mac/Linux shells). On Windows, you must be running
|
||||
from the ``Run Yotta`` command prompt.
|
||||
```
|
||||
pxt serve -yt
|
||||
```
|
||||
@ -53,11 +54,6 @@ pxt update
|
||||
|
||||
More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
|
||||
|
||||
### Building
|
||||
|
||||
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
|
||||
* open the ``win10/app.sln`` solution and launch the ``codethemicrobit`` project.
|
||||
|
||||
## Testing
|
||||
|
||||
The build automatically runs the following:
|
||||
@ -66,7 +62,6 @@ The build automatically runs the following:
|
||||
* `pxt run` in `libs/lang-test*` - this will run the test in command line runner;
|
||||
there is a number of asserts in both of these
|
||||
* `pxt testdir` in `tests` - this makes sure all the files compile and generates .hex files
|
||||
* run the TD->TS converter on a number of test scripts from `microbit.co.uk` and make sure the results compile
|
||||
|
||||
To test something on the device:
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
///<reference path='typings/browser.d.ts'/>
|
||||
var connections = [];
|
||||
// A list of "ports", i.e. connected clients (such as web pages). Multiple web
|
||||
// pages can connect to our service: they all receive the same data.
|
||||
@ -41,7 +40,7 @@ function findNewDevices() {
|
||||
function main() {
|
||||
// Register new clients in the [ports] global variable.
|
||||
chrome.runtime.onConnectExternal.addListener(function (port) {
|
||||
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit)$/.test(port.name)) {
|
||||
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit|pxt.microbit.org)$/.test(port.name)) {
|
||||
ports.push(port);
|
||||
port.onDisconnect.addListener(function () {
|
||||
ports = ports.filter(function (x) { return x != port; });
|
||||
|
@ -61,7 +61,7 @@ function findNewDevices() {
|
||||
function main() {
|
||||
// Register new clients in the [ports] global variable.
|
||||
chrome.runtime.onConnectExternal.addListener(function (port) {
|
||||
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit)$/.test(port.name)) {
|
||||
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit|pxt.microbit.org)$/.test(port.name)) {
|
||||
ports.push(port);
|
||||
port.onDisconnect.addListener(function () {
|
||||
ports = ports.filter(function (x) { return x != port });
|
||||
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.6 KiB |
@ -6,13 +6,13 @@
|
||||
},
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "code the micro:bit",
|
||||
"version": "0.6.0",
|
||||
"name": "pxt.microbit.org",
|
||||
"version": "0.7.0",
|
||||
"author": "Microsoft Corporation",
|
||||
"short_name": "code the micro:bit",
|
||||
"short_name": "pxt.microbit.org",
|
||||
|
||||
"description": "Extension for https://codethemicrobit.com.",
|
||||
"homepage_url": "https://codethemicrobit.com",
|
||||
"description": "Extension for https://pxt.microbit.org.",
|
||||
"homepage_url": "https://pxt.microbit.org",
|
||||
"offline_enabled": "true",
|
||||
"icons": {
|
||||
"48": "logo48.png",
|
||||
@ -25,6 +25,6 @@
|
||||
],
|
||||
|
||||
"externally_connectable": {
|
||||
"matches": [ "*://localhost/*", "https://codethemicrobit.com/*", "https://*.codethemicrobit.com/*" ]
|
||||
"matches": [ "*://localhost/*", "https://pxt.microbit.org/*", "https://*.microbit.org/*" ]
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@
|
||||
}
|
||||
|
||||
- (void)launchEditor:(id)sender {
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://codethemicrobit.com/"]];
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://pxt.microbit.org/"]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -3,10 +3,10 @@
|
||||

|
||||
|
||||
This project is a clone of the [Windows
|
||||
uploader](https://codethemicrobit.com/uploader), but for OS X. Once launched,
|
||||
uploader](https://pxt.microbit.org/uploader), but for OS X. Once launched,
|
||||
the app runs in your menu bar and will automatically deploy any HEX files to
|
||||
your `micro:bit`. Like the Windows version, it is compatible with any browser
|
||||
that can run [codethemicrobit.com](http://codethemicrobit.com).
|
||||
that can run [pxt.microbit.org](http://pxt.microbit.org).
|
||||
|
||||
## Install the built version
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "m.pxt.io", "app\m.pxt.io.jsproj", "{39122940-AB16-4CD4-A0CE-79A3EB863ECF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.Build.0 = Debug|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.Build.0 = Debug|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.Build.0 = Release|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.ActiveCfg = Release|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.Build.0 = Release|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.Deploy.0 = Release|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.ActiveCfg = Release|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.Build.0 = Release|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1 +0,0 @@
|
||||
MainPackage=C:\gh\pxt-microbit\win10\app\bin\Debug\m.pxt.io_0.1.4.0_AnyCPU_Debug.appx
|
@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|AnyCPU">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>AnyCPU</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|ARM">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x86">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x86</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|AnyCPU">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>AnyCPU</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x86">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x86</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>39122940-ab16-4cd4-a0ce-79a3eb863ecf</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0'">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).Default.props" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).props" />
|
||||
<PropertyGroup>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>$(VersionNumberMajor).$(VersionNumberMinor)</MinimumVisualStudioVersion>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<PackageCertificateKeyFile>pxtwinapp_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
|
||||
<AppxBundle>Always</AppxBundle>
|
||||
<AppxBundlePlatforms>neutral</AppxBundlePlatforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<Content Include="msapp-error.js" />
|
||||
<Content Include="msapp-error.css" />
|
||||
<Content Include="msapp-error.html" />
|
||||
<Content Include="images\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="images\SplashScreen.scale-200.png" />
|
||||
<Content Include="images\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="images\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="images\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="images\StoreLogo.png" />
|
||||
<Content Include="images\Wide310x150Logo.scale-200.png" />
|
||||
<None Include="pxtwinapp_TemporaryKey.pfx" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\$(WMSJSProjectDirectory)\Microsoft.VisualStudio.$(WMSJSProject).targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below then uncomment
|
||||
that target and the DisableFastUpToDateCheck PropertyGroup.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
||||
</PropertyGroup>
|
||||
-->
|
||||
</Project>
|
@ -1,48 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25123.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "codethemicrobitapp", "codethemicrobitapp.jsproj", "{39122940-AB16-4CD4-A0CE-79A3EB863ECF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.Build.0 = Debug|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.Build.0 = Debug|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.Build.0 = Release|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.ActiveCfg = Release|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.Build.0 = Release|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.Deploy.0 = Release|x64
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.ActiveCfg = Release|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.Build.0 = Release|x86
|
||||
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 8.4 KiB |
@ -1,17 +0,0 @@
|
||||
body {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.tip {
|
||||
font-size: 90%;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.paramName {
|
||||
font-size: 100%;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.paramValue {
|
||||
color: black;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Navigation Error</title>
|
||||
<link href="msapp-error.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="msapp-error.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Navigation Error</h1>
|
||||
<div id="failureUrl" class="param">
|
||||
<span>-</span><span class="paramName">failureUrl</span><span>=</span>
|
||||
<span id="failureUrlValue" class="paramValue"></span>
|
||||
<span class="tip">(indicates the url where the error occurred)</span><br/>
|
||||
</div><br/>
|
||||
<div id="httpStatus" class="param">
|
||||
<span>-</span><span class="paramName">httpStatus</span><span>=</span>
|
||||
<span id="httpStatusValue" class="paramValue"></span>
|
||||
<span class="tip">(available when the error has an http status code)</span><br/>
|
||||
</div><br/>
|
||||
<div id="failureName">
|
||||
<span>-</span><span class="paramName">failureName</span><span>=</span>
|
||||
<span id="failureNameValue" class="paramValue"></span>
|
||||
<span class="tip">(available only when the error does not have a http status code)</span><br/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
(function () {
|
||||
var validParameterNames = [ "httpStatus", "failureName", "failureUrl" ];
|
||||
|
||||
function parseQueryParameters() {
|
||||
var query = location.search.slice(1);
|
||||
return query.split("&").reduce(function (queryParameters, rawPair) {
|
||||
var pair = rawPair.split("=").map(decodeURIComponent);
|
||||
queryParameters[pair[0]] = pair[1];
|
||||
return queryParameters;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
var queryParameters = parseQueryParameters();
|
||||
validParameterNames.forEach(function (parameterName) {
|
||||
var parameterValue = queryParameters[parameterName] || "N/A";
|
||||
document.getElementById(parameterName + "Value").textContent = parameterValue;
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", initialize);
|
||||
}());
|
@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
||||
<Identity Name="39122940-ab16-4cd4-a0ce-79a3eb863ecf" Version="0.1.5.0" Publisher="CN=jhalleux" />
|
||||
<mp:PhoneIdentity PhoneProductId="39122940-ab16-4cd4-a0ce-79a3eb863ecf" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||
<Properties>
|
||||
<DisplayName>codethemicrobit</DisplayName>
|
||||
<PublisherDisplayName>Microsoft</PublisherDisplayName>
|
||||
<Logo>images\storelogo.png</Logo>
|
||||
</Properties>
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
<Resources>
|
||||
<Resource Language="x-generate" />
|
||||
</Resources>
|
||||
<Applications>
|
||||
<Application Id="App" StartPage="https://codethemicrobit.com">
|
||||
<uap:ApplicationContentUriRules>
|
||||
<uap:Rule Match="https://m.pxt.io/" Type="include" WindowsRuntimeAccess="all" />
|
||||
<uap:Rule Match="https://codemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
|
||||
<uap:Rule Match="https://codethemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
|
||||
</uap:ApplicationContentUriRules>
|
||||
<uap:VisualElements DisplayName="code the micro:bit" Description="A code editor for the BBC micro:bit with Blocks or Javascript." BackgroundColor="white" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" ShortName="code the micro:bit">
|
||||
</uap:DefaultTile>
|
||||
<uap:SplashScreen Image="images\splashscreen.png" />
|
||||
</uap:VisualElements>
|
||||
<Extensions>
|
||||
<uap:Extension Category="windows.fileTypeAssociation">
|
||||
<uap:FileTypeAssociation Name="microbithex">
|
||||
<uap:DisplayName>BBC micro:bit binary file</uap:DisplayName>
|
||||
<uap:SupportedFileTypes>
|
||||
<uap:FileType ContentType="application/x-microbit-hex">.hex</uap:FileType>
|
||||
</uap:SupportedFileTypes>
|
||||
</uap:FileTypeAssociation>
|
||||
</uap:Extension>
|
||||
</Extensions>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<uap:Capability Name="removableStorage" />
|
||||
<DeviceCapability Name="bluetooth" />
|
||||
<DeviceCapability Name="serialcommunication">
|
||||
<Device Id="any">
|
||||
<Function Type="name:serialPort" />
|
||||
</Device>
|
||||
</DeviceCapability>
|
||||
</Capabilities>
|
||||
</Package>
|
Before Width: | Height: | Size: 172 KiB |
Before Width: | Height: | Size: 121 KiB |
Before Width: | Height: | Size: 54 KiB |
@ -32,7 +32,7 @@ namespace Microsoft.MicroBit
|
||||
private void openEditor()
|
||||
{
|
||||
// lanch editor
|
||||
try { Process.Start("https://codethemicrobit.com#uploader"); } catch (Exception) { }
|
||||
try { Process.Start("https://pxt.microbit.org#uploader"); } catch (Exception) { }
|
||||
}
|
||||
|
||||
private void initializeFileWatch()
|
||||
@ -236,7 +236,7 @@ namespace Microsoft.MicroBit
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start("https://codethemicrobit.com/uploader");
|
||||
Process.Start("https://pxt.microbit.org/uploader");
|
||||
}
|
||||
catch (IOException) { }
|
||||
}
|
||||
|
59
cmds/cmds.ts
@ -1,59 +0,0 @@
|
||||
/// <reference path="../node_modules/pxt-core/built/pxt.d.ts"/>
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as child_process from "child_process";
|
||||
|
||||
let writeFileAsync: any = Promise.promisify(fs.writeFile)
|
||||
let execAsync: (cmd: string, options?: { cwd?: string }) => Promise<Buffer> = Promise.promisify(child_process.exec)
|
||||
let readDirAsync = Promise.promisify(fs.readdir)
|
||||
|
||||
|
||||
export function deployCoreAsync(res: ts.pxtc.CompileResult) {
|
||||
return getBitDrivesAsync()
|
||||
.then(drives => {
|
||||
if (drives.length == 0) {
|
||||
let msg = "cannot find any drives to deploy to";
|
||||
console.log(msg);
|
||||
return Promise.reject(new Error(msg));
|
||||
}
|
||||
|
||||
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "))
|
||||
|
||||
return Promise.map(drives, d =>
|
||||
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
|
||||
.then(() => {
|
||||
console.log("wrote hex file to " + d)
|
||||
}))
|
||||
})
|
||||
.then(() => { })
|
||||
}
|
||||
|
||||
function getBitDrivesAsync(): Promise<string[]> {
|
||||
if (process.platform == "win32") {
|
||||
const rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
|
||||
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
|
||||
.then(buf => {
|
||||
let res: string[] = []
|
||||
buf.toString("utf8").split(/\n/).forEach(ln => {
|
||||
let m = rx.exec(ln)
|
||||
if (m) {
|
||||
res.push(m[1] + "/")
|
||||
}
|
||||
})
|
||||
return res
|
||||
})
|
||||
}
|
||||
else if (process.platform == "darwin") {
|
||||
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
||||
return readDirAsync("/Volumes")
|
||||
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
|
||||
} else if (process.platform == "linux") {
|
||||
const rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
||||
const user = process.env["USER"]
|
||||
return readDirAsync(`/media/${user}`)
|
||||
.then(lst => lst.filter(s => rx.test(s)).map(s => `/media/${user}/${s}/`))
|
||||
} else {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
}
|
7
cmds/pxtrequire.ts
Normal file
@ -0,0 +1,7 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
|
||||
import * as path from "path";
|
||||
export let pxtCore = require("pxt-core");
|
||||
// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir
|
||||
export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", "..");
|
@ -1,16 +0,0 @@
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="@codethemicrobit" />
|
||||
<meta name="twitter:title" content="code the micro:bit" />
|
||||
<meta name="twitter:description" content="Blocks+JavaScript for programming your micro:bit" />
|
||||
<meta name="twitter:image" content="https://az851932.vo.msecnd.net/pub/drbwxcth" />
|
||||
|
||||
<meta property="og:title" content="micro:bit editor" />
|
||||
<meta property="og:description" content="Blocks+JavaScript for programming your micro:bit" />
|
||||
<meta property="og:site_name" content="code the micro:bit" />
|
||||
<meta property="og:image" content="https://az851932.vo.msecnd.net/pub/drbwxcth" />
|
||||
<!--
|
||||
Canonical URL needs to wait until main release is updated.
|
||||
<meta property="og:url" content="https://codethemicrobit.com" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="fb:app_id" content="" />
|
||||
-->
|
@ -1,6 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
|
||||
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||
</script>
|
@ -1,21 +0,0 @@
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:site" content="@codethemicrobit" />
|
||||
<meta name="twitter:title" content="@name@" />
|
||||
<meta name="twitter:description" content="@description@" />
|
||||
<meta name="twitter:image" content="@cardLogo@" />
|
||||
|
||||
<meta property="og:title" content="@name@" />
|
||||
<meta property="og:site_name" content="code the micro:bit" />
|
||||
<meta property="og:description" content="@description@" />
|
||||
<meta property="og:image" content="@cardLogo@" />
|
||||
<!--
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="fb:app_id" content="" />
|
||||
-->
|
||||
|
||||
<link rel="apple-touch-icon" href="@appLogo@">
|
||||
<link rel="icon" type="image/png" href="@appLogo@">
|
||||
<link rel="mask-icon" href="https://az851932.vo.msecnd.net/pub/zwxazere/safari-pinned-tab.svg" color="#000000">
|
||||
<link rel="shortcut icon" href="@appLogo@">
|
||||
<meta name="theme-color" content="@accentColor@">
|
||||
|
@ -1,5 +0,0 @@
|
||||
#root .avatar .avatar-image {
|
||||
background-image: url(https://az851932.vo.msecnd.net/pub/jovrytni/microbit.simplified.svg);
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
|
||||
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
|
||||
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||
</script>
|
@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "koduj z micro:bit",
|
||||
"title": "koduj z micro:bit",
|
||||
"docMenu": [
|
||||
{
|
||||
"name": "O nas",
|
||||
"path": "/about"
|
||||
},
|
||||
{
|
||||
"name": "Lekcje",
|
||||
"path": "/lessons"
|
||||
},
|
||||
{
|
||||
"name": "Instrukcja obsługi",
|
||||
"path": "/reference"
|
||||
},
|
||||
{
|
||||
"name": "Urządzenie",
|
||||
"path": "/device"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
# Dokumentacja
|
||||
|
||||
Witamy na stronach dokumentacji!
|
||||
|
||||
* Przeglądnij [instrukcje obsługi](/reference)
|
||||
* Dowiedz się więcej o [urządzeniu](/device)
|
||||
* Wystartuj z [lekcjami](/lessons)
|
@ -2,90 +2,4 @@
|
||||
|
||||
# About
|
||||
|
||||
### @description A Blocks / Javascript code editor for the micro:bit, a pocket-size computer with 5x5 display, sensors and Bluetooth.
|
||||
|
||||
The [BBC micro:bit](https://www.microbit.co.uk) is a [pocket-size computer](/device) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone.
|
||||
The BBC micro:bit was made possible by many [partners](https://www.microbit.co.uk/partners).
|
||||
|
||||
The micro:bit provides an easy and fun introduction to programming and making – switch on, program it to do something fun – wear it, customize it.
|
||||
Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices.
|
||||
|
||||
* [Read the docs](/docs)
|
||||
|
||||
## [Hardware: The Device](/device)
|
||||
|
||||
The BBC micro:bit is packaged with sensors, radio and other goodies. Learn about the [hardware components](/device) of the micro:bit to make the most of it!
|
||||
|
||||
## Programming: [Blocks](/blocks) or [JavaScript](/javascript)
|
||||
|
||||
You can program the micro:bit using [Blocks](/blocks) or [JavaScript](/javascript) in your web browser via the [micro:bit APIs](/reference):
|
||||
|
||||
```block
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Hi!");
|
||||
})
|
||||
```
|
||||
```typescript
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Hi!");
|
||||
})
|
||||
```
|
||||
|
||||
The editor work in [most modern browsers](/browsers), work [offline](/offline) once loaded and do not require any installation.
|
||||
|
||||
## [Compile and Flash: Your Program!](/device/usb)
|
||||
|
||||
When you have your code ready, you connect your micro:bit to a computer via a USB cable, so it appears as a mounted drive (named MICROBIT).
|
||||
|
||||
Compilation to ARM thumb machine code from [Blocks](/blocks) or [JavaScript](/javascript) happens in the browser. You save the ARM binary
|
||||
program to a file, which you then copy to the micro:bit drive, which flashes the micro:bit device with the new program.
|
||||
|
||||
## Simulator: Test Your Code
|
||||
|
||||
You can run your code using the micro:bit simulator, all within the confines of a web browser.
|
||||
The simulator has support for the LED screen, buttons, as well as compass, accelerometer, and digital I/O pins.
|
||||
|
||||
```sim
|
||||
basic.forever(() => {
|
||||
basic.showString("Hi!");
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
led.stopAnimation();
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .`);
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
led.stopAnimation();
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .`);
|
||||
});
|
||||
```
|
||||
|
||||
## C++ Runtime
|
||||
|
||||
The [C++ micro:bit runtime](http://lancaster-university.github.io/microbit-docs/), created at [Lancaster University](http://www.lancaster.ac.uk/), provides access to the hardware functions of the micro:bit,
|
||||
as well as a set of helper functions (such as displaying a number/image/string on the LED screen).
|
||||
|
||||
The [micro:bit library](/reference) mirrors the functions of the C++ library.
|
||||
When code is compiled to ARM machine code, the calls to JavaScript micro:bit functions are replaced with calls to the corresponding C++ functions.
|
||||
|
||||
## [Command Line Tools](/cli)
|
||||
|
||||
Looking to use codethemicrobit.com in your favorite editor? Install the [command line tools](/cli) and get rolling!
|
||||
|
||||
## [Packages](/packages)
|
||||
|
||||
Create, edit and distribute your own blocks and JavaScript using [packages](/packages). Packages are hosted on GitHub and may be written
|
||||
using C++, JavaScript and/or ARM thumb.
|
||||
|
||||
## [Open Source](/open-source)
|
||||
|
||||
The code for the micro:bit is [open source](/open-source) on GitHub. Contributors are welcome!
|
||||
Read more at https://calliope.cc .
|
3
docs/beta-ref.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"appref": "v"
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
# Unsupported configuration
|
||||
|
||||
[codethemicrobit.com](https://codethemicrobit.com) doesn't currently support
|
||||
your browser or operating system. The following configurations are supported:
|
||||
Your browser is currently not supported. The following configurations are supported:
|
||||
|
||||
## Windows
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# Technical information about browser support
|
||||
|
||||
[codethemicrobit.com][] requires that you use a recent version of a modern
|
||||
[pxt.microbit.org][] requires that you use a recent version of a modern
|
||||
browser, such as Microsoft Edge, Google Chrome, Mozilla Firefox, Safari, Opera,
|
||||
or IE11. This is because the editor uses modern web technologies such as [web
|
||||
workers][] to enable compiling [TypeScript][] in the browser, or the using the
|
||||
same [Monaco][] editor that powers [Visual Studio Code][].
|
||||
|
||||
[codethemicrobit.com]: https://codethemicrobit.com
|
||||
[pxt.microbit.org]: https://pxt.microbit.org
|
||||
[web workers]: http://www.w3.org/TR/workers/
|
||||
[typescript]: http://www.typescriptlang.org
|
||||
[monaco]: https://microsoft.github.io/monaco-editor/
|
||||
|
17
docs/cli.md
@ -1,17 +0,0 @@
|
||||
# Command Line Interface
|
||||
|
||||
```sim
|
||||
basic.forever(() => {
|
||||
basic.showString("CLI<3")
|
||||
})
|
||||
```
|
||||
|
||||
It is possible to use the codethemicrobit tools from a command line interface (CLI). The PXT CLI allows to
|
||||
* edit, compile or deploy JavaScript programs
|
||||
* can easily be integrated in most IDEs. It comes with built-in support for [Visual Studio Code](/code)!
|
||||
* run a local web server for the web editor
|
||||
* author packages using JavaScript and/or C++
|
||||
|
||||
Using the CLI assumes that you have some experience with programming and will require to install tools on your machine as well.
|
||||
|
||||
* **[LET'S GET STARTED](https://pxt.io/cli)**
|
16
docs/code.md
@ -1,16 +0,0 @@
|
||||
# Visual Studio Code
|
||||
|
||||
[Visual Studio Code](https://code.visualstudio.com) is a Free Open Source code editor that you can use to edit your programs.
|
||||
|
||||
Working from Visual Studio code allows you to benefit from all the features
|
||||
of a professional IDE while working with PXT: working with files,
|
||||
git integration (or source control of your choice), hundreds of extensions.
|
||||
|
||||
* background compilation
|
||||
* auto-completion
|
||||
* pxt command line integration
|
||||
|
||||
**Follow [these instructions](https://pxt.io/cli)** to setup your machine and edit your programs in Visual Studio Code.
|
||||
|
||||

|
||||
|
@ -1,93 +0,0 @@
|
||||
# Device
|
||||
|
||||
All the bits and pieces that make up the BBC micro:bit
|
||||
|
||||

|
||||
|
||||
### LED Screen and Status LED
|
||||
|
||||
The red lights are [LEDs](/device/screen) (light emitting diodes) and form a 5 x 5 LED Screen.
|
||||
They can be set to on/off and the brightness can be controlled.
|
||||
|
||||
The yellow light on the back of the micro:bit is the status LED.
|
||||
It flashes yellow when the system wants to tell the user that something has happened.
|
||||
|
||||
### Buttons
|
||||
|
||||
Buttons A and B are a form of input. When you press a button, it completes an electrical circuit.
|
||||
The micro:bit can detect either of its two buttons being pressed/released and be programmed
|
||||
to act on these events.
|
||||
|
||||
Button R on the back of the micro:bit is a system button. It has different uses.
|
||||
When you have downloaded and run your code onto your micro:bit, press Button R to restart and run your program from the beginning.
|
||||
|
||||
### USB connection
|
||||
|
||||
When you plug in your micro:bit, it should appear as ``MICROBIT``.
|
||||
If you accidentally hold down the reset button as you’re plugging in your micro:bit,
|
||||
the micro:bit will appear as a MAINTENANCE drive instead of ``MICROBIT``. This is known as maintenance mode.**
|
||||
|
||||
To continue programming your micro:bit YOU MUST unplug your USB and reconnect it. Check that the drive now shows as ``MICROBIT``.
|
||||
|
||||
**Use with caution. If you click on the drive while it shows as ``MAINTENANCE``,
|
||||
you can see which version of firmware you have running on your micro:bit.
|
||||
Firmware on your micro:bit should be up-to-date already.
|
||||
You can find the version of firmware in the 'version.txt' file on the micro:bit. Further information on the firmware can be found here:
|
||||
|
||||
https://developer.mbed.org/platforms/Microbit/#firmware
|
||||
|
||||
### Compass
|
||||
|
||||
The compass can detect magnetic fields such as the Earth’s magnetic field.
|
||||
As the micro:bit has this compass, it is possible to detect the direction it is moving in.
|
||||
The micro:bit can detect where it is facing and movement in degrees.
|
||||
This data can be used by the micro:bit in a program or be sent to another device.
|
||||
|
||||
### Accelerometer
|
||||
|
||||
There is an accelerometer on your micro:bit which detects changes in the micro:bit’s speed.
|
||||
It converts analogue information into digital form that can be used in micro:bit programs.
|
||||
Output is in milli-g. The device will also detect a small number of standard actions e.g. shake, tilt and free-fall.
|
||||
|
||||
### Pins
|
||||
|
||||
The pins can be a form of input or output.
|
||||
There are labels for the input/output pins P0, P1, P2, which you can attach external sensors to such as thermometers or moisture detectors.
|
||||
You can read more about large and small pins [here](/device/pins).
|
||||
|
||||
### Light level
|
||||
|
||||
The screen can also be used a light level sensor (it's a really cool trick).
|
||||
|
||||
### How do I connect the micro:bit to my computer?
|
||||
|
||||
Your micro:bit can be connected to your computer via a micro USB cable.
|
||||
Data can be sent and received between the micro:bit and the computer so programs
|
||||
can be downloaded from Windows, Macs and Chromebooks onto the micro:bit via this USB data connection.
|
||||
You can read more information on how to run scripts on your micro:bit [here](/device/usb),
|
||||
and about the error messages you might get [here](/device/error-codes).
|
||||
|
||||
### Powering your micro:bit
|
||||
|
||||
When your micro:bit is connected to your computer with the micro USB, it doesn’t need another power source.
|
||||
When your micro:bit isn’t connected to your computer, tablet or mobile, you will need 2 x AAA 1.5 V batteries to power it.
|
||||
|
||||
The pins labelled 3V and GND are the power supply pins.
|
||||
You can attach an external device such as a motor to these and power it using the battery or USB.
|
||||
|
||||
### Serial Communication
|
||||
|
||||
The micro:bit can send an receive data via [serial communication](/device/serial). The serial data can be transfered via USB or BLE.
|
||||
|
||||
### Bluetooth Low Energy (BLE) Antenna
|
||||
|
||||
You will see the label BLE ANTENNA on the back of your micro:bit. It is for a messaging service,
|
||||
so that devices can talk to each other. The micro:bit is a peripheral
|
||||
device which can talk to a central device like a smart phone or tablet that has Bluetooth Low Energy (BLE).
|
||||
The micro:bit can send signals and receive signals from a central device so another BLE device can
|
||||
control the micro:bit or the micro:bit can control another BLE device.
|
||||
|
||||
### Technical Information
|
||||
|
||||
The micro:bit has been designed to be a bare-board micro controller for use by children aged 11-12.
|
||||
More information is available at the [BBC web site](http://www.microbit.co.uk/device).
|
@ -1,19 +0,0 @@
|
||||
# micro:bit - the device
|
||||
|
||||
The micro:bit is a very capable device with many components:
|
||||
|
||||
* [the USB connector](/device/usb)
|
||||
* [the LED screen](/device/screen)
|
||||
* [the buttons]
|
||||
* [the accelerometer]
|
||||
* [the compass]
|
||||
* [the pins](/device/pins)
|
||||
* [the battery plug]
|
||||
|
||||
The micro:bit embodies many fundamental concepts in computer science. To learn more, read:
|
||||
|
||||
* [the micro:bit - a reactive system](/device/reactive)
|
||||
|
||||
Sometimes, your micro:bit may display an error code. For more information, see:
|
||||
|
||||
* [the error codes](/device/error-codes)
|
@ -1,23 +0,0 @@
|
||||
# crocodile clips
|
||||
|
||||
The large holes at the bottom of the board are designed to attach alligator/crocodile clips.
|
||||
Register an event that will execute whenever the user attaches one side of the crocodile clip to the `GND` pin, then connects and disconnects the unattached side of the crocodile clip to pin `0`, `1`, or `2`.
|
||||
|
||||
### Example: on pin pressed with random numbers
|
||||
|
||||
This example displays a random number every time the crocodile clip holds `GND` then connects and disconnects the `P0` pin. Each time the crocodile clip is firmly connected and disconnected from pin `P0`, the micro:bit will return a random Number between 0 and the parameter limit
|
||||
|
||||
```blocks
|
||||
input.onPinPressed(TouchPin.P0, () => {
|
||||
basic.showNumber(Math.random(10))
|
||||
})
|
||||
```
|
||||
|
||||
### Connecting Crocodile Clips
|
||||
|
||||

|
||||
|
||||
### See also
|
||||
|
||||
[micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
||||
|
@ -1,25 +0,0 @@
|
||||
# Error codes
|
||||
|
||||
The micro:bit error codes
|
||||
|
||||
Your micro:bit may encounter a situation that prevents it from running your code. When this happens, a frowny face will appear on your micro:bit screen (see picture) followed by an error number.
|
||||
|
||||
Below is a list of error numbers and what they mean:
|
||||
|
||||
* **10** (`MICROBIT_I2C_LOCKUP`): the micro:bit's I2C bus is not working
|
||||
* **20** (`MICROBIT_OOM`): there is no free memory on the micro:bit
|
||||
|
||||
```sim
|
||||
basic.showLeds(`
|
||||
# . . . #
|
||||
# # . # #
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[Run scripts on your micro:bit](/device/usb)
|
||||
|
@ -1,63 +0,0 @@
|
||||
# micro:bit pins
|
||||
|
||||
The micro:bit pins
|
||||
|
||||

|
||||
|
||||
The micro:bit has 25 external connections on the edge connector of the board, which we refer to as ‘pins’. The edge connector is the grey area on the right side of the figure above.
|
||||
|
||||
There are five large pins, that are also connected to holes in the board labelled: 0, 1, 2, 3V, and GND. And along the same edge, there are 20 small pins that you can use when plugging the micro:bit into an edge connector.
|
||||
|
||||
### Large pins
|
||||
|
||||
You can easily attach crocodile clips or 4mm banana plugs to the five large pins.
|
||||
|
||||
The first three, labelled 0, 1 and 2 are flexible and can be used for many different things - which means they are often called ‘general purpose input and output’ (shortened to GPIO). These three pins also have the ability to read analogue voltages using something called an analogue-to-digital converter (ADC). They all have the same function:
|
||||
|
||||
* **0**: GPIO (general purpose digital input and output) with analogue to digital convertor (ADC).
|
||||
* **1**: GPIO with ADC
|
||||
* **2**: GPIO with ADC
|
||||
|
||||
The other two large pins (3V and GND) are very different!/td/td
|
||||
|
||||
### ~hint
|
||||
|
||||
Watch out! The pins labelled 3V and GND relate to the power supply of the board, and they should NEVER be connected together.
|
||||
|
||||
### ~
|
||||
|
||||
*power input*: If the micro:bit is powered by USB or a battery, then you can use the 3V pin as a *power output* to power peripherals with.
|
||||
|
||||
* **3V**: *3 volt power output* or *power input*. (1) *power output*: If the micro:bit is powered by USB or a battery, then you can use the 3V pin as a power output to power peripherals with; (2) *power input*: If the micro:bit is not being powered by USB or battery, you can use the 3V pin as a power input to power the micro:bit
|
||||
* **GND**: attaches to ground in order to complete a circuit (required when using the 3V pin)
|
||||
|
||||
If you hold the ‘GND’ pin with one hand, you can program the microbit to detect yourself touching the 0,1 or 2 pins with your other hand, giving you three more buttons to experiment with (you just used your body to complete an electrical circuit).
|
||||
|
||||
### Small pins
|
||||
|
||||
There are 20 small pins numbered sequentially from 3-22 (these pins are not labeled on the micro:bit, however, they are labelled in the picture above).
|
||||
|
||||
Unlike the three large pins that are dedicated to being used for external connections, some of the small pins are shared with other components on the micro:bit board. For example, pin 3 is shared with some of the LEDs on the screen of the micro:bit, so if you are using the screen to scroll messages, you can’t use this pin as well.
|
||||
|
||||
* **pin 3**: GPIO shared with LED Col 1 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off.
|
||||
* **pin 4**: GPIO shared with LED Col 2 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off.
|
||||
* **pin 5**: GPIO shared with Button A. This lets you trigger or detect a button "A" click externally. This pin has a pull-up resistor, which means that by default it is at voltage of 3V. To replace button A on the micro:bit with an external button, connect one end of the external button to pin 4 and the other end to GND. When the button is pressed, the voltage on pin 4 is pulled down to 0, which generates a button click event.
|
||||
* **pin 6**: GPIO shared with LED Col 9 of the LED screen; can be used for digital I/O when the LED screen is turned off.
|
||||
* **pin 7**: GPIO shared with LED Col 8 of the LED screen; can be used for digital I/O when the LED screen is turned off.
|
||||
* **pin 8**: Dedicated GPIO, for sending and sensing digital signals.
|
||||
* **pin 9**: GPIO shared with LED Col 7 of the LED screen; can be used for digital I/O when the LED screen is turned off.
|
||||
* **pin 10**: GPIO shared with LED Col 3 of the LED screen; can be used for ADC and digital I/O when the LED screen is turned off.
|
||||
* **pin 11**: GPIO shared with Button B. This lets you trigger or detect a button “B” click externally.
|
||||
* **pin 12**: this GPIO pin has been reserved to provide support for accessibility.
|
||||
* **pin 13**: GPIO that is conventionally used for the serial clock (SCK) signal of the 3-wire Serial Peripheral Interface (SPI) bus.
|
||||
* **pin 14**: GPIO that is conventionally used for the Master In Slave Out (MISO) signal of the SPI bus.
|
||||
* **pin 15**: GPIO that is conventionally used for the Master Out Slave In (MOSI) signal of the SPI bus.
|
||||
* **pin 16**: Dedicated GPIO (conventionally also used for SPI ‘Chip Select’ function).
|
||||
* **pins 17 and 18**: these pins are wired to the 3V supply, like the large ‘3V’ pad.
|
||||
* **pins 19 and 20**: implement the clock signal (SCL) and data line (SDA) of the I2C bus communication protocol. With I2C, several devices can be connected on the same bus and send/read messages to and from the CPU. Internally, the accelerometer and the compass are connected to i2c.
|
||||
* **pins 21 and 22**: these pins are wired to the GND pin and serve no other function
|
||||
|
||||
### Connecting to the small pins
|
||||
|
||||
It is recommended that an edge connector be acquired to connect to the small pins. More information on compatible edge connectors will be available later.
|
||||
|
@ -1,158 +0,0 @@
|
||||
# The micro:bit - a reactive system
|
||||
|
||||
### Computing systems
|
||||
|
||||
What sort of a *computing system* is the micro:bit?
|
||||
|
||||
### ~hint
|
||||
|
||||
There are different types of computing systems, to address different kinds of problems that arise in practice: *transaction processing systems* are used by banks to handle huge numbers of financial transactions by their customers; *distributed systems* make a set of networked computers appear as one big computer (like Google’s search engine); there are also *parallel systems*, such as graphic cards, which perform a huge number of primitive operations simultaneously, using a great number of small processing cores.
|
||||
|
||||
### ~
|
||||
|
||||
The micro:bit is a *reactive system* – it reacts continuously to external events, such as a person pressing the A button of the micro:bit or shaking the device. The reaction to an event may be to perform a computation, update variables, and change the display. After the device reacts to an event, it is ready to react to the next one. If this sounds like a computer game, that’s because most computer games are reactive systems too!
|
||||
|
||||
### Responsiveness
|
||||
|
||||
We want reactive systems to be responsive, which means to react in a timely manner to events. For example, when you play a computer game, it’s frustrating if you press a button to make a character jump, but it doesn’t immediately jump. A delay in reacting, or lack of responsiveness , can be the difference between life and death, both in the real and virtual worlds.
|
||||
|
||||
Let’s consider a simple example: you want to program your micro:bit to accurately count the number of times the A button has been pressed and continuously display the current count on the 5x5 [LED screen](/device/screen). Because the LED screen is small, we can only display one digit of a number at a time on it. The [show number](/reference/basic/show-number) function will scroll the digits of a number across the screen so you can read it.
|
||||
|
||||
Let’s say that the current count is 42 and the number 42 is scrolling across the LED screen. This means there is some code executing to perform the scroll. So, what should happen if you press the A button during the scroll? It would be a bad idea to ignore the button press, so some code should record the occurrence of the button press. But we just said there already is code running in order to scroll the number 42! If we wait until the code scrolling the 42 has finished to look for a button press, we will miss the button press. We want to avoid this sort of unresponsiveness.
|
||||
|
||||
### Concurrency
|
||||
|
||||
To be responsive, a reactive system needs to be able to do several things at the same time (concurrently), just like you can. But the micro:bit only has one CPU for executing your program, which means it can only execute one program instruction at a time. On the other hand, it can execute millions of instructions in a single second. This points the way to a solution.
|
||||
|
||||
Think about how a motion picture projector works - it projects only 24 frames per second, yet this is good enough to provide the illusion of fluid motion on the screen. The micro:bit can execute millions of instructions per second, so it seems quite possible for the device to both to smoothly scroll the number 42 across the LED screen while looking for button presses and counting them.
|
||||
|
||||
Let’s think about three sequences of instructions:
|
||||
|
||||
* Sequence S1 contains the instructions (let’s say several hundred thousand or so) that scroll the number 42 across the LED screen;
|
||||
* Sequence S2 contains a few instructions to check if button A is pressed;
|
||||
* Sequence S3 contains a few instructions to increment a counter.
|
||||
|
||||
In order to be responsive, we would like to *interrupt* the execution of sequence S1 *periodically* to execute the sequence S2, which will check if button A is pressed, which looks like:
|
||||
|
||||
TODO Diagram
|
||||
|
||||
The result is that it takes sequence S1 a little longer to complete, due to the interruptions to execute sequence S2, but we are checking often enough to detect a press of button A . When S2 detects a press of button A, then the sequence S3 can be executed before S1 resumes:
|
||||
|
||||
TODO Diagram
|
||||
|
||||
As we’ll soon see, there are other choices for how the sequences can be ordered to achieve the desired result.
|
||||
|
||||
### The micro:bit scheduler and queuing up subprograms
|
||||
|
||||
The micro:bit’s *scheduler* provides the capability to concurrently execute different code sequences, relieving us of a lot of low-level programming. In fact, scheduling is so useful that it is a part of every *operating system*!
|
||||
|
||||
The first job of the scheduler is to allow multiple *subprograms* to be queued up for later execution . For our purposes, a subprogram is just a statement or sequence of statements in the context of a larger program. Consider the Touch Develop program below for counting button presses.
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count++;
|
||||
})
|
||||
basic.forever(() => {
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
```
|
||||
|
||||
The program above contains three statements that execute in order from top to bottom.
|
||||
The first statement initializes the global variable `count` to zero.
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
```
|
||||
|
||||
The second statement informs the scheduler that on each and every event of the A button being pressed, a subprogram (called the event handler) should be queued for execution. The event handler is demarcated by the do/end keywords; it increments the global variable `count` by one.
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
// ...
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count++;
|
||||
})
|
||||
```
|
||||
|
||||
The third statement queues a `forever` loop for later execution by the scheduler; the body of this loop (between the do/end keywords) displays the current value of global variable `count` on the LED screen. The third statement
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
// ...
|
||||
basic.forever(() => {
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
The function ends after the execution of these three statements, but this is not the end of program execution! That’s because the function queued the `forever` loop for execution by the scheduler.
|
||||
|
||||
The second job of the scheduler is to periodically interrupt execution to read (poll) the various inputs to the micro:bit (the buttons, pins, etc.) and fire off events (such as “button A pressed”). Recall that the firing of an event causes the event handler subprogram associated with that event to be queued for later execution. The scheduler uses a timer built into the micro:bit hardware to interrupt execution every 6 milliseconds and poll the inputs, which is more than fast enough to catch the quickest press of a button.
|
||||
|
||||
### Cooperative passing of control
|
||||
|
||||
How does the forever loop get to start execution? Furthermore, once the forever loop is running, how does any other subprogram (like the event handler that increments the count) ever get a chance to execute?
|
||||
|
||||
The answer is “cooperation” and “passing”. Think of a football team doing a drill – there is one ball and each footballer gets to dribble the ball for a certain number of touches, after which they pass to another footballer. A footballer who never passes prevents all other footballers from dribbling. A cooperative footballer always passes to some other footballer after taking a few touches.
|
||||
|
||||
If you hadn’t guessed already, a footballer represents subprogram and dribbling the ball corresponds to that subprogram executing. Only one subprogram gets to execute at a time, as there is only one ball (processor). Footballer Alice passing the ball to footballer Bob corresponds to stopping execution of Alice’s subprogram (and remembering where it stopped) and starting/resuming execution of Bob’s subprogram.
|
||||
|
||||
We will call this “passing control of execution” rather than “passing the ball”. However, in the world of the micro:bit, the concurrently executing subprograms are not aware of each other, so they don’t actually pass control directly to one another. Rather they pass control of execution back to the scheduler and the scheduler determines the subprogram to pass control to next. The programmer inserts a call to the `pause` function to indicate a point in the subprogram where control of execution passes to the scheduler. Also, when a subprogram ends execution, control passes to the scheduler.
|
||||
|
||||
Let’s take a look at the implementation of the `basic.forever` function to see an example of cooperative scheduling:
|
||||
|
||||
```typescript
|
||||
function forever(body: () => void) {
|
||||
control.inBackground(() => {
|
||||
while(true) {
|
||||
body()
|
||||
basic.pause(20)
|
||||
}
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
The `forever` loop actually is a function that takes a subprogram (an *Action* in Touch Develop) as a parameter. The function uses the `control -> in background` function of the micro:bit runtime to queue a `while true` loop for execution by the scheduler. The while loop has two statements. The first statement runs the subprogram represented by the `body` parameter. The second statement passes control to the scheduler (requesting to “sleep” for 20 milliseconds).
|
||||
|
||||
Though the `while true` loop will repeatedly execute the body subprogram, between each execution of the body it will permit the scheduler to execute other subprograms. If the while loop did not contain the call to `pause`, then once control passed into the while loop, it would never pass back to the scheduler and no other subprogram would be able to execute (unless the body subprogram contained a call to `pause` itself).
|
||||
|
||||
### Round-robin scheduling
|
||||
|
||||
Now, we come to the third and final job of the scheduler, which is to determine which subprogram to pass control to next. The scheduler uses two queues to perform this task, the sleep queue and the run queue. The sleep queue contains the subprograms that have called the pause function and still have time left to sleep. The run queue contains all the non-sleeping subprograms, such as the event handlers queued by the firing of an event.
|
||||
|
||||
The scheduler moves the subprogram that has just paused into the sleep queue and then removes the subprogram at the head of the run queue and resumes its execution. Once a subprogram’s sleep period is over, the scheduler moves it from the sleep queue to the back of the run queue.
|
||||
|
||||
The property of such round-robin scheduling is that under the assumption that every subprogram periodically enters the sleep queue, then every subprogram will periodically get a chance to execute.
|
||||
|
||||
### Putting it all together
|
||||
|
||||
Let’s go back to the `count button presses` function and revisit its execution based on what we have learned about the micro:bit scheduler. As detailed before, the function executes three steps to: (1) set up the event handler for each press of button A; (2) queue the forever loop to the run queue; (3) initialize the global variable `count` to zero.
|
||||
|
||||
The function then ends execution and control passes back to the scheduler. Let’s assume the user has not pressed any buttons . The scheduler finds the `forever` loop in the run queue and passes control to it. The loop first calls `basic -> show number(0,150)`. In the diagram below, we use “Show 0” to refer to the execution of this function:
|
||||
|
||||

|
||||
|
||||
While "Show 0" (the blue sequence) is running, periodic interrupts by the scheduler (every 6 milliseconds) poll for button presses and queue an event handler for each press of button A. Let’s say that one button press takes place during this time, as shown above. This will cause an event handler (labelled “inc”) to be queued for later execution by the scheduler. Once the "Show 0" has completed, the loop then calls `basic -> pause(20)` to put the forever loop to sleep for 20 milliseconds and give the scheduler an opportunity to run any newly queued event handler. Control passes to the “inc” event handler which will increment the global variable `count` from 0 to 1 and then complete, returning control to the scheduler. At some point, the `forever` loop moves from the sleep queue to the run queue; the `forever` loop then will resume and call `basic -> show number(1,150)`.
|
||||
|
||||
### Final thoughts
|
||||
|
||||
Through this example, we have seen that the micro:bit scheduler enables you to create a program that is composed of concurrent subprograms. In essence, the programmer needs to only think about the concurrent subprograms cooperatively passing control back to the scheduler, making sure no subprogram hogs control (or “dribbles the ball without passing”) for too long. While a subprogram runs, the scheduler polls the buttons and other IO peripherals at a high frequency in order to fire off events and queue event handlers for later execution, but this is invisible to the programmer.
|
||||
|
||||
As a result, you can easily add a new capability to the micro:bit by just adding a new subprogram. For example, if you want to add a reset feature to the counter program, all you need to do is add a new event handler for a press of button B that sets the global variable "count" to zero, as shown below:
|
||||
|
||||
```typescript
|
||||
export function countButtonPressesWithReset() {
|
||||
let count = 0
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
count = count + 1
|
||||
})
|
||||
basic.forever(() => {
|
||||
basic.showNumber(count, 150)
|
||||
})
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
count = 0
|
||||
})
|
||||
}
|
||||
```
|
||||
|
@ -1,93 +0,0 @@
|
||||
# LED screen
|
||||
|
||||
The micro:bit LED screen
|
||||
|
||||
```sim
|
||||
basic.showLeds(`
|
||||
# . # . #
|
||||
. # . # .
|
||||
# . # . #
|
||||
. # . # .
|
||||
# . # . #
|
||||
`);
|
||||
```
|
||||
|
||||
The micro:bit LED screen consists of 25 red LED lights arranged in a 5X5 grid (5 LEDs across by 5 LEDs down).
|
||||
In the screen above, we created a checkerboard pattern using the LEDs.
|
||||
|
||||
### Which LED?
|
||||
|
||||
You use `(x ,y)` coordinates to specify a particular LED in the grid;
|
||||
where `x` is the horizontal position (0,1,2,3,4) and `y` is the vertical position
|
||||
(0, 1, 2, 3, 4).
|
||||
|
||||
To figure out the ``x``, ``y`` coordinates, position your micro:bit horizontally, like a credit card (see picture above).
|
||||
|
||||
Here are the x, y coordinates for the LEDs in the 5X5 grid:
|
||||
|
||||
`(0,0)` `(1,0)` `(2,0)` `(3,0)` `(4,0)`
|
||||
|
||||
`(0,1)` `(1,1)` `(2,1)` `(3,1)` `(4,1)`
|
||||
|
||||
`(0,2)` `(1,2)` `(2,2)` `(3,2)` `(4,2)`
|
||||
|
||||
`(0,3)` `(1,3)` `(2,3)` `(3,3)` `(4,3)`
|
||||
|
||||
`(0,4)` `(1,4)` `(2,4)` `(3,4)` `(4,4)`
|
||||
|
||||
The x, y coordinates for the LED in the centre of the grid are `(2,2)`. Starting from `(0,0)` count over 2 columns and then down 2 rows.
|
||||
|
||||
### Check your understanding
|
||||
|
||||
Which LEDs are turned on in the checkboard pattern above?
|
||||
|
||||
### Row, column - 1
|
||||
|
||||
Since the row and column numbers start at 0, an easy way to figure out the (x,y) coordinates
|
||||
is to subtract 1 from the row and column number (when counting from 1).
|
||||
In other words, to specify the LED in the 4th column 5th row, subtract 1 from each number to get coordinates `(3,4)`.
|
||||
|
||||
### Turn a LED on/off
|
||||
|
||||
Use [plot](/reference/led/plot) and [unplot](/reference/led/unplot) to turn a LED on or off
|
||||
|
||||
```blocks
|
||||
led.plot(0,0);
|
||||
led.plot(1,1);
|
||||
basic.pause(1000);
|
||||
led.unplot(0,0);
|
||||
basic.pause(1000);
|
||||
led.unplot(1,1);
|
||||
```
|
||||
|
||||
### Is a LED on/off?
|
||||
|
||||
Use the [point](/reference/led/point) function to find out if a LED is on or off.
|
||||
|
||||
```blocks
|
||||
if(led.point(0,0)) {
|
||||
}
|
||||
```
|
||||
|
||||
### Display images, strings and numbers
|
||||
|
||||
Instead of turning individual LEDs on or off, as above, you can display an [image](/reference/images/image) directly to the screen or show text/numbers on screen using the [show number](/reference/basic/show-number)/[show string](/reference/basic/show-string) function.
|
||||
|
||||
### The display buffer
|
||||
|
||||
The micro:bit runtime keeps an in-memory representation of the state of all 25 LEDS. This state is known as the "display buffer" and controls which LEDS are on and which are off. The plot/unplot/point functions access the display buffer directly. On the other hand, the functions that show an image, number or string overwrite the buffer completely. To illustrate, first try running this code sequence
|
||||
|
||||
```blocks
|
||||
basic.showString("d")
|
||||
led.plot(0, 0)
|
||||
```
|
||||
|
||||
You will see the letter "d" displayed as well as the LED in position `0,0` lit up. Now try reversing the order of the two statements above:
|
||||
|
||||
```blocks
|
||||
led.plot(0, 0)
|
||||
basic.showString("d", 150)
|
||||
```
|
||||
|
||||
You will not see the LED at position `0,0` lit up because the `show string` function overwrites the whole display buffer.
|
||||
|
@ -1,93 +0,0 @@
|
||||
# Serial
|
||||
|
||||
The [serial](/reference/serial) supports [serial communication](https://en.wikipedia.org/wiki/Serial_port) between the BBC micro:bit and another computer. Basically, this allows you to send data from the micro:bit to your own computer. This is very useful for debugging purposes: you can add `write line` statements in your code and see them display on your computer as the program executes.
|
||||
|
||||
The code below shows a simple script that sends a line when the BBC micro:bit starts and another line each time the button ``A`` is pressed.
|
||||
|
||||
```blocks
|
||||
serial.writeLine("started...")
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
serial.writeLine("A pressed")
|
||||
})
|
||||
```
|
||||
|
||||
Data is also automatically streamed to serial by the ** bar graph** block
|
||||
and picked up by the editor. This data can be streamed to the cloud as well.
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
led.plotBarGraph(input.acceleration(Dimension.X), 0);
|
||||
});
|
||||
```
|
||||
|
||||
## How to read the micro:bit's serial output from your computer
|
||||
|
||||
Unfortunately, using the serial library requires quite a bit of a setup.
|
||||
|
||||
### BBC micro:bit Chrome Extension
|
||||
|
||||
If you are using the Google Chrome browser, you can use our extension to get serial data streaming in the editor.
|
||||
|
||||
* Install the [Extension for BBC micro:bit](https://chrome.google.com/webstore/detail/extension-for-bbc-microbi/cihhkhnngbjlhahcfmhekmbnnjcjdbge?hl=en-US) on the Chrome Web Store.
|
||||
* Restart Chrome and open the [web editor](https://codethemicrobit.com)
|
||||
* The serial data will show below the simulator
|
||||
|
||||
### Windows
|
||||
|
||||
You must install a device driver (for the computer to recognize the
|
||||
serial interface of the micro:bit); then, you must also install a
|
||||
terminal emulator (which is going to connect to the micro:bit and read
|
||||
its output).
|
||||
|
||||
* Follow the instructions at
|
||||
https://developer.mbed.org/handbook/Windows-serial-configuration to
|
||||
install the device driver.
|
||||
|
||||
* Instructions for installing a terminal emulator are below.
|
||||
|
||||
#### Windows > Tera Term
|
||||
|
||||
* Install the terminal emulator [Tera Term](https://ttssh2.osdn.jp/index.html.en). At the time of this writing, the latest version is 4.88 and can be downloaded [from here](http://en.osdn.jp/frs/redir.php?m=jaist&f=%2Fttssh2%2F63767%2Fteraterm-4.88.exe). Follow the instructions from the installer.
|
||||
|
||||
Once both the driver and the terminal emulator are installed, plug in the micro:bit and wait until the device is fully setup. Then, open TeraTerm.
|
||||
|
||||
* Hit `File` > `New Connection`
|
||||
* Check "Serial"; in the dropdown menu, pick the COM port that says "mbed Serial Port". Hit `Ok`.
|
||||
* In the menus, hit `Setup` > `Serial Port` and set the baud rate to `115200`.
|
||||
|
||||
You should be good. Feel free to hit `Setup` > `Save Setup` in the menus to erase the default configuration file with a new one so that you don't have to type in the settings again.
|
||||
|
||||
Please note that Windows will assign you a different COM port if you plug in another micro:bit. If you're juggling between micro:bits, you'll have to change the COM port every time.
|
||||
|
||||
#### Windows > Putty
|
||||
|
||||
If you prefer another terminal emulator (such as [PuTTY](http://www.putty.org/)), here are some instructions.
|
||||
|
||||
* Open Windows's [Device Manager](https://windows.microsoft.com/en-us/windows/open-device-manager); expand the section called "Ports (COM & LPT)"; write down the com number for "mbed Serial Port" (e.g. COM14)
|
||||
* Open PuTTY; on the main screen, use the following settings: Serial / COM14 / 115200. Replace COM14 with the COM port number you wrote down previously. Feel free to type in a name and hit "Save" to remember this configuration.
|
||||
|
||||

|
||||
|
||||
* (optional): in the "Terminal" section, check "implicit cr in every lf"
|
||||
|
||||

|
||||
|
||||
### Linux
|
||||
|
||||
* Install the program `screen` if it is not already installed.
|
||||
* Plug in the micro:bit.
|
||||
* Open a terminal.
|
||||
* Find which device node the micro:bit was assigned to with the command `ls /dev/ttyACM*`.
|
||||
* If it was `/dev/ttyACM0`, type the command `screen /dev/ttyACM0 115200`. If it was some other device node,
|
||||
use that one in the command instead. **Note:** You may need root access to run `screen`
|
||||
successfully. You can probably use the command `sudo` like this: `sudo screen /dev/ttyACM0 115200`.
|
||||
* To exit `screen`, type `Ctrl-A` `Ctrl-D`.
|
||||
|
||||
Alternative programs include `minicom` and so on.
|
||||
|
||||
### Mac OS
|
||||
|
||||
* Plug in the micro:bit
|
||||
* Open a terminal
|
||||
* `ls /dev/cu.*` will return to you a list of serial devices; one of them will look like `/dev/cu.usbmodem1422` (the exact number depends on your computer)
|
||||
* `screen /dev/cu.usbmodem1422 115200` will open up the micro:bit's serial output. To exit, hit `Ctrl-A` `Ctrl-D`.
|
@ -1,25 +0,0 @@
|
||||
# Simulator
|
||||
|
||||
The JavaScript simulator allows to test and execute most BBC micro:bit programs in the browser.
|
||||
It allows to emulate sensor data or user interactions.
|
||||
|
||||
```sim
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("A");
|
||||
});
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showString("B");
|
||||
});
|
||||
input.onPinPressed(TouchPin.P0, () => {
|
||||
basic.showString("0");
|
||||
});
|
||||
input.onPinPressed(TouchPin.P1, () => {
|
||||
basic.showString("1");
|
||||
});
|
||||
input.onPinPressed(TouchPin.P2, () => {
|
||||
basic.showString("2");
|
||||
});
|
||||
input.temperature()
|
||||
input.compassHeading()
|
||||
input.lightLevel()
|
||||
```
|
@ -1,31 +0,0 @@
|
||||
# Uploading programs on your micro:bit
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||

|
||||
|
||||
## Instructions
|
||||
|
||||
Pick the instructions for your operating system and browser:
|
||||
|
||||
* [Windows - Microsoft Edge](/device/usb/windows-edge)
|
||||
* [Windows - Internet Explorer](/device/usb/windows-ie)
|
||||
* [Windows - Chrome](/device/usb/windows-chrome)
|
||||
* [Windows - Firefox](/device/usb/windows-firefox)
|
||||
* [Mac - Safari](/device/usb/mac-safari)
|
||||
* [Mac - Chrome](/device/usb/mac-chrome)
|
||||
* [Mac - Firefox](/device/usb/mac-firefox)
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,69 +0,0 @@
|
||||
# Uploading from Chrome for Mac
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
When you select **Download** in Chrome, the file will appear at the bottom of
|
||||
the browser. Click on the small arrow and select **Show in Finder**. This will
|
||||
show the file in your download folder. Drag and drop the file onto your
|
||||
`MICROBIT` drive.
|
||||
|
||||

|
||||
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,71 +0,0 @@
|
||||
# Uploading from Firefox for Mac
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
A dialogue box will appear, asking whether you would like to open or save your
|
||||
hex file. Select **Save file** and click **OK** and the file will then appear in
|
||||
your downloads in the top right of your browser. Right click on the file and
|
||||
click on **Show in Finder** and the file will appear in your downloads folder.
|
||||
Select the file and drag and drop it onto your `MICROBIT` drive.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,68 +0,0 @@
|
||||
# Uploading from Safari for Mac
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
When you select **Download** in Safari a file called `Unknown` will be
|
||||
downloaded into your Downloads folder. Open your Downloads folder and drag and
|
||||
drop the file onto your `MICROBIT` drive, under Devices:
|
||||
|
||||

|
||||
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,24 +0,0 @@
|
||||
# Troubleshooting Transfer
|
||||
|
||||
You can’t drag and drop more than one hex file at once onto your micro:bit. If
|
||||
you try to drag and drop a second hex file onto your micro:bit before the first
|
||||
file has finished downloading, then the second file may fail in different ways.
|
||||
|
||||
When the first program has been written to the micro:bit, the drive will
|
||||
disengage. If you drag and drop a second file at this point it may not find the
|
||||
drive and the second write will fail.
|
||||
|
||||
The errors may look like this:
|
||||
|
||||
**Windows**
|
||||
|
||||

|
||||
|
||||
**Mac**
|
||||
|
||||

|
||||
|
||||
Or it may appear that there are two hex files on your micro:bit so the micro:bit
|
||||
won’t be able to run multiple files. To rectify this, unplug your micro:bit and
|
||||
plug it in again. Make sure that your micro:bit appears as `MICROBIT` and not
|
||||
`MAINTENANCE`.
|
@ -1,79 +0,0 @@
|
||||
# Uploading from Chrome for Windows
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
### ~hint
|
||||
|
||||
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
Your `.hex` file appears as a download at the bottom of the browser. Click on
|
||||
the arrow next to the name of the file and then click **Show in folder**.
|
||||
|
||||

|
||||
|
||||
Drag and drop the `.hex` file from the download folder onto the `MICROBIT` drive.
|
||||
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
|
||||
|
||||

|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,89 +0,0 @@
|
||||
# Uploading from Edge on Windows
|
||||
|
||||
How to compile, transfer, and run a program on your micro:bit on **Microsoft Edge**.
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
### ~hint
|
||||
|
||||
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
A message will appear at the bottom of the browser asking what you want to do
|
||||
with the file. Click **Save**:
|
||||
|
||||

|
||||
|
||||
Then click **Open folder** and drag and drop the file from your Downloads to
|
||||
your `MICROBIT` drive.
|
||||
|
||||

|
||||
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* If you're using Windows, you can use **Send to** as described below
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
|
||||
|
||||

|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
If you want to save time, you can use the [micro:bit uploader](/uploader) to
|
||||
automatically deploy hex files to your micro:bit. It works on Windows and is
|
||||
compatible with any browser.
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,86 +0,0 @@
|
||||
# Uploading from Firefox on Windows
|
||||
|
||||
How to compile, transfer, and run a program on your micro:bit on **Firefox for Windows**.
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
### ~hint
|
||||
|
||||
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
A window will appear asking whether you want to save or open the `.hex` file.
|
||||
Select **Save File** and then select **OK**.
|
||||
|
||||

|
||||
|
||||
The file will then appear in your downloads in the top right of your browser.
|
||||
Click the **folder icon** next to the filename to open it in Windows Explorer.
|
||||
|
||||

|
||||
|
||||
Drag and drop the `.hex` file from the download folder onto the `MICROBIT` drive.
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* If you're using Windows, you can use **Send to** as described below
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
|
||||
|
||||

|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
@ -1,86 +0,0 @@
|
||||
# Uploading from Internet Explorer on Windows
|
||||
|
||||
While you're writing and testing your programs, you'll mostly be [running them
|
||||
in the simulator](/device/simulator), but once you've finished your program you
|
||||
can **compile** it and run it on your micro:bit.
|
||||
|
||||
The basic steps are:
|
||||
|
||||
1. Connect your micro:bit to your computer via USB
|
||||
2. Click **Download** and download the `.hex` file
|
||||
3. Copy the `.hex` file from your computer onto the micro:bit drive
|
||||
|
||||
### ~hint
|
||||
|
||||
You can use the [micro:bit uploader](/uploader) to automatically deploy ``.hex`` files to your micro:bit!
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
## Requirements
|
||||
|
||||
You need the following things to transfer and run a script on your micro:bit:
|
||||
|
||||
* A-Male to Micro USB cable to connect your computer to your micro:bit. This is
|
||||
the same cable that is commonly used to connect a smart phone to a computer.
|
||||
* A PC running Windows 7 or later, or a Mac running OS X 10.6 or later
|
||||
|
||||
## Step 1: Connect your micro:bit to your computer
|
||||
|
||||
First, connect the micro:bit:
|
||||
|
||||
1. Connect the small end of the USB cable to the micro USB port on your micro:bit.
|
||||
|
||||
2. Connect the other end of the USB cable to a USB port on your computer.
|
||||
|
||||
Your computer should recognise your micro:bit as a new drive. On computers
|
||||
running Windows, `MICROBIT` appears as a drive under Devices and drives. On a Mac
|
||||
it appears as a new drive under Devices.
|
||||
|
||||

|
||||
|
||||
## Step 2: Download your program
|
||||
|
||||
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com)
|
||||
2. Click **Download**
|
||||
3. When prompted, choose to **save** the compiled file onto your computer. The
|
||||
prompt will be different depending on which browser you are using, or
|
||||
whether you are using a Windows computer or a Mac
|
||||
|
||||
A message will appear at the bottom of the browser asking what you want to do
|
||||
with the file. Click **Save**:
|
||||
|
||||

|
||||
|
||||
Then click **Open folder** and drag and drop the file from your Downloads to
|
||||
your `MICROBIT` drive.
|
||||
|
||||

|
||||
|
||||
## Step 3: Transfer the file to your micro:bit
|
||||
|
||||
* Once you've found the folder containing your `.hex` file, drag and drop it
|
||||
onto your `MICROBIT` drive
|
||||
* If you're using Windows, you can use **Send to** as described below
|
||||
* The LED on the back of your micro:bit flashes during the transfer (which
|
||||
should only take a few seconds).
|
||||
* Once transferred, the code will run automatically on your micro:bit. To rerun
|
||||
your program, press the reset button on the back of your micro:bit. The reset
|
||||
button automatically runs the newest file on the micro:bit.
|
||||
|
||||
**Send to**: If you're using Windows you use *Send to* in File Explorer:
|
||||
|
||||
In File Explorer, right-click on the hex file (created in Step 2 above), choose **Send to**, and then **MICROBIT**.
|
||||
|
||||

|
||||
|
||||
By copying the script onto the `MICROBIT` drive, you have programmed it into the
|
||||
flash memory on the micro:bit, which means even after you unplug the micro:bit,
|
||||
your program will still run if the micro:bit is powered by battery.
|
||||
|
||||
|
||||
### ~hint
|
||||
|
||||
Transfer not working? See some [troubleshooting tips](/device/usb/troubleshooting).
|
||||
|
||||
### ~
|
26
docs/docs.md
@ -2,30 +2,6 @@
|
||||
|
||||
### @description Links to the documentation, reference and projects.
|
||||
|
||||
### Things to do
|
||||
|
||||
* **[Getting Started](/getting-started)**
|
||||
* [Ten projects](/projects)
|
||||
|
||||
### Micro:bit reference
|
||||
|
||||
* [The micro:bit APIs](/reference)
|
||||
* [The micro:bit device](/device)
|
||||
|
||||
### Language and data reference
|
||||
|
||||
* [The @boardname@ APIs](/reference)
|
||||
* [Blocks language](/blocks)
|
||||
* [JavaScript language](/javascript)
|
||||
* [Streaming data](/streaming)
|
||||
|
||||
### More questions?
|
||||
|
||||
* [Frequently Asked Question](/faq)
|
||||
* [Embedding project](/share)
|
||||
* [Help Translate](/translate)
|
||||
* [Release notes](/release-notes)
|
||||
|
||||
### Developers
|
||||
|
||||
* [Command Line Interface](/cli)
|
||||
* Learn about [packages](/packages)
|
||||
|
34
docs/faq.md
@ -1,34 +0,0 @@
|
||||
# Frequently Asked Questions
|
||||
|
||||
### @description Frequently asked questions and answers from our users.
|
||||
|
||||
### Where can I get a BBC micro:bit?
|
||||
|
||||
More information at [http://uk.farnell.com/bbc-microbit](http://uk.farnell.com/bbc-microbit).
|
||||
|
||||
### How do I send feedback?
|
||||
|
||||
Find the small bubble icon on the bottom of the editor and
|
||||
post your feedback from there!
|
||||
|
||||
### How do I save my code?
|
||||
|
||||
The web editor automatically saves your code in the browser cache. Simply reopen the browser and navigate to the web editor
|
||||
to reopen your latest project. You can also open previous project stored locally through **More -> Open Project**.
|
||||
|
||||
The project source is also stored in each compiled ``.hex`` file. Drag and drop the ``.hex`` file into the web editor to load the project.
|
||||
|
||||
To share your project with others, you can use the [Embed Project...](/share).
|
||||
It stores your project in the cloud and creates a URL that you can share with others.
|
||||
|
||||
If you are using [Visual Studio Code](/code), all your programs are stored as files on your computer and you can use your favorite source control system as needed.
|
||||
|
||||
## Is the web site available in other languages?
|
||||
|
||||
You can [help us translate](/translate) the web site, documentation and blocks via our crowd-source translations!
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### My micro:bit does not show up as a drive when I connect it to my computer.
|
||||
|
||||
A common cause for this is a broken cable. Pick another USB cable and try it. Otherwise, try another computer as well.
|
BIN
docs/favicon.ico
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 15 KiB |
@ -1,43 +0,0 @@
|
||||
# Getting started
|
||||
|
||||
### @description An activity for beginners to get started with the micro:bit
|
||||
|
||||
## ~avatar
|
||||
|
||||
Here are some challenges for you. Arrange the blocks in the editor
|
||||
to make real programs that work!
|
||||
|
||||
## ~
|
||||
|
||||
Use the **Basic** drawer in the editor
|
||||
to drag out and arrange three blocks to create this program:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
});
|
||||
```
|
||||
|
||||
When this program runs, you will see a smiley face, then a blank
|
||||
screen, then a smiley again -- it never stops! (That's because of the
|
||||
``forever`` block.)
|
||||
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
Make sure to follow the instructions.
|
||||
|
||||
### ~button /getting-started/screen
|
||||
NEXT: THE SCREEN
|
||||
### ~
|
@ -1,81 +0,0 @@
|
||||
# Button A and button B
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Buttons are great to build games!
|
||||
|
||||
### ~
|
||||
|
||||
This program will show the word **ANTEATER** on the LED
|
||||
screen when you press button `A`.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("ANTEATER");
|
||||
});
|
||||
```
|
||||
|
||||
#### ~hint
|
||||
|
||||
The ``showString`` block can show letters, numbers, and punctuation
|
||||
on the micro:bit screen.
|
||||
|
||||
#### ~
|
||||
|
||||
Now try to unscramble these blocks in the editor so that the micro:bit
|
||||
shows **BANANA** when you press button `B`.
|
||||
|
||||
```shuffle
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showString("BANANA");
|
||||
});
|
||||
```
|
||||
#### ~hint
|
||||
|
||||
You can find the letter `B` by clicking the letter `A` on the
|
||||
``onButtonPressed`` block.
|
||||
|
||||
#### ~
|
||||
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
#### Your turn!
|
||||
|
||||
Can you combine these blocks so your program shows your real name
|
||||
instead of **ANTEATER** when you press `A`, but _your secret agent
|
||||
name_ instead of **BANANA** when you press `B`?
|
||||
|
||||
### Pins
|
||||
|
||||
You can also use the pins as buttons. (The pins are the holes in the
|
||||
metal stripe at the bottom of the micro:bit board.) For example, hold
|
||||
the ``GND`` button with one hand and touch the ``0`` pin (called
|
||||
``P0``) with your other hand to tell the micro:bit you're pressing it.
|
||||
|
||||
Unscramble the blocks in the editor to show a heart when you touch
|
||||
pin ``P0``.
|
||||
|
||||
```shuffle
|
||||
input.onPinPressed(TouchPin.P0, () => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .`);
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
## ~hint
|
||||
|
||||
Try this experiment: find a friend and hold hands. Touch the ``GND``
|
||||
pin while your friend presses the ``P0`` pin. You should see the
|
||||
heart! The electric current is going through your bodies and across
|
||||
your handshake to make it happen!
|
||||
|
||||
## ~
|
||||
|
||||
### ~button /getting-started/shake
|
||||
NEXT: SHAKE
|
||||
### ~
|
@ -1,78 +0,0 @@
|
||||
# The amazing coin flipper
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Are you trying to choose whether to play soccer or go to the movies
|
||||
instead, or which toppings to have on your pizza? Build a coin
|
||||
flipping machine with the BBC micro:bit to choose for you!
|
||||
|
||||
### ~
|
||||
|
||||
Here are the blocks to make your coin flipper. When you press button
|
||||
`B`, the coin flipper will show either `H` for heads or `T` for tails
|
||||
on the LED screen.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
```
|
||||
### ~hint
|
||||
|
||||
The ``pick random true or false`` block randomly tells the ``if``
|
||||
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||
|
||||
That's it!
|
||||
|
||||
### ~
|
||||
|
||||
### Keeping score
|
||||
|
||||
#### ~avatar
|
||||
|
||||
To keep track out of how many guesses you've won,
|
||||
add these blocks to your coin flipper:
|
||||
|
||||
#### ~
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
```
|
||||
|
||||
These blocks mean that if you press button `A`, you will add `1` to
|
||||
your score, and if you press `A` and `B` together, the micro:bit will
|
||||
show your score.
|
||||
|
||||
When you're done, your coin flipping program should look like this:
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
if (Math.randomBoolean()) {
|
||||
basic.showString("H");
|
||||
} else {
|
||||
basic.showString("T");
|
||||
}
|
||||
});
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1);
|
||||
});
|
||||
input.onButtonPressed(Button.AB, () => {
|
||||
basic.showNumber(game.score());
|
||||
});
|
||||
```
|
||||
|
||||
Flip until your thumbs get tired!
|
||||
|
||||
### ~button /getting-started/rock-paper-scissors
|
||||
NEXT: ROCK PAPER SCISSORS
|
||||
### ~
|
@ -1,205 +0,0 @@
|
||||
# Rock Paper Scissors
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Build a Rock Paper Scissors game with the BBC micro:bit! You can play
|
||||
the game with a friend who has it on a micro:bit. You can also play
|
||||
it with friends who are just using their hands. (The game is built
|
||||
like a coin flipper, but with three choices instead of two.)
|
||||
|
||||
### ~
|
||||
|
||||
## Step 1: Getting started
|
||||
|
||||
We want the micro:bit to choose rock, paper, or scissors when you
|
||||
shake it. Try creating an ``on shake`` block so when you shake the
|
||||
micro:bit, it will run part of a program.
|
||||
|
||||
Clear up the blocks and add the blocks below.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
})
|
||||
```
|
||||
|
||||
Next, when you shake the micro:bit, it should pick a random number from `0` to `2`
|
||||
and store it in the variable `item`.
|
||||
|
||||
Add a ``set`` block with a variable. Then add a ``pick random`` block,
|
||||
and store the random number in the variable,
|
||||
like this:
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let item = Math.random(3)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
### ~hint
|
||||
No one can predict random numbers. That's what makes them great for Rock Paper Scissors!
|
||||
### ~
|
||||
|
||||
Each possible number these blocks can make (`0`, `1`, or `2`) means a different picture.
|
||||
We will show the right picture for that number on the LED screen.
|
||||
|
||||
|
||||
## Step 2: Picking paper
|
||||
|
||||
Put an ``if`` block after the ``let`` block that checks whether
|
||||
`item` is `0`. Make sure the ``if`` block has an ``else if`` part
|
||||
and an ``else`` part.
|
||||
|
||||
Next, add a ``show leds`` block that shows a
|
||||
picture of a piece of paper:
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let item = Math.random(3)
|
||||
if (item == 0) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #
|
||||
`)
|
||||
} else if (false) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Step 3: A random rock
|
||||
|
||||
Now we are going to add a new picture for the micro:bit to show
|
||||
when another random number comes up.
|
||||
|
||||
Make the ``else if`` part check if the variable `item` is `1`.
|
||||
Then add a ``show leds`` block with a picture of a rock.
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let item = Math.random(3)
|
||||
if (item == 0) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #
|
||||
`)
|
||||
} else if (item == 1) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. . . . .
|
||||
`)
|
||||
} else {
|
||||
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Step 4: Suddenly scissors
|
||||
|
||||
Add a ``show leds`` block with a picture of scissors to the ``else`` part:
|
||||
|
||||
```blocks
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
let item = Math.random(3)
|
||||
if (item == 0) {
|
||||
basic.showLeds(`
|
||||
# # # # #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# . . . #
|
||||
# # # # #
|
||||
`)
|
||||
|
||||
} else if (item == 1) {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. # # # .
|
||||
. . . . .
|
||||
`)
|
||||
} else {
|
||||
basic.showLeds(`
|
||||
# # . . #
|
||||
# # . # .
|
||||
. . # . .
|
||||
# # . # .
|
||||
# # . . #
|
||||
`)
|
||||
}
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
### ~hint
|
||||
|
||||
You don't need to check if `item` is `2` because `2` is the only number left out of `0`, `1`, and `2`.
|
||||
That's why you can use an ``else`` instead of an ``else if``.
|
||||
|
||||
### ~
|
||||
|
||||
Your game is ready!
|
||||
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
Have fun!
|
||||
|
||||
## Step 5: Are you the greatest?
|
||||
|
||||
Here is a way you can make your Rock Paper Scissors game better.
|
||||
When button ``A`` is pressed,
|
||||
the micro:bit will add `1` to your score.
|
||||
|
||||
Open the ``Game`` drawer, and then add the block ``change score by 1`` to your program,
|
||||
like this:
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1)
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
## Step 6: Prove you're the greatest!
|
||||
|
||||
After your micro:bit can add `1` to the score, show how many wins you have.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1)
|
||||
basic.showString("WINS:")
|
||||
basic.showNumber(game.score())
|
||||
})
|
||||
```
|
||||
## Step 7: Staying honest
|
||||
|
||||
Success! Your micro:bit can track wins!
|
||||
But what about losses?
|
||||
Use the ``Game`` drawer to subtract `1` from your score when you press button `B`.
|
||||
|
||||
Here are all the blocks you will need:
|
||||
|
||||
```shuffle
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
game.addScore(-1)
|
||||
basic.showString("LOSSES:")
|
||||
basic.showNumber(game.score())
|
||||
})
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
### ~button /projects
|
||||
NEXT: PROJECTS!
|
||||
### ~
|
@ -1,98 +0,0 @@
|
||||
# Screen
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
There are 25 bright LEDs on the micro:bit screen. Let's use them to create some cool animations!
|
||||
|
||||
### ~
|
||||
|
||||
### Happy unhappy face
|
||||
|
||||
Draw an unhappy face instead of the blank screen. Click on the dots
|
||||
in the second ``show leds`` block until it matches the blocks below.
|
||||
Now you have an **animation** (cartoon) that shows a happy face,
|
||||
then an unhappy one, then a happy one again, forever (or until
|
||||
you turn off your micro:bit)!
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
### Your turn!
|
||||
|
||||
Pile up more ``show leds`` blocks to create an animation! Create an
|
||||
animation with at least 5 pictures. What does this animation show?
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# # # # #
|
||||
. . . . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
# # # # #
|
||||
. . . # #
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
# . # . .
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . # . #
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
#### ~hint
|
||||
|
||||
You can find the ``show leds`` block in the **Basic** part of the editor.
|
||||
|
||||
#### ~
|
||||
|
||||
### ~button /getting-started/buttons
|
||||
NEXT: BUTTONS
|
||||
### ~
|
@ -1,24 +0,0 @@
|
||||
# Shake
|
||||
|
||||
You can find when someone is shaking the BBC micro:bit by checking its
|
||||
**accelerometer** (it finds whether the micro:bit is speeding up or
|
||||
slowing down).
|
||||
|
||||
Unscramble these blocks in the editor to show a frownie when someone
|
||||
shakes the micro:bit. (Ouch!)
|
||||
|
||||
```shuffle
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #`);
|
||||
});
|
||||
```
|
||||
Click **Download** to move your program to the BBC micro:bit!
|
||||
|
||||
### ~button /getting-started/coin-flipper
|
||||
NEXT: COIN FLIPPER GAME
|
||||
### ~
|
3
docs/index-ref.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"appref": "v0.8.30"
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
# JavaScript
|
||||
|
||||
Visit the cards below to starting programming JavaScript and TypeScript with the micro:bit:
|
||||
Visit the cards below to starting programming JavaScript
|
||||
with the @boardname@:
|
||||
|
||||
```codecard
|
||||
[{
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Call a function
|
||||
|
||||
The simplest way to get started in JavaScript with your micro:bit is to
|
||||
call one of the micro:bit's built-in JavaScript functions. Just like Blocks
|
||||
are organized into categories/drawers, the micro:bit functions are organized by
|
||||
The simplest way to get started in JavaScript with your @boardname@ is to
|
||||
call one of the @boardname@'s built-in JavaScript functions. Just like Blocks
|
||||
are organized into categories/drawers, the @boardname@ functions are organized by
|
||||
namespaces, with names corresponding to the drawer names. The `basic` namespace
|
||||
contains a number of helpful functions, such as:
|
||||
|
||||
|
@ -35,7 +35,7 @@ This calls into the constructor we defined earlier, creating a new object with t
|
||||
# Inheritance
|
||||
|
||||
### ~hint
|
||||
### Inheritance is not supported yet for the micro:bit. Coming soon...
|
||||
### Inheritance is not supported yet for the @boardname@. Coming soon...
|
||||
### ~
|
||||
|
||||
In TypeScript, we can use common object-oriented patterns.
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Frequently asked questions
|
||||
|
||||
# What is the language supported for the micro:bit?
|
||||
# What is the language supported for the @boardname@?
|
||||
|
||||
For the micro:bit, we support a "static" subset of TypeScript (itself a superset of JavaScript):
|
||||
For the @boardname@, we support a "static" subset of TypeScript (itself a superset of JavaScript):
|
||||
|
||||
## Supported language features
|
||||
|
||||
|
@ -13,7 +13,7 @@ basic.showNumber(add(1, 2))
|
||||
```
|
||||
|
||||
### ~ hint
|
||||
For the micro:bit, you must specify a [type](/js/types) for each function parameter.
|
||||
For the @boardname@, you must specify a [type](/js/types) for each function parameter.
|
||||
### ~
|
||||
|
||||
Functions can refer to variables outside of the function body.
|
||||
|
@ -1,9 +1,9 @@
|
||||
## Operators
|
||||
|
||||
The following JavaScript operators are supported for the micro:bit.
|
||||
The following JavaScript operators are supported for the @boardname@.
|
||||
|
||||
### ~hint
|
||||
Note that for the micro:bit all arithmetic is performed on integers, rather than floating point.
|
||||
Note that for the @boardname@ all arithmetic is performed on integers, rather than floating point.
|
||||
This also is true when simulating in the browser.
|
||||
### ~
|
||||
|
||||
|
@ -41,14 +41,14 @@ In JavaScript, there is the concept of an *empty statement*, which is whitespace
|
||||
a semicolon in the context where a statement is expected.
|
||||
So, the following code is an infinite loop
|
||||
followed by a call to `showNumber` that will never execute:
|
||||
```typescript
|
||||
while(true) ;
|
||||
```typescript-ignore
|
||||
while(true) ;
|
||||
basic.showNumber(1);
|
||||
```
|
||||
|
||||
|
||||
### ~hint
|
||||
For the micro:bit, we don't allow a program to contain an empty statement, such as shown above.
|
||||
For the @boardname@, we don't allow a program to contain an empty statement, such as shown above.
|
||||
If you really want an empty statement, you need to use curly braces to delimit an empty statement block:
|
||||
```typescript
|
||||
while(true) { }
|
||||
|