Compare commits

...

96 Commits

Author SHA1 Message Date
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
52e67c6bfc 0.6.43 2016-12-16 15:29:33 -08:00
5a6f23a7d0 Bump pxt-core to 0.6.5 2016-12-16 15:29:26 -08:00
d1b36f2022 0.6.42 2016-12-16 14:57:24 -08:00
284579181b Bump pxt-core to 0.6.4 2016-12-16 14:57:09 -08:00
20fcb05538 0.6.41 2016-12-16 14:40:12 -08:00
e1a2074ef5 Bump pxt-core to 0.6.3 2016-12-16 14:39:58 -08:00
fa3e33dab9 Default product.json for enabling Electron builds (#323) 2016-12-16 12:16:06 -08:00
300a98b858 0.6.40 2016-12-13 21:58:35 -08:00
5986671bcb Bump pxt-core to 0.6.1 2016-12-13 21:58:29 -08:00
efd5c46143 0.6.39 2016-12-14 09:16:58 +11:00
62c1a1da35 Bump pxt-core to 0.5.102 2016-12-14 09:16:57 +11:00
ebbc7c983d 0.6.38 2016-12-13 12:49:06 -08:00
173fc4bf7b Bump pxt-core to 0.5.101 2016-12-13 12:49:04 -08:00
111 changed files with 1549 additions and 603 deletions

2
.gitignore vendored
View File

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

View File

@ -1,2 +0,0 @@
node_modules
projects

View File

@ -1,5 +0,0 @@
# PXT micro:bit Electron app
A very basic wrapper around the web app. To install, copy the contents of this
directory to somewhere outside the main `pxt-microbit` repository. Then run `npm
install && npm start`.

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>code the micro:bit</title>
</head>
<body>
<webview id="webview" style="position:absolute; left:0; top:0; right:0; bottom:0"/>
<script>
const webview = document.getElementById("webview")
const url = `http://localhost:3232/${window.location.hash}`
webview.src = url
</script>
</body>
</html>

View File

@ -1,39 +0,0 @@
const {app, BrowserWindow, Menu} = require('electron')
const pxt = require('pxt-core')
const path = require('path')
let win
const cliPath = path.join(process.cwd(), "node_modules/pxt-microbit")
function startServerAndCreateWindow() {
pxt.mainCli(cliPath, ["serve", "-no-browser"])
createWindow()
}
function createWindow () {
win = new BrowserWindow({
width: 800,
height: 600,
title: "code the micro:bit"
})
Menu.setApplicationMenu(null)
win.loadURL(`file://${__dirname}/index.html#local_token=${pxt.globalConfig.localToken}`)
win.on('closed', () => {
win = null
})
}
app.on('ready', startServerAndCreateWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})

View File

@ -1,14 +0,0 @@
{
"name" : "code-the-microbit",
"version" : "1.0.0",
"description": "Blocks / Javascript editor",
"author": "Microsoft",
"main" : "main.js",
"scripts": {
"start": "node_modules/.bin/electron ."
},
"devDependencies": {
"electron": "*",
"pxt-microbit": "*"
}
}

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" /> /// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
import * as path from "path"; import * as path from "path";

View File

@ -11,4 +11,4 @@ Math.random(5);
## See Also ## 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: When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
```blocks ```blocks
let x = Math.random(5) input.onButtonPressed(Button.A, () => {
if(x < 5) { let x = Math.random(5)
basic.showString("low"); if(x < 5) {
} else { basic.showString("low");
basic.showString("high"); } 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. 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 ### Example: adjusting screen brightness
```blocks If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed:
if(input.lightLevel()<100){
led.setBrightness(255);
}
```
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 ### See also

View File

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

View File

@ -2,7 +2,7 @@
Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true. Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
```blocks ```block
while(true) { 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`). 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 ```blocks
let index = 4; input.onButtonPressed(Button.A, () => {
while(index >= 0) { let index = 4;
led.plot(index, index); while(index >= 0) {
index--; led.plot(index, index);
} index--;
}
})
``` ```
### See also ### 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 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 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@! Click **Download** to move your program to the @boardname@!
Make sure to follow the instructions. Make sure to follow the instructions.

View File

@ -17,7 +17,7 @@ input.onButtonPressed(Button.A, () => {
#### ~hint #### ~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. on the @boardname@ screen.
#### ~ #### ~
@ -33,7 +33,7 @@ input.onButtonPressed(Button.B, () => {
#### ~hint #### ~hint
You can find the letter `B` by clicking the letter `A` on the 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 ### ~hint
The ``pick random true or false`` block randomly tells the ``if`` The `[Math.randomBoolean()]` block randomly tells the ``if``
block `true` or `false`. If the ``pick`` block picked `true`, the block `true` or `false`. If value picked is `true`, the
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`. ``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
That's it! 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 ### Happy unhappy face
Draw an unhappy face instead of the blank screen. Click on the dots 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, Now you have an **animation** (cartoon) that shows a happy face,
then an unhappy one, then a happy one again, forever (or until then an unhappy one, then a happy one again, forever (or until
you turn off your @boardname@)! you turn off your @boardname@)!
@ -36,7 +36,7 @@ Click **Download** to move your program to the @boardname@!
### Your turn! ### 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? animation with at least 5 pictures. What does this animation show?
```blocks ```blocks
@ -87,12 +87,6 @@ basic.forever(() => {
``` ```
Click **Download** to move your program to the @boardname@! 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 ### ~button /getting-started/buttons
NEXT: BUTTONS NEXT: BUTTONS
### ~ ### ~

View File

@ -66,6 +66,10 @@ Fun games to build with your @boardname@.
```codecard ```codecard
[{ [{
"name": "Inchworm",
"url":"/projects/inchworm",
"imageUrl":"/static/mb/projects/inchworm.jpg"
}, {
"name": "Timing gates", "name": "Timing gates",
"url":"/projects/timing-gates", "url":"/projects/timing-gates",
"imageUrl":"/static/mb/projects/timing-gates.jpg" "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 ```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. 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,48 @@
# 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)
})
```

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': 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) 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': 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 ```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 ## 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. 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 ```blocks
let force = 0;
let isSwitched = false; let isSwitched = false;
basic.forever(() => { 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: 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 ```blocks
let force = 0;
let isSwitched = false; let isSwitched = false;
basic.forever(() => { basic.forever(() => {
isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100 force = Math.abs(input.magneticForce(Dimension.Strength));
isSwitched = force > 100
}) })
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {

View File

@ -18,15 +18,15 @@ and updates the screen with the direction.
basic.forever(() => { basic.forever(() => {
let heading = input.compassHeading() let heading = input.compassHeading()
if (heading < 45) { if (heading < 45) {
basic.showString("N", 100) basic.showString("N")
} else if (heading < 135) { } else if (heading < 135) {
basic.showString("E", 100) basic.showString("E")
} }
else if (heading < 225) { else if (heading < 225) {
basic.showString("S", 100) basic.showString("S")
} }
else { 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 ```blocks
let num = 0 let num = 0
basic.forever(() => { basic.forever(() => {
basic.showNumber(num, 150) basic.showNumber(num)
}) })
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
num = num + 1 num = num + 1
@ -56,10 +56,10 @@ Try this on your @boardname@:
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
basic.showNumber(6789, 150) basic.showNumber(6789)
}) })
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
basic.showNumber(2, 150) basic.showNumber(2)
}) })
``` ```

