Compare commits
46 Commits
v0.4.35
...
v0.5.0-rc0
Author | SHA1 | Date | |
---|---|---|---|
b5cbdef3b7 | |||
94556d3303 | |||
5a600245ff | |||
8bbfcb694c | |||
329da0b65b | |||
7850ff198d | |||
17b76559fd | |||
ef8d7185ee | |||
b0392da8b1 | |||
c817f9e3ff | |||
5f78f98f94 | |||
395b6184b9 | |||
3274964a11 | |||
f5e8b35df4 | |||
996073728c | |||
1e964ba1ea | |||
895a099ebf | |||
f7ed06108d | |||
0ffccdca85 | |||
9f5ebdfb78 | |||
6e64e80c05 | |||
dde16fec14 | |||
e1e8eab93f | |||
dface9083f | |||
31d4afc897 | |||
8427e89eb6 | |||
277d5a721c | |||
80131f2928 | |||
51bd8d57aa | |||
acd974b964 | |||
04e0529610 | |||
ee3f2e6470 | |||
29a4f3cf69 | |||
5649495a28 | |||
a8a9d7dcf0 | |||
09d7ebaf78 | |||
5c6b4c454b | |||
7e1408fc12 | |||
09dc67717c | |||
20dcd5ce34 | |||
e092961b5b | |||
28044af979 | |||
a9ba0a8f90 | |||
871694f99f | |||
8f6c81cd53 | |||
c819b815c4 |
3
.vscode/settings.json
vendored
@ -16,5 +16,6 @@
|
|||||||
"**/pxt_modules/**": true
|
"**/pxt_modules/**": true
|
||||||
},
|
},
|
||||||
"tslint.enable": true,
|
"tslint.enable": true,
|
||||||
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib"
|
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib",
|
||||||
|
"typescript.tsdk": "./node_modules/typescript/lib"
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<script type="text/javascript">
|
<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(" ");
|
(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||[]);
|
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 });
|
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||||
|
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script type="text/javascript">
|
<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(" ");
|
(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||[]);
|
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 });
|
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
|
||||||
|
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion });
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,11 +1,40 @@
|
|||||||
# crocodile clips
|
# crocodile clips
|
||||||
|
|
||||||
The large holes at the bottom of the board are designed to attach alligator/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`.
|
to create electrical circuit with other components.
|
||||||
|
|
||||||
### Example: on pin pressed with random numbers
|
# ~hint
|
||||||
|
|
||||||
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
|
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||||
|
|
||||||
|
# ~
|
||||||
|
|
||||||
|
|
||||||
|
## Connecting Crocodile Clips
|
||||||
|
|
||||||
|
The hole for ``P0`` and ``GND`` allow to grab the board on the side which makes for a great grip.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Pass one jaw in the hole and grab the side of the board with the other jaw.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
For the center holes, ``P1`` and ``P2``, you can also grab the bottom of the board but they are a bit harder to grip.
|
||||||
|
|
||||||
|
You can also grip the board between the jaws. In which case, you will want to make sure to avoid overlapping the jaws
|
||||||
|
with the other pins as it will create short-circuit in the board.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Adding a little tape helps keeping the crocodile clips in place.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 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
|
```blocks
|
||||||
input.onPinPressed(TouchPin.P0, () => {
|
input.onPinPressed(TouchPin.P0, () => {
|
||||||
@ -13,11 +42,6 @@ input.onPinPressed(TouchPin.P0, () => {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Connecting Crocodile Clips
|
## See also
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### 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)
|
|
||||||
|
|
||||||
|
[micro:bit pins](/device/pins)
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# Error codes
|
# 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.
|
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:
|
Below is a list of error numbers and what they mean:
|
||||||
|
52
docs/device/foil-circuits.md
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# foil circuits
|
||||||
|
|
||||||
|
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
|
||||||
|
to create electrical circuit with other components.
|
||||||
|
|
||||||
|
If you do not have crocodile clips at hand, dyou can use wires or even Aluminium foil to acheive the same result.
|
||||||
|
We will show you how to connect the micro:bit to headphones using Alumunium foil and tape.
|
||||||
|
|
||||||
|
https://youtu.be/mhXYyPuvpz0
|
||||||
|
|
||||||
|
### Materials
|
||||||
|
|
||||||
|
* micro:bit and battery pack (you can also power it via USB)
|
||||||
|
* a small piece of cardboard
|
||||||
|
* Aluminium foil
|
||||||
|
* tape
|
||||||
|
|
||||||
|
### Assembly instructions
|
||||||
|
|
||||||
|
Tape the micro:bit and battery pack to the card board. Make sure to remove the batteries while you are building your circuit.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Cut the thinest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you.
|
||||||
|
Build two of those wires.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Place the foil wire on the ``GND`` pin and attach with a piece of tape. Press hard to get the best connection between
|
||||||
|
the foil and the pin board. Make sure the foil is not overlapping with the other pins!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Place the second wire on the ``P0`` pin the same way. Make sure the wire does not overlap with the other pins!
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Tape the headphone jack connector to the cardboard and roll the wire coming from ``GND`` around the metal base.
|
||||||
|
Make sure the wire does not touch the other metal rings on the jack.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Tape the second wire on the head of the jack connector.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
[micro:bit pins](/device/pins)
|
3
docs/index-ref.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"appref": "264aab1cff34042de75045e93c20ceb7b8c861a0"
|
||||||
|
}
|
@ -7,11 +7,12 @@
|
|||||||
```sim
|
```sim
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
@ -29,11 +30,12 @@ Use [show leds](/reference/basic/show-leds) and make your code look like this:
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 2
|
## Step 2
|
||||||
@ -42,11 +44,11 @@ Add a [pause](/reference/basic/pause) to wait and [clear screen](/reference/basi
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
```
|
```
|
||||||
@ -58,11 +60,12 @@ Put a [forever loop](/reference/basic/forever) around it.
|
|||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
})
|
})
|
||||||
@ -75,11 +78,12 @@ Add a [pause](/reference/basic/pause) to wait after clearing the screen.
|
|||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
@ -94,20 +98,22 @@ Add a second image of a broken heart.
|
|||||||
```blocks
|
```blocks
|
||||||
basic.forever(() => {
|
basic.forever(() => {
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# # # # #
|
# # # # #
|
||||||
# # # # #
|
# # # # #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
# . # # #
|
# . # # #
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .
|
. # # # .
|
||||||
. . # . .`);
|
. . # . .`
|
||||||
|
);
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
basic.clearScreen();
|
basic.clearScreen();
|
||||||
basic.pause(500);
|
basic.pause(500);
|
||||||
|
@ -20,8 +20,8 @@ Use the Accelerometer to control guitar tempo
|
|||||||
## Duration: 30 - 45 minutes
|
## Duration: 30 - 45 minutes
|
||||||
|
|
||||||
*accelerometer controlled tempo*
|
*accelerometer controlled tempo*
|
||||||
https://youtu.be/h_gPkBaVkoo
|
https://youtu.be/kA0HpqCWsjs
|
||||||
TODO: add sound to video
|
|
||||||
## Blocks
|
## Blocks
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
|
@ -24,6 +24,12 @@ Build your own music player micro:bit from headphones.
|
|||||||
* [Connect your headphone](/projects/hack-your-headphone/making)
|
* [Connect your headphone](/projects/hack-your-headphone/making)
|
||||||
* [Play sounds!]()
|
* [Play sounds!]()
|
||||||
|
|
||||||
|
# ~hint
|
||||||
|
|
||||||
|
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||||
|
|
||||||
|
# ~
|
||||||
|
|
||||||
### ~button /projects/hack-your-headphones/making
|
### ~button /projects/hack-your-headphones/making
|
||||||
|
|
||||||
Let's get started!
|
Let's get started!
|
||||||
|
@ -6,6 +6,12 @@ Did you know you could attach your headhpones to the micro:bit to generate sound
|
|||||||
|
|
||||||
### ~
|
### ~
|
||||||
|
|
||||||
|
# ~hint
|
||||||
|
|
||||||
|
**No crocodile clips!?!?!** Use wires or Aluminium foil! [Read more...](/device/foil-circuits)
|
||||||
|
|
||||||
|
# ~
|
||||||
|
|
||||||
### Step 1
|
### Step 1
|
||||||
|
|
||||||

|

|
||||||
|
@ -10,11 +10,12 @@ Use [show leds](/reference/basic/show-leds) to make a smiley face:
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`
|
||||||
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 2
|
## Step 2
|
||||||
@ -24,18 +25,20 @@ frowny face inside it:
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
# . . . #
|
|
||||||
. # # # .`);
|
|
||||||
input.onButtonPressed(Button.A, () => {
|
|
||||||
basic.showLeds(`
|
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
. # # # .
|
# . . . #
|
||||||
# . . . #`);
|
. # # # .`
|
||||||
|
);
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
# . . . #`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -45,25 +48,28 @@ Now add blocks so that when [button B is pressed](/reference/input/button-is-pre
|
|||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
. # . # .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
# . . . #
|
|
||||||
. # # # .`);
|
|
||||||
input.onButtonPressed(Button.A, () => {
|
|
||||||
basic.showLeds(`
|
|
||||||
. # . # .
|
|
||||||
. # . # .
|
|
||||||
. . . . .
|
|
||||||
. # # # .
|
|
||||||
# . . . #`);
|
|
||||||
});
|
|
||||||
input.onButtonPressed(Button.B, () => {
|
|
||||||
basic.showLeds(`
|
|
||||||
. # . # .
|
. # . # .
|
||||||
. # . # .
|
. # . # .
|
||||||
. . . . .
|
. . . . .
|
||||||
# . . . #
|
# . . . #
|
||||||
. # # # .`);
|
. # # # .`
|
||||||
|
);
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
. # # # .
|
||||||
|
# . . . #`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
input.onButtonPressed(Button.B, () => {
|
||||||
|
basic.showLeds(`
|
||||||
|
. # . # .
|
||||||
|
. # . # .
|
||||||
|
. . . . .
|
||||||
|
# . . . #
|
||||||
|
. # # # .`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -1,20 +1,11 @@
|
|||||||
# Raspberry Pi and Raspbian
|
# Raspberry Pi and Raspbian
|
||||||
|
|
||||||
It is possible to run the web editor or [command line interface](/cli) from Raspbian on Raspberry Pi 2 or 3.
|
It is possible to run the web editor or [command line interface](/cli) from Raspbian on Raspberry Pi 2 or 3
|
||||||
|
with [Raspbian Jessie with Pixel](https://www.raspberrypi.org/downloads/raspbian/).
|
||||||
|
|
||||||
## Web editor
|
## Web editor
|
||||||
|
|
||||||
The web editor requires to install IceWeasel (Firefox) as the built-in browser cannot handle it.
|
Starting with **Raspbian Pixel**, Raspbian comes with Chromium. Simply open [](https://codethemicrobit.com).
|
||||||
|
|
||||||
```
|
|
||||||
sudo apt-get install iceweasel
|
|
||||||
```
|
|
||||||
|
|
||||||
Once installed simply navigate to https://codethemicrobit.com or type
|
|
||||||
|
|
||||||
```
|
|
||||||
firefox https://codethemicrobit.com
|
|
||||||
```
|
|
||||||
|
|
||||||
## Command line
|
## Command line
|
||||||
|
|
||||||
|
@ -10,6 +10,10 @@ input.onButtonPressed(Button.A, () => {
|
|||||||
music.playTone(0, 0);
|
music.playTone(0, 0);
|
||||||
led.plot(0, 0);
|
led.plot(0, 0);
|
||||||
radio.sendNumber(0);
|
radio.sendNumber(0);
|
||||||
|
```
|
||||||
|
## Advanced
|
||||||
|
|
||||||
|
```namespaces
|
||||||
game.addScore(1);
|
game.addScore(1);
|
||||||
images.createImage(`
|
images.createImage(`
|
||||||
. . . . .
|
. . . . .
|
||||||
@ -24,7 +28,8 @@ control.inBackground(() => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
## Advanced
|
|
||||||
|
## Bluetooth
|
||||||
|
|
||||||
```namespaces
|
```namespaces
|
||||||
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
||||||
|
BIN
docs/static/mb/device/croc-clips/badclamp.jpg
vendored
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
docs/static/mb/device/croc-clips/crocclipsclamped.jpg
vendored
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
docs/static/mb/device/croc-clips/foilcircuit.jpg
vendored
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
docs/static/mb/device/croc-clips/foilcut.jpg
vendored
Normal file
After Width: | Height: | Size: 79 KiB |
BIN
docs/static/mb/device/croc-clips/frontclamp.jpg
vendored
Normal file
After Width: | Height: | Size: 93 KiB |
BIN
docs/static/mb/device/croc-clips/groundconnected.jpg
vendored
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
docs/static/mb/device/croc-clips/jackconnect.jpg
vendored
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
docs/static/mb/device/croc-clips/jackground.jpg
vendored
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
docs/static/mb/device/croc-clips/microbitattached.jpg
vendored
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
docs/static/mb/device/croc-clips/microbitconnect.jpg
vendored
Normal file
After Width: | Height: | Size: 66 KiB |
BIN
docs/static/mb/device/croc-clips/sideclamp.jpg
vendored
Normal file
After Width: | Height: | Size: 34 KiB |
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "microbit-bluetooth",
|
"name": "bluetooth",
|
||||||
"description": "Bluetooth services",
|
"description": "Bluetooth services",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"README.md",
|
||||||
@ -10,7 +10,7 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit"
|
"core": "file:../core"
|
||||||
},
|
},
|
||||||
"yotta": {
|
"yotta": {
|
||||||
"config": {
|
"config": {
|
@ -110,6 +110,7 @@ enum EventBusValue {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//% weight=1 color="#333333"
|
//% weight=1 color="#333333"
|
||||||
|
//% advanced=true
|
||||||
namespace control {
|
namespace control {
|
||||||
void fiberDone(void *a)
|
void fiberDone(void *a)
|
||||||
{
|
{
|
||||||
@ -131,7 +132,7 @@ namespace control {
|
|||||||
*/
|
*/
|
||||||
//% weight=30 async help=control/reset blockGap=8
|
//% weight=30 async help=control/reset blockGap=8
|
||||||
//% blockId="control_reset" block="reset"
|
//% blockId="control_reset" block="reset"
|
||||||
void reset() {
|
void reset() {
|
||||||
microbit_reset();
|
microbit_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,16 +154,16 @@ namespace control {
|
|||||||
*/
|
*/
|
||||||
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
|
||||||
//% mode.defl=CREATE_AND_FIRE
|
//% mode.defl=CREATE_AND_FIRE
|
||||||
void raiseEvent(int src, int value, EventCreationMode mode) {
|
void raiseEvent(int src, int value, EventCreationMode mode) {
|
||||||
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
|
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Raises an event in the event bus.
|
* Raises an event in the event bus.
|
||||||
*/
|
*/
|
||||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
||||||
//% blockExternalInputs=1
|
//% blockExternalInputs=1
|
||||||
void onEvent(int src, int value, Action handler) {
|
void onEvent(int src, int value, Action handler) {
|
||||||
registerWithDal(src, value, handler);
|
registerWithDal(src, value, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ namespace control {
|
|||||||
int eventValue() {
|
int eventValue() {
|
||||||
return pxt::lastEvent.value;
|
return pxt::lastEvent.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the timestamp of the last event executed on the bus
|
* Gets the timestamp of the last event executed on the bus
|
||||||
*/
|
*/
|
||||||
@ -183,15 +184,15 @@ namespace control {
|
|||||||
int eventTimestamp() {
|
int eventTimestamp() {
|
||||||
return pxt::lastEvent.timestamp;
|
return pxt::lastEvent.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a friendly name for the device derived from the its serial number
|
* Gets a friendly name for the device derived from the its serial number
|
||||||
*/
|
*/
|
||||||
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
//% blockId="control_device_name" block="device name" weight=10 blockGap=8
|
||||||
StringData* deviceName() {
|
StringData* deviceName() {
|
||||||
return ManagedString(microbit_friendly_name()).leakData();
|
return ManagedString(microbit_friendly_name()).leakData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive a unique, consistent serial number of this device from internal data.
|
* Derive a unique, consistent serial number of this device from internal data.
|
||||||
*/
|
*/
|
@ -2,6 +2,7 @@
|
|||||||
* Runtime and event utilities.
|
* Runtime and event utilities.
|
||||||
*/
|
*/
|
||||||
//% weight=1 color="#333333"
|
//% weight=1 color="#333333"
|
||||||
|
//% advanced=true
|
||||||
namespace control {
|
namespace control {
|
||||||
|
|
||||||
/**
|
/**
|
26
libs/microbit/dal.d.ts → libs/core/dal.d.ts
vendored
@ -79,6 +79,7 @@ declare const enum DAL {
|
|||||||
MICROBIT_BLE_PAIRING_TIMEOUT = 90,
|
MICROBIT_BLE_PAIRING_TIMEOUT = 90,
|
||||||
MICROBIT_BLE_POWER_LEVELS = 8,
|
MICROBIT_BLE_POWER_LEVELS = 8,
|
||||||
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
MICROBIT_BLE_MAXIMUM_BONDS = 4,
|
||||||
|
MICROBIT_BLE_EDDYSTONE_URL_ADV_INTERVAL = 400,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitButtonService.h
|
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitButtonService.h
|
||||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitDFUService.h
|
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitDFUService.h
|
||||||
MICROBIT_DFU_OPCODE_START_DFU = 1,
|
MICROBIT_DFU_OPCODE_START_DFU = 1,
|
||||||
@ -88,6 +89,7 @@ declare const enum DAL {
|
|||||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
|
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
|
||||||
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
|
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
|
||||||
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
|
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
|
||||||
|
MICROBIT_PWM_PIN_SERVICE_DATA_SIZE = 2,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
|
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
|
||||||
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
|
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitMagnetometerService.h
|
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitMagnetometerService.h
|
||||||
@ -305,6 +307,30 @@ declare const enum DAL {
|
|||||||
MICROBIT_DISPLAY_ROTATION_90 = 1,
|
MICROBIT_DISPLAY_ROTATION_90 = 1,
|
||||||
MICROBIT_DISPLAY_ROTATION_180 = 2,
|
MICROBIT_DISPLAY_ROTATION_180 = 2,
|
||||||
MICROBIT_DISPLAY_ROTATION_270 = 3,
|
MICROBIT_DISPLAY_ROTATION_270 = 3,
|
||||||
|
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitFile.h
|
||||||
|
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitFileSystem.h
|
||||||
|
MBFS_FILENAME_LENGTH = 16,
|
||||||
|
MB_READ = 0x01,
|
||||||
|
MB_WRITE = 0x02,
|
||||||
|
MB_CREAT = 0x04,
|
||||||
|
MB_APPEND = 0x08,
|
||||||
|
MB_SEEK_SET = 0x01,
|
||||||
|
MB_SEEK_END = 0x02,
|
||||||
|
MB_SEEK_CUR = 0x04,
|
||||||
|
MBFS_STATUS_INITIALISED = 0x01,
|
||||||
|
MBFS_UNUSED = 0xFFFF,
|
||||||
|
MBFS_EOF = 0xEFFF,
|
||||||
|
MBFS_DELETED = 0x0000,
|
||||||
|
MBFS_DIRECTORY_ENTRY_FREE = 0x8000,
|
||||||
|
MBFS_DIRECTORY_ENTRY_VALID = 0x4000,
|
||||||
|
MBFS_DIRECTORY_ENTRY_DIRECTORY = 0x2000,
|
||||||
|
MBFS_DIRECTORY_ENTRY_NEW = 0xffff,
|
||||||
|
MBFS_DIRECTORY_ENTRY_DELETED = 0x0000,
|
||||||
|
MBFS_BLOCK_TYPE_FILE = 1,
|
||||||
|
MBFS_BLOCK_TYPE_DIRECTORY = 2,
|
||||||
|
MBFS_BLOCK_TYPE_FILETABLE = 3,
|
||||||
|
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitFlash.h
|
||||||
|
PAGE_SIZE = 1024,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitI2C.h
|
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitI2C.h
|
||||||
MICROBIT_I2C_MAX_RETRIES = 9,
|
MICROBIT_I2C_MAX_RETRIES = 9,
|
||||||
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitIO.h
|
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitIO.h
|
@ -1,5 +1,5 @@
|
|||||||
enum Direction {
|
enum Direction {
|
||||||
//% block=right
|
//% block=right
|
||||||
Right,
|
Right,
|
||||||
//% block=left
|
//% block=left
|
||||||
Left
|
Left
|
||||||
@ -22,6 +22,7 @@ enum LedSpriteProperty {
|
|||||||
* A single-LED sprite game engine
|
* A single-LED sprite game engine
|
||||||
*/
|
*/
|
||||||
//% color=#008272 weight=32
|
//% color=#008272 weight=32
|
||||||
|
//% advanced=true
|
||||||
namespace game {
|
namespace game {
|
||||||
let _score: number = 0;
|
let _score: number = 0;
|
||||||
let _life: number = 3;
|
let _life: number = 3;
|
@ -4,6 +4,7 @@
|
|||||||
* Creation, manipulation and display of LED images.
|
* Creation, manipulation and display of LED images.
|
||||||
*/
|
*/
|
||||||
//% color=#5C2D91 weight=31
|
//% color=#5C2D91 weight=31
|
||||||
|
//% advanced=true
|
||||||
namespace images {
|
namespace images {
|
||||||
/**
|
/**
|
||||||
* Creates an image that fits on the LED screen.
|
* Creates an image that fits on the LED screen.
|
||||||
@ -29,7 +30,7 @@ namespace images {
|
|||||||
namespace ImageMethods {
|
namespace ImageMethods {
|
||||||
/**
|
/**
|
||||||
* Plots the image at a given column to the screen
|
* Plots the image at a given column to the screen
|
||||||
*/
|
*/
|
||||||
//% help=images/plot-image
|
//% help=images/plot-image
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void plotImage(Image i, int xOffset = 0) {
|
void plotImage(Image i, int xOffset = 0) {
|
||||||
@ -46,7 +47,7 @@ namespace ImageMethods {
|
|||||||
void showImage(Image sprite, int xOffset) {
|
void showImage(Image sprite, int xOffset) {
|
||||||
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0);
|
uBit.display.print(MicroBitImage(sprite), -xOffset, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws the ``index``-th frame of the image on the screen.
|
* Draws the ``index``-th frame of the image on the screen.
|
||||||
* @param xOffset column index to start displaying the image
|
* @param xOffset column index to start displaying the image
|
||||||
@ -57,7 +58,7 @@ namespace ImageMethods {
|
|||||||
// TODO showImage() used in original implementation
|
// TODO showImage() used in original implementation
|
||||||
plotImage(i, xOffset * 5);
|
plotImage(i, xOffset * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls an image .
|
* Scrolls an image .
|
||||||
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
* @param frameOffset x offset moved on each animation step, eg: 5, 1, -1
|
@ -89,7 +89,7 @@ enum class Gesture {
|
|||||||
* Raised when the screen is pointing right
|
* Raised when the screen is pointing right
|
||||||
*/
|
*/
|
||||||
//% block="tilt right"
|
//% block="tilt right"
|
||||||
TiltRight = MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT,
|
TiltRight = MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT,
|
||||||
/**
|
/**
|
||||||
* Raised when the board is falling!
|
* Raised when the board is falling!
|
||||||
*/
|
*/
|
||||||
@ -132,7 +132,7 @@ namespace input {
|
|||||||
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||||
uBit.accelerometer.setRange(4);
|
uBit.accelerometer.setRange(4);
|
||||||
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
||||||
uBit.accelerometer.setRange(8);
|
uBit.accelerometer.setRange(8);
|
||||||
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,6 +159,7 @@ namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/on-pin-released weight=6 blockGap=8
|
//% help=input/on-pin-released weight=6 blockGap=8
|
||||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||||
|
//% advanced=true
|
||||||
void onPinReleased(TouchPin name, Action body) {
|
void onPinReleased(TouchPin name, Action body) {
|
||||||
auto pin = getPin((int)name);
|
auto pin = getPin((int)name);
|
||||||
if (!pin) return;
|
if (!pin) return;
|
||||||
@ -171,7 +172,7 @@ namespace input {
|
|||||||
/**
|
/**
|
||||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||||
*/
|
*/
|
||||||
//% help=input/button-is-pressed weight=57
|
//% help=input/button-is-pressed weight=60
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
//% blockId=device_get_button2
|
//% blockId=device_get_button2
|
||||||
//% icon="\uf192" blockGap=8
|
//% icon="\uf192" blockGap=8
|
||||||
@ -190,7 +191,7 @@ namespace input {
|
|||||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||||
* @param name pin used to detect the touch
|
* @param name pin used to detect the touch
|
||||||
*/
|
*/
|
||||||
//% help=input/pin-is-pressed weight=56
|
//% help=input/pin-is-pressed weight=58
|
||||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||||
//% blockGap=8
|
//% blockGap=8
|
||||||
bool pinIsPressed(TouchPin name) {
|
bool pinIsPressed(TouchPin name) {
|
||||||
@ -198,10 +199,44 @@ namespace input {
|
|||||||
return pin && pin->isTouched();
|
return pin && pin->isTouched();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getAccelerationStrength() {
|
||||||
|
double x = uBit.accelerometer.getX();
|
||||||
|
double y = uBit.accelerometer.getY();
|
||||||
|
double z = uBit.accelerometer.getZ();
|
||||||
|
return (int)sqrt(x*x+y*y+z*z);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||||
|
* @param dimension TODO
|
||||||
|
*/
|
||||||
|
//% help=input/acceleration weight=58 icon="\uf135"
|
||||||
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||||
|
//% parts="accelerometer"
|
||||||
|
int acceleration(Dimension dimension) {
|
||||||
|
switch (dimension) {
|
||||||
|
case Dimension::X: return uBit.accelerometer.getX();
|
||||||
|
case Dimension::Y: return uBit.accelerometer.getY();
|
||||||
|
case Dimension::Z: return uBit.accelerometer.getZ();
|
||||||
|
case Dimension::Strength: return getAccelerationStrength();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||||
|
*/
|
||||||
|
//% help=input/light-level weight=57
|
||||||
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||||
|
//% parts="ledmatrix"
|
||||||
|
int lightLevel() {
|
||||||
|
return uBit.display.readLightLevel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current compass heading in degrees.
|
* Get the current compass heading in degrees.
|
||||||
*/
|
*/
|
||||||
//% help=input/compass-heading
|
//% help=input/compass-heading
|
||||||
//% weight=56 icon="\uf14e"
|
//% weight=56 icon="\uf14e"
|
||||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||||
//% parts="compass"
|
//% parts="compass"
|
||||||
@ -221,54 +256,19 @@ namespace input {
|
|||||||
return uBit.thermometer.getTemperature();
|
return uBit.thermometer.getTemperature();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getAccelerationStrength() {
|
|
||||||
double x = uBit.accelerometer.getX();
|
|
||||||
double y = uBit.accelerometer.getY();
|
|
||||||
double z = uBit.accelerometer.getZ();
|
|
||||||
return (int)sqrt(x*x+y*y+z*z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
|
||||||
* @param dimension TODO
|
|
||||||
*/
|
|
||||||
//% help=input/acceleration weight=54 icon="\uf135"
|
|
||||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
|
||||||
//% parts="accelerometer"
|
|
||||||
int acceleration(Dimension dimension) {
|
|
||||||
switch (dimension) {
|
|
||||||
case Dimension::X: return uBit.accelerometer.getX();
|
|
||||||
case Dimension::Y: return uBit.accelerometer.getY();
|
|
||||||
case Dimension::Z: return uBit.accelerometer.getZ();
|
|
||||||
case Dimension::Strength: return getAccelerationStrength();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
|
||||||
*/
|
|
||||||
//% help=input/light-level weight=53
|
|
||||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
|
||||||
//% parts="ledmatrix"
|
|
||||||
int lightLevel() {
|
|
||||||
return uBit.display.readLightLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
||||||
* @param kind TODO
|
* @param kind TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/rotation weight=52
|
//% help=input/rotation weight=52
|
||||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||||
//% parts="accelerometer"
|
//% parts="accelerometer" advanced=true
|
||||||
int rotation(Rotation kind) {
|
int rotation(Rotation kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
case Rotation::Pitch: return uBit.accelerometer.getPitch();
|
||||||
case Rotation::Roll: return uBit.accelerometer.getRoll();
|
case Rotation::Roll: return uBit.accelerometer.getRoll();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -278,6 +278,7 @@ namespace input {
|
|||||||
//% help=input/magnetic-force weight=51
|
//% help=input/magnetic-force weight=51
|
||||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||||
//% parts="compass"
|
//% parts="compass"
|
||||||
|
//% advanced=true
|
||||||
int magneticForce(Dimension dimension) {
|
int magneticForce(Dimension dimension) {
|
||||||
if (!uBit.compass.isCalibrated())
|
if (!uBit.compass.isCalibrated())
|
||||||
uBit.compass.calibrate();
|
uBit.compass.calibrate();
|
||||||
@ -296,6 +297,7 @@ namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/running-time weight=50
|
//% help=input/running-time weight=50
|
||||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||||
|
//% advanced=true
|
||||||
int runningTime() {
|
int runningTime() {
|
||||||
return system_timer_current_time();
|
return system_timer_current_time();
|
||||||
}
|
}
|
||||||
@ -314,6 +316,7 @@ namespace input {
|
|||||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
//% weight=5
|
//% weight=5
|
||||||
//% parts="accelerometer"
|
//% parts="accelerometer"
|
||||||
|
//% advanced=true
|
||||||
void setAccelerometerRange(AcceleratorRange range) {
|
void setAccelerometerRange(AcceleratorRange range) {
|
||||||
uBit.accelerometer.setRange((int)range);
|
uBit.accelerometer.setRange((int)range);
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ namespace led {
|
|||||||
//% help=led/plot weight=78
|
//% help=led/plot weight=78
|
||||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void plot(int x, int y) {
|
void plot(int x, int y) {
|
||||||
uBit.display.image.setPixelValue(x, y, 1);
|
uBit.display.image.setPixelValue(x, y, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ namespace led {
|
|||||||
//% help=led/unplot weight=77
|
//% help=led/unplot weight=77
|
||||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void unplot(int x, int y) {
|
void unplot(int x, int y) {
|
||||||
uBit.display.image.setPixelValue(x, y, 0);
|
uBit.display.image.setPixelValue(x, y, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ namespace led {
|
|||||||
//% help=led/brightness weight=60
|
//% help=led/brightness weight=60
|
||||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true
|
||||||
int brightness() {
|
int brightness() {
|
||||||
return uBit.display.getBrightness();
|
return uBit.display.getBrightness();
|
||||||
}
|
}
|
||||||
@ -65,7 +66,8 @@ namespace led {
|
|||||||
//% help=led/set-brightness weight=59
|
//% help=led/set-brightness weight=59
|
||||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void setBrightness(int value) {
|
//% advanced=true
|
||||||
|
void setBrightness(int value) {
|
||||||
uBit.display.setBrightness(value);
|
uBit.display.setBrightness(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +77,8 @@ namespace led {
|
|||||||
//% weight=50 help=led/stop-animation
|
//% weight=50 help=led/stop-animation
|
||||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void stopAnimation() {
|
//% advanced=true
|
||||||
|
void stopAnimation() {
|
||||||
uBit.display.stopAnimation();
|
uBit.display.stopAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +88,7 @@ namespace led {
|
|||||||
*/
|
*/
|
||||||
//% weight=1 help=led/set-display-mode
|
//% weight=1 help=led/set-display-mode
|
||||||
//% parts="ledmatrix"
|
//% parts="ledmatrix"
|
||||||
void setDisplayMode(DisplayMode_ mode) {
|
void setDisplayMode(DisplayMode_ mode) {
|
||||||
uBit.display.setDisplayMode((DisplayMode)mode);
|
uBit.display.setDisplayMode((DisplayMode)mode);
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
@ -2,6 +2,7 @@
|
|||||||
* Control currents in Pins for analog/digital signals, servos, i2c, ...
|
* Control currents in Pins for analog/digital signals, servos, i2c, ...
|
||||||
*/
|
*/
|
||||||
//% color=#A80000 weight=30
|
//% color=#A80000 weight=30
|
||||||
|
//% advanced=true
|
||||||
namespace pins {
|
namespace pins {
|
||||||
/**
|
/**
|
||||||
* Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.
|
* Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "microbit",
|
"name": "core",
|
||||||
"description": "The microbit core library",
|
"description": "The microbit core library",
|
||||||
"installedVersion": "tsmdvf",
|
"installedVersion": "tsmdvf",
|
||||||
"files": [
|
"files": [
|
@ -20,9 +20,10 @@ enum class BaudRate {
|
|||||||
};
|
};
|
||||||
|
|
||||||
//% weight=2 color=30
|
//% weight=2 color=30
|
||||||
|
//% advanced=true
|
||||||
namespace serial {
|
namespace serial {
|
||||||
// note that at least one // followed by % is needed per declaration!
|
// note that at least one // followed by % is needed per declaration!
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a line of text from the serial port.
|
* Reads a line of text from the serial port.
|
||||||
*/
|
*/
|
||||||
@ -39,10 +40,10 @@ namespace serial {
|
|||||||
//% help=serial/write-string
|
//% help=serial/write-string
|
||||||
//% weight=87
|
//% weight=87
|
||||||
//% blockId=serial_writestring block="serial write string %text"
|
//% blockId=serial_writestring block="serial write string %text"
|
||||||
void writeString(StringData *text) {
|
void writeString(StringData *text) {
|
||||||
uBit.serial.send(ManagedString(text));
|
uBit.serial.send(ManagedString(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an event to be fired when one of the delimiter is matched
|
* Registers an event to be fired when one of the delimiter is matched
|
||||||
* @param delimiters the characters to match received characters against. eg:"\n"
|
* @param delimiters the characters to match received characters against. eg:"\n"
|
||||||
@ -53,7 +54,7 @@ namespace serial {
|
|||||||
uBit.serial.eventOn(ManagedString(delimiters));
|
uBit.serial.eventOn(ManagedString(delimiters));
|
||||||
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
|
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
|
||||||
* @param tx the new transmission pins
|
* @param tx the new transmission pins
|
@ -2,6 +2,7 @@
|
|||||||
* Reading and writing data over a serial connection.
|
* Reading and writing data over a serial connection.
|
||||||
*/
|
*/
|
||||||
//% weight=2 color=#002050
|
//% weight=2 color=#002050
|
||||||
|
//% advanced=true
|
||||||
namespace serial {
|
namespace serial {
|
||||||
/**
|
/**
|
||||||
* Prints a line of text to the serial
|
* Prints a line of text to the serial
|
68
libs/microbit/shims.d.ts → libs/core/shims.d.ts
vendored
@ -5,6 +5,7 @@
|
|||||||
* Creation, manipulation and display of LED images.
|
* Creation, manipulation and display of LED images.
|
||||||
*/
|
*/
|
||||||
//% color=#5C2D91 weight=31
|
//% color=#5C2D91 weight=31
|
||||||
|
//% advanced=true
|
||||||
declare namespace images {
|
declare namespace images {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -247,13 +248,14 @@ declare namespace input {
|
|||||||
* @param body the code to run when the pin is released
|
* @param body the code to run when the pin is released
|
||||||
*/
|
*/
|
||||||
//% help=input/on-pin-released weight=6 blockGap=8
|
//% help=input/on-pin-released weight=6 blockGap=8
|
||||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094" shim=input::onPinReleased
|
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||||
|
//% advanced=true shim=input::onPinReleased
|
||||||
function onPinReleased(name: TouchPin, body: () => void): void;
|
function onPinReleased(name: TouchPin, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||||
*/
|
*/
|
||||||
//% help=input/button-is-pressed weight=57
|
//% help=input/button-is-pressed weight=60
|
||||||
//% block="button|%NAME|is pressed"
|
//% block="button|%NAME|is pressed"
|
||||||
//% blockId=device_get_button2
|
//% blockId=device_get_button2
|
||||||
//% icon="\uf192" blockGap=8
|
//% icon="\uf192" blockGap=8
|
||||||
@ -264,15 +266,32 @@ declare namespace input {
|
|||||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||||
* @param name pin used to detect the touch
|
* @param name pin used to detect the touch
|
||||||
*/
|
*/
|
||||||
//% help=input/pin-is-pressed weight=56
|
//% help=input/pin-is-pressed weight=58
|
||||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||||
//% blockGap=8 shim=input::pinIsPressed
|
//% blockGap=8 shim=input::pinIsPressed
|
||||||
function pinIsPressed(name: TouchPin): boolean;
|
function pinIsPressed(name: TouchPin): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||||
|
* @param dimension TODO
|
||||||
|
*/
|
||||||
|
//% help=input/acceleration weight=58 icon="\uf135"
|
||||||
|
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||||
|
//% parts="accelerometer" shim=input::acceleration
|
||||||
|
function acceleration(dimension: Dimension): number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||||
|
*/
|
||||||
|
//% help=input/light-level weight=57
|
||||||
|
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||||
|
//% parts="ledmatrix" shim=input::lightLevel
|
||||||
|
function lightLevel(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current compass heading in degrees.
|
* Get the current compass heading in degrees.
|
||||||
*/
|
*/
|
||||||
//% help=input/compass-heading
|
//% help=input/compass-heading
|
||||||
//% weight=56 icon="\uf14e"
|
//% weight=56 icon="\uf14e"
|
||||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||||
//% parts="compass" shim=input::compassHeading
|
//% parts="compass" shim=input::compassHeading
|
||||||
@ -287,30 +306,13 @@ declare namespace input {
|
|||||||
//% parts="thermometer" shim=input::temperature
|
//% parts="thermometer" shim=input::temperature
|
||||||
function temperature(): number;
|
function temperature(): number;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
|
||||||
* @param dimension TODO
|
|
||||||
*/
|
|
||||||
//% help=input/acceleration weight=54 icon="\uf135"
|
|
||||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
|
||||||
//% parts="accelerometer" shim=input::acceleration
|
|
||||||
function acceleration(dimension: Dimension): number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
|
||||||
*/
|
|
||||||
//% help=input/light-level weight=53
|
|
||||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
|
||||||
//% parts="ledmatrix" shim=input::lightLevel
|
|
||||||
function lightLevel(): number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
* The pitch or roll of the device, rotation along the ``x-axis`` or ``y-axis``, in degrees.
|
||||||
* @param kind TODO
|
* @param kind TODO
|
||||||
*/
|
*/
|
||||||
//% help=input/rotation weight=52
|
//% help=input/rotation weight=52
|
||||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||||
//% parts="accelerometer" shim=input::rotation
|
//% parts="accelerometer" advanced=true shim=input::rotation
|
||||||
function rotation(kind: Rotation): number;
|
function rotation(kind: Rotation): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -319,14 +321,16 @@ declare namespace input {
|
|||||||
*/
|
*/
|
||||||
//% help=input/magnetic-force weight=51
|
//% help=input/magnetic-force weight=51
|
||||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||||
//% parts="compass" shim=input::magneticForce
|
//% parts="compass"
|
||||||
|
//% advanced=true shim=input::magneticForce
|
||||||
function magneticForce(dimension: Dimension): number;
|
function magneticForce(dimension: Dimension): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of milliseconds elapsed since power on.
|
* Gets the number of milliseconds elapsed since power on.
|
||||||
*/
|
*/
|
||||||
//% help=input/running-time weight=50
|
//% help=input/running-time weight=50
|
||||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017" shim=input::runningTime
|
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||||
|
//% advanced=true shim=input::runningTime
|
||||||
function runningTime(): number;
|
function runningTime(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,13 +346,15 @@ declare namespace input {
|
|||||||
//% help=input/set-accelerometer-range
|
//% help=input/set-accelerometer-range
|
||||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||||
//% weight=5
|
//% weight=5
|
||||||
//% parts="accelerometer" shim=input::setAccelerometerRange
|
//% parts="accelerometer"
|
||||||
|
//% advanced=true shim=input::setAccelerometerRange
|
||||||
function setAccelerometerRange(range: AcceleratorRange): void;
|
function setAccelerometerRange(range: AcceleratorRange): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//% weight=1 color="#333333"
|
//% weight=1 color="#333333"
|
||||||
|
//% advanced=true
|
||||||
declare namespace control {
|
declare namespace control {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -386,7 +392,7 @@ declare namespace control {
|
|||||||
/**
|
/**
|
||||||
* Raises an event in the event bus.
|
* Raises an event in the event bus.
|
||||||
*/
|
*/
|
||||||
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
|
||||||
//% blockExternalInputs=1 shim=control::onEvent
|
//% blockExternalInputs=1 shim=control::onEvent
|
||||||
function onEvent(src: number, value: number, handler: () => void): void;
|
function onEvent(src: number, value: number, handler: () => void): void;
|
||||||
|
|
||||||
@ -457,7 +463,8 @@ declare namespace led {
|
|||||||
*/
|
*/
|
||||||
//% help=led/brightness weight=60
|
//% help=led/brightness weight=60
|
||||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||||
//% parts="ledmatrix" shim=led::brightness
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true shim=led::brightness
|
||||||
function brightness(): number;
|
function brightness(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,7 +473,8 @@ declare namespace led {
|
|||||||
*/
|
*/
|
||||||
//% help=led/set-brightness weight=59
|
//% help=led/set-brightness weight=59
|
||||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||||
//% parts="ledmatrix" shim=led::setBrightness
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true shim=led::setBrightness
|
||||||
function setBrightness(value: number): void;
|
function setBrightness(value: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -474,7 +482,8 @@ declare namespace led {
|
|||||||
*/
|
*/
|
||||||
//% weight=50 help=led/stop-animation
|
//% weight=50 help=led/stop-animation
|
||||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||||
//% parts="ledmatrix" shim=led::stopAnimation
|
//% parts="ledmatrix"
|
||||||
|
//% advanced=true shim=led::stopAnimation
|
||||||
function stopAnimation(): void;
|
function stopAnimation(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -636,6 +645,7 @@ declare namespace pins {
|
|||||||
|
|
||||||
|
|
||||||
//% weight=2 color=30
|
//% weight=2 color=30
|
||||||
|
//% advanced=true
|
||||||
declare namespace serial {
|
declare namespace serial {
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "microbit-devices",
|
"name": "devices",
|
||||||
"description": "The BLE specific services",
|
"description": "The BLE specific services",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"README.md",
|
||||||
@ -9,7 +9,7 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit"
|
"core": "file:../core"
|
||||||
},
|
},
|
||||||
"yotta": {
|
"yotta": {
|
||||||
"config": {
|
"config": {
|
@ -6,7 +6,7 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit",
|
"core": "file:../core",
|
||||||
"microbit-radio": "file:../microbit-radio"
|
"radio": "file:../radio"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
"public": true,
|
"public": true,
|
||||||
"additionalFilePath": "../../node_modules/pxt-core/libs/lang-test0",
|
"additionalFilePath": "../../node_modules/pxt-core/libs/lang-test0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit"
|
"core": "file:../core"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit"
|
"core": "file:../core"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "microbit-radio",
|
"name": "radio",
|
||||||
"description": "The radio services",
|
"description": "The radio services",
|
||||||
"files": [
|
"files": [
|
||||||
"README.md",
|
"README.md",
|
||||||
@ -10,7 +10,7 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit"
|
"core": "file:../core"
|
||||||
},
|
},
|
||||||
"yotta": {
|
"yotta": {
|
||||||
"config": {
|
"config": {
|
@ -9,12 +9,12 @@ namespace radio {
|
|||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Radio
|
// Radio
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
bool radioEnabled = false;
|
bool radioEnabled = false;
|
||||||
bool transmitSerialNumber = false;
|
bool transmitSerialNumber = false;
|
||||||
|
|
||||||
PacketBuffer packet;
|
PacketBuffer packet;
|
||||||
|
|
||||||
int radioEnable() {
|
int radioEnable() {
|
||||||
int r = uBit.radio.enable();
|
int r = uBit.radio.enable();
|
||||||
if (r != MICROBIT_OK) {
|
if (r != MICROBIT_OK) {
|
||||||
@ -32,7 +32,7 @@ namespace radio {
|
|||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
uBit.radio.event.eventReceived(MicroBitEvent(MES_BROADCAST_GENERAL_ID, message, CREATE_ONLY));
|
uBit.radio.event.eventReceived(MicroBitEvent(MES_BROADCAST_GENERAL_ID, message, CREATE_ONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
void onBroadcastMessageReceived(int message, Action f) {
|
void onBroadcastMessageReceived(int message, Action f) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
registerWithDal(MES_BROADCAST_GENERAL_ID, message, f);
|
registerWithDal(MES_BROADCAST_GENERAL_ID, message, f);
|
||||||
@ -40,18 +40,18 @@ namespace radio {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a number over radio to any connected micro:bit in the group.
|
* Broadcasts a number over radio to any connected micro:bit in the group.
|
||||||
*/
|
*/
|
||||||
//% help=radio/send-number
|
//% help=radio/send-number
|
||||||
//% weight=60
|
//% weight=60
|
||||||
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8
|
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8
|
||||||
void sendNumber(int value) {
|
void sendNumber(int value) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
uint32_t t = system_timer_current_time();
|
uint32_t t = system_timer_current_time();
|
||||||
uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0;
|
uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0;
|
||||||
uint32_t buf[] = { (uint32_t)value, t, sn };
|
uint32_t buf[] = { (uint32_t)value, t, sn };
|
||||||
uBit.radio.datagram.send((uint8_t*)buf, 3*sizeof(uint32_t));
|
uBit.radio.datagram.send((uint8_t*)buf, 3*sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a name / value pair along with the device serial number
|
* Broadcasts a name / value pair along with the device serial number
|
||||||
* and running time to any connected micro:bit in the group.
|
* and running time to any connected micro:bit in the group.
|
||||||
@ -64,8 +64,8 @@ namespace radio {
|
|||||||
void sendValue(StringData* name, int value) {
|
void sendValue(StringData* name, int value) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
|
|
||||||
ManagedString n(name);
|
ManagedString n(name);
|
||||||
uint32_t t = system_timer_current_time();
|
uint32_t t = system_timer_current_time();
|
||||||
uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0;
|
uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0;
|
||||||
uint8_t buf[32];
|
uint8_t buf[32];
|
||||||
uint32_t* buf32 = (uint32_t*)buf;
|
uint32_t* buf32 = (uint32_t*)buf;
|
||||||
@ -75,28 +75,28 @@ namespace radio {
|
|||||||
buf32[2] = sn; // 4 bytes: serial number
|
buf32[2] = sn; // 4 bytes: serial number
|
||||||
uint8_t len = min(MAX_FIELD_NAME_LENGTH, n.length()); // 1 byte: string length
|
uint8_t len = min(MAX_FIELD_NAME_LENGTH, n.length()); // 1 byte: string length
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
buf[12] = len; //
|
buf[12] = len; //
|
||||||
memcpy(buf + 13, n.toCharArray(), len); // 13-25: field name
|
memcpy(buf + 13, n.toCharArray(), len); // 13-25: field name
|
||||||
}
|
}
|
||||||
uBit.radio.datagram.send(buf, 13 + len);
|
uBit.radio.datagram.send(buf, 13 + len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts a number over radio to any connected micro:bit in the group.
|
* Broadcasts a number over radio to any connected micro:bit in the group.
|
||||||
*/
|
*/
|
||||||
//% help=radio/send-string
|
//% help=radio/send-string
|
||||||
//% weight=58
|
//% weight=58
|
||||||
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
||||||
void sendString(StringData* msg) {
|
void sendString(StringData* msg) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
|
|
||||||
ManagedString s(msg);
|
ManagedString s(msg);
|
||||||
if (s.length() > MICROBIT_RADIO_MAX_PACKET_SIZE)
|
if (s.length() > MICROBIT_RADIO_MAX_PACKET_SIZE)
|
||||||
s = s.substring(0, MICROBIT_RADIO_MAX_PACKET_SIZE);
|
s = s.substring(0, MICROBIT_RADIO_MAX_PACKET_SIZE);
|
||||||
|
|
||||||
uBit.radio.datagram.send(s);
|
uBit.radio.datagram.send(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a value sent with `stream value` and writes it
|
* Reads a value sent with `stream value` and writes it
|
||||||
* to the serial stream as JSON
|
* to the serial stream as JSON
|
||||||
@ -104,29 +104,30 @@ namespace radio {
|
|||||||
//% help=radio/write-value-to-serial
|
//% help=radio/write-value-to-serial
|
||||||
//% weight=3
|
//% weight=3
|
||||||
//% blockId=radio_write_value_serial block="radio write value to serial"
|
//% blockId=radio_write_value_serial block="radio write value to serial"
|
||||||
|
//% advanced=true
|
||||||
void writeValueToSerial() {
|
void writeValueToSerial() {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
PacketBuffer p = uBit.radio.datagram.recv();
|
PacketBuffer p = uBit.radio.datagram.recv();
|
||||||
int length = p.length();
|
int length = p.length();
|
||||||
uint8_t* bytes = p.getBytes();
|
uint8_t* bytes = p.getBytes();
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
uBit.serial.send("{");
|
uBit.serial.send("{");
|
||||||
if (length >= 4) {
|
if (length >= 4) {
|
||||||
memcpy(&value, bytes, 4);
|
memcpy(&value, bytes, 4);
|
||||||
uBit.serial.send("\"v\":"); uBit.serial.send(value);
|
uBit.serial.send("\"v\":"); uBit.serial.send(value);
|
||||||
if(length >= 8) {
|
if(length >= 8) {
|
||||||
memcpy(&value, bytes + 4, 4);
|
memcpy(&value, bytes + 4, 4);
|
||||||
uBit.serial.send(",\"t\":"); uBit.serial.send(value);
|
uBit.serial.send(",\"t\":"); uBit.serial.send(value);
|
||||||
if (length >= 12) {
|
if (length >= 12) {
|
||||||
memcpy(&value, bytes + 8, 4);
|
memcpy(&value, bytes + 8, 4);
|
||||||
uBit.serial.send(",\"s\":"); uBit.serial.send(value);
|
uBit.serial.send(",\"s\":"); uBit.serial.send(value);
|
||||||
if (length >= 13) {
|
if (length >= 13) {
|
||||||
char name[MAX_FIELD_NAME_LENGTH+1];
|
char name[MAX_FIELD_NAME_LENGTH+1];
|
||||||
uint8_t len = min(MAX_FIELD_NAME_LENGTH, bytes[12]);
|
uint8_t len = min(MAX_FIELD_NAME_LENGTH, bytes[12]);
|
||||||
memcpy(name, bytes + 13, len);
|
memcpy(name, bytes + 13, len);
|
||||||
name[len] = 0;
|
name[len] = 0;
|
||||||
uBit.serial.send(",\"n\":\""); uBit.serial.send(name); uBit.serial.send("\"");
|
uBit.serial.send(",\"n\":\""); uBit.serial.send(name); uBit.serial.send("\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,7 +152,7 @@ namespace radio {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the next packet as a number from the radio queue.
|
* Reads the next packet as a number from the radio queue.
|
||||||
*/
|
*/
|
||||||
@ -173,12 +174,12 @@ namespace radio {
|
|||||||
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
|
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
|
||||||
void onDataReceived(Action body) {
|
void onDataReceived(Action body) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body);
|
registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body);
|
||||||
// make the the receive buffer has a free spot
|
// make the the receive buffer has a free spot
|
||||||
receiveNumber();
|
receiveNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the next packet as a string and returns it.
|
* Reads the next packet as a string and returns it.
|
||||||
*/
|
*/
|
||||||
@ -188,9 +189,9 @@ namespace radio {
|
|||||||
StringData* receiveString() {
|
StringData* receiveString() {
|
||||||
if (radioEnable() != MICROBIT_OK) return ManagedString().leakData();
|
if (radioEnable() != MICROBIT_OK) return ManagedString().leakData();
|
||||||
packet = uBit.radio.datagram.recv();
|
packet = uBit.radio.datagram.recv();
|
||||||
return ManagedString(packet).leakData();
|
return ManagedString(packet).leakData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.
|
* Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.
|
||||||
* namespace=radio
|
* namespace=radio
|
||||||
@ -198,6 +199,7 @@ namespace radio {
|
|||||||
//% help=radio/received-signal-strength
|
//% help=radio/received-signal-strength
|
||||||
//% weight=40
|
//% weight=40
|
||||||
//% blockId=radio_datagram_rssi block="radio received signal strength"
|
//% blockId=radio_datagram_rssi block="radio received signal strength"
|
||||||
|
//% advanced=true
|
||||||
int receivedSignalStrength() {
|
int receivedSignalStrength() {
|
||||||
if (radioEnable() != MICROBIT_OK) return 0;
|
if (radioEnable() != MICROBIT_OK) return 0;
|
||||||
return packet.getRSSI();
|
return packet.getRSSI();
|
||||||
@ -208,13 +210,13 @@ namespace radio {
|
|||||||
* @ param id the group id between ``0`` and ``255``, 1 eg
|
* @ param id the group id between ``0`` and ``255``, 1 eg
|
||||||
*/
|
*/
|
||||||
//% help=radio/set-group
|
//% help=radio/set-group
|
||||||
//% weight=10 blockGap=8
|
//% weight=10 blockGap=8 advanced=true
|
||||||
//% blockId=radio_set_group block="radio set group %ID"
|
//% blockId=radio_set_group block="radio set group %ID"
|
||||||
void setGroup(int id) {
|
void setGroup(int id) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
uBit.radio.setGroup(id);
|
uBit.radio.setGroup(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the output power level of the transmitter to the given value.
|
* Change the output power level of the transmitter to the given value.
|
||||||
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
|
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
|
||||||
@ -222,17 +224,20 @@ namespace radio {
|
|||||||
//% help=radio/set-transmit-power
|
//% help=radio/set-transmit-power
|
||||||
//% weight=9 blockGap=8
|
//% weight=9 blockGap=8
|
||||||
//% blockId=radio_set_transmit_power block="radio set transmit power %power"
|
//% blockId=radio_set_transmit_power block="radio set transmit power %power"
|
||||||
|
//% advanced=true
|
||||||
void setTransmitPower(int power) {
|
void setTransmitPower(int power) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
uBit.radio.setTransmitPower(power);
|
uBit.radio.setTransmitPower(power);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the radio to transmit the serial number in each message.
|
* Set the radio to transmit the serial number in each message.
|
||||||
|
* @param transmit value indicating if the serial number is transmitted, eg: true
|
||||||
*/
|
*/
|
||||||
//% help=radio/set-transmit-serial-number
|
//% help=radio/set-transmit-serial-number
|
||||||
//% weight=8 blockGap=8
|
//% weight=8 blockGap=8
|
||||||
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit"
|
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit"
|
||||||
|
//% advanced=true
|
||||||
void setTransmitSerialNumber(bool transmit) {
|
void setTransmitSerialNumber(bool transmit) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
transmitSerialNumber = transmit;
|
transmitSerialNumber = transmit;
|
@ -38,7 +38,8 @@ declare namespace radio {
|
|||||||
*/
|
*/
|
||||||
//% help=radio/write-value-to-serial
|
//% help=radio/write-value-to-serial
|
||||||
//% weight=3
|
//% weight=3
|
||||||
//% blockId=radio_write_value_serial block="radio write value to serial" shim=radio::writeValueToSerial
|
//% blockId=radio_write_value_serial block="radio write value to serial"
|
||||||
|
//% advanced=true shim=radio::writeValueToSerial
|
||||||
function writeValueToSerial(): void;
|
function writeValueToSerial(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +80,8 @@ declare namespace radio {
|
|||||||
*/
|
*/
|
||||||
//% help=radio/received-signal-strength
|
//% help=radio/received-signal-strength
|
||||||
//% weight=40
|
//% weight=40
|
||||||
//% blockId=radio_datagram_rssi block="radio received signal strength" shim=radio::receivedSignalStrength
|
//% blockId=radio_datagram_rssi block="radio received signal strength"
|
||||||
|
//% advanced=true shim=radio::receivedSignalStrength
|
||||||
function receivedSignalStrength(): number;
|
function receivedSignalStrength(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +89,7 @@ declare namespace radio {
|
|||||||
* @ param id the group id between ``0`` and ``255``, 1 eg
|
* @ param id the group id between ``0`` and ``255``, 1 eg
|
||||||
*/
|
*/
|
||||||
//% help=radio/set-group
|
//% help=radio/set-group
|
||||||
//% weight=10 blockGap=8
|
//% weight=10 blockGap=8 advanced=true
|
||||||
//% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup
|
//% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup
|
||||||
function setGroup(id: number): void;
|
function setGroup(id: number): void;
|
||||||
|
|
||||||
@ -97,15 +99,18 @@ declare namespace radio {
|
|||||||
*/
|
*/
|
||||||
//% help=radio/set-transmit-power
|
//% help=radio/set-transmit-power
|
||||||
//% weight=9 blockGap=8
|
//% weight=9 blockGap=8
|
||||||
//% blockId=radio_set_transmit_power block="radio set transmit power %power" shim=radio::setTransmitPower
|
//% blockId=radio_set_transmit_power block="radio set transmit power %power"
|
||||||
|
//% advanced=true shim=radio::setTransmitPower
|
||||||
function setTransmitPower(power: number): void;
|
function setTransmitPower(power: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the radio to transmit the serial number in each message.
|
* Set the radio to transmit the serial number in each message.
|
||||||
|
* @param transmit value indicating if the serial number is transmitted, eg: true
|
||||||
*/
|
*/
|
||||||
//% help=radio/set-transmit-serial-number
|
//% help=radio/set-transmit-serial-number
|
||||||
//% weight=8 blockGap=8
|
//% weight=8 blockGap=8
|
||||||
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit" shim=radio::setTransmitSerialNumber
|
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit"
|
||||||
|
//% advanced=true shim=radio::setTransmitSerialNumber
|
||||||
function setTransmitSerialNumber(transmit: boolean): void;
|
function setTransmitSerialNumber(transmit: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "file:../microbit",
|
"core": "file:../core",
|
||||||
"microbit-radio": "file:../microbit-radio"
|
"radio": "file:../radio"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pxt-microbit",
|
"name": "pxt-microbit",
|
||||||
"version": "0.4.35",
|
"version": "0.5.0",
|
||||||
"description": "micro:bit target for PXT",
|
"description": "micro:bit target for PXT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"JavaScript",
|
"JavaScript",
|
||||||
@ -29,6 +29,6 @@
|
|||||||
"typescript": "^1.8.7"
|
"typescript": "^1.8.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-core": "0.4.42"
|
"pxt-core": "0.5.0-rc0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,36 @@
|
|||||||
{
|
{
|
||||||
"id": "microbit",
|
"id": "microbit",
|
||||||
|
"nickname": "microbit",
|
||||||
"name": "code the micro:bit",
|
"name": "code the micro:bit",
|
||||||
"title": "code the micro:bit - Blocks / Javascript editor",
|
"title": "code the micro:bit - Blocks / Javascript editor",
|
||||||
"description": "A Blocks / JavaScript code editor for the micro:bit.",
|
"description": "A Blocks / JavaScript code editor for the micro:bit.",
|
||||||
"corepkg": "microbit",
|
"corepkg": "core",
|
||||||
"bundleddirs": [
|
"bundleddirs": [
|
||||||
"libs/microbit",
|
"libs/core",
|
||||||
"libs/microbit-radio",
|
"libs/radio",
|
||||||
"libs/microbit-devices",
|
"libs/devices",
|
||||||
"libs/microbit-bluetooth"
|
"libs/bluetooth"
|
||||||
],
|
],
|
||||||
"cloud": {
|
"cloud": {
|
||||||
"workspace": false,
|
"workspace": false,
|
||||||
"packages": true,
|
"packages": true,
|
||||||
|
"sharing": true,
|
||||||
|
"publish": false,
|
||||||
"preferredPackages": [
|
"preferredPackages": [
|
||||||
"Microsoft/pxt-neopixel",
|
"Microsoft/pxt-neopixel",
|
||||||
"Microsoft/pxt-sonar",
|
"Microsoft/pxt-sonar",
|
||||||
"Microsoft/pxt-max6675",
|
"Microsoft/pxt-max6675",
|
||||||
"Microsoft/pxt-i2c-fram"
|
"Microsoft/pxt-i2c-fram"
|
||||||
]
|
],
|
||||||
|
"githubPackages": true
|
||||||
},
|
},
|
||||||
"blocksprj": {
|
"blocksprj": {
|
||||||
"id": "blocksprj",
|
"id": "blocksprj",
|
||||||
"config": {
|
"config": {
|
||||||
"name": "{0} block",
|
"name": "{0} block",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "*",
|
"core": "*",
|
||||||
"microbit-radio": "*"
|
"radio": "*"
|
||||||
},
|
},
|
||||||
"description": "",
|
"description": "",
|
||||||
"files": [
|
"files": [
|
||||||
@ -46,8 +50,8 @@
|
|||||||
"config": {
|
"config": {
|
||||||
"name": "{0} bit",
|
"name": "{0} bit",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "*",
|
"core": "*",
|
||||||
"microbit-radio": "*"
|
"radio": "*"
|
||||||
},
|
},
|
||||||
"description": "",
|
"description": "",
|
||||||
"files": [
|
"files": [
|
||||||
@ -65,7 +69,23 @@
|
|||||||
"hasHex": true,
|
"hasHex": true,
|
||||||
"deployDrives": "(MICROBIT|MBED)",
|
"deployDrives": "(MICROBIT|MBED)",
|
||||||
"driveName": "MICROBIT",
|
"driveName": "MICROBIT",
|
||||||
"hexMimeType": "application/x-microbit-hex"
|
"hexMimeType": "application/x-microbit-hex",
|
||||||
|
"upgrades": [
|
||||||
|
{
|
||||||
|
"type": "package",
|
||||||
|
"map": {
|
||||||
|
"microbit": "core",
|
||||||
|
"microbit-bluetooth": "bluetooth",
|
||||||
|
"microbit-radio": "radio",
|
||||||
|
"microbit-devices": "devices",
|
||||||
|
"microbit-led": "",
|
||||||
|
"microbit-music": "",
|
||||||
|
"microbit-game": "",
|
||||||
|
"microbit-pins": "",
|
||||||
|
"microbit-serial": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"mathBlocks": true,
|
"mathBlocks": true,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/// <reference path="../../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
/// <reference path="../../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
||||||
/// <reference path="../../libs/microbit/dal.d.ts"/>
|
/// <reference path="../../libs/core/dal.d.ts"/>
|
||||||
/// <reference path="../../libs/microbit/shims.d.ts"/>
|
/// <reference path="../../libs/core/shims.d.ts"/>
|
||||||
/// <reference path="../../libs/microbit/enums.d.ts"/>
|
/// <reference path="../../libs/core/enums.d.ts"/>
|
||||||
|
|
||||||
namespace pxsim.visuals {
|
namespace pxsim.visuals {
|
||||||
const PIXEL_SPACING = PIN_DIST * 3;
|
const PIXEL_SPACING = PIN_DIST * 3;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
],
|
],
|
||||||
"public": true,
|
"public": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"microbit": "*",
|
"core": "*",
|
||||||
"microbit-radio": "*"
|
"radio": "*"
|
||||||
},
|
},
|
||||||
"installedVersion": "file:."
|
"installedVersion": "file:."
|
||||||
}
|
}
|
||||||
|