Compare commits

...

139 Commits

Author SHA1 Message Date
2e15d22e9e 0.7.37 2017-01-17 16:29:52 -08:00
57082654a9 0.7.36 2017-01-17 14:55:44 -08:00
8cbf7d38e3 0.7.35 2017-01-17 14:51:28 -08:00
a99a7325bf 0.7.34 2017-01-17 14:13:06 -08:00
fa3ed9dd21 0.7.33 2017-01-17 11:37:35 -08:00
45fd40a553 adding on pin pressed in getting-started 2017-01-17 11:37:20 -08:00
5a18bea9eb 0.7.32 2017-01-17 11:28:38 -08:00
d310312841 Bump pxt-core to 0.10.8 2017-01-17 11:28:35 -08:00
a4b93f7199 support for deletable on start 2017-01-17 11:18:22 -08:00
538a4b7bbf 0.7.31 2017-01-13 18:11:03 -08:00
0078e7bc12 Bump pxt-core to 0.10.7 2017-01-13 18:11:02 -08:00
d2726133a9 Revert "Control event value in simulator (#343)"
This reverts commit 00f4c9cbb3.
2017-01-13 18:04:38 -08:00
00f4c9cbb3 Control event value in simulator (#343)
* implement pxsim.control.eventValue and pxsim.control.eventTimestamp in the simulator
2017-01-13 16:46:52 -08:00
e15da5dee1 0.7.30 2017-01-13 15:47:16 -08:00
85dda4ea84 Bump pxt-core to 0.10.4 2017-01-13 15:47:15 -08:00
a3ffe4e1cf Set latest Electron to 0.7.29 (#342) 2017-01-13 14:11:46 -08:00
90c4d4f73b 0.7.29 2017-01-13 13:55:44 -08:00
6484d559d6 Bump pxt-core to 0.10.2 2017-01-13 13:55:43 -08:00
357436f14d refactored servostate (#341)
* refactored servostate

* Bump pxt-core to 0.10.1
2017-01-12 23:09:53 -08:00
85fe96b3fd 0.7.28 2017-01-12 16:08:35 -08:00
cdac932c42 Bump pxt-core to 0.9.5 2017-01-12 16:08:32 -08:00
dcfc2a110d Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2017-01-12 16:07:19 -08:00
e9561f54c3 removing custom loader logic 2017-01-12 16:07:10 -08:00
86f6b58d38 fix"string compare works differently in simulator/on target" (#340)
* fix for "string compare works differently in simulator/on target", fixes #901
2017-01-12 15:50:39 -08:00
eee52a5c04 0.7.27 2017-01-12 15:27:07 -08:00
1a0b0eac71 Bump pxt-core to 0.9.4 2017-01-12 15:27:04 -08:00
5a98ae0bb8 0.7.26 2017-01-12 11:54:33 -08:00
a9eea9a618 Bump pxt-core to 0.9.3 2017-01-12 11:54:30 -08:00
3086c521e3 0.7.25 2017-01-12 11:33:08 -08:00
6788f79650 Bump pxt-core to 0.9.2 2017-01-12 11:33:05 -08:00
5900239045 changing editor button colors 2017-01-12 10:45:39 -08:00
248267ec2c 0.7.24 2017-01-10 17:47:09 -08:00
9429075555 Bump pxt-core to 0.8.14 2017-01-10 17:47:07 -08:00
1fa871f2e7 Support for serial events (#339)
* added "serial->on data received"

* updated info

* updated docs

* added readline to read entire buffer

* lazy initialize of serial buffers

* init async on event

* updated docs
2017-01-10 16:27:02 -08:00
04dab7df2c One letter showString shouldn't disappear (#338)
* Fix for "One letter showString shouldn't disappear", fixes #798

* miss semicolon
2017-01-10 16:25:40 -08:00
b6474467bc Electron release (#333)
Set latest Electron app release to 0.7.23
2017-01-10 14:16:13 -08:00
79ead74af4 0.7.23 2017-01-10 10:31:04 -08:00
0f8ff95b72 Bump pxt-core to 0.8.13 2017-01-10 10:30:58 -08:00
05028c4527 Serial events (#337)
* added "serial->on data received"

* updated info

* updated docs

* added readline to read entire buffer

* lazy initialize of serial buffers

* init async on event

* updated docs
2017-01-10 10:26:44 -08:00
4054da3483 0.7.22 2017-01-09 21:33:47 -08:00
7052d27d6d Bump pxt-core to 0.8.12 2017-01-09 21:33:44 -08:00
365af8d672 Merge pull request #335 from Microsoft/default
Default values for array
2017-01-09 20:35:56 -08:00
5086ca308c 0.7.21 2017-01-09 16:08:58 -08:00
c1af770afc Bump pxt-core to 0.8.11 2017-01-09 16:08:58 -08:00
e175e70d01 Merge branch 'master' into editortoolbox 2017-01-09 16:01:35 -08:00
cbc228dca3 negative scroll fix
fix for Microsoft/pxt#813
2017-01-09 14:17:19 -08:00
462127c661 Loader (#336)
* Custom microbit loader

* updated animation

* use standardized name

* moving loader support to pxt
2017-01-09 07:51:00 -08:00
487da05eca Fix for https://github.com/Microsoft/pxt/issues/1057 2017-01-09 10:58:24 +00:00
c938618d29 adding default values for beyond the array.length access 2017-01-08 19:08:09 -08:00
91321dab83 Support for default values in array. 2017-01-08 18:43:14 -08:00
0cb3d6e44e Changes accompanying the editor toolbox. 2017-01-07 17:35:54 -08:00
7a98b06424 Custom microbit loader (#334)
* Custom microbit loader

* updated animation

* use standardized name
2017-01-06 17:39:48 -08:00
69c80d3aff Add css and default icon to NPM package for Electron app (#332) 2017-01-06 16:29:48 -08:00
1d82f08668 update instructions to use inline buttons 2017-01-06 14:41:33 -08:00
4681a68ffd added avatar image 2017-01-06 09:51:19 -08:00
0a69b773de missing package annotation 2017-01-06 07:19:00 -08:00
3f66a1c16d 0.7.20 2017-01-06 07:13:39 -08:00
d78781ad5a Bump pxt-core to 0.8.8 2017-01-06 07:13:38 -08:00
46281c3cd0 fixing broken links in docs 2017-01-06 06:12:39 -08:00
a58f67064f 0.7.19 2017-01-06 06:03:43 -08:00
efe784441f Bump pxt-core to 0.8.7 2017-01-06 06:03:41 -08:00
05174f094a updated translations 2017-01-06 06:03:33 -08:00
42773a1a0a updatd weights of radio 2017-01-06 05:43:50 -08:00
32f96d09d4 removing "getting-started" link 2017-01-06 04:58:00 -08:00
05d88cb4ba updated getting -started 2017-01-06 04:32:53 -08:00
7fe8dad1f6 0.7.18 2017-01-05 22:39:36 -08:00
858766ea3e Bump pxt-core to 0.8.6 2017-01-05 22:39:34 -08:00
81fe9afbb7 remove begin 2017-01-05 13:35:28 -08:00
65c615f256 Merge branch 'master' into tutorialmode 2017-01-05 13:33:41 -08:00
9c5c699fe7 0.7.17 2017-01-05 13:31:30 -08:00
dcede1703a fixing link 2017-01-05 13:31:05 -08:00
5d33ab019d 0.7.16 2017-01-05 13:30:30 -08:00
f7ec452ea0 updated steps 2017-01-05 13:30:14 -08:00
20260e8933 fixes to docs 2017-01-05 13:28:06 -08:00
d7704934e8 0.7.15 2017-01-05 13:17:24 -08:00
f1eafb0a6e Bump pxt-core to 0.8.5 2017-01-05 13:17:21 -08:00
27d6a8281a Inchworm (#331)
* images for inchworm project

* binding pictures

* updated inchworm lesson
2017-01-05 10:00:36 -08:00
c5128aa497 Merge branch 'master' into tutorialmode 2017-01-05 08:19:39 -08:00
a59394646c fixed docs 2017-01-05 07:37:46 -08:00
6851169dbe 0.7.14 2017-01-05 07:10:13 -08:00
36b3486194 Bump pxt-core to 0.8.3 2017-01-05 07:10:12 -08:00
5d8ccd1d6d adding namespace to api categories (#330)
* adding namespace to api categories

* add icon for led

* adding icons for control, game, images, pins and serial.
2017-01-05 07:01:50 -08:00
c713fe9bf4 0.7.13 2017-01-04 13:08:54 -08:00
f682e5e694 insertAt support for array (#328)
* Adding insertAt and setLength to array

* implemented review comments

* Bump pxt-core to 0.8.2
2017-01-04 13:07:58 -08:00
d2d776fd01 Updating getting started tutorial 2017-01-04 10:06:47 -08:00
641a5e9673 Merge branch 'master' into tutorialmode 2017-01-03 12:14:34 -08:00
93d90a2bde Few extra typing fixes. 2017-01-03 12:14:25 -08:00
a54504f31c Updating bluebird typings path 2017-01-03 11:38:21 -08:00
03111368e0 add more blocks 2017-01-02 22:14:40 -08:00
a973b2aec6 Merge branch 'master' into tutorialmode 2017-01-02 15:10:11 -08:00
a7adf0e6c6 minor ui fixes 2017-01-02 15:09:49 -08:00
c10761128e Tutorial mode changes 2017-01-01 18:52:22 -08:00
9965f169b2 0.7.12 2016-12-31 07:28:12 -08:00
8bf755c15c fixing eddystone uid encoding 2016-12-31 07:25:27 -08:00
d0b2a7db62 0.7.11 2016-12-31 06:49:30 -08:00
780192da3b Bump pxt-core to 0.7.13 2016-12-31 06:49:28 -08:00
07c1f08d18 fix for Microsoft/pxt#1014 2016-12-31 06:36:05 -08:00
25ac847266 converging with other targets on blockly toolbox width 2016-12-31 02:51:24 -08:00
63c8342b86 ui changes accompanying pxt mobile ui fixes 2016-12-31 01:43:45 -08:00
ea2bd7ba10 Merge pull request #326 from Microsoft/array
Array enhancements
2016-12-30 15:09:16 -08:00
cec2d1e8af 0.7.10 2016-12-30 15:05:31 -08:00
1b289b688b Bump pxt-core to 0.7.12 2016-12-30 15:05:28 -08:00
0cf91580cb Merge pull request #327 from Microsoft/pr/toggletheming
Blocks / JS menu toggle theming
2016-12-30 15:00:32 -08:00
392ebc8d07 0.7.9 2016-12-30 14:18:06 -08:00
9068aab12b Bump pxt-core to 0.7.11 2016-12-30 14:18:03 -08:00
85327a4e69 0.7.8 2016-12-30 13:50:03 -08:00
021260b3a4 Bump pxt-core to 0.7.10 2016-12-30 13:50:00 -08:00
4def93d7c5 Blocks / JS menu toggle theming 2016-12-30 13:07:16 -08:00
9aca0c19fc Merge branch 'master' into array 2016-12-23 19:53:06 -08:00
3fcbdbdd82 Array reimplementation as single segment with support for missing values 2016-12-23 19:49:15 -08:00
4b7b6eebca 0.7.7 2016-12-23 08:59:08 -08:00
2da0cf1178 support for buffer signature (#325) 2016-12-23 08:58:38 -08:00
141cb24e3d 0.7.6 2016-12-22 23:18:35 -08:00
35483487af Bump pxt-core to 0.7.9 2016-12-22 23:18:32 -08:00
ec3a805326 0.7.5 2016-12-22 11:35:58 -08:00
780d8bcf8d Bump pxt-core to 0.7.6 2016-12-22 11:35:56 -08:00
f9a12cac64 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-12-22 11:32:01 -08:00
03c2df3277 fixed default projects 2016-12-22 11:31:50 -08:00
a7e98ccb3d Change default product names for Electron app; Add release manifest 2016-12-21 12:31:00 -08:00
1014d2f361 0.7.4 2016-12-20 16:30:14 -08:00
89f20a64d5 Bump pxt-core to 0.7.5 2016-12-20 16:30:12 -08:00
fae36a74af 0.7.3 2016-12-20 13:06:13 -08:00
7e57c59b6f Bump pxt-core to 0.7.4 2016-12-20 13:06:09 -08:00
3141e12f4c support for 8G gestures 2016-12-20 13:05:06 -08:00
4ebe9f595a fix for Microsoft/pxt#961 2016-12-20 12:38:00 -08:00
50f0e85884 docs updates 2016-12-20 12:31:25 -08:00
e28b5d48d4 0.7.2 2016-12-19 16:08:31 -08:00
562e96e09e Bump pxt-core to 0.7.2 2016-12-19 16:08:21 -08:00
6c5088f811 update LESS variables 2016-12-19 16:08:01 -08:00
d5ccb7ad02 0.7.1 2016-12-19 14:11:17 -08:00
ade5176d21 upgraded to 0.7 2016-12-19 14:10:57 -08:00
d2f6d51c19 0.6.46 2016-12-19 14:10:12 -08:00
92b60a251d On start support (#324)
* annotating APIs to support onstart

* missed file

* updated templates

* adding new lines in main.ts

* fixing docs

* removing onstart

* updated docs

* updated various docs

* more docs

* adding upgrade policies for blocks

* updated pxt reference

* placing on start under "basic"
2016-12-19 14:09:35 -08:00
de9f2d7e67 More appropriate Electron app bundle ID on Mac OS 2016-12-19 07:59:52 -08:00
4de5e3bd11 0.6.45 2016-12-18 20:57:52 -08:00
86a33e8f65 Bump pxt-core to 0.6.7 2016-12-18 20:57:50 -08:00
89010b6a8a 0.6.44 2016-12-16 20:26:41 -08:00
48d4668a7a Bump pxt-core to 0.6.6 2016-12-16 20:26:39 -08:00
a2755dc4d2 annotate apis to support multiple forever blocks 2016-12-16 16:47:36 -08:00
117 changed files with 1781 additions and 616 deletions

2
.gitignore vendored
View File

@ -15,7 +15,7 @@ clients/win10/app/bld
clients/win10/*.opendb
clients/**/bin/**
clients/**/obj/**
clients/electron/projects
electron-out
hexcache
*.user

View File

@ -1,4 +1,4 @@
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
/// <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";

View File

@ -11,4 +11,4 @@ Math.random(5);
## See Also
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables)
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables), [on-start](/blocks/on-start)

View File

@ -86,12 +86,14 @@ if (led.point(1,1) && led.point(2,2)) {
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
```blocks
let x = Math.random(5)
if(x < 5) {
basic.showString("low");
} else {
basic.showString("high");
}
input.onButtonPressed(Button.A, () => {
let x = Math.random(5)
if(x < 5) {
basic.showString("low");
} else {
basic.showString("high");
}
})
```
See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function.

View File

@ -14,13 +14,15 @@ Click on the dark blue gear icon (see above) to add an *else* or *if* to the cur
### Example: adjusting screen brightness
```blocks
if(input.lightLevel()<100){
led.setBrightness(255);
}
```
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed:
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255`:
```blocks
input.onButtonPressed(Button.A, () => {
if(input.lightLevel()<100){
led.setBrightness(255);
}
})
```
### See also

View File

@ -4,14 +4,21 @@
Run part of the program the number of times you say.
```block
for(let i = 0; i <= 4; ++i) {
}
```
### Example: Count to 4
This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen.
```blocks
for(let i = 0; i < 5; ++i) {
basic.showNumber(i)
}
input.onButtonPressed(Button.A, () => {
for(let i = 0; i < 5; ++i) {
basic.showNumber(i)
}
})
```
### See also

View File

@ -2,7 +2,7 @@
Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
```blocks
```block
while(true) {
}
```
@ -16,11 +16,13 @@ The condition is tested before any code runs. Which means that if the condition
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
```blocks
let index = 4;
while(index >= 0) {
led.plot(index, index);
index--;
}
input.onButtonPressed(Button.A, () => {
let index = 4;
while(index >= 0) {
led.plot(index, index);
index--;
}
})
```
### See also

22
docs/blocks/on-start.md Normal file
View File

@ -0,0 +1,22 @@
# On Start
An event that runs when the program starts.
The ``on start`` is a special event that runs when the program starts, before any other event.
Use this event to initialize your program.
## Example
In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string.
```blocks
input.onButtonPressed(Button.A, () => {
basic.showString("Hello!")
})
led.setBrightness(50)
```
## What about JavaScript?
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.

View File

@ -33,7 +33,7 @@ basic.forever(() => {
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.)
`[basic.forever(() => {})]` block.)
Click **Download** to move your program to the @boardname@!
Make sure to follow the instructions.

View File

@ -17,7 +17,7 @@ input.onButtonPressed(Button.A, () => {
#### ~hint
The ``showString`` block can show letters, numbers, and punctuation
The `[basic.showString("HI")]` block can show letters, numbers, and punctuation
on the @boardname@ screen.
#### ~
@ -33,7 +33,7 @@ input.onButtonPressed(Button.B, () => {
#### ~hint
You can find the letter `B` by clicking the letter `A` on the
``onButtonPressed`` block.
`[input.onButtonPressed(Button.A, () => {})]` block.
#### ~

View File

@ -23,8 +23,8 @@ input.onButtonPressed(Button.B, () => {
```
### ~hint
The ``pick random true or false`` block randomly tells the ``if``
block `true` or `false`. If the ``pick`` block picked `true`, the
The `[Math.randomBoolean()]` block randomly tells the ``if``
block `true` or `false`. If value picked is `true`, the
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
That's it!

View File

@ -9,7 +9,7 @@ There are 25 bright LEDs on the @boardname@ screen. Let's use them to create som
### 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.
in the second `[basic.showLeds("")]` 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 @boardname@)!
@ -36,7 +36,7 @@ Click **Download** to move your program to the @boardname@!
### Your turn!
Pile up more ``show leds`` blocks to create an animation! Create an
Pile up more `[basic.showLeds("")]` blocks to create an animation! Create an
animation with at least 5 pictures. What does this animation show?
```blocks
@ -87,12 +87,6 @@ basic.forever(() => {
```
Click **Download** to move your program to the @boardname@!
#### ~hint
You can find the ``show leds`` block in the **Basic** part of the editor.
#### ~
### ~button /getting-started/buttons
NEXT: BUTTONS
### ~

View File

@ -66,6 +66,10 @@ Fun games to build with your @boardname@.
```codecard
[{
"name": "Inchworm",
"url":"/projects/inchworm",
"imageUrl":"/static/mb/projects/inchworm.jpg"
}, {
"name": "Timing gates",
"url":"/projects/timing-gates",
"imageUrl":"/static/mb/projects/timing-gates.jpg"

View File

@ -10,7 +10,9 @@ Let's start by adding a variable where you can store data. Then rename the varia
```blocks
let light = input.lightLevel();
input.onButtonPressed(Button.A, () => {
let light = input.lightLevel();
});
```
We want to play music on button pressed in order to register an event handler that will execute whenever when you run a script and click on button pressed on the simulator. We must start by opening the Input drawer and adding `on button pressed` A. Then add a block `rest` to plays nothing for a `1/16` beat. Modify your code so that your code looks like this.

40
docs/projects/inchworm.md Normal file
View File

@ -0,0 +1,40 @@
# Inchworm
### @description A inchworm like robot built with the micro:bit
### ~avatar avatar
Make a funny inchworm robot!
### ~
https://youtu.be/BiZLjugXMbM
## Duration
3 Activities, approx 30-45 min each based on familiarity with the coding concepts
## Materials
* Cardboard pieces (recycle!)
* Glue gun or Tape (masking, duct tape, and/or packing tape)
* Scissors that can cut cardboard
* 1 @boardname@, battery holder and 2 AAA batteries
* 3 Crocodile clips
* 1 micro servo 9g SG90
* 1 paper clip
![Materials](/static/mb/projects/inchworm/materials.jpg)
## Activities
* [Servo](/projects/inchworm/servo)
* [Chassis](/projects/inchworm/chassis)
* [Code](/projects/inchworm/code)
### ~button /projects/inchworm/servo
Let's get started!
### ~

View File

@ -0,0 +1,88 @@
# Chassis
### @description Building the cardboard inchworm
### ~avatar avatar
Turn a piece of cardboard into an inchworm!
### ~
## Duration: ~45 minutes
## Materials
* Cardboard
* Scissors or cutters
* glue gun or tape
* 1 paper clip
## Step 1: cardboard
Cutout a cardboard rectangle. You can use the @boardname@ as a ruler to figure out the size.
![](/static/mb/projects/inchworm/chassis1.jpg)
## Step 2: center fold
Fold the cardboard in half over the short edge.
![](/static/mb/projects/inchworm/chassis2.jpg)
## Step 3: legs
Fold each end so they rest flat on the ground.
![](/static/mb/projects/inchworm/chassis3.jpg)
## Step 4: front teeth
Fold each corners on one end of the cardbard. This will be the front of the inchworm which is supposed to grip the ground.
![](/static/mb/projects/inchworm/chassis4.jpg)
## Step 5: back teeth
Using a scissor or a cutter (watch the fingers!), cut out various strips in the other edge. Fold one after the other.
![](/static/mb/projects/inchworm/chassis5.jpg)
## Step 6: mounting the board
Using tape or a glue gun, mount the @boardname@ on one side and the microservo on the cardobard.
![](/static/mb/projects/inchworm/chassis6.jpg)
## Step 7: mounting the servo
Attach the servo on the **edge** of the other cardboard side.
![](/static/mb/projects/inchworm/chassis7.jpg)
## Step 8: Cable clean up (optional)
Use tape to route the cables nicely on the inchworm.
![](/static/mb/projects/inchworm/chassis8.jpg)
## Step 9: attaching paper clip to servo
Unfold a paper clip and attach it to the servo arm.
![](/static/mb/projects/inchworm/clip2.jpg)
## Step 10: attaching paper clip to cardboard
Slide the folder paper clip into the cardboard, and use tape to secure it.
You might need to toy around with the size of the clip so that the servo rotation opens the inchworm sufficiently.
![](/static/mb/projects/inchworm/clip3.jpg)
## Step 11: it's ready!
Your inchworm is ready!
![](/static/mb/projects/inchworm/ready.jpg)
### ~button /projects/inchworm/code
NEXT: Code
### ~

View File

@ -0,0 +1,52 @@
# Code
### @description code to make the inchworm alive
### ~avatar avatar
Add code to make the inchworm move.
### ~
## Duration: ~30 minutes
## Step 1: walk forever
In order for the inchworm to move, the @boardname@ needs to command the servo to go between ``0`` and ``180`` degrees
at a certain pace. In the code below, the user pressed button ``A`` to launch the inchworm.
```blocks
input.onButtonPressed(Button.A, () => {
pins.servoWritePin(AnalogPin.P0, 0);
basic.pause(500);
pins.servoWritePin(AnalogPin.P0, 180);
basic.pause(500);
});
```
### ~ hint
You may have noticed that the inchworm can be rather slow or simply won't move. Try to improve the design of your legs, teeth
so that the inchworm goes as fast as possible. Trying it on carpet also great helps avoiding skidding.
### ~
## Step 2: radio controlled inchworm
You will need 2 @boardname@ for this part. By using the radio, we can make the inchworm controlled by another @boardname@.
Download the code below to the @boardname@ on the inchworm and another "controller" @boardname@. Whenere A is pressed, the inchworm will move once.
```blocks
radio.onDataPacketReceived(({receivedNumber}) => {
pins.servoWritePin(AnalogPin.P0, 0)
basic.pause(500)
pins.servoWritePin(AnalogPin.P0, 180)
basic.pause(500)
})
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
```
```package
radio
```

View File

@ -0,0 +1,130 @@
# Preparing the servo
### @description Connecting the servo to crocodile clips
### ~avatar avatar
Equip the microservo with crocodile clips.
### ~
## Duration: ~30 minutes
## Materials
* Cutting pliers or wire cutter
* Tape (masking, duct tape, and/or packing tape)
* 3 crocodile clips, yellow, red and black.
* 1 micro servo 9g (SG90)
## Using a microservo with the @boardname@
The @boardname@ provides just enough current to operate the SG90 microservo.
The servo requires 3 connections: GND, 3V and a logic pin.
In this tutorial, we will equip the servo with crocodile clips to make it easier to use.
However, you could also use a shield or female to crocodile clips to acheive the same effect.
If you are running a class or activity, you should consider preparing all servos before hand.
### ~ hint
Kitronik wrote an excellent in-depth guide about using servos with the @boardname@.
Check it out at https://www.kitronik.co.uk/blog/using-bbc-microbit-control-servo/ .
### ~
## Step 1: cutout the connector
Using the cutting pliers, cut out the dark plastic connector.
![](/static/mb/projects/inchworm/servo1.jpg)
## Step 2: strip out cables
Using the plier or a wire stripper, strip the plastic from the cables.
![](/static/mb/projects/inchworm/servotrim.jpg)
## Step 3: threading the servo cablers
Thread the servo cables.
![](/static/mb/projects/inchworm/servo3.jpg)
## Step 4: crocobile clip claps
Cut a crocodile cable in two and strip out the casing.
If possible try to use the same cable colors as the servo!
![](/static/mb/projects/inchworm/servo4.jpg)
## Step 5: thread cables together
Place the cables next to each other
![](/static/mb/projects/inchworm/servo5.jpg)
... and thread them together.
![](/static/mb/projects/inchworm/servo6.jpg)
### ~ hint
It is very **important** to ensure that there is a good connection between the 2 cables.
If the connection is weak, the microservo will not receive enough current and it will not work.
If you have access to a soldering iron, we strongly recommend to solver this connection.
### ~
## Step 4: protect the connection
Protect the connection with electrical or duct tape.
![](/static/mb/projects/inchworm/servo7.jpg)
## Step 5: repeat for all cables
Repeat the same process until all cables are connected.
![](/static/mb/projects/inchworm/servo8.jpg)
## Step 6: testing!
It's time to test that your connection are all proper and that the servo will function **when the @boardname@ is powered by battery**.
* Connect the microservo to the @boardname@. Black cable on ``GND``, red cable on ``3V`` and remaining cable on ``P0``.
![](/static/mb/projects/inchworm/circuit1.jpg)
### ~ hint
When attaching the crocodile clips to the pins, don't hesitate to grab the side of the board with the jaws.
![](/static/mb/projects/inchworm/circuit2.jpg)
### ~
* Download the following code to your @boardname@
```blocks
let a = 0
basic.forever(() => {
a = input.acceleration(Dimension.X)
pins.servoWritePin(AnalogPin.P0, pins.map(
a,
-512,
512,
0,
180
))
})
```
* When powered by USB, make sure that the servo moves when you tilt the board.
* When powered by batteries **only**, make sure that the servo moves when you tilt the board.
If your servo seems to sutter and stay stuck at a particular position, it means that it is not receiving enough power.
This is probably due to a weak connection or low battery level. Check each connection and check your batteries.
### ~button /projects/inchworm/chassis
NEXT: Chassis
### ~

View File

@ -37,7 +37,7 @@ input.onButtonPressed(Button.B, () => {
We will use the @boardname@'s compass to detect the magnet. Compass's tell us what direction we are pointing by detecting the Earth's magnetic field but they can also detect any other magnet nearby. We will use that to check if our magnet is next to the @boardname@ by using the [magnetic force](/reference/input/magnetic-force) block found in the input menu's 'more' section. As we only want to measure the strength we change the drop down to select 'strength':
```blocks
```block
input.magneticForce(Dimension.Strength)
```
@ -50,16 +50,19 @@ If you have ever played with magnets you know they have two ends, often called a
So in the code below we will check if the absolute value of our magnetic field strength reading is more than 100 and save the result of that check in a new variable called 'isSwitched':
```blocks
let isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
let force = Math.abs(input.magneticForce(Dimension.Strength));
let isSwitched = force > 100
```
## Step 4: running our 'magnet nearby' check all the time
At the moment our code to detect the magnet being nearby will only run once so we need to put it into a [forever](/reference/basic/forever) block so that it keeps getting run again and again checking for the magnet to come near to the @boardname@. We should also make sure 'isSwitched' is false when our program starts.
```blocks
let force = 0;
let isSwitched = false;
basic.forever(() => {
let isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
force = Math.abs(input.magneticForce(Dimension.Strength));
isSwitched = force > 100
})
```
@ -68,10 +71,11 @@ basic.forever(() => {
Now we can check the value of our variable 'isSwitched' whenever we want and we will know that the magnet is nearby if it's value is 'true'. Let's use that to change how the buttons work and complete the code for our trick. We will add an 'if, else' block to each button's code and check if we should swap over what each button displays because 'isSwitched' is equal to true:
```blocks
let force = 0;
let isSwitched = false;
basic.forever(() => {
isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
force = Math.abs(input.magneticForce(Dimension.Strength));
isSwitched = force > 100
})
input.onButtonPressed(Button.A, () => {

View File

@ -18,15 +18,15 @@ and updates the screen with the direction.
basic.forever(() => {
let heading = input.compassHeading()
if (heading < 45) {
basic.showString("N", 100)
basic.showString("N")
} else if (heading < 135) {
basic.showString("E", 100)
basic.showString("E")
}
else if (heading < 225) {
basic.showString("S", 100)
basic.showString("S")
}
else {
basic.showString("W", 100)
basic.showString("W")
}
})
```
@ -40,7 +40,7 @@ You can use a program like this to count things with your @boardname@.
```blocks
let num = 0
basic.forever(() => {
basic.showNumber(num, 150)
basic.showNumber(num)
})
input.onButtonPressed(Button.A, () => {
num = num + 1
@ -56,10 +56,10 @@ Try this on your @boardname@:
```blocks
basic.forever(() => {
basic.showNumber(6789, 150)
basic.showNumber(6789)
})
input.onButtonPressed(Button.A, () => {
basic.showNumber(2, 150)
basic.showNumber(2)
})
```

View File

@ -35,7 +35,8 @@ bluetooth.uartWriteValue("", 0);
## Eddystone
```cards
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7);
bluetooth.advertiseUid(42, 1, 7, true);
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
bluetooth.stopAdvertising();
```

View File

@ -0,0 +1,37 @@
# Avertise UID Buffer
Advertises a UID via the Eddystone protocol over Bluetooth.
## ~hint
### Eddystone
Bluetooth beacons are used to indicate proximity to a place or object of interest.
Beacons use Bluetooth advertising to broadcast a small amount of data,
which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
iBeacon is Apple's beacon message format. Eddystone comes from Google.
Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ .
## ~
```sig
bluetooth.advertiseUidBuffer(pins.createBuffer(16), 7, true);
```
### Parameters
* ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes).
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the micro:bit should accept connections.
## See Also
[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid)
```package
bluetooth
```

View File

@ -0,0 +1,46 @@
# Avertise UID
Advertises a UID via the Eddystone protocol over Bluetooth.
## ~hint
### Eddystone
Bluetooth beacons are used to indicate proximity to a place or object of interest.
Beacons use Bluetooth advertising to broadcast a small amount of data,
which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
iBeacon is Apple's beacon message format. Eddystone comes from Google.
Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ .
## ~
```sig
bluetooth.advertiseUid(42, 1, 7, true);
```
### Parameters
* ``namespace`` last 4 bytes of the namespace uid (6 to 9)
* ``instance`` last 4 bytes of the instance (2 to 5)
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the micro:bit should accept connections.
## Encoding
The bytes of ``namespace`` and ``instance`` are encoded to generate the 10 bytes UID namespace and 6 bytes UID instance.
```
UID namespace: [0, ..., namespace]
UID instance: [0, ..., instance]
```
## See Also
[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid-buffer](/reference/bluetooth/advertise-uid-buffer)
```package
bluetooth
```

View File

@ -25,6 +25,7 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
* ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 17 characters long, excluding the protocol (eg: ``https://``) which gets encoded as 1 byte.
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the micro:bit should accept connections.
### Example: Broadcast a secret code
@ -34,7 +35,7 @@ bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true);
## See Also
[stop-advertising](/reference/bluetooth/stop-advertising)
[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid)
```package
bluetooth

View File

@ -7,8 +7,11 @@ serial.writeLine("");
serial.writeNumber(0);
serial.writeValue("x", 0);
serial.writeString("");
serial.readUntil(",");
serial.readLine();
serial.readString();
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
serial.onDataReceived(",", () => {})
```
### See Also

View File

@ -0,0 +1,29 @@
# Serial On Data Received
Registers an event to be fired when one of the delimiter is matched.
```sig
serial.onDataReceived(",", () => {})
```
### Parameters
* `delimiters` is a [string](/reference/types/string) containing any of the character to match
### Example
Read values separated by `,`:
```blocks
serial.onDataReceived(serial.delimiters(Delimiters.Comma), () => {
basic.showString(serial.readUntil(serial.delimiters(Delimiters.Comma)))
})
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write value](/reference/serial/write-value)

View File

@ -0,0 +1,27 @@
# Serial Read String
Read the buffered serial data as a string
```sig
serial.readString();
```
### Returns
* a [string](/reference/types/string) containing input from the serial port. Empty if no data available.
### Example
The following program scrolls text on the screen as it arrives from serial.
```blocks
basic.forever(() => {
basic.showString(serial.readString());
});
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write value](/reference/serial/write-value)

61
docs/static/avatar.svg vendored Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
role="img"
aria-labelledby="title desc"
xml:space="preserve"
enable-background="new 0 0 280 32.755"
height="52.672001"
width="52.672001"
version="1.1"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="logo.square.black.svg"><sodipodi:namedview
pagecolor="#ff00ff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1536"
inkscape:window-height="801"
id="namedview14"
showgrid="false"
inkscape:zoom="2.0836233"
inkscape:cx="83.390493"
inkscape:cy="16.071144"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" /><rect
id="backgroundrect"
width="195.47368"
height="34.210526"
x="0"
y="18.461473"
class=""
style="fill:none;stroke:none" /><title
id="title"
lang="en-GB">BBC micro:bit</title><desc
id="desc"
lang="en-GB">BBC micro:bit logo</desc><metadata
id="metadata37"><rdf:rdf><cc:work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:work></rdf:rdf><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title>BBC micro:bit</dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs35" /><path
inkscape:connector-curvature="0"
class=""
d="m 37.363,29.377 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 M 15.052,23.3 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.0299993,-4.053 -9.0299993,-9.031 C 6.0180007,21.357 10.072,17.31 15.049,17.31 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 C 6.7500007,11.286 6.9250488e-7,18.038 6.9250488e-7,26.337 6.9250488e-7,34.636 6.7500007,41.386 15.049,41.386 l 22.576,0"
id="path21"
style="fill:#000000"
sodipodi:nodetypes="csssccsssccsssscccsssssc" /></svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

61
docs/static/loader.svg vendored Normal file
View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
role="img"
aria-labelledby="title desc"
xml:space="preserve"
enable-background="new 0 0 280 32.755"
height="52.672001"
width="52.672001"
version="1.1"
id="svg2"
inkscape:version="0.91 r13725"
sodipodi:docname="logo.square.white.svg"><sodipodi:namedview
pagecolor="#ff00ff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1536"
inkscape:window-height="801"
id="namedview14"
showgrid="false"
inkscape:zoom="2.0836233"
inkscape:cx="83.390493"
inkscape:cy="16.071144"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" /><rect
id="backgroundrect"
width="195.47368"
height="34.210526"
x="0"
y="18.461473"
class=""
style="fill:none;stroke:none" /><title
id="title"
lang="en-GB">BBC micro:bit</title><desc
id="desc"
lang="en-GB">BBC micro:bit logo</desc><metadata
id="metadata37"><rdf:rdf><cc:work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:work></rdf:rdf><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title>BBC micro:bit</dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs35" /><path
inkscape:connector-curvature="0"
class=""
d="m 37.363,29.377 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 M 15.052,23.3 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.0299993,-4.053 -9.0299993,-9.031 C 6.0180007,21.357 10.072,17.31 15.049,17.31 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 C 6.7500007,11.286 6.9250488e-7,18.038 6.9250488e-7,26.337 6.9250488e-7,34.636 6.7500007,41.386 15.049,41.386 l 22.576,0"
id="path21"
style="fill:#ffffff"
sodipodi:nodetypes="csssccsssccsssscccsssssc" /></svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
docs/static/mb/projects/inchworm.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@ -0,0 +1,74 @@
# Getting started
### Step 1
Place blocks in the workspace to scroll text on the screen.
```blocks
basic.showString("Hello!")
```
### Step 2
Click ``|Download|`` to transfer your code in your @boardname@!
### Step 3
Great, the text scrolled! But then it stopped.
Let's make it scroll when button **A** is pressed.
```block
input.onButtonPressed(Button.A, () => {
basic.showString("Hello!")
});
```
### Step 4
Click ``|Download|`` to transfer your code
and press **A** to scroll your text.
### Step 5
Place more blocks to display a smiley when button **B** is pressed.
Use the dropdown to find ``B``!
```block
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
# . . . #
. # # # .
`)
})
```
### Step 6
Drag more blocks to display a frownie when @boardname@ is shaken.
```block
input.onGesture(Gesture.Shake, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
. # # # .
# . . . #
`)
})
```
### Step 7
Drag more blocks to display a random number when pin ``P0`` is touched.
Hold your right thumb on the ``GND`` metal pin
at press the ``0`` pin with your right hand to trigger this event.
```block
input.onPinPressed(TouchPin.P0, () => {
basic.showNumber(Math.random(7))
})
```

View File

@ -1,14 +1,14 @@
{
"applicationName": "pxt-microbit-oss",
"dataFolderName": ".pxt-microbit-oss",
"darwinBundleIdentifier": "com.microsoft.pxtoss",
"nameShort": "PXT Microbit - OSS",
"nameLong": "PXT Microbit - OSS",
"darwinBundleIdentifier": "com.microsoft.pxtmicrobitoss",
"nameShort": "PXT microbit - OSS",
"nameLong": "PXT micro:bit - OSS",
"targetId": "pxt-microbit",
"win32AppId": "{{92db071a-6f58-4938-8c97-13c873f4da13}",
"win32AppUserModelId": "Microsoft.PXTMicrobitOss",
"win32DirName": "Microsoft PXT-Microbit - OSS",
"win32AppUserModelId": "Microsoft.PXTmicrobitOss",
"win32DirName": "Microsoft PXT microbit - OSS",
"win32MutexName": "pxtmicrobitoss",
"win32NameVersion": "Microsoft PXT-Microbit-OSS",
"win32RegValueName": "PXTMicrobitOss"
"win32NameVersion": "Microsoft PXT microbit-OSS",
"win32RegValueName": "PXTmicrobitOss"
}

9
electron/release.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": {
"0": {
"latest": "v0.7.29",
"banned": [],
"prompt": "v0.7.29"
}
}
}

View File

@ -1,62 +1,4 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="device_forever">
<statement name="HANDLER">
<block type="device_show_leds">
<field name="LED00">FALSE</field>
<field name="LED10">FALSE</field>
<field name="LED20">FALSE</field>
<field name="LED30">FALSE</field>
<field name="LED40">FALSE</field>
<field name="LED01">FALSE</field>
<field name="LED11">TRUE</field>
<field name="LED21">FALSE</field>
<field name="LED31">TRUE</field>
<field name="LED41">FALSE</field>
<field name="LED02">FALSE</field>
<field name="LED12">FALSE</field>
<field name="LED22">FALSE</field>
<field name="LED32">FALSE</field>
<field name="LED42">FALSE</field>
<field name="LED03">TRUE</field>
<field name="LED13">FALSE</field>
<field name="LED23">FALSE</field>
<field name="LED33">FALSE</field>
<field name="LED43">TRUE</field>
<field name="LED04">FALSE</field>
<field name="LED14">TRUE</field>
<field name="LED24">TRUE</field>
<field name="LED34">TRUE</field>
<field name="LED44">FALSE</field>
<next>
<block type="device_show_leds">
<field name="LED00">FALSE</field>
<field name="LED10">FALSE</field>
<field name="LED20">FALSE</field>
<field name="LED30">FALSE</field>
<field name="LED40">FALSE</field>
<field name="LED01">FALSE</field>
<field name="LED11">FALSE</field>
<field name="LED21">FALSE</field>
<field name="LED31">FALSE</field>
<field name="LED41">FALSE</field>
<field name="LED02">FALSE</field>
<field name="LED12">FALSE</field>
<field name="LED22">FALSE</field>
<field name="LED32">FALSE</field>
<field name="LED42">FALSE</field>
<field name="LED03">FALSE</field>
<field name="LED13">FALSE</field>
<field name="LED23">FALSE</field>
<field name="LED33">FALSE</field>
<field name="LED43">FALSE</field>
<field name="LED04">FALSE</field>
<field name="LED14">FALSE</field>
<field name="LED24">FALSE</field>
<field name="LED34">FALSE</field>
<field name="LED44">FALSE</field>
</block>
</next>
</block>
</statement>
</block>
<block type="pxt-on-start"></block>
<block type="device_forever"></block>
</xml>

View File

@ -1,16 +1 @@
basic.forever(() => {
basic.showLeds(`
. # . # .
# . # . #
# . . . #
. # . # .
. . # . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})

View File

@ -1,5 +1,14 @@
{
"bluetooth": "Support for additional Bluetooth services.",
"bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.",
"bluetooth.advertiseUid": "Advertise an Eddystone UID",
"bluetooth.advertiseUidBuffer": "Advertise an Eddystone UID",
"bluetooth.advertiseUidBuffer|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
"bluetooth.advertiseUidBuffer|param|nsAndInstance": "16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)",
"bluetooth.advertiseUidBuffer|param|power": "power level between 0 and 7, eg: 7",
"bluetooth.advertiseUid|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
"bluetooth.advertiseUid|param|instance": "4 last bytes of the instance uid",
"bluetooth.advertiseUid|param|ns": "4 last bytes of the namespace uid",
"bluetooth.advertiseUid|param|power": "power level between 0 and 7, eg: 7",
"bluetooth.advertiseUrl": "Advertise an Eddystone URL",
"bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
"bluetooth.advertiseUrl|param|power": "power level between 0 and 7, eg: 7",

View File

@ -1,4 +1,5 @@
{
"bluetooth.advertiseUid|block": "bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable",
"bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power|connectable %connectable",
"bluetooth.onBluetoothConnected|block": "on bluetooth connected",
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",

View File

@ -7,7 +7,7 @@ using namespace pxt;
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
//% color=#0082FB weight=96 icon="\uf294"
namespace bluetooth {
MicroBitUARTService *uart = NULL;
@ -137,6 +137,24 @@ namespace bluetooth {
uBit.bleManager.setTransmitPower(power);
}
/**
* Advertise an Eddystone UID
* @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)
* @param power power level between 0 and 7, eg: 7
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
*/
//% parts=bluetooth weight=12 advanced=true
void advertiseUidBuffer(Buffer nsAndInstance, int power, bool connectable) {
ManagedBuffer buf(nsAndInstance);
if (buf.length() != 16) return;
power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power));
int8_t level = CALIBRATED_POWERS[power];
uint8_t uidNs[10]; buf.readBytes(uidNs, 0, 10);
uint8_t uidInst[6]; buf.readBytes(uidInst, 10, 6);
uBit.bleManager.advertiseEddystoneUid((const char*)uidNs, (const char*)uidInst, level, connectable);
}
/**
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.

View File

@ -1,7 +1,7 @@
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
//% color=#0082FB weight=96 icon="\uf294"
namespace bluetooth {
/**
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
@ -46,4 +46,21 @@ namespace bluetooth {
// dummy implementation for simulator
return "???"
}
/**
* Advertise an Eddystone UID
* @param ns 4 last bytes of the namespace uid
* @param instance 4 last bytes of the instance uid
* @param power power level between 0 and 7, eg: 7
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
*/
//% blockId=eddystone_advertise_uid block="bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable"
//% parts=bluetooth weight=12 blockGap=8
//% help=bluetooth/advertise-uid blockExternalInputs=1
export function advertiseUid(ns: number, instance: number, power: number, connectable: boolean) {
const buf = pins.createBuffer(16);
buf.setNumber(NumberFormat.Int32BE, 6, ns);
buf.setNumber(NumberFormat.Int32BE, 12, instance);
bluetooth.advertiseUidBuffer(buf, power, connectable);
}
}

View File

@ -6,7 +6,8 @@
"enums.d.ts",
"shims.d.ts",
"bluetooth.ts",
"bluetooth.cpp"
"bluetooth.cpp",
"_locales/de/bluetooth-jsdoc-strings.json"
],
"public": true,
"dependencies": {
@ -30,14 +31,14 @@
"event_service": 1,
"device_info_service": 1,
"eddystone_url": 1,
"eddystone_uid": 0,
"eddystone_uid": 1,
"open": 0,
"pairing_mode": 1,
"whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
}
},
"gatt_table_size": "0x700"
},
"gatt_table_size": "0x700"
}
},
"userConfigs": [
{
@ -46,7 +47,7 @@
"microbit-dal": {
"bluetooth": {
"open": 1,
"pairing_mode": 0,
"pairing_mode": 0,
"whitelist": 0,
"security_level": null
}

View File

@ -4,7 +4,7 @@
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
//% color=#0082FB weight=96 icon="\uf294"
declare namespace bluetooth {
/**
@ -92,6 +92,15 @@ declare namespace bluetooth {
//% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl
function advertiseUrl(url: string, power: number, connectable: boolean): void;
/**
* Advertise an Eddystone UID
* @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)
* @param power power level between 0 and 7, eg: 7
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
*/
//% parts=bluetooth weight=12 advanced=true shim=bluetooth::advertiseUidBuffer
function advertiseUidBuffer(nsAndInstance: Buffer, power: number, connectable: boolean): void;
/**
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.

View File

@ -1,62 +1,3 @@
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="device_forever">
<statement name="HANDLER">
<block type="device_show_leds">
<field name="LED00">FALSE</field>
<field name="LED10">FALSE</field>
<field name="LED20">FALSE</field>
<field name="LED30">FALSE</field>
<field name="LED40">FALSE</field>
<field name="LED01">FALSE</field>
<field name="LED11">TRUE</field>
<field name="LED21">FALSE</field>
<field name="LED31">TRUE</field>
<field name="LED41">FALSE</field>
<field name="LED02">FALSE</field>
<field name="LED12">FALSE</field>
<field name="LED22">FALSE</field>
<field name="LED32">FALSE</field>
<field name="LED42">FALSE</field>
<field name="LED03">TRUE</field>
<field name="LED13">FALSE</field>
<field name="LED23">FALSE</field>
<field name="LED33">FALSE</field>
<field name="LED43">TRUE</field>
<field name="LED04">FALSE</field>
<field name="LED14">TRUE</field>
<field name="LED24">TRUE</field>
<field name="LED34">TRUE</field>
<field name="LED44">FALSE</field>
<next>
<block type="device_show_leds">
<field name="LED00">FALSE</field>
<field name="LED10">FALSE</field>
<field name="LED20">FALSE</field>
<field name="LED30">FALSE</field>
<field name="LED40">FALSE</field>
<field name="LED01">FALSE</field>
<field name="LED11">FALSE</field>
<field name="LED21">FALSE</field>
<field name="LED31">FALSE</field>
<field name="LED41">FALSE</field>
<field name="LED02">FALSE</field>
<field name="LED12">FALSE</field>
<field name="LED22">FALSE</field>
<field name="LED32">FALSE</field>
<field name="LED42">FALSE</field>
<field name="LED03">FALSE</field>
<field name="LED13">FALSE</field>
<field name="LED23">FALSE</field>
<field name="LED33">FALSE</field>
<field name="LED43">FALSE</field>
<field name="LED04">FALSE</field>
<field name="LED14">FALSE</field>
<field name="LED24">FALSE</field>
<field name="LED34">FALSE</field>
<field name="LED44">FALSE</field>
</block>
</next>
</block>
</statement>
</block>
<block type="pxt-on-start"></block>
</xml>

View File

@ -1,16 +1 @@
basic.forever(() => {
basic.showLeds(`
. # . # .
# . # . #
# . . . #
. # . # .
. . # . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})

View File

@ -231,8 +231,10 @@
"pins.spiWrite|param|value": "Data to be sent to the SPI slave",
"serial": "Reading and writing data over a serial connection.",
"serial.delimiters": "Returns the delimiter corresponding string",
"serial.onLineReceived": "Registers an event to be fired when a line has been received",
"serial.onDataReceived": "Registers an event to be fired when one of the delimiter is matched.",
"serial.onDataReceived|param|delimiters": "the characters to match received characters against.",
"serial.readLine": "Reads a line of text from the serial port.",
"serial.readString": "Reads the buffered received data as a string",
"serial.readUntil": "Reads a line of text from the serial port and returns the buffer when the delimiter is met.",
"serial.readUntil|param|delimiter": "text delimiter that separates each text chunk",
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",

View File

@ -33,6 +33,8 @@
"DisplayMode.Greyscale|block": "greyscale",
"EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).",
"EventCreationMode.CreateOnly": "MicroBitEvent is initialised, and no further processing takes place.",
"Gesture.EightG": "Raised when a 8G shock is detected",
"Gesture.EightG|block": "8g",
"Gesture.FreeFall": "Raised when the board is falling!",
"Gesture.FreeFall|block": "free fall",
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",
@ -169,7 +171,9 @@
"pins.spiWrite|block": "spi write %value",
"pins|block": "pins",
"serial.delimiters|block": "%del",
"serial.onDataReceived|block": "serial|on data received %delimiters=serial_delimiter_conv",
"serial.readLine|block": "serial|read line",
"serial.readString|block": "serial|read string",
"serial.readUntil|block": "serial|read until %delimiter=serial_delimiter_conv",
"serial.redirect|block": "serial|redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",

View File

@ -64,7 +64,6 @@
"control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4",
"game": "Eine Einzel-LED-Sprite-Spielumgebung",
"game.addLife": "Fügt Leben zum aktuellen Spielstand hinzu",
"game.addLife|param|lives": "TODO",
"game.addScore": "Fügt zum aktuellen Spielstand Punkte hinzu",
"game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1",
"game.createSprite": "Erzeugt einen neuen LED-Sprite, der nach rechts zeigt.",
@ -79,12 +78,9 @@
"game.levelUp": "Erhöht das Level und zeigt eine Nachricht an.",
"game.life": "Ruft das aktuelle Leben ab",
"game.removeLife": "Entfernt ein Leben",
"game.removeLife|param|life": "TODO",
"game.score": "Ruft den aktuellen Punktestand ab",
"game.setLife": "Setzt den aktuellen Wert der Leben",
"game.setLife|param|value": "TODO",
"game.setScore": "Setzt den aktuellen Wert des Spielstands",
"game.setScore|param|value": "TODO",
"game.showScore": "Zeigt den Spielstand auf dem Display.",
"game.startCountdown": "Startet einen Spiel-Countdown",
"game.startCountdown|param|ms": "Countdown-Dauer in Millisekunden, z.B.: 10000",
@ -94,38 +90,24 @@
"images.createImage": "Erstellt ein Bild, das auf den LED-Bildschirm passt.",
"input": "Ereignisse und Daten der Sensoren",
"input.acceleration": "Holt den Beschleunigungswert in Milli-Erdanziehung (wenn das Board flach mit dem Display nach oben liegt, X = 0, y = 0 und Z =-1024)",
"input.acceleration|param|dimension": "TODO",
"input.buttonIsPressed": "Erhalte den Sie den Tastenstatus (gepresst oder nicht) für ``A`` und ``B``.",
"input.calibrate": "Veraltet, Kompasskalibrierung erfolgt automatisch.",
"input.compassHeading": "Holt die aktuelle Kompassrichtung in Grad.",
"input.lightLevel": "Liest die Lichtintensität auf dem LED-Bildschirm im Bereich von ``0`` (dunkel) und `` 255`` (hell).",
"input.magneticForce": "Ruft den Wert der Magnetkraft in ``Mikro-Tesla`` (``µT``) ab. Diese Funktion wird im Simulator nicht unterstützt.",
"input.magneticForce|param|dimension": "TODO",
"input.onButtonPressed": "Tue etwas, wenn eine Taste (``A``, ``B`` oder ``A + B``) gedrückt wird",
"input.onButtonPressed|param|body": "TODO",
"input.onButtonPressed|param|button": "TODO",
"input.onGesture": "Mache etwas, wenn eine Geste gemacht wird (wie den mini zu schütteln).",
"input.onGesture|param|body": "TODO",
"input.onLogoDown": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach unten zeigt und das Board vertikal ausgerichtet ist.",
"input.onLogoDown|param|body": "TODO",
"input.onLogoUp": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach oben zeigt und das Board vertikal ausgerichtet ist.",
"input.onLogoUp|param|body": "TODO",
"input.onPinPressed": "Mache etwas, wenn eine Pin gehalten wird.",
"input.onPinPressed|param|body": "Code, der ausführt wird, wenn ein Pin gehalten wird",
"input.onPinPressed|param|name": "Der Pin, der gehalten werden muss",
"input.onPinReleased": "Mache etwas, wenn der Pin losgelassen wird.",
"input.onPinReleased|param|body": "Code, der ausgeführt werden soll, wenn der Pin losgelassen wird",
"input.onPinReleased|param|name": "Der Pin, der losgelassen werden muss",
"input.onScreenDown": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach unten zeigt.",
"input.onScreenDown|param|body": "TODO",
"input.onScreenUp": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach oben zeigt.",
"input.onScreenUp|param|body": "TODO",
"input.onShake": "Hängt Code an, der ausgeführt wird, wenn der mini geschüttelt wird.",
"input.onShake|param|body": "TODO",
"input.pinIsPressed": "Ruft den Pin-Zustand (gehalten oder nicht) ab. Die Erdung muss gehalten werden, um den Stromkreis zu schließen.",
"input.pinIsPressed|param|name": "Pin, der verwendet wird, um eine Berührung zu erkennen",
"input.rotation": "Die Neigung und Drehung des mini Drehung auf ``X-Achse``oder ``Y-Achse``, in Grad.",
"input.rotation|param|kind": "TODO",
"input.runningTime": "Ruft die Anzahl der Millisekunden auf, die seit dem Einschalten vergangen sind.",
"input.setAccelerometerRange": "Legt die Stichprobenbereich des Beschleunigungssensors in Schwerkraft fest.",
"input.setAccelerometerRange|param|range": "Ein Wert, der die maximale Stärke der gemessenen Beschleunigung beschreibt",
@ -134,19 +116,13 @@
"led.brightness": "Ruft die Helligkeit des Bildschirms ab, von 0 (aus) bis 255 (volle Helligkeit).",
"led.enable": "Schaltet das Display an und aus",
"led.fadeIn": "Blendet die Bildschirmanzeige ein.",
"led.fadeIn|param|ms": "TODO",
"led.fadeOut": "Blendet die Bildschirmhelligkeit aus.",
"led.fadeOut|param|ms": "TODO",
"led.plot": "Schalte die angegebene LED mit Hilfe von X- und Y-Koordinaten ein (X ist horizontal, Y ist vertikal). (0,0) ist die obere linke Ecke.",
"led.plotAll": "Schaltet alle LEDs an",
"led.plotBarGraph": "Zeigt ein vertikales Balkendiagramm an, basierend auf dem `Wert`und dem `Hoch`-Wert. Wenn `Hoch`0 ist, wird das Diagramm automatisch angepasst.",
"led.plotBarGraph|param|high": "maximalen Wert. Wenn dieser 0 ist, wird der Maximalwert automatisch angepasst, z.B.: 0",
"led.plotBarGraph|param|value": "aktueller Wert zum Darstellen",
"led.plot|param|x": "TODO",
"led.plot|param|y": "TODO",
"led.point": "Ruft den An/Aus-Status einer vorgegebenen LED mittels X-/Y-Koordinaten ab. (0,0) ist oben links.",
"led.point|param|x": "TODO",
"led.point|param|y": "TODO",
"led.screenshot": "Macht einen Screenshot vom LED-Bildschirm und gibt ein Bild aus.",
"led.setBrightness": "Lege die Helligkeit des Bildschirms fest, von 0 (aus) bis 255 (volle Helligkeit).",
"led.setBrightness|param|value": "Helligkeitswert, z.B.: 255, 127, 0",
@ -155,17 +131,12 @@
"led.stopAnimation": "Bricht die aktuelle Animation ab und löscht andere ausstehende Animationen.",
"led.toggle": "Schaltet ein bestimmtes Pixel ein",
"led.toggleAll": "Invertiert die aktuelle LED-Anzeige",
"led.toggle|param|x": "TODO",
"led.toggle|param|y": "TODO",
"led.unplot": "Schalte die angegebene LED mit x-und y-Koordinaten ab (X ist horizontal, y ist vertikal). (0,0) ist oben links.",
"led.unplot|param|x": "TODO",
"led.unplot|param|y": "TODO",
"music": "Generierung von von Musik durch Pin ``P0``.",
"music.beat": "Gibt die Dauer eines Taktes in Milli-Sekunden aus",
"music.changeTempoBy": "Ändere die Geschwindigkeit um den angegebenen Betrag",
"music.changeTempoBy|param|bpm": "Die Änderung in Schlägen pro Minute auf das Tempo, z.B.: 20",
"music.noteFrequency": "Ruft die Frequenz einer Note ab.",
"music.noteFrequency|param|name": "der Name der Notiz",
"music.playTone": "Spielt einen Ton für den angegebenen Zeitraum über Pin ``P0`` ab.",
"music.playTone|param|frequency": "Tonhöhe des abzuspielenden Tones in Hertz (Hz)",
"music.playTone|param|ms": "Tondauer in Millisekunden (ms)",
@ -181,21 +152,15 @@
"pins.analogPitch|param|frequency": "TODO",
"pins.analogPitch|param|ms": "TODO",
"pins.analogReadPin": "Lese den Anschlusswert als Analog aus, d. h. als einen Wert zwischen 0 und 1023.",
"pins.analogReadPin|param|name": "Pin, auf den geschrieben werden soll",
"pins.analogSetPeriod": "Stellt die Pulsweite Modulation (PWM) des Analogausganges auf den angegebenen Wert in ** Mikrosekunden ** oder `1/1000` Millisekunden ein.\nWenn dieser Pin nicht als einen Analogausgang (mit `analog write pin`) konfiguriert ist, hat der Vorgang keine Auswirkungen.",
"pins.analogSetPeriod|param|micros": "Zeit in Mikrosekunden. z.B.: 20000",
"pins.analogSetPeriod|param|name": "analoger Pin, der zeitlich festgelegt werden soll",
"pins.analogSetPitchPin": "Setzt den genutzten Pin, wenn `pins->analog pitch`angewendet wird.",
"pins.analogSetPitchPin|param|name": "TODO",
"pins.analogWritePin": "Legt den Wert des Verbinders auf analog fest. Der Wert muss zwischen 0 und 1023 liegen.",
"pins.analogWritePin|param|name": "PIN-Name, auf den geschrieben werden soll",
"pins.analogWritePin|param|value": "Wert, der auf den Pin geschrieben werden soll, zwischen ``0`` und ``1023`` z.B.: 1023,0",
"pins.createBuffer": "Erstellt einen Null-initialisierten Zwischenspeicher.",
"pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher",
"pins.digitalReadPin": "Lese den angegebene Pin oder Verbinder als 0 oder 1",
"pins.digitalReadPin|param|name": "Pin, aus dem gelesen werden soll",
"pins.digitalWritePin": "Setzt einen Pin- oder Verbinder-Wert auf 0 oder 1.",
"pins.digitalWritePin|param|name": "Pin, auf den geschrieben werden soll",
"pins.digitalWritePin|param|value": "Wert, der auf dem Pin 1 gesetzt werden soll, z.B. 0",
"pins.i2cReadBuffer": "Lese `Größe`bytes aus einer 7-bit I2C-Adresse.",
"pins.i2cReadNumber": "Lese eine Nummer aus einer 7-bit I2C-Adresse.",
@ -210,17 +175,12 @@
"pins.onPulsed": "Stellt diesen Pin als einen Digitaleingang ein und generiert Ereignisse, deren Zeitstempel die Dauer darstellt, in der der Pin entweder ``hoch``oder ``niedrig``war.",
"pins.pulseDuration": "Ruft die Dauer des letzten Impulses in Mikrosendungen ab. Diese Funktion soll von einem `onPulsed`-Handler aufgerufen werden.",
"pins.pulseIn": "Gibt die Dauer eines Pulses in Mikrosekunden an",
"pins.pulseIn|param|name": "der Pin, der den Puls misst",
"pins.pulseIn|param|value": "der Wert des Pulses (Standard hoch)",
"pins.servoSetPulse": "Konfiguriert diesen IO-Pin als einen analogen/PWM-Ausgang, stellt den Zeitraum auf 20 ms ein und setzt die Pulsweite fest, basieren auf dem angegeben Wert **Mikrosekunden** oder `1/1000`Millisekunden.",
"pins.servoSetPulse|param|micros": "Impulsdauer in Mikrosekunden, z.B.: 1500",
"pins.servoSetPulse|param|name": "PIN-Name",
"pins.servoWritePin": "Schreibt einen Wert in den Servo, der die Welle entsprechend kontroliert. Auf einem Standard-Servo wird so der Winkel der Welle (in Grad) eingestellt, sodass sich die Welle entsprechend anpasst. Auf einem kontinuierlich drehenden Servo wird dadurch die Geschwindigkeit des Servos festgelegt, wobei ``0``die volle Geschwindigkeit in eine Richtung darstellt, ``180``die volle Geschwindigkeit in die andere, und ein Wert von ``90`` einen Stillstand erzeugt.",
"pins.servoWritePin|param|name": "Pin, auf den geschrieben werden soll",
"pins.servoWritePin|param|value": "Winkel oder Rotationsbeschleunigung, z.B.: 180,90,0",
"pins.setPull": "Stellt die Anziehungskraft des Pins ein.",
"pins.setPull|param|name": "Pin, auf dem der Pull-Modus aktiviert wird",
"pins.setPull|param|pull": "eine der mbed-Pull-Konfigurationen: PullUp, PullDown, PullNone",
"pins.sizeOf": "Ruft die Bytegröße im spezifierten Nummernformat ab.",
"pins.spiWrite": "Schreibe in den SPI-Slave und gebe die Antwort aus",
"pins.spiWrite|param|value": "Daten, die an den SPI-Slave geschickt werden sollen",
@ -231,8 +191,6 @@
"serial.readUntil": "Liest aus eine Textzeile aus dem seriellen Anschluss und gibt den Puffer aus, wenn die Begrenzung erreicht wurde.",
"serial.readUntil|param|delimiter": "Text-Begrenzung, die die Textblöcke voneinander trennt",
"serial.redirect": "Konfiguriert dynamisch die serielle Instanz, damit sie andere Pins als USBTX und USBRX benutzt.",
"serial.redirect|param|rx": "der neue Empfangs-Pin",
"serial.redirect|param|tx": "Der neue Übertragungs-Pin",
"serial.writeLine": "Gibt eine Zeile des Textes an die serielle",
"serial.writeNumber": "Gibt einen numerischen Wert an die serielle",
"serial.writeString": "Sendet ein Stück Text über serielle Verbindung.",

View File

@ -7,12 +7,71 @@
"AcceleratorRange.OneG|block": "1g",
"AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g",
"AcceleratorRange.TwoG|block": "2g",
"BaudRate.BaudRate115200|block": "11520",
"BaudRate.BaudRate9600|block": "9600",
"BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4",
"BeatFraction.Sixteenth|block": "1/16",
"BeatFraction.Whole|block": "1",
"Button.AB|block": "A+B",
"Delimiters.Dollar|block": "$",
"Delimiters.Hash|block": "#",
"Delimiters.NewLine|block": "Neue Zeile",
"Dimension.Strength|block": "Stärke",
"Dimension.X|block": "x",
"Dimension.Y|block": "y",
"Dimension.Z|block": "z",
"Direction.Left|block": "links",
"Direction.Right|block": "rechts",
"DisplayMode.BackAndWhite|block": "Schwarz-Weiß",
"DisplayMode.Greyscale|block": "Graustufen",
"EventCreationMode.CreateAndFire": "Calliope mini-Event wurde initialisiert, seine Event-Handler werden unverzüglich ausgeführt (nicht geeignet für die Nutzung bei Unterbrechungen!).",
"EventCreationMode.CreateOnly": "Calliope mini-Event wurde initialisiert, es wird keine weitere Verarbeitung vorgenommen.",
"Gesture.EightG|block": "8g",
"Gesture.FreeFall": "Wird ausgeführt, wenn das Board fällt!",
"Gesture.FreeFall|block": "freier Fall",
"Gesture.LogoDown": "Wird ausgeführt, wenn das Logo nach unten zeigt und das Display vertikal ist.",
"Gesture.LogoDown|block": "Logo nach unten",
"Gesture.LogoUp": "Wird ausgeführt, wenn das Logo nach oben zeigt und das Display vertikal ist.",
"Gesture.LogoUp|block": "Logo oben",
"Gesture.ScreenDown": "Wird ausgeführt, wenn das Display nach oben zeigt und das Board horizontal ist.",
"Gesture.ScreenDown|block": "Display nach unten",
"Gesture.ScreenUp": "Wird ausgeführt, wenn das Display nach unten zeigt und das Board horizontal ist.",
"Gesture.ScreenUp|block": "Display nach oben",
"Gesture.Shake": "Wird erhöht, wenn geschüttelt",
"Gesture.Shake|block": "geschüttelt",
"Gesture.SixG": "Wird ausgeführt, ein 6g starker Stoß erkannt wird",
"Gesture.SixG|block": "6g",
"Gesture.ThreeG": "Wird ausgeführt, ein 3g starker Stoß erkannt wird",
"Gesture.ThreeG|block": "3g",
"Gesture.TiltLeft": "Wird ausgeführt, wenn das Display nach links zeigt",
"Gesture.TiltLeft|block": "nach links neigen",
"Gesture.TiltRight": "Wird ausgeführt, wenn das Display nach rechts zeigt",
"Gesture.TiltRight|block": "nach rechts neigen",
"LedSpriteProperty.Blink|block": "blinken",
"LedSpriteProperty.Brightness|block": "Helligkeit",
"LedSpriteProperty.Direction|block": "Richtung",
"LedSpriteProperty.X|block": "x",
"LedSpriteProperty.Y|block": "y",
"Math.randomBoolean|block": "wähle zufälligen Wahr- oder Falsch-Wert",
"Math|block": "Mathematik",
"Note.CSharp3|block": "C#3",
"Note.CSharp4|block": "C#4",
"Note.CSharp5|block": "C#5",
"Note.CSharp|block": "C#",
"Note.FSharp3|block": "F#3",
"Note.FSharp4|block": "F#4",
"Note.FSharp5|block": "F#5",
"Note.FSharp|block": "F#",
"Note.GSharp3|block": "G#3",
"Note.GSharp4|block": "G#4",
"Note.GSharp5|block": "G#5",
"Note.GSharp|block": "G#",
"PinPullMode.PullDown|block": "nach unten",
"PinPullMode.PullUp|block": "nach oben",
"Rotation.Pitch|block": "Winkel",
"Rotation.Roll|block": "rollen",
"String.charAt|block": "Zeichen an Position %pos aus|%this",
"String.compare|block": "vergleiche %this| mit %that",
"String.concat|block": "hänge %this| mit %other aneinander",
@ -23,10 +82,10 @@
"String|block": "Zeichenfolge",
"basic.clearScreen|block": "Bildschirminhalt löschen",
"basic.forever|block": "dauerhaft",
"basic.pause|block": "Pausiere (ms) %pause",
"basic.pause|block": "pausiere (ms) %pause",
"basic.showLeds|block": "zeige LEDs",
"basic.showNumber|block": "zeige|Nummer %number",
"basic.showString|block": "Zeige|Zeichenfolge %text",
"basic.showString|block": "zeige|Zeichenfolge %text",
"basic|block": "Grundlagen",
"control.deviceName|block": "Gerätename",
"control.deviceSerialNumber|block": "Seriennnummer",
@ -56,7 +115,6 @@
"input.magneticForce|block": "Magnetkraft (µT) |%NAME",
"input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt",
"input.onGesture|block": "wenn |%NAME",
"input.onPinPressed|block": "wenn Pin %NAME|gedrückt",
"input.onPinReleased|block": "wenn Pin %NAME|losgelassen",
"input.pinIsPressed|block": "Pin %NAME|ist gedrückt",
"input.rotation|block": "Rotation (°)|%NAME",
@ -71,7 +129,7 @@
"led.setBrightness|block": "Setze Helligkeit auf %value",
"led.stopAnimation|block": "Halte Animation an",
"led.toggle|block": "Schalte zwischen|x %x|y %y",
"led.unplot|block": "Unplot|x %x|y %y",
"led.unplot|block": "schalte Pixel|x %x|y %y aus",
"led|block": "LED",
"music.beat|block": "%fraction|Takt",
"music.changeTempoBy|block": "ändere die Geschwindigkeit (bpm)|%value",

View File

@ -21,59 +21,40 @@
"basic.showString|param|text": "le texte à faire défiler sur lécran, par exemple : « Bonjour ! »",
"control.inBackground": "Planifie le code qui sexécute en arrière-plan.",
"control.reset": "Réinitialise le micro:bit de BBC.",
"control.waitMicros": "Bloque la fibre courante pour le nombre de microsecondes donné",
"control.waitMicros|param|micros": "nombre de microsecondes à attendre. par ex. : 4",
"game": "Un moteur de jeu avec une unique LED",
"game.addLife|param|lives": "TODO",
"game.addScore": "Ajoute des points au score actuel",
"game.addScore|param|points": "nombre de points à changer, par ex. : 1",
"game.gameOver": "Affiche un animation de fin de jeu.",
"game.removeLife|param|life": "TODO",
"game.score": "Obtient le score actuel",
"game.setLife|param|value": "TODO",
"game.setScore": "Définit la valeur du score actuel",
"game.setScore|param|value": "TODO",
"game.startCountdown": "Démarre un compte à rebours de jeu",
"game.startCountdown|param|ms": "durée du compte à rebours en millisecondes, par ex. : 10000",
"images": "Création, manipulation et affichage dimages LED.",
"images.createBigImage": "Crée une image à partir de 2 images.",
"images.createImage": "Crée une image qui sadapte aux dimensions de lécran LED.",
"input": "Événements et des données provenant de capteurs",
"input.acceleration|param|dimension": "TODO",
"input.acceleration": "Donne la valeur de l'accélération en milli-g (quand la carte est à plat avec l'écran vers le haut, x=0, y=0 et z=-1024)",
"input.buttonIsPressed": "Donne l'état du bouton (appuyé ou non) pour ``A`` et ``B``.",
"input.calibrate": "Obsolète, le calibrage de la boussole est automatique.",
"input.compassHeading": "Obtient la direction actuelle du compas en degrés.",
"input.magneticForce|param|dimension": "TODO",
"input.onButtonPressed|param|body": "TODO",
"input.onButtonPressed|param|button": "TODO",
"input.onGesture|param|body": "TODO",
"input.onLogoDown|param|body": "TODO",
"input.onLogoUp|param|body": "TODO",
"input.lightLevel": "Lit le niveau de lumière appliqué à l'écran LED de ``0`` (sombre) à ``255`` lumineux.",
"input.magneticForce": "Obtenir la valeur de la force magnétique en ``micro-Teslas`` (``µT``). Cette fonction nest pas supportée par le simulateur.",
"input.onButtonPressed": "Faire quelque chose quand un bouton (``A``, ``B`` ou les deux ``A+B``) est appuyé",
"input.onGesture": "Faire quelque chose lorsque lorsquun geste est fait (par exemple secouer le micro:bit).",
"input.onPinPressed": "Faire quelque chose lorsque vous appuyez sur une broche.",
"input.onPinPressed|param|body": "code à exécuter lorsque la broche est enfoncée",
"input.onPinPressed|param|name": "la broche qui doit être pressée",
"input.onPinReleased": "Faire quelque chose quand une broche est relâchée.",
"input.onPinReleased|param|body": "le code à exécuter lorsque la broche est relâchée",
"input.onPinReleased|param|name": "la broche qui doit être relâchée",
"input.onScreenDown|param|body": "TODO",
"input.onScreenUp|param|body": "TODO",
"input.onShake|param|body": "TODO",
"input.pinIsPressed|param|name": "broche utilisée pour détecter le contact",
"input.rotation|param|kind": "TODO",
"input.pinIsPressed": "Donne létat de la broche (pressée ou non). Nécessite de tenir la masse pour fermer le circuit.",
"input.runningTime": "Donne le nombre de millisecondes écoulées depuis la mise en route.",
"input.temperature": "Obtient la température en degrés Celsius (°C).",
"led": "Contrôle de lécran LED.",
"led.enable": "Active ou désactive laffichage",
"led.fadeIn|param|ms": "TODO",
"led.fadeOut|param|ms": "TODO",
"led.plotAll": "Allume toutes les LEDS",
"led.plotBarGraph|param|value": "valeur actuelle à tracer",
"led.plot|param|x": "TODO",
"led.plot|param|y": "TODO",
"led.point|param|x": "TODO",
"led.point|param|y": "TODO",
"led.setBrightness|param|value": "valeur de la luminosité, par ex. : 255, 127, 0",
"led.toggle|param|x": "TODO",
"led.toggle|param|y": "TODO",
"led.unplot|param|x": "TODO",
"led.unplot|param|y": "TODO",
"music.rest": "Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
"pins.analogPitch|param|frequency": "TODO",
"pins.analogPitch|param|ms": "TODO",

View File

@ -30,7 +30,6 @@
"input.magneticForce|block": "force magnétique (µT) |%NAME",
"input.onButtonPressed|block": "lorsque le button|%NAME|est pressé",
"input.onGesture|block": "lorsque|%NAME",
"input.onPinPressed|block": "lorsque le pin %NAME|est pressé",
"input.onPinReleased|block": "lorsque la broche %NAME|est lachée",
"input.pinIsPressed|block": "broche %NAME| est pressée",
"input.rotation|block": "rotation (°)|%NAME",

View File

@ -0,0 +1,82 @@
{
"AcceleratorRange.EightG": "8Gまでの加速度を測ります。",
"AcceleratorRange.EightG|block": "8G",
"AcceleratorRange.FourG": "4Gまでの加速度を測ります。",
"AcceleratorRange.FourG|block": "4G",
"AcceleratorRange.OneG": "1Gまでの加速度を測ります。",
"AcceleratorRange.OneG|block": "1G",
"AcceleratorRange.TwoG": "2Gまでの加速度を測ります。",
"AcceleratorRange.TwoG|block": "2G",
"BaudRate.BaudRate115200|block": "115200",
"BaudRate.BaudRate9600|block": "9600",
"BeatFraction.Breve|block": "4",
"BeatFraction.Double|block": "2",
"BeatFraction.Eighth|block": "1/8",
"BeatFraction.Half|block": "1/2",
"BeatFraction.Quarter|block": "1/4",
"BeatFraction.Sixteenth|block": "1/16",
"BeatFraction.Whole|block": "1",
"Button.AB|block": "A+B",
"Delimiters.Dollar|block": "$",
"Delimiters.Hash|block": "#",
"Delimiters.NewLine|block": "改行",
"Gesture.EightG": "8Gの衝撃があったときに発生します。",
"Gesture.EightG|block": "8G",
"Gesture.FreeFall": "ボードを落としたときに発生します。",
"Gesture.FreeFall|block": "落とした",
"Gesture.LogoDown": "画面が垂直で、ロゴの位置が下になったときに発生します。",
"Gesture.LogoDown|block": "ロゴが下になった",
"Gesture.LogoUp": "画面が垂直で、ロゴの位置が上になったときに発生します。",
"Gesture.LogoUp|block": "ロゴが上になった",
"Gesture.ScreenDown": "ボードが水平で、画面が下向きになったときに発生します。",
"Gesture.ScreenDown|block": "画面が下になった",
"Gesture.ScreenUp": "ボードが水平で、画面が上向きになったときに発生します。",
"Gesture.ScreenUp|block": "画面が上になった",
"Gesture.Shake": "ボードがゆさぶられたときに発生します。",
"Gesture.Shake|block": "ゆさぶられた",
"Gesture.SixG": "6Gの衝撃があったときに発生します。",
"Gesture.SixG|block": "6G",
"Gesture.ThreeG": "3Gの衝撃があったときに発生します。",
"Gesture.ThreeG|block": "3G",
"Gesture.TiltLeft": "画面を左に傾けたときに発生します。",
"Gesture.TiltLeft|block": "左に傾けた",
"Gesture.TiltRight": "画面を右に傾けたときに発生します。",
"Gesture.TiltRight|block": "右に傾けた",
"LedSpriteProperty.Brightness|block": "明るさ",
"Math.randomBoolean|block": "真または偽をランダムに選ぶ",
"Math|block": "計算",
"String.fromCharCode|block": "文字コード %code|の文字",
"basic.clearScreen|block": "表示を消す",
"basic.forever|block": "ずっと",
"basic.pause|block": "ひと休み(ミリ秒) %pause",
"basic.showLeds|block": "LEDに表示",
"basic.showNumber|block": "数を表示|%number",
"basic.showString|block": "文字列を表示|%text",
"basic|block": "基本",
"control.inBackground|block": "バックグラウンドで実行する",
"control.reset|block": "リセット",
"control|block": "制御",
"game.gameOver|block": "ゲームオーバー",
"game|block": "ゲーム",
"images.createBigImage|block": "大きな画像を作成",
"images.createImage|block": "画像を作成",
"images|block": "画像",
"input.acceleration|block": "加速度ミリG|%NAME",
"input.onPinPressed|block": "端子 %name|がタッチされたとき",
"input.onPinReleased|block": "端子 %NAME|がタッチされなくなったとき",
"input.pinIsPressed|block": "端子 %NAME|がタッチされている",
"input.rotation|block": "傾斜(°)|%NAME",
"input.runningTime|block": "稼働時間(ミリ秒)",
"input.setAccelerometerRange|block": "加速度センサの計測範囲を設定する %range",
"input.temperature|block": "温度(℃)",
"led.brightness|block": "明るさ",
"led.enable|block": "表示をオンまたはオフにする %on",
"led.plot|block": "点灯|x %x|y %y",
"led|block": "LED",
"music.setTempo|block": "テンポを設定するbpm|%value",
"music.tempo|block": "テンポbpm",
"music|block": "音楽",
"{id:category}Basic": "基本",
"{id:category}Led": "LED",
"{id:category}Math": "計算"
}

View File

@ -0,0 +1,9 @@
{
"Math.abs": "Gir absoluttverdien av et tall (størrelsen av tallet, uavhengig av om det er positivt eller negativt).\nFor eksempel er absoluttverdien av -5 og absoluttverdien av 5 begge lik 5.",
"Math.abs|param|x": "Et tall eller matematisk uttrykk som vi ønsker absoluttverdien av.",
"Math.max": "Gir verdien til det største av to tall eller matematiske uttrykk.",
"Math.randomBoolean": "Gir en tilfeldig logisk verdi, \"sann\" eller \"usann\".",
"String.fromCharCode": "Lag en tekst som består av tegnet med den angitte ASCII-koden.",
"basic": "Blokker for grunnleggende mikro:bit-funksjonalitet.",
"basic.clearScreen": "Slå av alle lysene på skjermen"
}

View File

@ -0,0 +1,3 @@
{
"serial|block": "føljetong"
}

View File

@ -0,0 +1,5 @@
{
"Math.abs": "Returnerar absolutbeloppet av ett tal (värdet utan hänsyn till huruvida det är positivt eller negativt). \nTill exempel är absolutbeloppet av -5 detsamma som absolutbeloppet av 5.",
"Math.max": "Returnerar det större av två givna numeriska uttryck.",
"Math.min": "Returnerar det mindre av två givna numeriska uttryck."
}

View File

@ -4,7 +4,7 @@
/**
* Provides access to basic micro:bit functionality.
*/
//% color=#0078D7 weight=100
//% color=#0078D7 weight=100 icon="\uf00a"
namespace basic {
/**
@ -13,7 +13,7 @@ namespace basic {
*/
//% help=basic/show-number
//% weight=96
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
//% blockId=device_show_number block="show|number %number" blockGap=8
//% async
//% parts="ledmatrix"
void showNumber(int value, int interval = 150) {
@ -50,7 +50,7 @@ namespace basic {
*/
//% help=basic/show-string
//% weight=87 blockGap=8
//% block="show|string %text" icon="\uf031"
//% block="show|string %text"
//% async
//% blockId=device_print_message
//% parts="ledmatrix"
@ -73,7 +73,7 @@ namespace basic {
* Turn off all LEDs
*/
//% help=basic/clear-screen weight=79
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
//% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix"
void clearScreen() {
uBit.display.image.clear();
@ -112,7 +112,7 @@ namespace basic {
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
//% help=basic/forever weight=55 blockGap=8
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1
//% blockId=device_forever block="forever" icon="\uf01e"
void forever(Action a) {
if (a != 0) {

View File

@ -121,7 +121,7 @@ namespace control {
/**
* Schedules code that run in the background.
*/
//% help=control/in-background
//% help=control/in-background blockAllowMultiple=1
//% blockId="control_in_background" block="run in background" blockGap=8
void inBackground(Action a) {
runInBackground(a);

View File

@ -1,7 +1,7 @@
/**
* Runtime and event utilities.
*/
//% weight=1 color="#333333"
//% weight=1 color="#333333" icon="\uf233"
//% advanced=true
namespace control {
@ -31,7 +31,7 @@ namespace control {
/**
* If the condition is false, display msg on serial console, and panic with code 098.
*/
export function assert(condition: boolean, msg ?: string) {
export function assert(condition: boolean, msg?: string) {
if (!condition) {
console.log("ASSERTION FAILED")
if (msg != null) {

View File

@ -21,7 +21,12 @@ namespace String_ {
//%
int compare(StringData *s, StringData *that) {
return strcmp(s->data, that->data);
int compareResult = strcmp(s->data, that->data);
if (compareResult < 0)
return -1;
else if (compareResult > 0)
return 1;
return 0;
}
//%
@ -76,7 +81,7 @@ namespace Boolean_ {
}
//%
bool bang(bool v) { return !v; }
bool bang(int v) { return v == 0; }
}
namespace Number_ {
@ -153,13 +158,19 @@ namespace Array_ {
//%
int length(RefCollection *c) { return c->length(); }
//%
void setLength(RefCollection *c, int newLength) { c->setLength(newLength); }
//%
void push(RefCollection *c, uint32_t x) { c->push(x); }
//%
uint32_t pop(RefCollection *c) { return c->pop(); }
//%
uint32_t getAt(RefCollection *c, int x) { return c->getAt(x); }
//%
void removeAt(RefCollection *c, int x) { c->removeAt(x); }
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
//%
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
uint32_t removeAt(RefCollection *c, int x) { return c->removeAt(x); }
//%
void insertAt(RefCollection *c, int x, uint32_t value) { c->insertAt(x, value); }
//%
int indexOf(RefCollection *c, uint32_t x, int start) { return c->indexOf(x, start); }
//%

View File

@ -115,6 +115,11 @@ declare namespace basic {
*/
//% block="6g"
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_6G
/**
* Raised when a 8G shock is detected
*/
//% block="8g"
EightG = 10, // MICROBIT_ACCELEROMETER_EVT_8G
}
declare namespace input {
}

View File

@ -21,7 +21,7 @@ enum LedSpriteProperty {
/**
* A single-LED sprite game engine
*/
//% color=#008272 weight=32
//% color=#008272 weight=32 icon="\uf11b"
//% advanced=true
namespace game {
let _score: number = 0;

View File

@ -3,7 +3,7 @@
/**
* Creation, manipulation and display of LED images.
*/
//% color=#5C2D91 weight=31
//% color=#5C2D91 weight=31 icon="\uf03e"
//% advanced=true
namespace images {
/**

View File

@ -104,10 +104,15 @@ enum class Gesture {
* Raised when a 6G shock is detected
*/
//% block="6g"
SixG = MICROBIT_ACCELEROMETER_EVT_6G
SixG = MICROBIT_ACCELEROMETER_EVT_6G,
/**
* Raised when a 8G shock is detected
*/
//% block="8g"
EightG = MICROBIT_ACCELEROMETER_EVT_8G
};
//% color=300 weight=99
//% color=300 weight=99 icon="\uf192"
namespace input {
/**
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
@ -115,7 +120,7 @@ namespace input {
* @param body code to run when event is raised
*/
//% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair"
void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
@ -127,14 +132,15 @@ namespace input {
* @param body code to run when gesture is raised
*/
//% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
//% blockId=device_gesture_event block="on |%NAME"
//% parts="accelerometer"
void onGesture(Gesture gesture, Action body) {
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
int gi = (int)gesture;
if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
uBit.accelerometer.setRange(4);
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
else if ((gi == MICROBIT_ACCELEROMETER_EVT_6G || gi == MICROBIT_ACCELEROMETER_EVT_8G) && uBit.accelerometer.getRange() < 6)
uBit.accelerometer.setRange(8);
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
registerWithDal(MICROBIT_ID_GESTURE, gi, body);
}
/**
@ -143,7 +149,7 @@ namespace input {
* @param body the code to run when the pin is pressed
*/
//% help=input/on-pin-pressed weight=83
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094"
//% blockId=device_pin_event block="on pin %name|pressed"
void onPinPressed(TouchPin name, Action body) {
auto pin = getPin((int)name);
if (!pin) return;
@ -159,7 +165,7 @@ namespace input {
* @param body the code to run when the pin is released
*/
//% 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"
//% advanced=true
void onPinReleased(TouchPin name, Action body) {
auto pin = getPin((int)name);
@ -194,7 +200,7 @@ namespace input {
* @param name pin used to detect the touch, eg: TouchPin.P0
*/
//% 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"
//% blockGap=8
bool pinIsPressed(TouchPin name) {
auto pin = getPin((int)name);
@ -212,7 +218,7 @@ namespace input {
* 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"
//% help=input/acceleration weight=58
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
//% parts="accelerometer"
int acceleration(Dimension dimension) {
@ -229,7 +235,7 @@ namespace input {
* 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"
//% blockId=device_get_light_level block="light level" blockGap=8
//% parts="ledmatrix"
int lightLevel() {
return uBit.display.readLightLevel();
@ -239,7 +245,7 @@ namespace input {
* Get the current compass heading in degrees.
*/
//% help=input/compass-heading
//% weight=56 icon="\uf14e"
//% weight=56
//% blockId=device_heading block="compass heading (°)" blockGap=8
//% parts="compass"
int compassHeading() {
@ -250,7 +256,7 @@ namespace input {
/**
* Gets the temperature in Celsius degrees (°C).
*/
//% weight=55 icon="\uf06d"
//% weight=55
//% help=input/temperature
//% blockId=device_temperature block="temperature (°C)" blockGap=8
//% parts="thermometer"
@ -263,7 +269,7 @@ namespace input {
* @param kind TODO
*/
//% 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
//% parts="accelerometer" advanced=true
int rotation(Rotation kind) {
switch (kind) {
@ -278,7 +284,7 @@ namespace input {
* @param dimension TODO
*/
//% 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
//% parts="compass"
//% advanced=true
int magneticForce(Dimension dimension) {
@ -298,7 +304,7 @@ namespace input {
* Gets the number of milliseconds elapsed since power on.
*/
//% 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)"
//% advanced=true
int runningTime() {
return system_timer_current_time();
@ -315,7 +321,7 @@ namespace input {
* @param range a value describe the maximum strengh of acceleration measured
*/
//% 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"
//% weight=5
//% parts="accelerometer"
//% advanced=true

View File

@ -1,7 +1,7 @@
/**
* Events and data from sensors
*/
//% color=#B4009E weight=99
//% color=#B4009E weight=99 icon="\uf192"
namespace input {
/**
* Attaches code to run when the screen is facing up.

View File

@ -8,7 +8,7 @@ enum class DisplayMode_ {
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
};
//% color=3 weight=35
//% color=3 weight=35 icon="\uf205"
namespace led {
/**
@ -17,7 +17,7 @@ namespace led {
* @param y TODO
*/
//% 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" blockGap=8
//% parts="ledmatrix"
void plot(int x, int y) {
uBit.display.image.setPixelValue(x, y, 1);
@ -29,7 +29,7 @@ namespace led {
* @param y TODO
*/
//% 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" blockGap=8
//% parts="ledmatrix"
void unplot(int x, int y) {
uBit.display.image.setPixelValue(x, y, 0);
@ -41,7 +41,7 @@ namespace led {
* @param y TODO
*/
//% help=led/point weight=76
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
//% blockId=device_point block="point|x %x|y %y"
//% parts="ledmatrix"
bool point(int x, int y) {
int pix = uBit.display.image.getPixelValue(x, y);
@ -52,7 +52,7 @@ namespace led {
* Get the screen brightness from 0 (off) to 255 (full bright).
*/
//% help=led/brightness weight=60
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
//% blockId=device_get_brightness block="brightness" blockGap=8
//% parts="ledmatrix"
//% advanced=true
int brightness() {
@ -64,7 +64,7 @@ namespace led {
* @param value the brightness value, eg:255, 127, 0
*/
//% help=led/set-brightness weight=59
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
//% blockId=device_set_brightness block="set brightness %value"
//% parts="ledmatrix"
//% advanced=true
void setBrightness(int value) {
@ -75,7 +75,7 @@ namespace led {
* Cancels the current animation and clears other pending animations.
*/
//% weight=50 help=led/stop-animation
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
//% blockId=device_stop_animation block="stop animation"
//% parts="ledmatrix"
//% advanced=true
void stopAnimation() {
@ -95,7 +95,7 @@ namespace led {
/**
* Turns on or off the display
*/
//% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
//% help=led/enable blockId=device_led_enable block="led enable %on"
//% advanced=true parts="ledmatrix"
void enable(bool on) {
if (on) uBit.display.enable();

View File

@ -1,7 +1,7 @@
/**
* Control of the LED screen.
*/
//% color=#5C2D91 weight=97
//% color=#5C2D91 weight=97 icon="\uf205"
namespace led {
// what's the current high value

View File

@ -129,7 +129,7 @@ enum BeatFraction {
/**
* Generation of music tones through pin ``P0``.
*/
//% color=#D83B01 weight=98
//% color=#D83B01 weight=98 icon="\uf025"
namespace music {
let beatsPerMinute: number = 120;
@ -139,7 +139,7 @@ namespace music {
* @param ms tone duration in milliseconds (ms)
*/
//% help=music/play-tone weight=90
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" blockGap=8
//% parts="headphone"
export function playTone(frequency: number, ms: number): void {
pins.analogPitch(frequency, ms);
@ -150,7 +150,7 @@ namespace music {
* @param frequency pitch of the tone to play in Hertz (Hz)
*/
//% help=music/ring-tone weight=80
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" blockGap=8
//% parts="headphone"
export function ringTone(frequency: number): void {
pins.analogPitch(frequency, 0);

View File

@ -1,7 +1,7 @@
/**
* Control currents in Pins for analog/digital signals, servos, i2c, ...
*/
//% color=#A80000 weight=30
//% color=#A80000 weight=30 icon="\uf140"
//% advanced=true
namespace pins {
/**

View File

@ -141,63 +141,327 @@ namespace pxt {
printf("RefRecord %p r=%d size=%d bytes\n", r, r->refcnt, r->getVTable()->numbytes);
}
void RefCollection::push(uint32_t x) {
if (isRef()) incr(x);
data.push_back(x);
}
uint32_t RefCollection::getAt(int x) {
if (in_range(x)) {
uint32_t tmp = data.at(x);
if (isRef()) incr(tmp);
return tmp;
}
else {
error(ERR_OUT_OF_BOUNDS);
return 0;
uint32_t Segment::get(uint32_t i)
{
#ifdef DEBUG_BUILD
printf("In Segment::get index:%u\n", i);
this->print();
#endif
if (i < length)
{
return data[i];
}
return Segment::DefaultValue;
}
void RefCollection::removeAt(int x) {
if (!in_range(x))
return;
if (isRef()) decr(data.at(x));
data.erase(data.begin()+x);
}
void RefCollection::setAt(int x, uint32_t y) {
if (!in_range(x))
return;
if (isRef()) {
decr(data.at(x));
incr(y);
}
data.at(x) = y;
}
int RefCollection::indexOf(uint32_t x, int start) {
if (!in_range(start))
return -1;
if (isString()) {
StringData *xx = (StringData*)x;
for (uint32_t i = start; i < data.size(); ++i) {
StringData *ee = (StringData*)data.at(i);
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
return (int)i;
void Segment::set(uint32_t i, uint32_t value)
{
if (i < size)
{
data[i] = value;
}
} else {
for (uint32_t i = start; i < data.size(); ++i)
if (data.at(i) == x)
else if (i < Segment::MaxSize)
{
growByMin(i + 1);
data[i] = value;
}
if (length <= i)
{
length = i + 1;
}
#ifdef DEBUG_BUILD
printf("In Segment::set\n");
this->print();
#endif
return;
}
uint16_t Segment::growthFactor(uint16_t size)
{
if (size == 0)
{
return 4;
}
if (size < 64)
{
return size * 2; // Double
}
if (size < 512)
{
return size * 5/3; //Grow by 1.66 rate
}
return size + 256; //Grow by constant rate
}
void Segment::growByMin(uint16_t minSize)
{
growBy(max(minSize, growthFactor(size)));
}
void Segment::growBy(uint16_t newSize)
{
#ifdef DEBUG_BUILD
printf("growBy: %d\n", newSize);
this->print();
#endif
if (size < newSize)
{
//this will throw if unable to allocate
uint32_t *tmp = (uint32_t*)(::operator new(newSize * sizeof(uint32_t)));
//Copy existing data
if (size)
{
memcpy(tmp, data, size * sizeof(uint32_t));
}
//fill the rest with default value
memset(tmp + size, Segment::DefaultValue, (newSize - size) * sizeof(uint32_t));
//free older segment;
::operator delete(data);
data = tmp;
size = newSize;
#ifdef DEBUG_BUILD
printf("growBy - after reallocation\n");
this->print();
#endif
}
//else { no shrinking yet; }
return;
}
void Segment::ensure(uint16_t newSize)
{
if (newSize < size)
{
return;
}
growByMin(newSize);
}
void Segment::setLength(uint32_t newLength)
{
if (newLength > size)
{
ensure(length);
}
length = newLength;
return;
}
void Segment::push(uint32_t value)
{
this->set(length, value);
}
uint32_t Segment::pop()
{
#ifdef DEBUG_BUILD
printf("In Segment::pop\n");
this->print();
#endif
if (length > 0)
{
uint32_t value = data[length];
data[length] = Segment::DefaultValue;
--length;
return value;
}
return Segment::DefaultValue;
}
//this function removes an element at index i and shifts the rest of the elements to
//left to fill the gap
uint32_t Segment::remove(uint32_t i)
{
#ifdef DEBUG_BUILD
printf("In Segment::remove index:%u\n", i);
this->print();
#endif
if (i < length)
{
//value to return
uint32_t ret = data[i];
if (i + 1 < length)
{
//Move the rest of the elements to fill in the gap.
memmove(data + i, data + i + 1, (length - i - 1) * sizeof(uint32_t));
}
length--;
data[length] = Segment::DefaultValue;
#ifdef DEBUG_BUILD
printf("After Segment::remove index:%u\n", i);
this->print();
#endif
return ret;
}
return Segment::DefaultValue;
}
//this function inserts element value at index i by shifting the rest of the elements right.
void Segment::insert(uint32_t i, uint32_t value)
{
#ifdef DEBUG_BUILD
printf("In Segment::insert index:%u value:%u\n", i, value);
this->print();
#endif
if (i < length)
{
ensure(length + 1);
if (i + 1 < length)
{
//Move the rest of the elements to fill in the gap.
memmove(data + i + 1, data + i, (length - i) * sizeof(uint32_t));
}
data[i] = value;
length++;
}
else
{
//This is insert beyond the length, just call set which will adjust the length
set(i, value);
}
#ifdef DEBUG_BUILD
printf("After Segment::insert index:%u\n", i);
this->print();
#endif
}
void Segment::print()
{
printf("Segment: %x, length: %u, size: %u\n", data, (uint)length, (uint)size);
for(uint i = 0; i < size; i++)
{
printf("%d ",(uint)data[i]);
}
printf("\n");
}
bool Segment::isValidIndex(uint32_t i)
{
if (i > length)
{
return false;
}
return true;
}
void Segment::destroy()
{
#ifdef DEBUG_BUILD
printf("In Segment::destroy\n");
this->print();
#endif
length = size = 0;
::operator delete(data);
data = nullptr;
}
void RefCollection::push(uint32_t x)
{
if (isRef()) incr(x);
head.push(x);
}
uint32_t RefCollection::pop()
{
uint32_t ret = head.pop();
if (isRef())
{
incr(ret);
}
return ret;
}
uint32_t RefCollection::getAt(int i)
{
uint32_t tmp = head.get(i);
if (isRef())
{
incr(tmp);
}
return tmp;
}
uint32_t RefCollection::removeAt(int i)
{
if (isRef())
{
decr(head.get(i));
}
return head.remove(i);
}
void RefCollection::insertAt(int i, uint32_t value)
{
head.insert(i, value);
if (isRef())
{
incr(value);
}
}
void RefCollection::setAt(int i, uint32_t value)
{
if (isRef())
{
if (head.isValidIndex((uint32_t)i))
{
decr(head.get(i));
}
incr(value);
}
head.set(i, value);
}
int RefCollection::indexOf(uint32_t x, int start)
{
if (isString())
{
StringData *xx = (StringData*)x;
uint32_t i = start;
while(head.isValidIndex(i))
{
StringData *ee = (StringData*)head.get(i);
if (ee == xx)
{
//handles ee being null
return (int) i;
}
if (ee && xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
{
return (int)i;
}
i++;
}
}
else
{
uint32_t i = start;
while(head.isValidIndex(i))
{
if (head.get(i) == x)
{
return (int)i;
}
i++;
}
}
return -1;
}
int RefCollection::removeElement(uint32_t x) {
int RefCollection::removeElement(uint32_t x)
{
int idx = indexOf(x, 0);
if (idx >= 0) {
removeAt(idx);
@ -239,17 +503,20 @@ namespace pxt {
void RefCollection::destroy()
{
if (this->isRef())
for (uint32_t i = 0; i < this->data.size(); ++i) {
decr(this->data[i]);
this->data[i] = 0;
{
for(uint32_t i = 0; i < this->head.getLength(); i++)
{
decr(this->head.get(i));
}
this->data.resize(0);
}
this->head.destroy();
delete this;
}
void RefCollection::print()
{
printf("RefCollection %p r=%d flags=%d size=%d [%p, ...]\n", this, refcnt, getFlags(), data.size(), data.size() > 0 ? data[0] : 0);
printf("RefCollection %p r=%d flags=%d size=%d\n", this, refcnt, getFlags(), head.getLength());
head.print();
}
PXT_VTABLE_CTOR(RefAction) {}

View File

@ -1,7 +1,7 @@
#ifndef __PXT_H
#define __PXT_H
// #define DEBUG_MEMLEAKS 1
//#define DEBUG_MEMLEAKS 1
#pragma GCC diagnostic ignored "-Wunused-parameter"
@ -167,11 +167,49 @@ namespace pxt {
}
};
class Segment {
private:
uint32_t* data;
uint16_t length;
uint16_t size;
static const uint16_t MaxSize = 0xFFFF;
static const uint32_t DefaultValue = 0x0;
static uint16_t growthFactor(uint16_t size);
void growByMin(uint16_t minSize);
void growBy(uint16_t newSize);
void ensure(uint16_t newSize);
public:
Segment() : data (nullptr), length(0), size(0) {};
uint32_t get(uint32_t i);
void set(uint32_t i, uint32_t value);
uint32_t getLength() { return length;};
void setLength(uint32_t newLength);
void push(uint32_t value);
uint32_t pop();
uint32_t remove(uint32_t i);
void insert(uint32_t i, uint32_t value);
bool isValidIndex(uint32_t i);
void destroy();
void print();
};
// A ref-counted collection of either primitive or ref-counted objects (String, Image,
// user-defined record, another collection)
class RefCollection
: public RefObject
{
private:
Segment head;
public:
// 1 - collection of refs (need decr)
// 2 - collection of strings (in fact we always have 3, never 2 alone)
@ -179,23 +217,23 @@ namespace pxt {
inline bool isRef() { return getFlags() & 1; }
inline bool isString() { return getFlags() & 2; }
std::vector<uint32_t> data;
RefCollection(uint16_t f);
inline bool in_range(int x) {
return (0 <= x && x < (int)data.size());
}
inline int length() { return data.size(); }
void destroy();
void print();
uint32_t length() { return head.getLength();}
void setLength(uint32_t newLength) { head.setLength(newLength); }
void push(uint32_t x);
uint32_t getAt(int x);
void removeAt(int x);
void setAt(int x, uint32_t y);
uint32_t pop();
uint32_t getAt(int i);
void setAt(int i, uint32_t x);
//removes the element at index i and shifts the other elements left
uint32_t removeAt(int i);
//inserts the element at index i and moves the other elements right.
void insertAt(int i, uint32_t x);
int indexOf(uint32_t x, int start);
int removeElement(uint32_t x);
};

View File

@ -37,7 +37,11 @@
"_locales/fr/core-jsdoc-strings.json",
"_locales/fr/core-strings.json",
"_locales/de/core-jsdoc-strings.json",
"_locales/de/core-strings.json"
"_locales/de/core-strings.json",
"_locales/no/core-strings.json",
"_locales/ja/core-strings.json",
"_locales/sv-SE/core-jsdoc-strings.json",
"_locales/no/core-jsdoc-strings.json"
],
"public": true,
"dependencies": {},
@ -50,4 +54,4 @@
}
}
}
}
}

View File

@ -34,7 +34,7 @@ enum Delimiters {
Hash = 6,
};
//% weight=2 color=30
//% weight=2 color=30 icon="\uf287"
//% advanced=true
namespace serial {
// note that at least one // followed by % is needed per declaration!
@ -51,24 +51,27 @@ namespace serial {
}
/**
* Reads a line of text from the serial port.
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8
StringData* readLine() {
return readUntil(ManagedString("\n").leakData());
* Reads the buffered received data as a string
*/
//% blockId=serial_read_buffer block="serial|read string"
//% weight=18
StringData* readString() {
int n = uBit.serial.getRxBufferSize();
if (n == 0) return ManagedString("").leakData();
return ManagedString(uBit.serial.read(n, MicroBitSerialMode::ASYNC)).leakData();
}
/**
* Registers an event to be fired when one of the delimiter is matched
* @param delimiters the characters to match received characters against. eg:"\n"
* Registers an event to be fired when one of the delimiter is matched.
* @param delimiters the characters to match received characters against.
*/
// help=serial/on-data-received
// weight=18
//% help=serial/on-data-received
//% weight=18 blockId=serial_on_data_received block="serial|on data received %delimiters=serial_delimiter_conv"
void onDataReceived(StringData* delimiters, Action body) {
uBit.serial.eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
// lazy initialization of serial buffers
uBit.serial.read(MicroBitSerialMode::ASYNC);
}
/**
@ -92,7 +95,10 @@ namespace serial {
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
uBit.serial.redirect((PinName)tx, (PinName)rx);
MicroBitPin* txp = getPin(tx); if (!tx) return;
MicroBitPin* rxp = getPin(rx); if (!rx) return;
uBit.serial.redirect(txp->name, rxp->name);
uBit.serial.baud((int)rate);
}
}

View File

@ -1,7 +1,7 @@
/**
* Reading and writing data over a serial connection.
*/
//% weight=2 color=#002050
//% weight=2 color=#002050 icon="\uf287"
//% advanced=true
namespace serial {
/**
@ -38,20 +38,20 @@ namespace serial {
}
/**
* Registers an event to be fired when a line has been received
*/
// help=serial/on-line-received
// blockId=serial_on_line_received block="serial on line received"
// weight=21 blockGap=8
export function onLineReceived(body: Action): void {
// serial.onDataReceived("\n", body);
* Reads a line of text from the serial port.
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8
export function readLine(): string {
return serial.readUntil(delimiters(Delimiters.NewLine));
}
/**
* Returns the delimiter corresponding string
*/
//% blockId="serial_delimiter_conv" block="%del"
//% weight=1
//% weight=1 blockHidden=true
export function delimiters(del: Delimiters): string {
// even though it might not look like, this is more
// (memory) efficient than the C++ implementation, because the

77
libs/core/shims.d.ts vendored
View File

@ -4,7 +4,7 @@
/**
* Creation, manipulation and display of LED images.
*/
//% color=#5C2D91 weight=31
//% color=#5C2D91 weight=31 icon="\uf03e"
//% advanced=true
declare namespace images {
@ -126,7 +126,7 @@ declare interface Image {
/**
* Provides access to basic micro:bit functionality.
*/
//% color=#0078D7 weight=100
//% color=#0078D7 weight=100 icon="\uf00a"
declare namespace basic {
/**
@ -135,7 +135,7 @@ declare namespace basic {
*/
//% help=basic/show-number
//% weight=96
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
//% blockId=device_show_number block="show|number %number" blockGap=8
//% async
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
function showNumber(value: number, interval?: number): void;
@ -160,7 +160,7 @@ declare namespace basic {
*/
//% help=basic/show-string
//% weight=87 blockGap=8
//% block="show|string %text" icon="\uf031"
//% block="show|string %text"
//% async
//% blockId=device_print_message
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
@ -170,7 +170,7 @@ declare namespace basic {
* Turn off all LEDs
*/
//% help=basic/clear-screen weight=79
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
//% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix" shim=basic::clearScreen
function clearScreen(): void;
@ -195,7 +195,7 @@ declare namespace basic {
* Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute
*/
//% help=basic/forever weight=55 blockGap=8
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
function forever(a: () => void): void;
@ -211,7 +211,7 @@ declare namespace basic {
//% color=300 weight=99
//% color=300 weight=99 icon="\uf192"
declare namespace input {
/**
@ -220,7 +220,7 @@ declare namespace input {
* @param body code to run when event is raised
*/
//% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
//% blockId=device_button_event block="on button|%NAME|pressed"
//% parts="buttonpair" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void;
@ -230,7 +230,7 @@ declare namespace input {
* @param body code to run when gesture is raised
*/
//% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
//% blockId=device_gesture_event block="on |%NAME"
//% parts="accelerometer" shim=input::onGesture
function onGesture(gesture: Gesture, body: () => void): void;
@ -240,7 +240,7 @@ declare namespace input {
* @param body the code to run when the pin is pressed
*/
//% help=input/on-pin-pressed weight=83
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094" shim=input::onPinPressed
//% blockId=device_pin_event block="on pin %name|pressed" shim=input::onPinPressed
function onPinPressed(name: TouchPin, body: () => void): void;
/**
@ -249,7 +249,7 @@ declare namespace input {
* @param body the code to run when the pin is released
*/
//% 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"
//% advanced=true shim=input::onPinReleased
function onPinReleased(name: TouchPin, body: () => void): void;
@ -269,7 +269,7 @@ declare namespace input {
* @param name pin used to detect the touch, eg: TouchPin.P0
*/
//% 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"
//% blockGap=8 shim=input::pinIsPressed
function pinIsPressed(name: TouchPin): boolean;
@ -277,7 +277,7 @@ declare namespace input {
* 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"
//% help=input/acceleration weight=58
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
//% parts="accelerometer" shim=input::acceleration
function acceleration(dimension: Dimension): number;
@ -286,7 +286,7 @@ declare namespace input {
* 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"
//% blockId=device_get_light_level block="light level" blockGap=8
//% parts="ledmatrix" shim=input::lightLevel
function lightLevel(): number;
@ -294,7 +294,7 @@ declare namespace input {
* Get the current compass heading in degrees.
*/
//% help=input/compass-heading
//% weight=56 icon="\uf14e"
//% weight=56
//% blockId=device_heading block="compass heading (°)" blockGap=8
//% parts="compass" shim=input::compassHeading
function compassHeading(): number;
@ -302,7 +302,7 @@ declare namespace input {
/**
* Gets the temperature in Celsius degrees (°C).
*/
//% weight=55 icon="\uf06d"
//% weight=55
//% help=input/temperature
//% blockId=device_temperature block="temperature (°C)" blockGap=8
//% parts="thermometer" shim=input::temperature
@ -313,7 +313,7 @@ declare namespace input {
* @param kind TODO
*/
//% 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
//% parts="accelerometer" advanced=true shim=input::rotation
function rotation(kind: Rotation): number;
@ -322,7 +322,7 @@ declare namespace input {
* @param dimension TODO
*/
//% 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
//% parts="compass"
//% advanced=true shim=input::magneticForce
function magneticForce(dimension: Dimension): number;
@ -331,7 +331,7 @@ declare namespace input {
* Gets the number of milliseconds elapsed since power on.
*/
//% 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)"
//% advanced=true shim=input::runningTime
function runningTime(): number;
@ -346,7 +346,7 @@ declare namespace input {
* @param range a value describe the maximum strengh of acceleration measured
*/
//% 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"
//% weight=5
//% parts="accelerometer"
//% advanced=true shim=input::setAccelerometerRange
@ -362,7 +362,7 @@ declare namespace control {
/**
* Schedules code that run in the background.
*/
//% help=control/in-background
//% help=control/in-background blockAllowMultiple=1
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
function inBackground(a: () => void): void;
@ -427,7 +427,7 @@ declare namespace control {
//% color=3 weight=35
//% color=3 weight=35 icon="\uf205"
declare namespace led {
/**
@ -436,7 +436,7 @@ declare namespace led {
* @param y TODO
*/
//% 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" blockGap=8
//% parts="ledmatrix" shim=led::plot
function plot(x: number, y: number): void;
@ -446,7 +446,7 @@ declare namespace led {
* @param y TODO
*/
//% 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" blockGap=8
//% parts="ledmatrix" shim=led::unplot
function unplot(x: number, y: number): void;
@ -456,7 +456,7 @@ declare namespace led {
* @param y TODO
*/
//% help=led/point weight=76
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
//% blockId=device_point block="point|x %x|y %y"
//% parts="ledmatrix" shim=led::point
function point(x: number, y: number): boolean;
@ -464,7 +464,7 @@ declare namespace led {
* Get the screen brightness from 0 (off) to 255 (full bright).
*/
//% help=led/brightness weight=60
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
//% blockId=device_get_brightness block="brightness" blockGap=8
//% parts="ledmatrix"
//% advanced=true shim=led::brightness
function brightness(): number;
@ -474,7 +474,7 @@ declare namespace led {
* @param value the brightness value, eg:255, 127, 0
*/
//% help=led/set-brightness weight=59
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
//% blockId=device_set_brightness block="set brightness %value"
//% parts="ledmatrix"
//% advanced=true shim=led::setBrightness
function setBrightness(value: number): void;
@ -483,7 +483,7 @@ declare namespace led {
* Cancels the current animation and clears other pending animations.
*/
//% weight=50 help=led/stop-animation
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
//% blockId=device_stop_animation block="stop animation"
//% parts="ledmatrix"
//% advanced=true shim=led::stopAnimation
function stopAnimation(): void;
@ -499,7 +499,7 @@ declare namespace led {
/**
* Turns on or off the display
*/
//% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
//% help=led/enable blockId=device_led_enable block="led enable %on"
//% advanced=true parts="ledmatrix" shim=led::enable
function enable(on: boolean): void;
@ -658,7 +658,7 @@ declare namespace pins {
//% weight=2 color=30
//% weight=2 color=30 icon="\uf287"
//% advanced=true
declare namespace serial {
@ -672,12 +672,19 @@ declare namespace serial {
function readUntil(delimiter: string): string;
/**
* Reads a line of text from the serial port.
* Reads the buffered received data as a string
*/
//% help=serial/read-line
//% blockId=serial_read_line block="serial|read line"
//% weight=20 blockGap=8 shim=serial::readLine
function readLine(): string;
//% blockId=serial_read_buffer block="serial|read string"
//% weight=18 shim=serial::readString
function readString(): string;
/**
* Registers an event to be fired when one of the delimiter is matched.
* @param delimiters the characters to match received characters against.
*/
//% help=serial/on-data-received
//% weight=18 blockId=serial_on_data_received block="serial|on data received %delimiters=serial_delimiter_conv" shim=serial::onDataReceived
function onDataReceived(delimiters: string, body: () => void): void;
/**
* Sends a piece of text through Serial connection.

View File

@ -0,0 +1,3 @@
{
"devices": "Contrôler un téléphone avec le BBC micro : bit via Bluetooth."
}

View File

@ -5,7 +5,8 @@
"README.md",
"enums.d.ts",
"shims.d.ts",
"devices.cpp"
"devices.cpp",
"_locales/fr/devices-jsdoc-strings.json"
],
"public": true,
"dependencies": {
@ -13,4 +14,4 @@
"bluetooth": "file:../bluetooth"
},
"installedVersion": "ljipgq"
}
}

View File

@ -0,0 +1,24 @@
{
"radio": "Daten mithilfe von Funk-Paketen übertragen",
"radio.onDataPacketReceived": "Registriert Funktionen, die ausgeführt werden, wenn das Radio ein Datenpaket empfängt. Entnimmt das empfangene Paket aus der Warteschlange des Radios.",
"radio.onDataReceived": "Registriert Code der ausgeführt wird, wenn ein Paket über Funk empfangen wird.",
"radio.receiveNumber": "Liest das nächste Paket aus der Funk-Warteschlange und gibt die Paketnummer oder 0 aus, wenn das Paket keine Nummer enthält.",
"radio.receiveString": "Liest das nächste Paket aus der Funk-Warteschlange und gibt die enthaltene Zeichenfolge oder die leere Zeichenfolge aus, wenn das Paket keine Zeichenfolge enthält.",
"radio.receivedNumber": "Extrahiert eine Zahl aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios (via ``Zahl empfangen``, ``Zeichenkette empfangen``, etc) entnommen wurde oder eine 0, wenn das Paket keine Zahl enthält.",
"radio.receivedSerial": "Extrahiert die Seriennummer des Calliope mini Senders aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios entnommen wurde oder eine 0, wenn der Absender keine Seriennummer gesendet hat.",
"radio.receivedSignalStrength": "Ruft den empfangenen Signalstärkeindikator (RSSI) aus dem letzten Paket aus der Funk-Warteschlange aus (via ``receiveNumber``, ``receiveString``, etc). Wird im Simulator nicht unterstützt.\nnamespace=radio",
"radio.receivedString": "Extrahiert die Zeichenkette aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios (via ``Zahl empfangen``, ``Zeichenkette empfangen``, etc) entnommen wurde oder eine leere Zeichenkette, wenn das Paket keine Zeichenkette enthält.",
"radio.receivedTime": "Extrahiert die Systemzeit des Absenders aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios (via ``Zahl empfangen``, ``Zeichenkette empfangen``, etc) entnommen wurde.",
"radio.sendNumber": "Überträgt eine Nummer über Funk an jeden angeschlossenen mini in der Gruppe.",
"radio.sendString": "Überträgt eine Zeichenfolge über Funk mit Seriennummer des Geräts und Laufzeit an jeden angeschlossenen mini in der Gruppe.",
"radio.sendValue": "Sendet ein Name / Wert-Paar zusammen mit der Seriennummer des Geräts und die Laufzeit auf alle angeschlossenen minis in der Gruppe.",
"radio.sendValue|param|name": "die Feldnamen (max. 12 Zeichen), z.B.: \"Daten\"",
"radio.sendValue|param|value": "der numerische Wert",
"radio.setGroup": "Setzt die Gruppen-ID für Funkverbindungen. Ein mini kann nur ein Gruppen-ID hören.\nDie Gruppen-ID zwischen liegt zwischen 0 und 255, z.B. 1",
"radio.setTransmitPower": "Ändere die Ausgabeleistung des Senders auf den angegebenen Wert.",
"radio.setTransmitPower|param|power": "ein Wert im Bereich 0.. 7, wo 0 die niedrigste Leistung und 7 ist ist die höchste. z.B. 7",
"radio.setTransmitSerialNumber": "Stelle den Dunk so ein, dass die Seriennummer in jeder Nachricht übertragen wird.",
"radio.setTransmitSerialNumber|param|transmit": "Wert, der anzeigt, ob die Seriennummer übertragen wird, z.B. wahr",
"radio.writeReceivedPacketToSerial": "Schreibt das letzte empfangene Paket als JSON auf Seriell. Sollte in einem ´´onDataPacketReceived``-Callback aufgerufen werden.",
"radio.writeValueToSerial": "Liest das nächste Paket aus der Funk-Warteschlange und schreibt dieses als JSON auf Seriell."
}

View File

@ -0,0 +1,17 @@
{
"radio.onDataPacketReceived|block": "wenn Datenpaket empfangen",
"radio.onDataReceived|block": "über Funk empfangene Daten",
"radio.receiveNumber|block": "über Funk empfangene Zahl",
"radio.receiveString|block": "über Funk empfangene Zeichenfolge",
"radio.receivedSignalStrength|block": "über Funk empfangene Signalstärke",
"radio.sendNumber|block": "sende Zahl %value über Funk",
"radio.sendString|block": "sende Zeichenfolge %msg über Funk",
"radio.sendValue|block": "schicke | Wert %name |=%value über Funk",
"radio.setGroup|block": "setze Gruppe %ID über Funk",
"radio.setTransmitPower|block": "lege Übertragungsstärke %power über Funk fest",
"radio.setTransmitSerialNumber|block": "übertrage Übertragungs-Seriennummer %transmit über Funk",
"radio.writeReceivedPacketToSerial|block": "schreibe das über Funk emfangene Paket auf Seriell",
"radio.writeValueToSerial|block": "schreibe Wert auf Seriell über Funk",
"radio|block": "Funk",
"{id:category}Radio": "Funk"
}

View File

@ -6,7 +6,9 @@
"shims.d.ts",
"enums.d.ts",
"radio.cpp",
"radio.ts"
"radio.ts",
"_locales/de/radio-strings.json",
"_locales/de/radio-jsdoc-strings.json"
],
"public": true,
"dependencies": {

Some files were not shown because too many files have changed in this diff Show More