View File

@ -35,7 +35,8 @@ bluetooth.uartWriteValue("", 0);
## Eddystone ## Eddystone
```cards ```cards
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7); bluetooth.advertiseUid(42, 1, 7, true);
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
bluetooth.stopAdvertising(); 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. * ``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). * ``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 ### Example: Broadcast a secret code
@ -34,7 +35,7 @@ bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true);
## See Also ## See Also
[stop-advertising](/reference/bluetooth/stop-advertising) [stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid)
```package ```package
bluetooth bluetooth

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,67 @@
# Getting started
### Step 1
Place blocks in the workspace to scroll text on the screen.
```blocks
basic.showString("Hi!")
```
### Step 2
Transfer your code in your @boardname@! Click the **Download** button
and follow the instructions.
ANIMATEDGIF
### 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("Hi!")
});
```
### Step 4
Transfer your code in your @boardname@ and try pressing **A**.
ANIMATEDGIF
### Step 5
Place more blocks to display a smiley when button **B** is pressed.
Download your code and try it!
```block
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
# . . . #
. # # # .
`)
})
```
### Step 6
Drag more blocks to display a frownie when @boardname@ is shaken.
Download your code and try it!
```block
input.onGesture(Gesture.Shake, () => {
basic.showLeds(`
# # . # #
# # . # #
. . . . .
. # # # .
# . . . #
`)
})
```

14
electron/product.json Normal file
View File

@ -0,0 +1,14 @@
{
"applicationName": "pxt-microbit-oss",
"dataFolderName": ".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",
"win32MutexName": "pxtmicrobitoss",
"win32NameVersion": "Microsoft PXT microbit-OSS",
"win32RegValueName": "PXTmicrobitOss"
}

9
electron/release.json Normal file
View File

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

View File

@ -1,62 +1,3 @@
<xml xmlns="http://www.w3.org/1999/xhtml"> <xml xmlns="http://www.w3.org/1999/xhtml">
<block type="device_forever"> <block type="pxt-on-start"></block>
<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>
</xml> </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": "Advertise an Eddystone URL",
"bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.", "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", "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.advertiseUrl|block": "bluetooth advertise url %url|with power %power|connectable %connectable",
"bluetooth.onBluetoothConnected|block": "on bluetooth connected", "bluetooth.onBluetoothConnected|block": "on bluetooth connected",
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected", "bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",

View File

@ -7,7 +7,7 @@ using namespace pxt;
/** /**
* Support for additional Bluetooth services. * Support for additional Bluetooth services.
*/ */
//% color=#0082FB weight=20 //% color=#0082FB weight=96 icon="\uf294"
namespace bluetooth { namespace bluetooth {
MicroBitUARTService *uart = NULL; MicroBitUARTService *uart = NULL;
@ -137,6 +137,24 @@ namespace bluetooth {
uBit.bleManager.setTransmitPower(power); 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). * Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7. * @param power power level between 0 (minimal) and 7 (maximum), eg: 7.

View File

@ -1,7 +1,7 @@
/** /**
* Support for additional Bluetooth services. * Support for additional Bluetooth services.
*/ */
//% color=#0082FB weight=20 //% color=#0082FB weight=96 icon="\uf294"
namespace bluetooth { namespace bluetooth {
/** /**
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device. * 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 // dummy implementation for simulator
return "???" 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", "enums.d.ts",
"shims.d.ts", "shims.d.ts",
"bluetooth.ts", "bluetooth.ts",
"bluetooth.cpp" "bluetooth.cpp",
"_locales/de/bluetooth-jsdoc-strings.json"
], ],
"public": true, "public": true,
"dependencies": { "dependencies": {
@ -30,14 +31,14 @@
"event_service": 1, "event_service": 1,
"device_info_service": 1, "device_info_service": 1,
"eddystone_url": 1, "eddystone_url": 1,
"eddystone_uid": 0, "eddystone_uid": 1,
"open": 0, "open": 0,
"pairing_mode": 1, "pairing_mode": 1,
"whitelist": 1, "whitelist": 1,
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM" "security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
} },
}, "gatt_table_size": "0x700"
"gatt_table_size": "0x700" }
}, },
"userConfigs": [ "userConfigs": [
{ {
@ -46,7 +47,7 @@
"microbit-dal": { "microbit-dal": {
"bluetooth": { "bluetooth": {
"open": 1, "open": 1,
"pairing_mode": 0, "pairing_mode": 0,
"whitelist": 0, "whitelist": 0,
"security_level": null "security_level": null
} }

View File

@ -4,7 +4,7 @@
/** /**
* Support for additional Bluetooth services. * Support for additional Bluetooth services.
*/ */
//% color=#0082FB weight=20 //% color=#0082FB weight=96 icon="\uf294"
declare namespace bluetooth { declare namespace bluetooth {
/** /**
@ -92,6 +92,15 @@ declare namespace bluetooth {
//% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl //% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl
function advertiseUrl(url: string, power: number, connectable: boolean): void; 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). * Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7. * @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"> <xml xmlns="http://www.w3.org/1999/xhtml">
<block type="device_forever"> <block type="pxt-on-start"></block>
<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>
</xml> </xml>

View File

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

View File

@ -33,6 +33,8 @@
"DisplayMode.Greyscale|block": "greyscale", "DisplayMode.Greyscale|block": "greyscale",
"EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).", "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.", "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": "Raised when the board is falling!",
"Gesture.FreeFall|block": "free fall", "Gesture.FreeFall|block": "free fall",
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical", "Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",

View File

@ -64,7 +64,6 @@
"control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4", "control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4",
"game": "Eine Einzel-LED-Sprite-Spielumgebung", "game": "Eine Einzel-LED-Sprite-Spielumgebung",
"game.addLife": "Fügt Leben zum aktuellen Spielstand hinzu", "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": "Fügt zum aktuellen Spielstand Punkte hinzu",
"game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1", "game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1",
"game.createSprite": "Erzeugt einen neuen LED-Sprite, der nach rechts zeigt.", "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.levelUp": "Erhöht das Level und zeigt eine Nachricht an.",
"game.life": "Ruft das aktuelle Leben ab", "game.life": "Ruft das aktuelle Leben ab",
"game.removeLife": "Entfernt ein Leben", "game.removeLife": "Entfernt ein Leben",
"game.removeLife|param|life": "TODO",
"game.score": "Ruft den aktuellen Punktestand ab", "game.score": "Ruft den aktuellen Punktestand ab",
"game.setLife": "Setzt den aktuellen Wert der Leben", "game.setLife": "Setzt den aktuellen Wert der Leben",
"game.setLife|param|value": "TODO",
"game.setScore": "Setzt den aktuellen Wert des Spielstands", "game.setScore": "Setzt den aktuellen Wert des Spielstands",
"game.setScore|param|value": "TODO",
"game.showScore": "Zeigt den Spielstand auf dem Display.", "game.showScore": "Zeigt den Spielstand auf dem Display.",
"game.startCountdown": "Startet einen Spiel-Countdown", "game.startCountdown": "Startet einen Spiel-Countdown",
"game.startCountdown|param|ms": "Countdown-Dauer in Millisekunden, z.B.: 10000", "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.", "images.createImage": "Erstellt ein Bild, das auf den LED-Bildschirm passt.",
"input": "Ereignisse und Daten der Sensoren", "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": "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.buttonIsPressed": "Erhalte den Sie den Tastenstatus (gepresst oder nicht) für ``A`` und ``B``.",
"input.calibrate": "Veraltet, Kompasskalibrierung erfolgt automatisch.", "input.calibrate": "Veraltet, Kompasskalibrierung erfolgt automatisch.",
"input.compassHeading": "Holt die aktuelle Kompassrichtung in Grad.", "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.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": "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": "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": "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": "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": "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": "Mache etwas, wenn eine Pin gehalten wird.",
"input.onPinPressed|param|body": "Code, der ausführt wird, wenn ein 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": "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|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": "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": "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": "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": "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": "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.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": "Legt die Stichprobenbereich des Beschleunigungssensors in Schwerkraft fest.",
"input.setAccelerometerRange|param|range": "Ein Wert, der die maximale Stärke der gemessenen Beschleunigung beschreibt", "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.brightness": "Ruft die Helligkeit des Bildschirms ab, von 0 (aus) bis 255 (volle Helligkeit).",
"led.enable": "Schaltet das Display an und aus", "led.enable": "Schaltet das Display an und aus",
"led.fadeIn": "Blendet die Bildschirmanzeige ein.", "led.fadeIn": "Blendet die Bildschirmanzeige ein.",
"led.fadeIn|param|ms": "TODO",
"led.fadeOut": "Blendet die Bildschirmhelligkeit aus.", "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.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.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": "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|high": "maximalen Wert. Wenn dieser 0 ist, wird der Maximalwert automatisch angepasst, z.B.: 0",
"led.plotBarGraph|param|value": "aktueller Wert zum Darstellen", "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": "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.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": "Lege die Helligkeit des Bildschirms fest, von 0 (aus) bis 255 (volle Helligkeit).",
"led.setBrightness|param|value": "Helligkeitswert, z.B.: 255, 127, 0", "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.stopAnimation": "Bricht die aktuelle Animation ab und löscht andere ausstehende Animationen.",
"led.toggle": "Schaltet ein bestimmtes Pixel ein", "led.toggle": "Schaltet ein bestimmtes Pixel ein",
"led.toggleAll": "Invertiert die aktuelle LED-Anzeige", "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": "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": "Generierung von von Musik durch Pin ``P0``.",
"music.beat": "Gibt die Dauer eines Taktes in Milli-Sekunden aus", "music.beat": "Gibt die Dauer eines Taktes in Milli-Sekunden aus",
"music.changeTempoBy": "Ändere die Geschwindigkeit um den angegebenen Betrag", "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.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": "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": "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|frequency": "Tonhöhe des abzuspielenden Tones in Hertz (Hz)",
"music.playTone|param|ms": "Tondauer in Millisekunden (ms)", "music.playTone|param|ms": "Tondauer in Millisekunden (ms)",
@ -181,21 +152,15 @@
"pins.analogPitch|param|frequency": "TODO", "pins.analogPitch|param|frequency": "TODO",
"pins.analogPitch|param|ms": "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": "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": "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|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.analogSetPitchPin|param|name": "TODO",
"pins.analogWritePin": "Legt den Wert des Verbinders auf analog fest. Der Wert muss zwischen 0 und 1023 liegen.", "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.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": "Erstellt einen Null-initialisierten Zwischenspeicher.",
"pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher", "pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher",
"pins.digitalReadPin": "Lese den angegebene Pin oder Verbinder als 0 oder 1", "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": "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.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.i2cReadBuffer": "Lese `Größe`bytes aus einer 7-bit I2C-Adresse.",
"pins.i2cReadNumber": "Lese eine Nummer 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.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.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": "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": "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|micros": "Impulsdauer in Mikrosekunden, z.B.: 1500",
"pins.servoSetPulse|param|name": "PIN-Name", "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": "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.servoWritePin|param|value": "Winkel oder Rotationsbeschleunigung, z.B.: 180,90,0",
"pins.setPull": "Stellt die Anziehungskraft des Pins ein.", "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.sizeOf": "Ruft die Bytegröße im spezifierten Nummernformat ab.",
"pins.spiWrite": "Schreibe in den SPI-Slave und gebe die Antwort aus", "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", "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": "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.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": "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.writeLine": "Gibt eine Zeile des Textes an die serielle",
"serial.writeNumber": "Gibt einen numerischen Wert an die serielle", "serial.writeNumber": "Gibt einen numerischen Wert an die serielle",
"serial.writeString": "Sendet ein Stück Text über serielle Verbindung.", "serial.writeString": "Sendet ein Stück Text über serielle Verbindung.",

View File

@ -7,12 +7,71 @@
"AcceleratorRange.OneG|block": "1g", "AcceleratorRange.OneG|block": "1g",
"AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g", "AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g",
"AcceleratorRange.TwoG|block": "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": "Wird erhöht, wenn geschüttelt",
"Gesture.Shake|block": "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.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.randomBoolean|block": "wähle zufälligen Wahr- oder Falsch-Wert",
"Math|block": "Mathematik", "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.Pitch|block": "Winkel",
"Rotation.Roll|block": "rollen",
"String.charAt|block": "Zeichen an Position %pos aus|%this", "String.charAt|block": "Zeichen an Position %pos aus|%this",
"String.compare|block": "vergleiche %this| mit %that", "String.compare|block": "vergleiche %this| mit %that",
"String.concat|block": "hänge %this| mit %other aneinander", "String.concat|block": "hänge %this| mit %other aneinander",
@ -23,10 +82,10 @@
"String|block": "Zeichenfolge", "String|block": "Zeichenfolge",
"basic.clearScreen|block": "Bildschirminhalt löschen", "basic.clearScreen|block": "Bildschirminhalt löschen",
"basic.forever|block": "dauerhaft", "basic.forever|block": "dauerhaft",
"basic.pause|block": "Pausiere (ms) %pause", "basic.pause|block": "pausiere (ms) %pause",
"basic.showLeds|block": "zeige LEDs", "basic.showLeds|block": "zeige LEDs",
"basic.showNumber|block": "zeige|Nummer %number", "basic.showNumber|block": "zeige|Nummer %number",
"basic.showString|block": "Zeige|Zeichenfolge %text", "basic.showString|block": "zeige|Zeichenfolge %text",
"basic|block": "Grundlagen", "basic|block": "Grundlagen",
"control.deviceName|block": "Gerätename", "control.deviceName|block": "Gerätename",
"control.deviceSerialNumber|block": "Seriennnummer", "control.deviceSerialNumber|block": "Seriennnummer",
@ -56,7 +115,6 @@
"input.magneticForce|block": "Magnetkraft (µT) |%NAME", "input.magneticForce|block": "Magnetkraft (µT) |%NAME",
"input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt", "input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt",
"input.onGesture|block": "wenn |%NAME", "input.onGesture|block": "wenn |%NAME",
"input.onPinPressed|block": "wenn Pin %NAME|gedrückt",
"input.onPinReleased|block": "wenn Pin %NAME|losgelassen", "input.onPinReleased|block": "wenn Pin %NAME|losgelassen",
"input.pinIsPressed|block": "Pin %NAME|ist gedrückt", "input.pinIsPressed|block": "Pin %NAME|ist gedrückt",
"input.rotation|block": "Rotation (°)|%NAME", "input.rotation|block": "Rotation (°)|%NAME",
@ -71,7 +129,7 @@
"led.setBrightness|block": "Setze Helligkeit auf %value", "led.setBrightness|block": "Setze Helligkeit auf %value",
"led.stopAnimation|block": "Halte Animation an", "led.stopAnimation|block": "Halte Animation an",
"led.toggle|block": "Schalte zwischen|x %x|y %y", "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", "led|block": "LED",
"music.beat|block": "%fraction|Takt", "music.beat|block": "%fraction|Takt",
"music.changeTempoBy|block": "ändere die Geschwindigkeit (bpm)|%value", "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 ! »", "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.inBackground": "Planifie le code qui sexécute en arrière-plan.",
"control.reset": "Réinitialise le micro:bit de BBC.", "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", "control.waitMicros|param|micros": "nombre de microsecondes à attendre. par ex. : 4",
"game": "Un moteur de jeu avec une unique LED", "game": "Un moteur de jeu avec une unique LED",
"game.addLife|param|lives": "TODO",
"game.addScore": "Ajoute des points au score actuel", "game.addScore": "Ajoute des points au score actuel",
"game.addScore|param|points": "nombre de points à changer, par ex. : 1", "game.addScore|param|points": "nombre de points à changer, par ex. : 1",
"game.gameOver": "Affiche un animation de fin de jeu.", "game.gameOver": "Affiche un animation de fin de jeu.",
"game.removeLife|param|life": "TODO",
"game.score": "Obtient le score actuel", "game.score": "Obtient le score actuel",
"game.setLife|param|value": "TODO",
"game.setScore": "Définit la valeur du score actuel", "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": "Démarre un compte à rebours de jeu",
"game.startCountdown|param|ms": "durée du compte à rebours en millisecondes, par ex. : 10000", "game.startCountdown|param|ms": "durée du compte à rebours en millisecondes, par ex. : 10000",
"images": "Création, manipulation et affichage dimages LED.", "images": "Création, manipulation et affichage dimages LED.",
"images.createBigImage": "Crée une image à partir de 2 images.", "images.createBigImage": "Crée une image à partir de 2 images.",
"images.createImage": "Crée une image qui sadapte aux dimensions de lécran LED.", "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": "É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.calibrate": "Obsolète, le calibrage de la boussole est automatique.",
"input.compassHeading": "Obtient la direction actuelle du compas en degrés.", "input.compassHeading": "Obtient la direction actuelle du compas en degrés.",
"input.magneticForce|param|dimension": "TODO", "input.lightLevel": "Lit le niveau de lumière appliqué à l'écran LED de ``0`` (sombre) à ``255`` lumineux.",
"input.onButtonPressed|param|body": "TODO", "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|param|button": "TODO", "input.onButtonPressed": "Faire quelque chose quand un bouton (``A``, ``B`` ou les deux ``A+B``) est appuyé",
"input.onGesture|param|body": "TODO", "input.onGesture": "Faire quelque chose lorsque lorsquun geste est fait (par exemple secouer le micro:bit).",
"input.onLogoDown|param|body": "TODO",
"input.onLogoUp|param|body": "TODO",
"input.onPinPressed": "Faire quelque chose lorsque vous appuyez sur une broche.", "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|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": "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|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.pinIsPressed": "Donne létat de la broche (pressée ou non). Nécessite de tenir la masse pour fermer le circuit.",
"input.onScreenDown|param|body": "TODO", "input.runningTime": "Donne le nombre de millisecondes écoulées depuis la mise en route.",
"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.temperature": "Obtient la température en degrés Celsius (°C).", "input.temperature": "Obtient la température en degrés Celsius (°C).",
"led": "Contrôle de lécran LED.", "led": "Contrôle de lécran LED.",
"led.enable": "Active ou désactive laffichage", "led.enable": "Active ou désactive laffichage",
"led.fadeIn|param|ms": "TODO",
"led.fadeOut|param|ms": "TODO",
"led.plotAll": "Allume toutes les LEDS", "led.plotAll": "Allume toutes les LEDS",
"led.plotBarGraph|param|value": "valeur actuelle à tracer", "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.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''.", "music.rest": "Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
"pins.analogPitch|param|frequency": "TODO", "pins.analogPitch|param|frequency": "TODO",
"pins.analogPitch|param|ms": "TODO", "pins.analogPitch|param|ms": "TODO",

View File

@ -30,7 +30,6 @@
"input.magneticForce|block": "force magnétique (µT) |%NAME", "input.magneticForce|block": "force magnétique (µT) |%NAME",
"input.onButtonPressed|block": "lorsque le button|%NAME|est pressé", "input.onButtonPressed|block": "lorsque le button|%NAME|est pressé",
"input.onGesture|block": "lorsque|%NAME", "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.onPinReleased|block": "lorsque la broche %NAME|est lachée",
"input.pinIsPressed|block": "broche %NAME| est pressée", "input.pinIsPressed|block": "broche %NAME| est pressée",
"input.rotation|block": "rotation (°)|%NAME", "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. * Provides access to basic micro:bit functionality.
*/ */
//% color=#0078D7 weight=100 //% color=#0078D7 weight=100 icon="\uf00a"
namespace basic { namespace basic {
/** /**
@ -13,7 +13,7 @@ namespace basic {
*/ */
//% help=basic/show-number //% help=basic/show-number
//% weight=96 //% 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 //% async
//% parts="ledmatrix" //% parts="ledmatrix"
void showNumber(int value, int interval = 150) { void showNumber(int value, int interval = 150) {
@ -50,7 +50,7 @@ namespace basic {
*/ */
//% help=basic/show-string //% help=basic/show-string
//% weight=87 blockGap=8 //% weight=87 blockGap=8
//% block="show|string %text" icon="\uf031" //% block="show|string %text"
//% async //% async
//% blockId=device_print_message //% blockId=device_print_message
//% parts="ledmatrix" //% parts="ledmatrix"
@ -73,7 +73,7 @@ namespace basic {
* Turn off all LEDs * Turn off all LEDs
*/ */
//% help=basic/clear-screen weight=79 //% help=basic/clear-screen weight=79
//% blockId=device_clear_display block="clear screen" icon="\uf12d" //% blockId=device_clear_display block="clear screen"
//% parts="ledmatrix" //% parts="ledmatrix"
void clearScreen() { void clearScreen() {
uBit.display.image.clear(); 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. * Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute * @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" //% blockId=device_forever block="forever" icon="\uf01e"
void forever(Action a) { void forever(Action a) {
if (a != 0) { if (a != 0) {

View File

@ -121,7 +121,7 @@ namespace control {
/** /**
* Schedules code that run in the background. * 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 //% blockId="control_in_background" block="run in background" blockGap=8
void inBackground(Action a) { void inBackground(Action a) {
runInBackground(a); runInBackground(a);

View File

@ -1,7 +1,7 @@
/** /**
* Runtime and event utilities. * Runtime and event utilities.
*/ */
//% weight=1 color="#333333" //% weight=1 color="#333333" icon="\uf233"
//% advanced=true //% advanced=true
namespace control { namespace control {
@ -31,7 +31,7 @@ namespace control {
/** /**
* If the condition is false, display msg on serial console, and panic with code 098. * 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) { if (!condition) {
console.log("ASSERTION FAILED") console.log("ASSERTION FAILED")
if (msg != null) { if (msg != null) {

View File

@ -153,13 +153,19 @@ namespace Array_ {
//% //%
int length(RefCollection *c) { return c->length(); } 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); } 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); } 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); } 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" //% block="6g"
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_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 { declare namespace input {
} }

View File

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

View File

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

View File

@ -104,10 +104,15 @@ enum class Gesture {
* Raised when a 6G shock is detected * Raised when a 6G shock is detected
*/ */
//% block="6g" //% 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 { namespace input {
/** /**
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed * 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 * @param body code to run when event is raised
*/ */
//% help=input/on-button-pressed weight=85 blockGap=8 //% 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" //% parts="buttonpair"
void onButtonPressed(Button button, Action body) { void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body); registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
@ -127,14 +132,15 @@ namespace input {
* @param body code to run when gesture is raised * @param body code to run when gesture is raised
*/ */
//% help=input/on-gesture weight=84 blockGap=8 //% 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" //% parts="accelerometer"
void onGesture(Gesture gesture, Action body) { 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); 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); 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 * @param body the code to run when the pin is pressed
*/ */
//% help=input/on-pin-pressed weight=83 //% 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) { void onPinPressed(TouchPin name, Action body) {
auto pin = getPin((int)name); auto pin = getPin((int)name);
if (!pin) return; if (!pin) return;
@ -159,7 +165,7 @@ namespace input {
* @param body the code to run when the pin is released * @param body the code to run when the pin is released
*/ */
//% help=input/on-pin-released weight=6 blockGap=8 //% help=input/on-pin-released weight=6 blockGap=8
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094" //% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true //% advanced=true
void onPinReleased(TouchPin name, Action body) { void onPinReleased(TouchPin name, Action body) {
auto pin = getPin((int)name); auto pin = getPin((int)name);
@ -194,7 +200,7 @@ namespace input {
* @param name pin used to detect the touch, eg: TouchPin.P0 * @param name pin used to detect the touch, eg: TouchPin.P0
*/ */
//% help=input/pin-is-pressed weight=58 //% 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 //% blockGap=8
bool pinIsPressed(TouchPin name) { bool pinIsPressed(TouchPin name) {
auto pin = getPin((int)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) * 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 * @param dimension TODO
*/ */
//% help=input/acceleration weight=58 icon="\uf135" //% help=input/acceleration weight=58
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 //% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
//% parts="accelerometer" //% parts="accelerometer"
int acceleration(Dimension dimension) { 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. * Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
*/ */
//% help=input/light-level weight=57 //% 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" //% parts="ledmatrix"
int lightLevel() { int lightLevel() {
return uBit.display.readLightLevel(); return uBit.display.readLightLevel();
@ -239,7 +245,7 @@ namespace input {
* Get the current compass heading in degrees. * Get the current compass heading in degrees.
*/ */
//% help=input/compass-heading //% help=input/compass-heading
//% weight=56 icon="\uf14e" //% weight=56
//% blockId=device_heading block="compass heading (°)" blockGap=8 //% blockId=device_heading block="compass heading (°)" blockGap=8
//% parts="compass" //% parts="compass"
int compassHeading() { int compassHeading() {
@ -250,7 +256,7 @@ namespace input {
/** /**
* Gets the temperature in Celsius degrees (°C). * Gets the temperature in Celsius degrees (°C).
*/ */
//% weight=55 icon="\uf06d" //% weight=55
//% help=input/temperature //% help=input/temperature
//% blockId=device_temperature block="temperature (°C)" blockGap=8 //% blockId=device_temperature block="temperature (°C)" blockGap=8
//% parts="thermometer" //% parts="thermometer"
@ -263,7 +269,7 @@ namespace input {
* @param kind TODO * @param kind TODO
*/ */
//% help=input/rotation weight=52 //% help=input/rotation weight=52
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" //% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
//% parts="accelerometer" advanced=true //% parts="accelerometer" advanced=true
int rotation(Rotation kind) { int rotation(Rotation kind) {
switch (kind) { switch (kind) {
@ -278,7 +284,7 @@ namespace input {
* @param dimension TODO * @param dimension TODO
*/ */
//% help=input/magnetic-force weight=51 //% help=input/magnetic-force weight=51
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076" //% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
//% parts="compass" //% parts="compass"
//% advanced=true //% advanced=true
int magneticForce(Dimension dimension) { int magneticForce(Dimension dimension) {
@ -298,7 +304,7 @@ namespace input {
* Gets the number of milliseconds elapsed since power on. * Gets the number of milliseconds elapsed since power on.
*/ */
//% help=input/running-time weight=50 //% help=input/running-time weight=50
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017" //% blockId=device_get_running_time block="running time (ms)"
//% advanced=true //% advanced=true
int runningTime() { int runningTime() {
return system_timer_current_time(); return system_timer_current_time();
@ -315,7 +321,7 @@ namespace input {
* @param range a value describe the maximum strengh of acceleration measured * @param range a value describe the maximum strengh of acceleration measured
*/ */
//% help=input/set-accelerometer-range //% help=input/set-accelerometer-range
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135" //% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
//% weight=5 //% weight=5
//% parts="accelerometer" //% parts="accelerometer"
//% advanced=true //% advanced=true

View File

@ -1,7 +1,7 @@
/** /**
* Events and data from sensors * Events and data from sensors
*/ */
//% color=#B4009E weight=99 //% color=#B4009E weight=99 icon="\uf192"
namespace input { namespace input {
/** /**
* Attaches code to run when the screen is facing up. * 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 // TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
}; };
//% color=3 weight=35 //% color=3 weight=35 icon="\uf205"
namespace led { namespace led {
/** /**
@ -17,7 +17,7 @@ namespace led {
* @param y TODO * @param y TODO
*/ */
//% help=led/plot weight=78 //% help=led/plot weight=78
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8 //% blockId=device_plot block="plot|x %x|y %y" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
void plot(int x, int y) { void plot(int x, int y) {
uBit.display.image.setPixelValue(x, y, 1); uBit.display.image.setPixelValue(x, y, 1);
@ -29,7 +29,7 @@ namespace led {
* @param y TODO * @param y TODO
*/ */
//% help=led/unplot weight=77 //% help=led/unplot weight=77
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8 //% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
void unplot(int x, int y) { void unplot(int x, int y) {
uBit.display.image.setPixelValue(x, y, 0); uBit.display.image.setPixelValue(x, y, 0);
@ -41,7 +41,7 @@ namespace led {
* @param y TODO * @param y TODO
*/ */
//% help=led/point weight=76 //% 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" //% parts="ledmatrix"
bool point(int x, int y) { bool point(int x, int y) {
int pix = uBit.display.image.getPixelValue(x, 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). * Get the screen brightness from 0 (off) to 255 (full bright).
*/ */
//% help=led/brightness weight=60 //% help=led/brightness weight=60
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8 //% blockId=device_get_brightness block="brightness" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true //% advanced=true
int brightness() { int brightness() {
@ -64,7 +64,7 @@ namespace led {
* @param value the brightness value, eg:255, 127, 0 * @param value the brightness value, eg:255, 127, 0
*/ */
//% help=led/set-brightness weight=59 //% help=led/set-brightness weight=59
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042" //% blockId=device_set_brightness block="set brightness %value"
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true //% advanced=true
void setBrightness(int value) { void setBrightness(int value) {
@ -75,7 +75,7 @@ namespace led {
* Cancels the current animation and clears other pending animations. * Cancels the current animation and clears other pending animations.
*/ */
//% weight=50 help=led/stop-animation //% weight=50 help=led/stop-animation
//% blockId=device_stop_animation block="stop animation" icon="\uf04d" //% blockId=device_stop_animation block="stop animation"
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true //% advanced=true
void stopAnimation() { void stopAnimation() {
@ -95,7 +95,7 @@ namespace led {
/** /**
* Turns on or off the display * 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" //% advanced=true parts="ledmatrix"
void enable(bool on) { void enable(bool on) {
if (on) uBit.display.enable(); if (on) uBit.display.enable();

View File

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

View File

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

View File

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

View File

@ -141,63 +141,373 @@ namespace pxt {
printf("RefRecord %p r=%d size=%d bytes\n", r, r->refcnt, r->getVTable()->numbytes); printf("RefRecord %p r=%d size=%d bytes\n", r, r->refcnt, r->getVTable()->numbytes);
} }
void RefCollection::push(uint32_t x) { uint32_t Segment::get(uint32_t i)
if (isRef()) incr(x); {
data.push_back(x); #ifdef DEBUG_BUILD
printf("In Segment::get index:%u\n", i);
this->print();
#endif
if (i < length)
{
if (data[i] != Segment::MissingValue)
{
return data[i];
}
error(ERR_MISSING_VALUE);
return 0;
}
error(ERR_OUT_OF_BOUNDS);
return 0;
} }
uint32_t RefCollection::getAt(int x) { void Segment::set(uint32_t i, uint32_t value)
if (in_range(x)) { {
uint32_t tmp = data.at(x); if (i < size)
if (isRef()) incr(tmp); {
data[i] = value;
}
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 missing values;
for(uint16_t i = size; i < newSize; i++)
{
tmp[i] = Segment::MissingValue;
}
//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::MissingValue;
--length;
return value;
}
error(ERR_OUT_OF_BOUNDS);
return 0;
}
//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::MissingValue;
#ifdef DEBUG_BUILD
printf("After Segment::remove index:%u\n", i);
this->print();
#endif
return ret;
}
error(ERR_OUT_OF_BOUNDS);
return 0;
}
//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 || data[i] == Segment::MissingValue)
{
return false;
}
return true;
}
bool Segment::getNextValidIndex(uint32_t i, uint32_t *result)
{
while (i < length)
{
if (data[i] != Segment::MissingValue)
{
*result = i;
#ifdef DEBUG_BUILD
printf("In Segment::getNextValidIndex result=%u\n",i);
this->print();
#endif
return true;
}
i++;
}
return false;
}
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)
{
if (head.isValidIndex(i))
{
uint32_t tmp = head.get(i);
if (isRef())
{
incr(tmp);
}
return tmp; return tmp;
} }
else { else
{
error(ERR_OUT_OF_BOUNDS); error(ERR_OUT_OF_BOUNDS);
return 0; return 0;
} }
} }
void RefCollection::removeAt(int x) { uint32_t RefCollection::removeAt(int i)
if (!in_range(x)) {
return; if (!head.isValidIndex((uint32_t)i))
{
if (isRef()) decr(data.at(x)); error(ERR_OUT_OF_BOUNDS);
data.erase(data.begin()+x); return 0;
}
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; if (isRef())
{
decr(head.get(i));
}
return head.remove(i);
} }
int RefCollection::indexOf(uint32_t x, int start) { void RefCollection::insertAt(int i, uint32_t value)
if (!in_range(start)) {
return -1; if (i < length())
{
head.insert(i, value);
if (isRef())
{
incr(value);
}
}
else
{
error(ERR_OUT_OF_BOUNDS);
}
}
if (isString()) { void RefCollection::setAt(int i, uint32_t value)
StringData *xx = (StringData*)x; {
for (uint32_t i = start; i < data.size(); ++i) { if (isRef())
StringData *ee = (StringData*)data.at(i); {
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0) if (head.isValidIndex((uint32_t)i))
return (int)i; {
decr(head.get(i));
} }
} else { incr(value);
for (uint32_t i = start; i < data.size(); ++i) }
if (data.at(i) == x) head.set(i, value);
}
int RefCollection::indexOf(uint32_t x, int start)
{
if (isString())
{
StringData *xx = (StringData*)x;
uint32_t i = start;
while(head.getNextValidIndex(start, &i))
{
StringData *ee = (StringData*)head.get(i);
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
{
return (int)i; return (int)i;
}
start = i;
}
}
else
{
uint32_t i = start;
while(head.getNextValidIndex(start, &i))
{
if (head.get(i) == x)
{
return (int)i;
}
start = i;
}
} }
return -1; return -1;
} }
int RefCollection::removeElement(uint32_t x) { int RefCollection::removeElement(uint32_t x)
{
int idx = indexOf(x, 0); int idx = indexOf(x, 0);
if (idx >= 0) { if (idx >= 0) {
removeAt(idx); removeAt(idx);
@ -239,17 +549,23 @@ namespace pxt {
void RefCollection::destroy() void RefCollection::destroy()
{ {
if (this->isRef()) if (this->isRef())
for (uint32_t i = 0; i < this->data.size(); ++i) { {
decr(this->data[i]); uint32_t start = 0;
this->data[i] = 0; uint32_t i = 0;
while(head.getNextValidIndex(start, &i))
{
decr(this->head.get(i));
start = i;
} }
this->data.resize(0); }
this->head.destroy();
delete this; delete this;
} }
void RefCollection::print() 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) {} PXT_VTABLE_CTOR(RefAction) {}

View File

@ -1,7 +1,7 @@
#ifndef __PXT_H #ifndef __PXT_H
#define __PXT_H #define __PXT_H
// #define DEBUG_MEMLEAKS 1 //#define DEBUG_MEMLEAKS 1
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
@ -38,6 +38,7 @@ namespace pxt {
ERR_OUT_OF_BOUNDS = 8, ERR_OUT_OF_BOUNDS = 8,
ERR_REF_DELETED = 7, ERR_REF_DELETED = 7,
ERR_SIZE = 9, ERR_SIZE = 9,
ERR_MISSING_VALUE = 10,
} ERROR; } ERROR;
extern const uint32_t functionsAndBytecode[]; extern const uint32_t functionsAndBytecode[];
@ -167,11 +168,53 @@ namespace pxt {
} }
}; };
class Segment {
private:
uint32_t* data;
uint16_t length;
uint16_t size;
static const uint16_t MaxSize = 0xFFFF;
static const uint32_t MissingValue = 0x80000000;
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);
//Returns true if there is a valid index greater than or equal to 'i', returns false otherwise
//If 'i' is valid returns it in 'result', if not tries to find the next valid
//index < length which is valid.
bool getNextValidIndex(uint32_t i, uint32_t *result);
bool isValidIndex(uint32_t i);
void destroy();
void print();
};
// A ref-counted collection of either primitive or ref-counted objects (String, Image, // A ref-counted collection of either primitive or ref-counted objects (String, Image,
// user-defined record, another collection) // user-defined record, another collection)
class RefCollection class RefCollection
: public RefObject : public RefObject
{ {
private:
Segment head;
public: public:
// 1 - collection of refs (need decr) // 1 - collection of refs (need decr)
// 2 - collection of strings (in fact we always have 3, never 2 alone) // 2 - collection of strings (in fact we always have 3, never 2 alone)
@ -179,23 +222,23 @@ namespace pxt {
inline bool isRef() { return getFlags() & 1; } inline bool isRef() { return getFlags() & 1; }
inline bool isString() { return getFlags() & 2; } inline bool isString() { return getFlags() & 2; }
std::vector<uint32_t> data;
RefCollection(uint16_t f); 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 destroy();
void print(); void print();
uint32_t length() { return head.getLength();}
void setLength(uint32_t newLength) { head.setLength(newLength); }
void push(uint32_t x); void push(uint32_t x);
uint32_t getAt(int x); uint32_t pop();
void removeAt(int x); uint32_t getAt(int i);
void setAt(int x, uint32_t y); 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 indexOf(uint32_t x, int start);
int removeElement(uint32_t x); int removeElement(uint32_t x);
}; };

View File

@ -37,7 +37,11 @@
"_locales/fr/core-jsdoc-strings.json", "_locales/fr/core-jsdoc-strings.json",
"_locales/fr/core-strings.json", "_locales/fr/core-strings.json",
"_locales/de/core-jsdoc-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, "public": true,
"dependencies": {}, "dependencies": {},
@ -50,4 +54,4 @@
} }
} }
} }
} }

View File

@ -34,7 +34,7 @@ enum Delimiters {
Hash = 6, Hash = 6,
}; };
//% weight=2 color=30 //% weight=2 color=30 icon="\uf287"
//% advanced=true //% advanced=true
namespace serial { namespace serial {
// note that at least one // followed by % is needed per declaration! // note that at least one // followed by % is needed per declaration!
@ -92,7 +92,10 @@ namespace serial {
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate" //% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1 //% blockExternalInputs=1
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) { 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); uBit.serial.baud((int)rate);
} }
} }

View File

@ -1,7 +1,7 @@
/** /**
* Reading and writing data over a serial connection. * Reading and writing data over a serial connection.
*/ */
//% weight=2 color=#002050 //% weight=2 color=#002050 icon="\uf287"
//% advanced=true //% advanced=true
namespace serial { namespace serial {
/** /**

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

@ -4,7 +4,7 @@
/** /**
* Creation, manipulation and display of LED images. * Creation, manipulation and display of LED images.
*/ */
//% color=#5C2D91 weight=31 //% color=#5C2D91 weight=31 icon="\uf03e"
//% advanced=true //% advanced=true
declare namespace images { declare namespace images {
@ -126,7 +126,7 @@ declare interface Image {
/** /**
* Provides access to basic micro:bit functionality. * Provides access to basic micro:bit functionality.
*/ */
//% color=#0078D7 weight=100 //% color=#0078D7 weight=100 icon="\uf00a"
declare namespace basic { declare namespace basic {
/** /**
@ -135,7 +135,7 @@ declare namespace basic {
*/ */
//% help=basic/show-number //% help=basic/show-number
//% weight=96 //% 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 //% async
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber //% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
function showNumber(value: number, interval?: number): void; function showNumber(value: number, interval?: number): void;
@ -160,7 +160,7 @@ declare namespace basic {
*/ */
//% help=basic/show-string //% help=basic/show-string
//% weight=87 blockGap=8 //% weight=87 blockGap=8
//% block="show|string %text" icon="\uf031" //% block="show|string %text"
//% async //% async
//% blockId=device_print_message //% blockId=device_print_message
//% parts="ledmatrix" interval.defl=150 shim=basic::showString //% parts="ledmatrix" interval.defl=150 shim=basic::showString
@ -170,7 +170,7 @@ declare namespace basic {
* Turn off all LEDs * Turn off all LEDs
*/ */
//% help=basic/clear-screen weight=79 //% 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 //% parts="ledmatrix" shim=basic::clearScreen
function clearScreen(): void; 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. * Repeats the code forever in the background. On each iteration, allows other codes to run.
* @param body code to execute * @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 //% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
function forever(a: () => void): void; 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 { declare namespace input {
/** /**
@ -220,7 +220,7 @@ declare namespace input {
* @param body code to run when event is raised * @param body code to run when event is raised
*/ */
//% help=input/on-button-pressed weight=85 blockGap=8 //% 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 //% parts="buttonpair" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void; function onButtonPressed(button: Button, body: () => void): void;
@ -230,7 +230,7 @@ declare namespace input {
* @param body code to run when gesture is raised * @param body code to run when gesture is raised
*/ */
//% help=input/on-gesture weight=84 blockGap=8 //% 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 //% parts="accelerometer" shim=input::onGesture
function onGesture(gesture: Gesture, body: () => void): void; 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 * @param body the code to run when the pin is pressed
*/ */
//% help=input/on-pin-pressed weight=83 //% 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; 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 * @param body the code to run when the pin is released
*/ */
//% help=input/on-pin-released weight=6 blockGap=8 //% help=input/on-pin-released weight=6 blockGap=8
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094" //% blockId=device_pin_released block="on pin %NAME|released"
//% advanced=true shim=input::onPinReleased //% advanced=true shim=input::onPinReleased
function onPinReleased(name: TouchPin, body: () => void): void; 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 * @param name pin used to detect the touch, eg: TouchPin.P0
*/ */
//% help=input/pin-is-pressed weight=58 //% 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 //% blockGap=8 shim=input::pinIsPressed
function pinIsPressed(name: TouchPin): boolean; 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) * 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 * @param dimension TODO
*/ */
//% help=input/acceleration weight=58 icon="\uf135" //% help=input/acceleration weight=58
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8 //% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
//% parts="accelerometer" shim=input::acceleration //% parts="accelerometer" shim=input::acceleration
function acceleration(dimension: Dimension): number; 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. * Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
*/ */
//% help=input/light-level weight=57 //% 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 //% parts="ledmatrix" shim=input::lightLevel
function lightLevel(): number; function lightLevel(): number;
@ -294,7 +294,7 @@ declare namespace input {
* Get the current compass heading in degrees. * Get the current compass heading in degrees.
*/ */
//% help=input/compass-heading //% help=input/compass-heading
//% weight=56 icon="\uf14e" //% weight=56
//% blockId=device_heading block="compass heading (°)" blockGap=8 //% blockId=device_heading block="compass heading (°)" blockGap=8
//% parts="compass" shim=input::compassHeading //% parts="compass" shim=input::compassHeading
function compassHeading(): number; function compassHeading(): number;
@ -302,7 +302,7 @@ declare namespace input {
/** /**
* Gets the temperature in Celsius degrees (°C). * Gets the temperature in Celsius degrees (°C).
*/ */
//% weight=55 icon="\uf06d" //% weight=55
//% help=input/temperature //% help=input/temperature
//% blockId=device_temperature block="temperature (°C)" blockGap=8 //% blockId=device_temperature block="temperature (°C)" blockGap=8
//% parts="thermometer" shim=input::temperature //% parts="thermometer" shim=input::temperature
@ -313,7 +313,7 @@ declare namespace input {
* @param kind TODO * @param kind TODO
*/ */
//% help=input/rotation weight=52 //% help=input/rotation weight=52
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197" //% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
//% parts="accelerometer" advanced=true shim=input::rotation //% parts="accelerometer" advanced=true shim=input::rotation
function rotation(kind: Rotation): number; function rotation(kind: Rotation): number;
@ -322,7 +322,7 @@ declare namespace input {
* @param dimension TODO * @param dimension TODO
*/ */
//% help=input/magnetic-force weight=51 //% help=input/magnetic-force weight=51
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076" //% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
//% parts="compass" //% parts="compass"
//% advanced=true shim=input::magneticForce //% advanced=true shim=input::magneticForce
function magneticForce(dimension: Dimension): number; function magneticForce(dimension: Dimension): number;
@ -331,7 +331,7 @@ declare namespace input {
* Gets the number of milliseconds elapsed since power on. * Gets the number of milliseconds elapsed since power on.
*/ */
//% help=input/running-time weight=50 //% help=input/running-time weight=50
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017" //% blockId=device_get_running_time block="running time (ms)"
//% advanced=true shim=input::runningTime //% advanced=true shim=input::runningTime
function runningTime(): number; function runningTime(): number;
@ -346,7 +346,7 @@ declare namespace input {
* @param range a value describe the maximum strengh of acceleration measured * @param range a value describe the maximum strengh of acceleration measured
*/ */
//% help=input/set-accelerometer-range //% help=input/set-accelerometer-range
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135" //% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
//% weight=5 //% weight=5
//% parts="accelerometer" //% parts="accelerometer"
//% advanced=true shim=input::setAccelerometerRange //% advanced=true shim=input::setAccelerometerRange
@ -362,7 +362,7 @@ declare namespace control {
/** /**
* Schedules code that run in the background. * 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 //% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
function inBackground(a: () => void): void; 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 { declare namespace led {
/** /**
@ -436,7 +436,7 @@ declare namespace led {
* @param y TODO * @param y TODO
*/ */
//% help=led/plot weight=78 //% help=led/plot weight=78
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8 //% blockId=device_plot block="plot|x %x|y %y" blockGap=8
//% parts="ledmatrix" shim=led::plot //% parts="ledmatrix" shim=led::plot
function plot(x: number, y: number): void; function plot(x: number, y: number): void;
@ -446,7 +446,7 @@ declare namespace led {
* @param y TODO * @param y TODO
*/ */
//% help=led/unplot weight=77 //% help=led/unplot weight=77
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8 //% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
//% parts="ledmatrix" shim=led::unplot //% parts="ledmatrix" shim=led::unplot
function unplot(x: number, y: number): void; function unplot(x: number, y: number): void;
@ -456,7 +456,7 @@ declare namespace led {
* @param y TODO * @param y TODO
*/ */
//% help=led/point weight=76 //% 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 //% parts="ledmatrix" shim=led::point
function point(x: number, y: number): boolean; 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). * Get the screen brightness from 0 (off) to 255 (full bright).
*/ */
//% help=led/brightness weight=60 //% help=led/brightness weight=60
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8 //% blockId=device_get_brightness block="brightness" blockGap=8
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true shim=led::brightness //% advanced=true shim=led::brightness
function brightness(): number; function brightness(): number;
@ -474,7 +474,7 @@ declare namespace led {
* @param value the brightness value, eg:255, 127, 0 * @param value the brightness value, eg:255, 127, 0
*/ */
//% help=led/set-brightness weight=59 //% help=led/set-brightness weight=59
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042" //% blockId=device_set_brightness block="set brightness %value"
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true shim=led::setBrightness //% advanced=true shim=led::setBrightness
function setBrightness(value: number): void; function setBrightness(value: number): void;
@ -483,7 +483,7 @@ declare namespace led {
* Cancels the current animation and clears other pending animations. * Cancels the current animation and clears other pending animations.
*/ */
//% weight=50 help=led/stop-animation //% weight=50 help=led/stop-animation
//% blockId=device_stop_animation block="stop animation" icon="\uf04d" //% blockId=device_stop_animation block="stop animation"
//% parts="ledmatrix" //% parts="ledmatrix"
//% advanced=true shim=led::stopAnimation //% advanced=true shim=led::stopAnimation
function stopAnimation(): void; function stopAnimation(): void;
@ -499,7 +499,7 @@ declare namespace led {
/** /**
* Turns on or off the display * 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 //% advanced=true parts="ledmatrix" shim=led::enable
function enable(on: boolean): void; function enable(on: boolean): void;
@ -658,7 +658,7 @@ declare namespace pins {
//% weight=2 color=30 //% weight=2 color=30 icon="\uf287"
//% advanced=true //% advanced=true
declare namespace serial { declare namespace serial {

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", "README.md",
"enums.d.ts", "enums.d.ts",
"shims.d.ts", "shims.d.ts",
"devices.cpp" "devices.cpp",
"_locales/fr/devices-jsdoc-strings.json"
], ],
"public": true, "public": true,
"dependencies": { "dependencies": {
@ -13,4 +14,4 @@
"bluetooth": "file:../bluetooth" "bluetooth": "file:../bluetooth"
}, },
"installedVersion": "ljipgq" "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", "shims.d.ts",
"enums.d.ts", "enums.d.ts",
"radio.cpp", "radio.cpp",
"radio.ts" "radio.ts",
"_locales/de/radio-strings.json",
"_locales/de/radio-jsdoc-strings.json"
], ],
"public": true, "public": true,
"dependencies": { "dependencies": {

View File

@ -24,7 +24,7 @@ using namespace pxt;
// payload: string length (9), string (10 ... 28) // payload: string length (9), string (10 ... 28)
#define PACKET_TYPE_STRING 2 #define PACKET_TYPE_STRING 2
//% color=270 weight=34 //% color=270 weight=96 icon="\uf012"
namespace radio { namespace radio {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------

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