Compare commits
82 Commits
Author | SHA1 | Date | |
---|---|---|---|
4215574a7c | |||
da9d986a3e | |||
7481b9c24c | |||
de5def8dde | |||
dd011b977a | |||
20d0dd91ad | |||
825c6d57e7 | |||
b3edb81d3c | |||
78089da134 | |||
3aef765d35 | |||
f4727f12c9 | |||
a36cb65aa5 | |||
3b16e59ee1 | |||
f2c43c74ac | |||
1c4c93dc60 | |||
d73847bfba | |||
4e46682489 | |||
ab7aa00747 | |||
2bebb6056d | |||
22046c417c | |||
dc8afa6d45 | |||
22e2ab5ad9 | |||
f365726a8e | |||
e329b3bd2e | |||
d7b709e97b | |||
9714ec46e9 | |||
20ef54f565 | |||
554df0bce9 | |||
6c89dddef6 | |||
23f91895f7 | |||
3f83cda087 | |||
7e79635413 | |||
56e1cf91ac | |||
f9f96f33f0 | |||
0b33073be1 | |||
65594842fc | |||
c6ed665f84 | |||
79462deb24 | |||
5c05f3e241 | |||
4f7dd75fbe | |||
338e507b51 | |||
601231a5dc | |||
f0850336e5 | |||
a6b2187ec5 | |||
28ae4f4230 | |||
09933b6a8d | |||
45bb6e7cb3 | |||
33c234a87e | |||
e9aa343d67 | |||
d83039430c | |||
5b2e877aef | |||
c5b28f5b8e | |||
e765021bf9 | |||
dbcd9e535c | |||
cff88d67ad | |||
3f241e8bc9 | |||
69c3d2d249 | |||
bc04d30595 | |||
63a26835b1 | |||
79113115e0 | |||
573ed7f6f2 | |||
61da1032d6 | |||
36d455c693 | |||
42c766b6d7 | |||
6f00384891 | |||
8440f7c763 | |||
8a8e864f99 | |||
7a3402b782 | |||
5e9a5b29f4 | |||
aff9d1ee60 | |||
8add7e8efb | |||
e7dfd0531b | |||
d2b1f70ce2 | |||
28b28d0b52 | |||
0ee2b285c0 | |||
d5cb085264 | |||
c055a5d329 | |||
8fe8b78f4c | |||
f627f125c0 | |||
7d3254477a | |||
3149ed4c1d | |||
baeafcdebe |
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,6 +7,9 @@ typings
|
||||
tmp
|
||||
temp
|
||||
projects/**
|
||||
clients/win10/app/AppPackages
|
||||
clients/win10/app/BundlePackages
|
||||
clients/win10/app/BundleArtifacts
|
||||
clients/win10/app/bin
|
||||
clients/win10/app/bld
|
||||
clients/win10/*.opendb
|
||||
|
@ -4,6 +4,9 @@ node_js:
|
||||
script:
|
||||
- "node node_modules/pxt-core/built/pxt.js travis"
|
||||
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js run)"
|
||||
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js run)"
|
||||
- "(cd libs/lang-test0; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "(cd libs/lang-test1; node ../../node_modules/pxt-core/built/pxt.js test)"
|
||||
- "node node_modules/pxt-core/built/pxt.js testdir tests"
|
||||
- "node node_modules/pxt-core/built/pxt.js uploaddoc"
|
||||
- "(cd libs/hello; node ../../node_modules/pxt-core/built/pxt.js testconv https://az851932.vo.msecnd.net/files/td-converter-tests-v0.json)"
|
||||
|
32
README.md
32
README.md
@ -9,12 +9,19 @@ PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt
|
||||
|
||||
## Local server
|
||||
|
||||
The local server allows to run the editor and the documentation from your computer.
|
||||
|
||||
### Setup
|
||||
|
||||
The following commands are a 1-time setup after synching the repo on your machine.
|
||||
|
||||
* clone this repo to your computer
|
||||
* install the PXT command line
|
||||
* if not yet installed, install [Node.js 4.4.5 or higher](https://nodejs.org/en/download/)
|
||||
* [clone this repo](https://help.github.com/articles/cloning-a-repository/) to your computer and go in the project folder
|
||||
```
|
||||
git clone https://github.com/microsoft/pxt-microbit
|
||||
cd pxt-microbit
|
||||
```
|
||||
* install the PXT command line (add ``sudo`` for Mac/Linux shells).
|
||||
```
|
||||
npm install -g pxt
|
||||
```
|
||||
@ -37,7 +44,9 @@ If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt``
|
||||
pxt serve -yt
|
||||
```
|
||||
|
||||
To make sure you're running the latest tools, run (add ``sudo`` for Mac/Linux shells)
|
||||
## Updates
|
||||
|
||||
To update your PXT version and make sure you're running the latest tools, run (add ``sudo`` for Mac/Linux shells)
|
||||
```
|
||||
pxt update
|
||||
```
|
||||
@ -54,6 +63,23 @@ that wraps ``codethemicrobit.com`` and provides additional features.
|
||||
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
|
||||
* open the ``win10/app.sln`` solution and launch the ``codethemicrobit`` project.
|
||||
|
||||
## Testing
|
||||
|
||||
The build automatically runs the following:
|
||||
|
||||
* make sure the built-in packages compile
|
||||
* `pxt run` in `libs/lang-test*` - this will run the test in command line runner;
|
||||
there is a number of asserts in both of these
|
||||
* `pxt testdir` in `tests` - this makes sure all the files compile and generates .hex files
|
||||
* run the TD->TS converter on a number of test scripts from `microbit.co.uk` and make sure the results compile
|
||||
|
||||
To test something on the device:
|
||||
|
||||
* do a `pxt deploy` in `libs/lang-test*` - they should show `1` or `2` on the screen (and not unhappy face)
|
||||
* run `pxt testdir` in `tests` and deploy some of the hex files from `tests/built`
|
||||
|
||||
The `lang-test0` source comes from the `pxt-core` package. It's also tested with `pxt run` there.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
||||
|
@ -20,22 +20,18 @@
|
||||
<ProjectConfiguration Include="Release|AnyCPU">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>AnyCPU</Platform>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM</Platform>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x86">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x86</Platform>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
BIN
clients/win10/store/desktopblocks1366x768.png
Normal file
BIN
clients/win10/store/desktopblocks1366x768.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 172 KiB |
BIN
clients/win10/store/desktopjavascript1366x768.png
Normal file
BIN
clients/win10/store/desktopjavascript1366x768.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 121 KiB |
BIN
clients/win10/store/mobileblocks480x800.png
Normal file
BIN
clients/win10/store/mobileblocks480x800.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
@ -28,11 +28,12 @@ export function deployCoreAsync(res: ts.pxt.CompileResult) {
|
||||
|
||||
function getBitDrivesAsync(): Promise<string[]> {
|
||||
if (process.platform == "win32") {
|
||||
let rx = new RegExp("^([A-Z]:).* " + pxt.appTarget.compile.deployDrives)
|
||||
return execAsync("wmic PATH Win32_LogicalDisk get DeviceID, VolumeName, FileSystem")
|
||||
.then(buf => {
|
||||
let res: string[] = []
|
||||
buf.toString("utf8").split(/\n/).forEach(ln => {
|
||||
let m = /^([A-Z]:).* MICROBIT/.exec(ln)
|
||||
let m = rx.exec(ln)
|
||||
if (m) {
|
||||
res.push(m[1] + "/")
|
||||
}
|
||||
@ -41,8 +42,9 @@ function getBitDrivesAsync(): Promise<string[]> {
|
||||
})
|
||||
}
|
||||
else if (process.platform == "darwin") {
|
||||
let rx = new RegExp(pxt.appTarget.compile.deployDrives)
|
||||
return readDirAsync("/Volumes")
|
||||
.then(lst => lst.filter(s => /MICROBIT/.test(s)).map(s => "/Volumes/" + s + "/"))
|
||||
.then(lst => lst.filter(s => rx.test(s)).map(s => "/Volumes/" + s + "/"))
|
||||
} else {
|
||||
return Promise.resolve([])
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ if (led.point(1,1) && led.point(2,2)) {
|
||||
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
|
||||
|
||||
```blocks
|
||||
let x = math.random(5)
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
|
@ -27,5 +27,10 @@ Visit the cards below to starting programming JavaScript and TypeScript with the
|
||||
},{
|
||||
"name": "Classes",
|
||||
"url": "/js/classes"
|
||||
}]
|
||||
},{
|
||||
"name": "FAQ",
|
||||
"url": "/js/faq"
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
58
docs/js/faq.md
Normal file
58
docs/js/faq.md
Normal file
@ -0,0 +1,58 @@
|
||||
# Frequently asked questions
|
||||
|
||||
# What is the language supported for the micro:bit?
|
||||
|
||||
For the micro:bit, we support a "static" subset of TypeScript (itself a superset of JavaScript):
|
||||
|
||||
## Supported language features
|
||||
|
||||
* variables with `let`, `const`, and `var`
|
||||
* functions with lexical scoping and recursion
|
||||
* top-level code in the file; hello world really is `console.log("Hello world")`
|
||||
* `if ... else if ... else` statements
|
||||
* `while` and `do ... while` loops
|
||||
* `for(;;)` loops (see below about `for ... in/of`)
|
||||
* `break/continue`; also with labeled loops
|
||||
* `switch` statement (on numbers only)
|
||||
* `debugger` statement for breakpoints
|
||||
* conditional operator `? :`; lazy boolean operators
|
||||
* namespaces (a form of modules)
|
||||
* all arithmetic operators (including bitwise operators); note that in microcontroller targets
|
||||
all arithmetic is performed on integers, also when simulating in the browser
|
||||
* strings (with a few common methods)
|
||||
* [string templates](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) (`` `x is ${x}` ``)
|
||||
* arrow functions `() => ...`
|
||||
* classes with fields, methods and constructors; `new` keyword
|
||||
* array literals `[1, 2, 3]`
|
||||
* enums
|
||||
|
||||
## Unsupported language features
|
||||
|
||||
We generally stay away from the more dynamic parts of JavaScript.
|
||||
Things you may miss and we may implement:
|
||||
|
||||
* exceptions (`throw`, `try ... catch`, `try ... finally`)
|
||||
* `for ... of` statements
|
||||
* object literals `{ foo: 1, bar: "two" }`
|
||||
* method-like properties (get/set accessors)
|
||||
* class inheritance
|
||||
|
||||
For JS-only targets we may implement the following:
|
||||
|
||||
* regular expressions
|
||||
* classes implementing interfaces
|
||||
|
||||
Things that we are not very likely to implement:
|
||||
|
||||
* file-based modules (`import * from ...`, `module.exports` etc); we do support namespaces
|
||||
* spread operator
|
||||
* `yield` expression and ``function*``
|
||||
* `await` expression and `async function`
|
||||
* `typeof` expression
|
||||
* tagged templates ``tag `text ${expression} more text` ``; regular templates are supported
|
||||
* binding with arrays or objects: `let [a, b] = ...; let { x, y } = ...`
|
||||
* `with` statement
|
||||
* `eval`
|
||||
* `delete` statement
|
||||
* `for ... in` statements
|
||||
* JSX (HTML as part of JavaScript)
|
@ -35,7 +35,7 @@ basic.showNumber(1);
|
||||
basic.showNumber(2);
|
||||
```
|
||||
|
||||
## The empty statement
|
||||
### The empty statement
|
||||
|
||||
In JavaScript, there is the concept of an *empty statement*, which is whitespace followed by
|
||||
a semicolon in the context where a statement is expected.
|
||||
|
@ -5,7 +5,7 @@
|
||||
Your beginning code should look like this:
|
||||
|
||||
```blocks
|
||||
let coll = (<string[]>[])
|
||||
let coll: string[] = []
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
@ -27,7 +27,7 @@ game.startCountdown(30000)
|
||||
Let's add more words for the player to act out! But first, we need to increase the time in one round to give the player more time get through all the words. Let's change the `game->start countdown` statement.
|
||||
|
||||
```blocks
|
||||
let coll = (<string[]>[])
|
||||
let coll: string[] = []
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
@ -52,7 +52,8 @@ game.startCountdown(60000)
|
||||
Now let's add 5 more words to our list of charade words. Right above the the line `word:=coll->at(index)` add 5 lines that say `coll->add("")`. In this example, we will add the words **bicycle, telephone, sun, car, and ant** but you can add whatever words you like.
|
||||
|
||||
```blocks
|
||||
let coll.push("puppy")
|
||||
let coll: string[] = []
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
coll.push("cat")
|
||||
|
@ -19,7 +19,7 @@ A 'collection' is a group of variables of the same type stored together. A 'coll
|
||||
## 2. Consider the following lines of code.
|
||||
|
||||
```blocks
|
||||
let coll = (<string[]>[])
|
||||
let coll: string[] = []
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
```
|
||||
@ -35,7 +35,7 @@ basic.showString(coll[0], 150)
|
||||
## 3. Consider the following lines of code.
|
||||
|
||||
```blocks
|
||||
let coll = (<string[]>[])
|
||||
let coll: string[] = []
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("cat")
|
||||
@ -52,7 +52,7 @@ basic.showString(coll[2], 150)
|
||||
## 4. Consider the following line of code.
|
||||
|
||||
```blocks
|
||||
let coll = (<string[]>[])
|
||||
let coll: string[] = []
|
||||
```
|
||||
|
||||
Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
|
||||
@ -60,7 +60,8 @@ Write the five (5) lines of code that will add the following five words to `data
|
||||
<br/>
|
||||
|
||||
```blocks
|
||||
let coll.push("puppy")
|
||||
let coll: string[] = []
|
||||
coll.push("puppy")
|
||||
coll.push("clock")
|
||||
coll.push("night")
|
||||
coll.push("cat")
|
||||
|
@ -211,7 +211,7 @@ Let's setup the logic for the food and the ghost to be in different quadrants. F
|
||||
let hero = game.createSprite(2, 2);
|
||||
let food = game.createSprite(4, 4);
|
||||
let ghost = game.createSprite(0, 0);
|
||||
let ghost.change(LedSpriteProperty.Blink, 100);
|
||||
ghost.change(LedSpriteProperty.Blink, 100);
|
||||
food = led.brightness() == 8;
|
||||
while (true) {
|
||||
basic.pause(400);
|
||||
@ -265,7 +265,7 @@ while (true) {
|
||||
}
|
||||
|
||||
}
|
||||
0.set(LedSpriteProperty.X, 4);
|
||||
ghost.set(LedSpriteProperty.X, 4);
|
||||
|
||||
|
||||
```
|
||||
|
@ -148,12 +148,6 @@ Trim any leftover fabric, threads or tape.
|
||||
|
||||
Your watch is ready!
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/projects/rock-paper-scissors)!
|
||||
|
||||
### ~
|
||||
|
||||
### Acknowledgements
|
||||
|
||||
Artistic design by Melinda Hoeneisen.
|
||||
|
@ -22,15 +22,18 @@ control.inBackground(() => {
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
|
||||
```namespaces
|
||||
devices.tellCameraTo(MesCameraEvent.TakePhoto);
|
||||
bluetooth.onBluetoothConnected(() => {});
|
||||
```
|
||||
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
microbit-bluetooth
|
||||
```
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[basic](/reference/basic), [input](/reference/input), [music](/reference/music), [led](/reference/led), [Math](/reference/Math), [String](/reference/String), [game](/reference/game), [images](/reference/images), [pins](/reference/pins), [serial](/reference/serial), [control](/reference/control), [radio](/reference/radio), [devices](/reference/devices), [bluetooth](/reference/bluetooth)
|
||||
|
@ -3,3 +3,7 @@
|
||||
```cards
|
||||
String.fromCharCode(0);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[fromCharCode](/reference//math/string-from-char-code)
|
||||
|
@ -32,3 +32,7 @@ basic.showAnimation(`
|
||||
. . . . .
|
||||
`);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[showNumber](/reference/basic/show-number), [showLeds](/reference/basic/show-leds), [showString](/reference/basic/show-string), [clearScreen](/reference/basic/clear-screen), [forever](/reference/basic/forever), [pause](/reference/basic/pause), [plotLeds](/reference/basic/plot-leds), [showAnimation](/reference/basic/show-animation)
|
||||
|
@ -21,4 +21,8 @@ bluetooth.onBluetoothDisconnected(() => {
|
||||
|
||||
```package
|
||||
microbit-bluetooth
|
||||
```
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[startAccelerometerService](/reference/bluetooth/start-accelerometer-service), [startButtonService](/reference/bluetooth/start-button-service), [startIOPinService](/reference/bluetooth/start-io-pin-service), [startLEDService](/reference/bluetooth/start-led-service), [startMagnetometerService](/reference/bluetooth/start-magnetometer-service), [startTemperatureService](/reference/bluetooth/start-temperature-service), [uartRead](/reference/bluetooth/uart-read), [uartWrite](/reference/bluetooth/uart-write), [onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected), [onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected)
|
||||
|
@ -8,3 +8,7 @@ control.inBackground(() => {
|
||||
});
|
||||
control.reset();
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[inBackground](/reference/control/in-background), [reset](/reference/control/reset)
|
||||
|
@ -17,3 +17,11 @@ devices.onSignalStrengthChanged(() => {
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
```package
|
||||
microbit-devices
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[tellCameraTo](/reference/devices/tell-camera-to), [tellRemoteControlTo](/reference/devices/tell-remote-control-to), [raiseAlertTo](/reference/devices/raise-alert-to), [onNotified](/reference/devices/on-notified), [onGamepadButton](/reference/devices/on-gamepad-button), [signalStrength](/reference/devices/signal-strength), [onSignalStrengthChanged](/reference/devices/on-signal-strength-changed)
|
||||
|
@ -9,3 +9,7 @@ game.startCountdown(10000);
|
||||
game.gameOver();
|
||||
game.setScore(0);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[addScore](/reference/game/add-score), [score](/reference/game/score), [startCountdown](/reference/game/start-countdown), [gameOver](/reference/game/game-over), [setScore](/reference/game/set-score)
|
||||
|
@ -1,148 +0,0 @@
|
||||
# Game Library
|
||||
|
||||
The game library supports simple single-player time-based games. The player has a **sprite**, number of **lives** and a **score**. The game has a sprite, number of **levels** and a **countdown clock**. The general goal of a game will be to move the sprite and achieve a top score before time runs out or the number of lives goes to zero.
|
||||
|
||||
The code below shows a simple game where the user gets to press the button ``A`` as much times as possible in 10 seconds.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
game.addScore(1)
|
||||
})
|
||||
game.startCountdown(10000)
|
||||
```
|
||||
|
||||
### [Create sprite](/reference/game/create-sprite)
|
||||
|
||||
Create sprite with x, y coordinates and returns a LED Sprite. Create a new LED sprite.
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function createSprite(x: number, y: number) : micro_bitSprites.LedSprite
|
||||
```
|
||||
|
||||
### [Move](/reference/game/move)
|
||||
|
||||
Sprite move by a certain number
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function move(_this: micro_bitSprites.LedSprite, leds: number)
|
||||
```
|
||||
|
||||
### [Turn](/reference/game/turn)
|
||||
|
||||
Rotates a sprite to the right by a certain number of degrees
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function turnRight(_this: micro_bitSprites.LedSprite, degrees: number)
|
||||
```
|
||||
|
||||
Rotates a sprite to the left by a certain number of degrees
|
||||
|
||||
```
|
||||
export function turnLeft(_this: micro_bitSprites.LedSprite, degrees: number)
|
||||
```
|
||||
|
||||
### [Change](/reference/game/change)
|
||||
|
||||
Sprite will change the x position by this number
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function changeXBy(_this: micro_bitSprites.LedSprite, x: number)
|
||||
```
|
||||
|
||||
Sprite will change the y position by this number
|
||||
|
||||
```
|
||||
export function changeYBy(_this: micro_bitSprites.LedSprite, y: number)
|
||||
```
|
||||
|
||||
### [Set](/reference/game/set)
|
||||
|
||||
Sprite will change the x position by this number
|
||||
|
||||
```
|
||||
export function setX(_this: micro_bitSprites.LedSprite, x: number)
|
||||
```
|
||||
|
||||
Sprite will change the y position by this number
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function changeYBy(_this: micro_bitSprites.LedSprite, y: number)
|
||||
```
|
||||
|
||||
### [If on edge, bounce](/reference/game/if-on-edge-bounce)
|
||||
|
||||
Sprite - If the sprite is on the edge, the sprite will bounce
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function ifOnEdgeBounce(_this: micro_bitSprites.LedSprite)
|
||||
```
|
||||
|
||||
### [Change score by](/reference/game/change-score-by)
|
||||
|
||||
When a player achieves a goal, you can increase the game score
|
||||
|
||||
* add score points to the current score
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function addScore(points: number)
|
||||
```
|
||||
|
||||
### [Score](/reference/game/score)
|
||||
|
||||
* set the current score to a particular value.
|
||||
|
||||
```
|
||||
export function setScore(value: number)
|
||||
```
|
||||
|
||||
* get the current score value
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function score() : number
|
||||
```
|
||||
|
||||
### [Countdown](/reference/game/start-countdown)
|
||||
|
||||
If your game has a time limit, you can start a countdown in which case `game->current time` returns the remaining time.
|
||||
|
||||
* start a countdown with the maximum duration of the game in milliseconds.
|
||||
|
||||

|
||||
|
||||
```
|
||||
export function startCountdown(ms: number)
|
||||
```
|
||||
|
||||
### [Game over](/reference/game/game-over)
|
||||
|
||||
If the `life` reaches zero or the time expires (see countdown), the game enters the **game over** mode. When the game is over, `game->is running` returns false
|
||||
|
||||
* check if the game still running.
|
||||
|
||||
```
|
||||
let running = game.isRunning()
|
||||
```
|
||||
|
||||
You can also end the game by calling the `game -> game over` function:
|
||||
|
||||

|
||||
|
||||
```
|
||||
game.gameOver()
|
||||
```
|
@ -18,3 +18,7 @@ images.createBigImage(`
|
||||
. . . . .
|
||||
`);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[createImage](/reference/images/create-image), [createBigImage](/reference/images/create-big-image)
|
||||
|
@ -16,7 +16,7 @@ export function showFrame(img: micro_bit.Image, frame: number)
|
||||
|
||||
### Difference from `plot frame`
|
||||
|
||||
The `show frame` function is the same as [plot frame](/reference/image/plot-frame), but contains a built-in delay after the LED screen has been updated (whereas `plot frame` has no built-in delay)
|
||||
The `show frame` function is the same as [plot frame](/reference/images/plot-frame), but contains a built-in delay after the LED screen has been updated (whereas `plot frame` has no built-in delay)
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -14,6 +14,7 @@ input.onPinPressed(TouchPin.P0, () => {
|
||||
});
|
||||
input.buttonIsPressed(Button.A);
|
||||
input.compassHeading();
|
||||
input.pinIsPressed(TouchPin.P0);
|
||||
input.temperature();
|
||||
input.acceleration(Dimension.X);
|
||||
input.lightLevel();
|
||||
@ -21,7 +22,6 @@ input.rotation(Rotation.Pitch);
|
||||
input.magneticForce(Dimension.X);
|
||||
input.runningTime();
|
||||
input.setAccelerometerRange(AcceleratorRange.OneG);
|
||||
input.pinIsPressed(TouchPin.P0);
|
||||
input.calibrate();
|
||||
input.onLogoDown(() => {
|
||||
|
||||
@ -39,3 +39,7 @@ input.onShake(() => {
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[onButtonPressed](/reference/input/on-button-pressed), [onGesture](/reference/input/on-gesture), [onPinPressed](/reference/input/on-pin-pressed), [buttonIsPressed](/reference/input/button-is-pressed), [compassHeading](/reference/input/compass-heading), [pinIsPressed](/reference/input/pin-is-pressed), [temperature](/reference/input/temperature), [acceleration](/reference/input/acceleration), [lightLevel](/reference/input/light-level), [rotation](/reference//input/rotation), [magneticForce](/reference/input/magnetic-force), [runningTime](/reference/input/running-time), [setAccelerometerRange](/reference/input/set-accelerometer-range), [calibrate](/reference/input/calibrate), [onLogoDown](/reference/input/on-logo-down), [onLogoUp](/reference/input/on-logo-up), [onScreenDown](/reference/input/on-screen-down), [onScreenUp](/reference/input/on-screen-up), [onShake](/reference/input/on-shake)
|
||||
|
48
docs/reference/input/on-pin-released.md
Normal file
48
docs/reference/input/on-pin-released.md
Normal file
@ -0,0 +1,48 @@
|
||||
# On Pin Released
|
||||
|
||||
Start an [event handler](/reference/event-handler) (part of the
|
||||
program that will run when something happens, like when a button is
|
||||
pressed). This handler works when you release pin `0`, `1`, or `2`
|
||||
together with `GND`. When you are using this function in a web
|
||||
browser, click and release the pins on the screen instead of the ones on the BBC
|
||||
micro:bit.
|
||||
|
||||
If you hold the `GND` pin with one hand and touch pin `0`, `1`, or `2`
|
||||
with the other, a very small (safe) amount of electricity will flow
|
||||
through your body and back into the micro:bit. This is called
|
||||
**completing a circuit**. It's like you're a big wire!
|
||||
|
||||
```sig
|
||||
input.onPinReleased(TouchPin.P0, () => {
|
||||
})
|
||||
```
|
||||
|
||||
## ~hint
|
||||
|
||||
This function works best when the BBC micro:bit is using batteries for power,
|
||||
instead of the USB cable.
|
||||
|
||||
## ~
|
||||
|
||||
## Parameters
|
||||
|
||||
* ``name`` means the pin that is being released, either `P0`, `P1`, or `P2`
|
||||
|
||||
### Example: pin pressed counter
|
||||
|
||||
This program counts how many times you release the `P0` pin.
|
||||
Every time you release the pin, the program shows the number of times on the screen.
|
||||
|
||||
```blocks
|
||||
let count = 0
|
||||
basic.showNumber(count, 100)
|
||||
input.onPinReleased(TouchPin.P0, () => {
|
||||
count = count + 1
|
||||
basic.showNumber(count, 100)
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
[BBC micro:bit pins](/device/pins), [pin is pressed](/reference/input/pin-is-pressed), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
|
||||
|
@ -18,3 +18,7 @@ led.toggle(0, 0);
|
||||
led.toggleAll();
|
||||
led.setDisplayMode(DisplayMode.BackAndWhite);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[plot](/reference/led/plot), [unplot](/reference/led/unplot), [point](/reference/led/point), [brightness](/reference/led/brightness), [setBrightness](/reference/led/set-brightness), [stopAnimation](/reference/led/stop-animation), [plotBarGraph](/reference//led/plot-bar-graph), [fadeIn](/reference/led/fade-in), [fadeOut](/reference/led/fade-out), [plotAll](/reference/led/plot-all), [screenshot](/reference/led/screenshot), [toggle](/reference/led/toggle), [toggleAll](/reference/led/toggle-all), [setDisplayMode](/reference//led/set-display-mode)
|
||||
|
@ -3,11 +3,11 @@
|
||||
Display an [Image](/reference/images/image) on the BBC micro:bit's [LED screen](/device/screen). NOTE: `basic -> plot image` has been replaced by `basic -> show leds`.
|
||||
|
||||
```sig
|
||||
basic.plotLeds(`
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
# ; . . #
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
```
|
||||
@ -16,14 +16,14 @@ basic.plotLeds(`
|
||||
|
||||
* leds - a series of LED on/off states that form an image (see steps below)
|
||||
|
||||
### Example: simley
|
||||
### Example: smiley
|
||||
|
||||
```blocks
|
||||
basic.plotLeds(`
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
# ; . . #
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
```
|
||||
|
@ -9,14 +9,24 @@ led.stopAnimation()
|
||||
|
||||
### Example
|
||||
|
||||
This program...
|
||||
This program sets up the ``stop animation`` part of the program,
|
||||
and then shows a string that you can stop with button ``B``.
|
||||
|
||||
```blocks
|
||||
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
led.stopAnimation();
|
||||
});
|
||||
'```
|
||||
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");
|
||||
```
|
||||
|
||||
### ~hint
|
||||
|
||||
It's important to set up ``stop animation`` before showing the
|
||||
animation, so the ``stop animation`` part of the program will be ready
|
||||
to go.
|
||||
|
||||
### ~
|
||||
|
||||
### See Also
|
||||
|
||||
|
||||
[show animation](/reference/basic/show-animation)
|
||||
|
@ -12,3 +12,7 @@ music.tempo();
|
||||
music.changeTempoBy(20);
|
||||
music.setTempo(120);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[playTone](/reference/music/play-tone), [ringTone](/reference/music/ring-tone), [rest](/reference/music/rest), [noteFrequency](/reference/music/note-frequency), [beat](/reference/music/beat), [tempo](/reference/music/tempo), [changeTempoBy](/reference/music/change-tempo), [setTempo](/reference/music/set-tempo)
|
||||
|
@ -21,3 +21,7 @@ pins.setPull(DigitalPin.P0, PinPullMode.PullDown);
|
||||
pins.analogPitch(0, 0);
|
||||
pins.analogSetPitchPin(AnalogPin.P0);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[digitalReadPin](/reference/pins/digital-read-pin), [digitalWritePin](/reference/pins/digital-write-pin), [analogReadPin](/reference/pins/analog-read-pin), [analogWritePin](/reference/pins/analog-write-pin), [analogSetPeriod](/reference/pins/analog-set-period), [map](/reference/pins/map), [onPulsed](/reference/pins/on-pulsed), [pulseDuration](/reference/pins/pulse-duration), [servoWritePin](/reference/pins/servo-write-pin), [servoSetPulse](/reference/pins/serial-set-pulse), [i2cReadNumber](/reference/pins/i2c-read-number), [i2cWriteNumber](/reference/pins/i2c-write-number), [setPull](/reference/pins/set-pull), [analogPitch](/reference/pins/analog-pitch), [analogSetPitchPin](/reference/pins/analog-set-pitch)
|
||||
|
@ -14,7 +14,15 @@ radio.receivedNumberAt(0);
|
||||
radio.receiveString();
|
||||
radio.receivedSignalStrength();
|
||||
radio.setGroup(0);
|
||||
radio.setTransmitPower(0);
|
||||
radio.setTransmitPower(7);
|
||||
radio.setTransmitSerialNumber(false);
|
||||
radio.writeValueToSerial();
|
||||
radio.setTransmitSerialNumber(true);
|
||||
```
|
||||
|
||||
```package
|
||||
microbit-radio
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[sendNumber](/reference/radio/send-number), [sendValue](/reference/radio/send-value), [sendString](/reference/radio/send-string), [onDataReceived](/reference/radio/on-data-received), [receiveNumber](/reference/radio/receive-number), [receivedNumberAt](/reference/radio/received-number-at), [receiveString](/reference/radio/receive-string), [receivedSignalStrength](/reference/radio/received-signal-strength), [setGroup](/reference/radio/set-group), [setTransmitPower](/reference/radio/set-transmit-power), [setTransmitSerialNumber](/reference/radio/set-transmit-serial-number), [writeValueToSerial](/reference/radio/write-value-to-serial)
|
||||
|
@ -1,18 +1,26 @@
|
||||
# Write Value To Serial
|
||||
|
||||
Writes the full data received data via ``radio`` to serial in JSON format.
|
||||
|
||||
**Note** - This method only works for [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value). It does not work for [send string](/reference/radio/send-string) (although a string can be sent with [send value](/reference/radio/send-value)).
|
||||
Writes the data received by ``radio`` to serial in JSON format.
|
||||
|
||||
```sig
|
||||
radio.writeValueToSerial();
|
||||
```
|
||||
|
||||
## Data received format
|
||||
The format for received data printed to serial is as follows
|
||||
- [send number](/reference/radio/send-number) - ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused}```
|
||||
- [send value](/reference/radio/send-number) - ```{v:Value,t:MicrobitTimeAlive,s:Unused,n:"Name"}```
|
||||
- [send string](/reference/radio/send-string) - ```{}``` (currently unavailable)
|
||||
### ~hint
|
||||
|
||||
This method only works for [send number](/reference/radio/send-number)
|
||||
and [send value](/reference/radio/send-value). It does not work for
|
||||
[send string](/reference/radio/send-string), although you can send a
|
||||
string as part of [send value](/reference/radio/send-value).
|
||||
|
||||
### ~
|
||||
|
||||
### Data received format
|
||||
|
||||
The format for received data printed to serial is as follows:
|
||||
|
||||
- [send number](/reference/radio/send-number): ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused}```
|
||||
- [send value](/reference/radio/send-value): ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused,n:"Name"}```
|
||||
|
||||
### Simulator
|
||||
|
||||
@ -20,7 +28,9 @@ This function only works on the micro:bit, not in browsers.
|
||||
|
||||
### Examples
|
||||
|
||||
When ```radio``` data is received (after pressing A button on 2nd micro:bit), output temperature data to serial.
|
||||
When ```radio``` data is received (after pressing the ``A`` button on
|
||||
the second micro:bit), this program sends temperature data to
|
||||
serial.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
@ -30,9 +40,11 @@ radio.onDataReceived(() => {
|
||||
radio.writeValueToSerial();
|
||||
});
|
||||
```
|
||||
Example output to serial when A button pressed:
|
||||
Sample output to serial when ``A`` button pressed:
|
||||
```{v:27,t:323,s:0}```
|
||||
|
||||
### See also
|
||||
|
||||
[send number](/reference/radio/send-number), [send value](/reference/radio/send-number), [on data received](/reference/radio/on-data-received)
|
||||
[send number](/reference/radio/send-number),
|
||||
[send value](/reference/radio/send-value),
|
||||
[on data received](/reference/radio/on-data-received)
|
||||
|
@ -10,3 +10,7 @@ serial.writeString("");
|
||||
serial.readLine();
|
||||
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
|
||||
```
|
||||
|
||||
### See Also
|
||||
|
||||
[writeLine](/reference/serial/write-line), [writeNumber](/reference/serial/write-number), [writeValue](/reference/serial/write-value), [writeString](/reference/serial/write-string), [readLine](/reference/serial/read-line), [redirect](/reference/serial/redirect-to)
|
||||
|
@ -46,8 +46,6 @@ for
|
||||
|
||||
forever
|
||||
|
||||
game-library
|
||||
|
||||
game-over
|
||||
|
||||
if
|
||||
|
@ -61,7 +61,7 @@ The [math library](/blocks/math) includes math related functions.
|
||||
For example, the `absolute` function returns the returns the absolute value of input parameter `x`:
|
||||
|
||||
```blocks
|
||||
let abs = math.absolute(-42);
|
||||
let abs = Math.abs(-42);
|
||||
basic.showNumber(abs);
|
||||
```
|
||||
|
||||
|
3
docs/support.md
Normal file
3
docs/support.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Support
|
||||
|
||||
Please use the [GitHub issue tracker](https://github.com/microsoft/pxt-microbit) to report bugs.
|
@ -1,774 +0,0 @@
|
||||
//
|
||||
// Note that this is supposed to run from command line.
|
||||
// Do not use anything besides basic.pause, control.inBackground, console.log
|
||||
//
|
||||
|
||||
//% shim=pxtrt::panic
|
||||
function panic(code2: number): void { }
|
||||
|
||||
function msg(s: string): void {
|
||||
//console.log(s)
|
||||
//basic.pause(50);
|
||||
}
|
||||
|
||||
function assert(cond: boolean, msg_: string) {
|
||||
if (!cond) {
|
||||
console.log("ASSERT: " + msg_);
|
||||
panic(45);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// start tests
|
||||
//
|
||||
|
||||
var glb1: number;
|
||||
var s2: string;
|
||||
var x: number;
|
||||
var action: Action;
|
||||
var tot: string;
|
||||
var lazyAcc: number;
|
||||
var sum: number;
|
||||
|
||||
var xyz = 12;
|
||||
|
||||
console.log("Starting...")
|
||||
|
||||
//lib.print_17(3);
|
||||
basic.showNumber(0);
|
||||
//assert(lib3.getX() == 17 * 3, "");
|
||||
|
||||
testNums();
|
||||
testStrings();
|
||||
testNumCollection();
|
||||
testStringCollection();
|
||||
testStringOps();
|
||||
testReccoll();
|
||||
inBg();
|
||||
testAction(1);
|
||||
testAction(7);
|
||||
testIter();
|
||||
testActionSave();
|
||||
testLazyOps();
|
||||
testRefLocals();
|
||||
testByRefParams();
|
||||
testFunDecl();
|
||||
testDefaultArgs();
|
||||
testMemoryFree();
|
||||
testMemoryFreeHOF();
|
||||
postPreFix()
|
||||
eqOp()
|
||||
testEnums()
|
||||
testBuffer()
|
||||
|
||||
// test some top-level code
|
||||
let xsum = 0;
|
||||
for (let i = 0; i < 11; ++i) {
|
||||
xsum = xsum + i;
|
||||
}
|
||||
assert(xsum == 55, "mainfor")
|
||||
|
||||
control.inBackground(() => {
|
||||
xsum = xsum + 10;
|
||||
})
|
||||
|
||||
basic.pause(20)
|
||||
assert(xsum == 65, "mainforBg")
|
||||
|
||||
assert(xyz == 12, "init")
|
||||
|
||||
function incrXyz() {
|
||||
xyz++;
|
||||
return 0;
|
||||
}
|
||||
var unusedInit = incrXyz();
|
||||
|
||||
assert(xyz == 13, "init2")
|
||||
|
||||
|
||||
testClass()
|
||||
|
||||
basic.showNumber(1)
|
||||
|
||||
|
||||
console.log("ALL TESTS OK")
|
||||
|
||||
|
||||
function defaultArgs(x: number, y = 3, z = 7) {
|
||||
return x + y + z;
|
||||
}
|
||||
|
||||
function testDefaultArgs() {
|
||||
msg("testDefaultArgs");
|
||||
assert(defaultArgs(1) == 11, "defl0")
|
||||
assert(defaultArgs(1, 4) == 12, "defl1")
|
||||
assert(defaultArgs(1, 4, 8) == 13, "defl2")
|
||||
|
||||
assert(optargs(1) == 1, "opt0");
|
||||
assert(optargs(1, 2) == 3, "opt1");
|
||||
assert(optargs(1, 2, 3) == 3, "opt2");
|
||||
|
||||
assert(optstring(3) == 6, "os0")
|
||||
assert(optstring(3, "7") == 10, "os1")
|
||||
assert(optstring2(3) == 6, "os0")
|
||||
assert(optstring2(3, "7") == 10, "os1")
|
||||
}
|
||||
|
||||
function optargs(x: number, y ?: number, z ?: number) {
|
||||
return x + y;
|
||||
}
|
||||
|
||||
function optstring(x: number, s ?: string) {
|
||||
if (s != null) {
|
||||
return parseInt(s) + x;
|
||||
}
|
||||
return x * 2;
|
||||
}
|
||||
|
||||
function optstring2(x: number, s: string = null) {
|
||||
if (s != null) {
|
||||
return parseInt(s) + x;
|
||||
}
|
||||
return x * 2;
|
||||
}
|
||||
|
||||
function testNums(): void {
|
||||
let x = 40 + 2;
|
||||
assert(x == 42, "add");
|
||||
x = 40 / 2;
|
||||
assert(x == 20, "div");
|
||||
let r = fib(15);
|
||||
msg("FIB" + r);
|
||||
assert(r == 987, "fib");
|
||||
let x3 = doStuff(x, 2);
|
||||
assert(x3 == 10, "call order");
|
||||
glb1 = 5;
|
||||
incrBy_2();
|
||||
assert(glb1 == 7, "glb1");
|
||||
incrBy_2();
|
||||
assert(glb1 == 9, "glb2");
|
||||
assert(Math.abs(-42) == 42, "abs");
|
||||
assert(Math.abs(42) == 42, "abs");
|
||||
assert(Math.sign(42) == 1, "abs");
|
||||
testIf();
|
||||
|
||||
assert((3 & 6) == 2, "&")
|
||||
assert((3 | 6) == 7, "|")
|
||||
assert((3 ^ 6) == 5, "^")
|
||||
assert((-10 >> 2) == -3, ">>")
|
||||
assert((-10 >>> 20) == 4095, ">>>")
|
||||
assert((-10 << 2) == -40, "<<")
|
||||
assert((10 << 2) == 40, "<<+")
|
||||
assert((10 >> 2) == 2, ">>+")
|
||||
assert((10 >>> 2) == 2, ">>>+")
|
||||
assert(1000000 * 1000000 == -727379968, "*")
|
||||
assert(100000001 * 100000001 == 2074919425, "*2")
|
||||
|
||||
assert(105 % 100 == 5, "perc")
|
||||
}
|
||||
|
||||
|
||||
|
||||
function fib(p: number): number {
|
||||
if (p <= 2) {
|
||||
return p;
|
||||
}
|
||||
let p2 = p - 1;
|
||||
return fib(p2) + fib(p - 2);
|
||||
}
|
||||
|
||||
function doStuff(x: number, x2: number): number {
|
||||
let x3 = x / x2;
|
||||
return x3;
|
||||
}
|
||||
|
||||
|
||||
function testIf(): void {
|
||||
let b = false;
|
||||
if (!b) {
|
||||
glb1 = 7;
|
||||
} else {
|
||||
assert(false, "b0");
|
||||
}
|
||||
assert(glb1 == 7, "glb3");
|
||||
if (b) {
|
||||
assert(false, "b1");
|
||||
} else {
|
||||
glb1 = 8;
|
||||
}
|
||||
assert(glb1 == 8, "glb3");
|
||||
}
|
||||
|
||||
|
||||
function incrBy_2(): void {
|
||||
glb1 = glb1 + 2;
|
||||
}
|
||||
|
||||
function testStrings(): void {
|
||||
assert((42).toString() == "42", "42");
|
||||
|
||||
let s = "live";
|
||||
assert(s == "live", "hello eq");
|
||||
s = s + "4OK";
|
||||
s2 = s;
|
||||
assert(s.charCodeAt(4) == 52, "hello eq2");
|
||||
assert(s.charAt(4) == "4", "hello eq2X");
|
||||
assert(s[4] == "4", "hello eq2X");
|
||||
assert(s.length == 7, "len7");
|
||||
s = "";
|
||||
for (let i = 0; i < 10; i++) {
|
||||
s = s + i;
|
||||
}
|
||||
assert(s == "0123456789", "for");
|
||||
let x = 10;
|
||||
s = "";
|
||||
while (x >= 0) {
|
||||
s = s + x;
|
||||
x = x - 1;
|
||||
}
|
||||
assert(s == "109876543210", "while");
|
||||
msg(s);
|
||||
msg(s2);
|
||||
|
||||
s2 = "";
|
||||
// don't leak ref
|
||||
|
||||
x = 21
|
||||
s = "foo"
|
||||
s = `a${ x * 2 }X${ s }X${ s }Z`
|
||||
assert(s == "a42XfooXfoo" + "Z", "`")
|
||||
|
||||
assert("X" + true == "Xt" + "rue", "boolStr")
|
||||
}
|
||||
|
||||
|
||||
function testNumCollection(): void {
|
||||
let collXYZ: number[] =[];
|
||||
assert(collXYZ.length == 0, "");
|
||||
collXYZ.push(42);
|
||||
assert(collXYZ.length == 1, "");
|
||||
collXYZ.push(22);
|
||||
assert(collXYZ[1] == 22, "");
|
||||
collXYZ.splice(0, 1);
|
||||
assert(collXYZ[0] == 22, "");
|
||||
collXYZ.removeElement(22);
|
||||
assert(collXYZ.length == 0, "");
|
||||
for (let i = 0; i < 100; i++) {
|
||||
collXYZ.push(i);
|
||||
}
|
||||
assert(collXYZ.length == 100, "");
|
||||
|
||||
collXYZ =[1, 2, 3];
|
||||
assert(collXYZ.length == 3, "cons");
|
||||
assert(collXYZ[0] == 1, "cons0");
|
||||
assert(collXYZ[1] == 2, "cons1");
|
||||
assert(collXYZ[2] == 3, "cons2");
|
||||
}
|
||||
|
||||
function testStringCollection(): void {
|
||||
let coll = (< string[] >[]);
|
||||
coll.push("foobar");
|
||||
coll.push((12).toString());
|
||||
coll.push(coll[0] + "xx");
|
||||
assert(coll.indexOf("12") == 1, "idx");
|
||||
coll =[
|
||||
"a" + "b",
|
||||
coll[2],
|
||||
]
|
||||
assert(coll[0] == "ab", "")
|
||||
assert(coll[1] == "foob" + "arxx", "")
|
||||
assert(coll.length == 2, "")
|
||||
}
|
||||
|
||||
function testStringOps(): void {
|
||||
assert("foo".concat("bar") == "foobar", "concat");
|
||||
assert("xAb".charCodeAt(1) == 65, "code at");
|
||||
assert("B".charCodeAt(0) == 66, "tcc");
|
||||
assert(parseInt("-123") == -123, "tonum");
|
||||
assert("fo"[1] == "o", "at");
|
||||
assert("fo".length == 2, "count");
|
||||
assert("fo".charCodeAt(17) == 0, "ct oor");
|
||||
}
|
||||
|
||||
class Testrec {
|
||||
str: string;
|
||||
num: number;
|
||||
bool: boolean;
|
||||
str2: string;
|
||||
}
|
||||
|
||||
function recordId(x: Testrec) {
|
||||
lazyAcc++
|
||||
return x
|
||||
}
|
||||
|
||||
function postPreFix() {
|
||||
msg("postPref")
|
||||
let x = new Testrec()
|
||||
lazyAcc = 0
|
||||
recordId(x).num = 12
|
||||
assert(x.num == 12 && lazyAcc == 1, "X0")
|
||||
let y = recordId(x).num++
|
||||
assert(x.num == 13 && lazyAcc == 2, "X1")
|
||||
assert(y == 12, "X2")
|
||||
y = ++recordId(x).num
|
||||
assert(y == 14 && x.num == 14 && lazyAcc == 3, "X2")
|
||||
|
||||
recordId(x).num >>= 1
|
||||
assert(x.num == 7, "X3")
|
||||
assert(lazyAcc == 4, "X4")
|
||||
}
|
||||
|
||||
function eqOp() {
|
||||
msg("eqOp")
|
||||
let x = 12
|
||||
assert((x += 10) == 22, "Y0")
|
||||
assert(x == 22, "Y1")
|
||||
x /= 2
|
||||
assert(x == 11, "Y2")
|
||||
|
||||
let s = ("fo" + 1)
|
||||
let t = ("ba" + 2)
|
||||
s += t
|
||||
assert(s == "fo1b" + "a2", "fb")
|
||||
}
|
||||
|
||||
function testRec0(): Testrec {
|
||||
let testrec = new Testrec();
|
||||
testrec.str2 = "Hello" + " world";
|
||||
testrec.str = testrec.str2;
|
||||
testrec.num = 42;
|
||||
assert(testrec.str == "Hello world", "recstr");
|
||||
assert(testrec.num == 42, "recnum");
|
||||
msg(testrec.str2);
|
||||
let testrec2 = < Testrec > null;
|
||||
assert(testrec2 == null, "isinv");
|
||||
assert(testrec == testrec, "eq");
|
||||
assert(testrec != null, "non inv");
|
||||
return testrec;
|
||||
}
|
||||
|
||||
function testReccoll(): void {
|
||||
let coll: Testrec[] =[];
|
||||
let item = testRec0();
|
||||
msg("in reccoll");
|
||||
coll.push(item);
|
||||
}
|
||||
|
||||
function inBg() {
|
||||
let k = 7
|
||||
let q = 14
|
||||
let rec = new Testrec();
|
||||
glb1 = 0
|
||||
control.inBackground(() => {
|
||||
glb1 = glb1 + 10 + (q - k)
|
||||
rec.str = "foo"
|
||||
})
|
||||
control.inBackground(() => {
|
||||
glb1 = glb1 + 1
|
||||
})
|
||||
basic.pause(50)
|
||||
assert(glb1 == 18, "inbg0")
|
||||
assert(rec.str == "foo", "inbg1")
|
||||
}
|
||||
|
||||
function runTwice(fn: Action): void {
|
||||
msg("r2 start");
|
||||
fn();
|
||||
fn();
|
||||
msg("r2 stop");
|
||||
}
|
||||
|
||||
function iter(max: number, fn: (v: number) => void) {
|
||||
for (var i = 0; i < max; ++i) {
|
||||
fn(i);
|
||||
}
|
||||
}
|
||||
|
||||
function testIter() {
|
||||
x = 0
|
||||
iter(10, v => {
|
||||
x = x + (v + 1)
|
||||
})
|
||||
assert(x == 55, "55")
|
||||
}
|
||||
|
||||
function testAction(p: number): void {
|
||||
let s = "hello" + "1";
|
||||
let coll =[] as number[];
|
||||
let p2 = p * 2;
|
||||
x = 42;
|
||||
runTwice(() => {
|
||||
x = x + p + p2;
|
||||
coll.push(x);
|
||||
msg(s + x);
|
||||
});
|
||||
assert(x == 42 + p * 6, "run2");
|
||||
assert(coll.length == 2, "run2");
|
||||
}
|
||||
|
||||
function add7() {
|
||||
sum = sum + 7;
|
||||
}
|
||||
|
||||
function testFunDecl() {
|
||||
msg("testFunDecl");
|
||||
let x = 12;
|
||||
sum = 0;
|
||||
function addX() {
|
||||
sum = sum + x;
|
||||
}
|
||||
function add10() {
|
||||
sum = sum + 10;
|
||||
}
|
||||
runTwice(addX)
|
||||
assert(sum == 24, "cap")
|
||||
msg("testAdd10");
|
||||
runTwice(add10);
|
||||
msg("end-testAdd10");
|
||||
assert(sum == 44, "nocap");
|
||||
runTwice(add7);
|
||||
assert(sum == 44 + 14, "glb")
|
||||
addX();
|
||||
add10();
|
||||
assert(sum == 44 + 14 + x + 10, "direct");
|
||||
}
|
||||
|
||||
function saveAction(fn: Action): void {
|
||||
action = fn;
|
||||
}
|
||||
|
||||
function saveGlobalAction(): void {
|
||||
let s = "foo" + "42";
|
||||
tot = "";
|
||||
saveAction(() => {
|
||||
tot = tot + s;
|
||||
});
|
||||
}
|
||||
|
||||
function testActionSave(): void {
|
||||
saveGlobalAction();
|
||||
runTwice(action);
|
||||
msg(tot);
|
||||
assert(tot == "foo42foo42", "");
|
||||
tot = "";
|
||||
action = null;
|
||||
}
|
||||
|
||||
function testLazyOps(): void {
|
||||
lazyAcc = 0;
|
||||
if (incrLazyAcc(10, false) && incrLazyAcc(1, true)) {
|
||||
assert(false, "");
|
||||
} else {
|
||||
assert(lazyAcc == 10, "lazy1");
|
||||
}
|
||||
assert(lazyAcc == 10, "lazy2");
|
||||
if (incrLazyAcc(100, true) && incrLazyAcc(1, false)) {
|
||||
assert(false, "");
|
||||
} else {
|
||||
assert(lazyAcc == 111, "lazy4");
|
||||
}
|
||||
lazyAcc = 0;
|
||||
if (incrLazyAcc(100, true) && incrLazyAcc(8, true)) {
|
||||
assert(lazyAcc == 108, "lazy5");
|
||||
} else {
|
||||
assert(false, "");
|
||||
}
|
||||
lazyAcc = 0;
|
||||
if (incrLazyAcc(10, true) || incrLazyAcc(1, true)) {
|
||||
assert(lazyAcc == 10, "lazy1b");
|
||||
} else {
|
||||
assert(false, "");
|
||||
}
|
||||
assert(lazyAcc == 10, "lazy2xx");
|
||||
if (incrLazyAcc(100, false) || incrLazyAcc(1, false)) {
|
||||
assert(false, "");
|
||||
} else {
|
||||
assert(lazyAcc == 111, "lazy4x");
|
||||
}
|
||||
lazyAcc = 0;
|
||||
if (incrLazyAcc(100, false) || incrLazyAcc(8, true)) {
|
||||
assert(lazyAcc == 108, "lazy5");
|
||||
} else {
|
||||
assert(false, "");
|
||||
}
|
||||
lazyAcc = 0;
|
||||
if (incrLazyAcc(10, true) && incrLazyAcc(1, true) && incrLazyAcc(100, false)) {
|
||||
assert(false, "");
|
||||
} else {
|
||||
assert(lazyAcc == 111, "lazy10");
|
||||
}
|
||||
lazyAcc = 0;
|
||||
if (incrLazyAcc(10, true) && incrLazyAcc(1, true) || incrLazyAcc(100, false)) {
|
||||
assert(lazyAcc == 11, "lazy101");
|
||||
} else {
|
||||
assert(false, "");
|
||||
}
|
||||
|
||||
lazyAcc = 0;
|
||||
assert((true ? incrLazyNum(1, 42): incrLazyNum(10, 36)) == 42, "?:")
|
||||
assert(lazyAcc == 1, "?:0");
|
||||
assert((false ? incrLazyNum(1, 42): incrLazyNum(10, 36)) == 36, "?:1")
|
||||
assert(lazyAcc == 11, "?:2");
|
||||
}
|
||||
|
||||
function incrLazyAcc(delta: number, res: boolean): boolean {
|
||||
lazyAcc = lazyAcc + delta;
|
||||
return res;
|
||||
}
|
||||
|
||||
function incrLazyNum(delta: number, res: number) {
|
||||
lazyAcc = lazyAcc + delta;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
function testRefLocals(): void {
|
||||
msg("start test ref locals");
|
||||
let s = "";
|
||||
// For 4 or more it runs out of memory
|
||||
for (let i = 0; i < 3; i++) {
|
||||
msg(i + "");
|
||||
let copy = i;
|
||||
control.inBackground(() => {
|
||||
basic.pause(10 * i);
|
||||
copy = copy + 10;
|
||||
});
|
||||
control.inBackground(() => {
|
||||
basic.pause(20 * i);
|
||||
s = s + copy;
|
||||
});
|
||||
}
|
||||
basic.pause(200);
|
||||
assert(s == "101112", "reflocals");
|
||||
}
|
||||
|
||||
function byRefParam_0(p: number): void {
|
||||
control.inBackground(() => {
|
||||
basic.pause(1);
|
||||
sum = sum + p;
|
||||
});
|
||||
p = p + 1;
|
||||
}
|
||||
|
||||
function byRefParam_2(pxx: number): void {
|
||||
pxx = pxx + 1;
|
||||
control.inBackground(() => {
|
||||
basic.pause(1);
|
||||
sum = sum + pxx;
|
||||
});
|
||||
}
|
||||
|
||||
function testByRefParams(): void {
|
||||
msg("testByRefParams");
|
||||
refparamWrite("a" + "b");
|
||||
refparamWrite2(new Testrec());
|
||||
refparamWrite3(new Testrec());
|
||||
sum = 0;
|
||||
let x = 1;
|
||||
control.inBackground(() => {
|
||||
basic.pause(1);
|
||||
sum = sum + x;
|
||||
});
|
||||
x = 2;
|
||||
byRefParam_0(4);
|
||||
byRefParam_2(10);
|
||||
basic.pause(30);
|
||||
assert(sum == 18, "by ref");
|
||||
}
|
||||
|
||||
function refparamWrite(s: string): void {
|
||||
s = s + "c";
|
||||
assert(s == "abc", "abc");
|
||||
}
|
||||
|
||||
function refparamWrite2(testrec: Testrec): void {
|
||||
testrec = new Testrec();
|
||||
assert(testrec.bool == false, "");
|
||||
}
|
||||
|
||||
function refparamWrite3(testrecX: Testrec): void {
|
||||
control.inBackground(() => {
|
||||
basic.pause(1);
|
||||
assert(testrecX.str == "foo", "ff");
|
||||
testrecX.str = testrecX.str + "x";
|
||||
});
|
||||
testrecX = new Testrec();
|
||||
testrecX.str = "foo";
|
||||
basic.pause(30);
|
||||
assert(testrecX.str == "foox", "ff2");
|
||||
}
|
||||
|
||||
function testMemoryFree(): void {
|
||||
msg("testMemoryFree");
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
allocImage();
|
||||
}
|
||||
}
|
||||
|
||||
function runOnce(fn: Action): void {
|
||||
fn();
|
||||
}
|
||||
|
||||
function createObj() {
|
||||
return new Testrec();
|
||||
}
|
||||
|
||||
function testMemoryFreeHOF(): void {
|
||||
msg("testMemoryFreeHOF");
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
runOnce(() => {
|
||||
let tmp = createObj();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function allocImage(): void {
|
||||
let tmp = createObj();
|
||||
}
|
||||
|
||||
class Foo {
|
||||
pin: number;
|
||||
buf: number[];
|
||||
|
||||
constructor(k: number, l: number) {
|
||||
this.pin = k - l
|
||||
}
|
||||
|
||||
setPin(p: number) {
|
||||
this.pin = p
|
||||
}
|
||||
|
||||
getPin() {
|
||||
return this.pin
|
||||
}
|
||||
|
||||
init() {
|
||||
this.buf =[1, 2]
|
||||
}
|
||||
}
|
||||
|
||||
function testClass() {
|
||||
let f = new Foo(272, 100);
|
||||
assert(f.getPin() == 172, "ctor")
|
||||
f.setPin(42)
|
||||
assert(f.getPin() == 42, "getpin")
|
||||
}
|
||||
|
||||
enum En {
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
D = 4200,
|
||||
E,
|
||||
}
|
||||
|
||||
enum En2 {
|
||||
D0 = En.D,
|
||||
D1,
|
||||
D2 = 1,
|
||||
}
|
||||
|
||||
|
||||
function testEnums() {
|
||||
msg("enums")
|
||||
|
||||
let k = En.C as number
|
||||
assert(k == 2, "e0")
|
||||
k = En.D as number
|
||||
assert(k == 4200, "e1")
|
||||
k = En.E as number
|
||||
assert(k == 4201, "e43")
|
||||
|
||||
k = En2.D0 as number
|
||||
assert(k == 4200, "eX0")
|
||||
k = En2.D1 as number
|
||||
assert(k == 4201, "eX1")
|
||||
|
||||
msg("enums0")
|
||||
assert(switchA(En.A) == 7, "s1")
|
||||
assert(switchA(En.B) == 7, "s2")
|
||||
assert(switchA(En.C) == 12, "s3")
|
||||
assert(switchA(En.D) == 13, "s4")
|
||||
assert(switchA(En.E) == 12, "s5")
|
||||
assert(switchA(-3 as En) == 12, "s6")
|
||||
|
||||
msg("enums1")
|
||||
assert(switchB(En.A) == 7, "x1")
|
||||
assert(switchB(En.B) == 7, "x2")
|
||||
assert(switchB(En.C) == 17, "x3")
|
||||
assert(switchB(En.D) == 13, "x4")
|
||||
assert(switchB(En.E) == 14, "x5")
|
||||
}
|
||||
|
||||
|
||||
function switchA(e: En) {
|
||||
let r = 12;
|
||||
switch (e) {
|
||||
case En.A:
|
||||
case En.B: return 7;
|
||||
case En.D: r = 13; break;
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
function switchB(e: En) {
|
||||
let r = 33;
|
||||
switch (e) {
|
||||
case En.A:
|
||||
case En.B: return 7;
|
||||
case En.D: r = 13; break;
|
||||
case En.E: r = 14; break;
|
||||
default: return 17;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function bufferIs(b: Buffer, a: number[]) {
|
||||
assert(b.length == a.length, "bis-len")
|
||||
for (let i = 0; i < a.length; ++i) {
|
||||
if (a[i] != b[i]) {
|
||||
assert(false, `bufferIs: buf[${ i }]:${ b[i] } != ${ a[i] }`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testBuffer() {
|
||||
let b = pins.createBuffer(3);
|
||||
assert(b[0] == 0, "buf0");
|
||||
assert(b[1] == 0, "buf0");
|
||||
assert(b[2] == 0, "buf0");
|
||||
assert(b[-100000] == 0, "bufM");
|
||||
assert(b[100000] == 0, "bufM");
|
||||
|
||||
b[0] = 42;
|
||||
bufferIs(b,[42, 0, 0]);
|
||||
b[2] = 41;
|
||||
bufferIs(b,[42, 0, 41]);
|
||||
|
||||
b.rotate(1)
|
||||
bufferIs(b,[0, 41, 42]);
|
||||
b.rotate(-2)
|
||||
bufferIs(b,[41, 42, 0]);
|
||||
b.shift(1)
|
||||
bufferIs(b,[42, 0, 0]);
|
||||
b.rotate(9)
|
||||
bufferIs(b,[42, 0, 0]);
|
||||
b.rotate(-9)
|
||||
bufferIs(b,[42, 0, 0]);
|
||||
|
||||
b.fill(4);
|
||||
bufferIs(b,[4, 4, 4]);
|
||||
|
||||
b.fill(12, 1, 1);
|
||||
bufferIs(b,[4, 12, 4]);
|
||||
|
||||
b.fill(13, 1, -1);
|
||||
bufferIs(b,[4, 13, 13]);
|
||||
|
||||
b.fill(100, -1, -1);
|
||||
bufferIs(b,[4, 13, 13]);
|
||||
|
||||
b.shift(-1)
|
||||
bufferIs(b,[0, 4, 13]);
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
"lang-test0.ts"
|
||||
],
|
||||
"public": true,
|
||||
"additionalFilePath": "../../node_modules/pxt-core/libs/lang-test0",
|
||||
"dependencies": {
|
||||
"microbit": "file:../microbit"
|
||||
}
|
||||
|
77
libs/lang-test1/lang-test1.ts
Normal file
77
libs/lang-test1/lang-test1.ts
Normal file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// Note that this is supposed to run from command line.
|
||||
// Do not use anything besides basic.pause, control.inBackground, console.log
|
||||
//
|
||||
|
||||
//% shim=pxtrt::panic
|
||||
function panic(code2: number): void { }
|
||||
|
||||
function msg(s: string): void {
|
||||
//console.log(s)
|
||||
//basic.pause(50);
|
||||
}
|
||||
|
||||
function assert(cond: boolean, msg_: string) {
|
||||
if (!cond) {
|
||||
console.log("ASSERT: " + msg_);
|
||||
panic(45);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Starting...")
|
||||
basic.showNumber(0);
|
||||
|
||||
testBuffer()
|
||||
|
||||
basic.showNumber(2);
|
||||
console.log("ALL TESTS OK")
|
||||
|
||||
|
||||
function bufferIs(b: Buffer, a: number[]) {
|
||||
assert(b.length == a.length, "bis-len")
|
||||
for (let i = 0; i < a.length; ++i) {
|
||||
if (a[i] != b[i]) {
|
||||
assert(false, `bufferIs: buf[${i}]:${b[i]} != ${a[i]}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function testBuffer() {
|
||||
let b = pins.createBuffer(3);
|
||||
assert(b[0] == 0, "buf0");
|
||||
assert(b[1] == 0, "buf0");
|
||||
assert(b[2] == 0, "buf0");
|
||||
assert(b[-100000] == 0, "bufM");
|
||||
assert(b[100000] == 0, "bufM");
|
||||
|
||||
b[0] = 42;
|
||||
bufferIs(b, [42, 0, 0]);
|
||||
b[2] = 41;
|
||||
bufferIs(b, [42, 0, 41]);
|
||||
|
||||
b.rotate(1)
|
||||
bufferIs(b, [0, 41, 42]);
|
||||
b.rotate(-2)
|
||||
bufferIs(b, [41, 42, 0]);
|
||||
b.shift(1)
|
||||
bufferIs(b, [42, 0, 0]);
|
||||
b.rotate(9)
|
||||
bufferIs(b, [42, 0, 0]);
|
||||
b.rotate(-9)
|
||||
bufferIs(b, [42, 0, 0]);
|
||||
|
||||
b.fill(4);
|
||||
bufferIs(b, [4, 4, 4]);
|
||||
|
||||
b.fill(12, 1, 1);
|
||||
bufferIs(b, [4, 12, 4]);
|
||||
|
||||
b.fill(13, 1, -1);
|
||||
bufferIs(b, [4, 13, 13]);
|
||||
|
||||
b.fill(100, -1, -1);
|
||||
bufferIs(b, [4, 13, 13]);
|
||||
|
||||
b.shift(-1)
|
||||
bufferIs(b, [0, 4, 13]);
|
||||
}
|
12
libs/lang-test1/pxt.json
Normal file
12
libs/lang-test1/pxt.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "lang-test1",
|
||||
"description": "Test for the TypeScript -> HEX compiler; microbit specific parts",
|
||||
"installedVersion": "file:.",
|
||||
"files": [
|
||||
"lang-test1.ts"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"microbit": "file:../microbit"
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"bluetooth": "Support for additional Bluetooth services.",
|
||||
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
|
||||
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
|
||||
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
|
||||
"bluetooth.onBluetoothDisconnected|param|body": "Code to run when a Bluetooth connection is lost",
|
||||
"bluetooth.startAccelerometerService": "Starts the Bluetooth accelerometer service",
|
||||
"bluetooth.startButtonService": "Starts the Bluetooth button service",
|
||||
"bluetooth.startIOPinService": "Starts the Bluetooth IO pin service.",
|
||||
"bluetooth.startLEDService": "Starts the Bluetooth LED service",
|
||||
"bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service",
|
||||
"bluetooth.startTemperatureService": "Starts the Bluetooth temperature service",
|
||||
"bluetooth.uartRead": "Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.",
|
||||
"bluetooth.uartWrite": "Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device."
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"bluetooth.onBluetoothConnected|block": "on bluetooth connected",
|
||||
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",
|
||||
"bluetooth.startAccelerometerService|block": "bluetooth accelerometer service",
|
||||
"bluetooth.startButtonService|block": "bluetooth button service",
|
||||
"bluetooth.startIOPinService|block": "bluetooth io pin service",
|
||||
"bluetooth.startLEDService|block": "bluetooth led service",
|
||||
"bluetooth.startMagnetometerService|block": "bluetooth magnetometer service",
|
||||
"bluetooth.startTemperatureService|block": "bluetooth temperature service",
|
||||
"bluetooth.uartRead|block": "bluetooth uart read %del=bluetooth_uart_delimiter_conv",
|
||||
"bluetooth.uartWrite|block": "bluetooth uart write %data",
|
||||
"bluetooth|block": "bluetooth"
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"devices": "Control a phone with the BBC micro:bit via Bluetooth.",
|
||||
"devices.onGamepadButton": "Register code to run when the micro:bit receives a command from the paired gamepad.",
|
||||
"devices.onGamepadButton|param|body": "code to run when button is pressed",
|
||||
"devices.onGamepadButton|param|name": "button name",
|
||||
"devices.onNotified": "Registers code to run when the device notifies about a particular event.",
|
||||
"devices.onNotified|param|body": "code handler when event is triggered",
|
||||
"devices.onNotified|param|event": "event description",
|
||||
"devices.onSignalStrengthChanged": "Registers code to run when the device notifies about a change of signal strength.",
|
||||
"devices.onSignalStrengthChanged|param|body": "Code run when the signal strength changes.",
|
||||
"devices.raiseAlertTo": "Sends an ``alert`` command to the parent device.",
|
||||
"devices.raiseAlertTo|param|event": "event description",
|
||||
"devices.signalStrength": "Returns the last signal strength reported by the paired device.",
|
||||
"devices.tellCameraTo": "Sends a ``camera`` command to the parent device.",
|
||||
"devices.tellCameraTo|param|event": "event description",
|
||||
"devices.tellRemoteControlTo": "Sends a ``remote control`` command to the parent device.",
|
||||
"devices.tellRemoteControlTo|param|event": "event description"
|
||||
}
|
10
libs/microbit-devices/_locales/microbit-devices-strings.json
Normal file
10
libs/microbit-devices/_locales/microbit-devices-strings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"devices.onGamepadButton|block": "on gamepad button|%NAME",
|
||||
"devices.onNotified|block": "on notified|%event",
|
||||
"devices.onSignalStrengthChanged|block": "on signal strength changed",
|
||||
"devices.raiseAlertTo|block": "raise alert to|%property",
|
||||
"devices.signalStrength|block": "signal strength",
|
||||
"devices.tellCameraTo|block": "tell camera to|%property",
|
||||
"devices.tellRemoteControlTo|block": "tell remote control to|%property",
|
||||
"devices|block": "devices"
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
{
|
||||
"radio": "Communicate data using radio packets",
|
||||
"radio.onDataReceived": "Registers code to run when a packet is received over radio.",
|
||||
"radio.receiveNumber": "Reads the next packet as a number from the radio queue.",
|
||||
"radio.receiveString": "Reads the next packet as a string and returns it.",
|
||||
"radio.receivedNumberAt": "Reads a number at a given index, between ``0`` and ``3``, from the packet received by ``receive number``. Not supported in simulator.",
|
||||
"radio.receivedNumberAt|param|index": "index of the number to read from 0 to 3. 1 eg",
|
||||
"radio.receivedSignalStrength": "Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.\nnamespace=radio",
|
||||
"radio.sendNumber": "Broadcasts a number over radio to any connected micro:bit in the group.",
|
||||
"radio.sendString": "Broadcasts a number over radio to any connected micro:bit in the group.",
|
||||
"radio.sendValue": "Broadcasts a name / value pair along with the device serial number\nand running time to any connected micro:bit in the group.",
|
||||
"radio.sendValue|param|name": "the field name (max 12 characters), eg: \"data\"",
|
||||
"radio.sendValue|param|value": "the numberic value",
|
||||
"radio.setGroup": "Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time.\n@ param id the group id between ``0`` and ``255``, 1 eg",
|
||||
"radio.setTransmitPower": "Change the output power level of the transmitter to the given value.",
|
||||
"radio.setTransmitPower|param|power": "a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7",
|
||||
"radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.",
|
||||
"radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON"
|
||||
}
|
@ -1,101 +1,15 @@
|
||||
{
|
||||
"basic": "Provides access to basic micro:bit functionality.",
|
||||
"basic.clearScreen": "Turn off all LEDs",
|
||||
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||
"basic.pause": "Pause for the specified time in milliseconds",
|
||||
"basic.plotLeds": "Draws an image on the LED screen.",
|
||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||
"basic.showLeds": "Draws an image on the LED screen.",
|
||||
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
|
||||
"basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
|
||||
"control": "Runtime and event utilities.",
|
||||
"control.inBackground": "Schedules code that run in the background.",
|
||||
"control.reset": "Resets the BBC micro:bit.",
|
||||
"game": "A single-LED sprite game engine",
|
||||
"game.addScore": "Adds points to the current score",
|
||||
"game.gameOver": "Displays a game over animation.",
|
||||
"game.score": "Gets the current score",
|
||||
"game.setScore": "Sets the current score value",
|
||||
"game.startCountdown": "Starts a game countdown timer",
|
||||
"images": "Creation, manipulation and display of LED images.",
|
||||
"images.createBigImage": "Creates an image with 2 frames.",
|
||||
"images.createImage": "Creates an image that fits on the LED screen.",
|
||||
"input": "Events and data from sensors",
|
||||
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||
"input.compassHeading": "Get the current compass compass heading in degrees.",
|
||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||
"input.onGesture": "Attaches code to run when the screen is facing up.",
|
||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||
"input.onPinPressed": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.",
|
||||
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||
"input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||
"led": "Control of the LED screen.",
|
||||
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.fadeIn": "Fades in the screen display.",
|
||||
"led.fadeOut": "Fades out the screen brightness.",
|
||||
"led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.plotAll": "Turns all LEDS on",
|
||||
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
||||
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
||||
"led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
|
||||
"led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
|
||||
"led.stopAnimation": "Cancels the current animation and clears other pending animations.",
|
||||
"led.toggle": "Toggles a particular pixel",
|
||||
"led.toggleAll": "Inverts the current LED display",
|
||||
"led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"music": "Generation of music tones through pin ``P0``.",
|
||||
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||
"music.noteFrequency": "Gets the frequency of a note.",
|
||||
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
||||
"music.ringTone": "Plays a tone through pin ``P0``.",
|
||||
"music.setTempo": "Sets the tempo to the specified amount",
|
||||
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
||||
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
||||
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
||||
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
||||
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
||||
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
|
||||
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
|
||||
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
||||
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.",
|
||||
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||
"radio": "Communicate data using radio packets",
|
||||
"radio.onDataReceived": "Registers code to run when a packet is received over radio.",
|
||||
"radio.receiveNumber": "Reads the next packet as a number from the radio queue.",
|
||||
"radio.receiveString": "Reads the next packet as a string and returns it.",
|
||||
"radio.receivedNumberAt": "Reads a number at a given index, between ``0`` and ``3``, from the packet received by ``receive number``. Not supported in simulator.",
|
||||
"radio.receivedSignalStrength": "Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.\nnamespace=radio",
|
||||
"radio.sendNumber": "Broadcasts a number over radio to any connected micro:bit in the group.",
|
||||
"radio.sendString": "Broadcasts a number over radio to any connected micro:bit in the group.",
|
||||
"radio.sendValue": "Broadcasts a name / value pair along with the device serial number\nand running time to any connected BBC micro:bit in the group.",
|
||||
"radio.setGroup": "Sets the group id for radio communications. A micro:bit can only listen to one group ID at any time.\n@ param id the group id between ``0`` and ``255``, 1 eg",
|
||||
"radio.setTransmitPower": "Change the output power level of the transmitter to the given value.",
|
||||
"radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.",
|
||||
"radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON",
|
||||
"serial": "Reading and writing data over a serial connection.",
|
||||
"serial.readLine": "Reads a line of text from the serial port.",
|
||||
"serial.writeLine": "Prints a line of text to the serial",
|
||||
"serial.writeNumber": "Prints a numeric value to the serial",
|
||||
"serial.writeString": "Sends a piece of text through Serial connection.",
|
||||
"serial.writeValue": "Writes a ``name: value`` pair line to the serial."
|
||||
"radio.onDataReceived|block": "radio on data received",
|
||||
"radio.receiveNumber|block": "radio receive number",
|
||||
"radio.receiveString|block": "radio receive string",
|
||||
"radio.receivedNumberAt|block": "radio receive number|at %VALUE",
|
||||
"radio.receivedSignalStrength|block": "radio received signal strength",
|
||||
"radio.sendNumber|block": "radio send number %value",
|
||||
"radio.sendString|block": "radio send string %msg",
|
||||
"radio.sendValue|block": "radio send|value %name|= %value",
|
||||
"radio.setGroup|block": "radio set group %ID",
|
||||
"radio.setTransmitPower|block": "radio set transmit power %power",
|
||||
"radio.setTransmitSerialNumber|block": "radio set transmit serial number %transmit",
|
||||
"radio.writeValueToSerial|block": "radio write value to serial",
|
||||
"radio|block": "radio"
|
||||
}
|
@ -43,7 +43,7 @@ namespace radio {
|
||||
*/
|
||||
//% help=radio/send-number
|
||||
//% weight=60
|
||||
//% blockId=radio_datagram_send block="send number %value" blockGap=8
|
||||
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8
|
||||
void sendNumber(int value) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
uint32_t t = system_timer_current_time();
|
||||
@ -54,13 +54,13 @@ namespace radio {
|
||||
|
||||
/**
|
||||
* Broadcasts a name / value pair along with the device serial number
|
||||
* and running time to any connected BBC micro:bit in the group.
|
||||
* and running time to any connected micro:bit in the group.
|
||||
* @param name the field name (max 12 characters), eg: "data"
|
||||
* @param value the numberic value
|
||||
*/
|
||||
//% help=radio/send-value
|
||||
//% weight=59
|
||||
//% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8
|
||||
//% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8
|
||||
void sendValue(StringData* name, int value) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
|
||||
@ -86,7 +86,7 @@ namespace radio {
|
||||
*/
|
||||
//% help=radio/send-string
|
||||
//% weight=58
|
||||
//% blockId=radio_datagram_send_string block="send string %msg"
|
||||
//% blockId=radio_datagram_send_string block="radio send string %msg"
|
||||
void sendString(StringData* msg) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
|
||||
@ -103,7 +103,7 @@ namespace radio {
|
||||
*/
|
||||
//% help=radio/write-value-to-serial
|
||||
//% weight=3
|
||||
//% blockId=radio_write_value_serial block="write value to serial"
|
||||
//% blockId=radio_write_value_serial block="radio write value to serial"
|
||||
void writeValueToSerial() {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
PacketBuffer p = uBit.radio.datagram.recv();
|
||||
@ -134,16 +134,6 @@ namespace radio {
|
||||
uBit.serial.send("}\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers code to run when a packet is received over radio.
|
||||
*/
|
||||
//% help=radio/on-data-received
|
||||
//% weight=50
|
||||
//% blockId=radio_datagram_received_event block="on data received" blockGap=8
|
||||
void onDataReceived(Action body) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a number at a given index, between ``0`` and ``3``, from the packet received by ``receive number``. Not supported in simulator.
|
||||
@ -151,7 +141,7 @@ namespace radio {
|
||||
*/
|
||||
//% help=radio/received-number-at
|
||||
//% weight=45 debug=true
|
||||
//% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8
|
||||
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8
|
||||
int receivedNumberAt(int index) {
|
||||
if (radioEnable() != MICROBIT_OK) return 0;
|
||||
if (0 <= index && index < packet.length() / 4) {
|
||||
@ -162,24 +152,38 @@ namespace radio {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next packet as a number from the radio queue.
|
||||
*/
|
||||
//% help=radio/receive-number
|
||||
//% weight=46
|
||||
//% blockId=radio_datagram_receive block="receive number" blockGap=8
|
||||
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8
|
||||
int receiveNumber()
|
||||
{
|
||||
if (radioEnable() != MICROBIT_OK) return 0;
|
||||
packet = uBit.radio.datagram.recv();
|
||||
return receivedNumberAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers code to run when a packet is received over radio.
|
||||
*/
|
||||
//% help=radio/on-data-received
|
||||
//% weight=50
|
||||
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8
|
||||
void onDataReceived(Action body) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
registerWithDal(MICROBIT_ID_RADIO, MICROBIT_RADIO_EVT_DATAGRAM, body);
|
||||
// make the the receive buffer has a free spot
|
||||
receiveNumber();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reads the next packet as a string and returns it.
|
||||
*/
|
||||
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
|
||||
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
|
||||
//% weight=44
|
||||
//% help=radio/receive-string
|
||||
StringData* receiveString() {
|
||||
@ -194,7 +198,7 @@ namespace radio {
|
||||
*/
|
||||
//% help=radio/received-signal-strength
|
||||
//% weight=40
|
||||
//% blockId=radio_datagram_rssi block="received signal strength"
|
||||
//% blockId=radio_datagram_rssi block="radio received signal strength"
|
||||
int receivedSignalStrength() {
|
||||
if (radioEnable() != MICROBIT_OK) return 0;
|
||||
return packet.getRSSI();
|
||||
@ -205,8 +209,8 @@ namespace radio {
|
||||
* @ param id the group id between ``0`` and ``255``, 1 eg
|
||||
*/
|
||||
//% help=radio/set-group
|
||||
//% weight=10
|
||||
//% blockId=radio_set_group block="set group %ID"
|
||||
//% weight=10 blockGap=8
|
||||
//% blockId=radio_set_group block="radio set group %ID"
|
||||
void setGroup(int id) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
uBit.radio.setGroup(id);
|
||||
@ -217,8 +221,8 @@ namespace radio {
|
||||
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
|
||||
*/
|
||||
//% help=radio/set-transmit-power
|
||||
//% weight=9
|
||||
//% blockId=radio_set_transmit_power block="set transmit power %power"
|
||||
//% weight=9 blockGap=8
|
||||
//% blockId=radio_set_transmit_power block="radio set transmit power %power"
|
||||
void setTransmitPower(int power) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
uBit.radio.setTransmitPower(power);
|
||||
@ -228,9 +232,10 @@ namespace radio {
|
||||
* Set the radio to transmit the serial number in each message.
|
||||
*/
|
||||
//% help=radio/set-transmit-serial-number
|
||||
//% weight=8
|
||||
//% block=radio_set_transmit_serial_number block="set tranmist serial number %transmit"
|
||||
//% weight=8 blockGap=8
|
||||
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit"
|
||||
void setTransmitSerialNumber(bool transmit) {
|
||||
if (radioEnable() != MICROBIT_OK) return;
|
||||
transmitSerialNumber = transmit;
|
||||
}
|
||||
}
|
||||
|
46
libs/microbit-radio/shims.d.ts
vendored
46
libs/microbit-radio/shims.d.ts
vendored
@ -10,18 +10,18 @@ declare namespace radio {
|
||||
*/
|
||||
//% help=radio/send-number
|
||||
//% weight=60
|
||||
//% blockId=radio_datagram_send block="send number %value" blockGap=8 shim=radio::sendNumber
|
||||
//% blockId=radio_datagram_send block="radio send number %value" blockGap=8 shim=radio::sendNumber
|
||||
function sendNumber(value: number): void;
|
||||
|
||||
/**
|
||||
* Broadcasts a name / value pair along with the device serial number
|
||||
* and running time to any connected BBC micro:bit in the group.
|
||||
* and running time to any connected micro:bit in the group.
|
||||
* @param name the field name (max 12 characters), eg: "data"
|
||||
* @param value the numberic value
|
||||
*/
|
||||
//% help=radio/send-value
|
||||
//% weight=59
|
||||
//% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8 shim=radio::sendValue
|
||||
//% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8 shim=radio::sendValue
|
||||
function sendValue(name: string, value: number): void;
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ declare namespace radio {
|
||||
*/
|
||||
//% help=radio/send-string
|
||||
//% weight=58
|
||||
//% blockId=radio_datagram_send_string block="send string %msg" shim=radio::sendString
|
||||
//% blockId=radio_datagram_send_string block="radio send string %msg" shim=radio::sendString
|
||||
function sendString(msg: string): void;
|
||||
|
||||
/**
|
||||
@ -38,24 +38,16 @@ declare namespace radio {
|
||||
*/
|
||||
//% help=radio/write-value-to-serial
|
||||
//% weight=3
|
||||
//% blockId=radio_write_value_serial block="write value to serial" shim=radio::writeValueToSerial
|
||||
//% blockId=radio_write_value_serial block="radio write value to serial" shim=radio::writeValueToSerial
|
||||
function writeValueToSerial(): void;
|
||||
|
||||
/**
|
||||
* Registers code to run when a packet is received over radio.
|
||||
*/
|
||||
//% help=radio/on-data-received
|
||||
//% weight=50
|
||||
//% blockId=radio_datagram_received_event block="on data received" blockGap=8 shim=radio::onDataReceived
|
||||
function onDataReceived(body: () => void): void;
|
||||
|
||||
/**
|
||||
* Reads a number at a given index, between ``0`` and ``3``, from the packet received by ``receive number``. Not supported in simulator.
|
||||
* @param index index of the number to read from 0 to 3. 1 eg
|
||||
*/
|
||||
//% help=radio/received-number-at
|
||||
//% weight=45 debug=true
|
||||
//% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
|
||||
//% blockId=radio_datagram_received_number_at block="radio receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
|
||||
function receivedNumberAt(index: number): number;
|
||||
|
||||
/**
|
||||
@ -63,13 +55,21 @@ declare namespace radio {
|
||||
*/
|
||||
//% help=radio/receive-number
|
||||
//% weight=46
|
||||
//% blockId=radio_datagram_receive block="receive number" blockGap=8 shim=radio::receiveNumber
|
||||
//% blockId=radio_datagram_receive block="radio receive number" blockGap=8 shim=radio::receiveNumber
|
||||
function receiveNumber(): number;
|
||||
|
||||
/**
|
||||
* Registers code to run when a packet is received over radio.
|
||||
*/
|
||||
//% help=radio/on-data-received
|
||||
//% weight=50
|
||||
//% blockId=radio_datagram_received_event block="radio on data received" blockGap=8 shim=radio::onDataReceived
|
||||
function onDataReceived(body: () => void): void;
|
||||
|
||||
/**
|
||||
* Reads the next packet as a string and returns it.
|
||||
*/
|
||||
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
|
||||
//% blockId=radio_datagram_receive_string block="radio receive string" blockGap=8
|
||||
//% weight=44
|
||||
//% help=radio/receive-string shim=radio::receiveString
|
||||
function receiveString(): string;
|
||||
@ -80,7 +80,7 @@ declare namespace radio {
|
||||
*/
|
||||
//% help=radio/received-signal-strength
|
||||
//% weight=40
|
||||
//% blockId=radio_datagram_rssi block="received signal strength" shim=radio::receivedSignalStrength
|
||||
//% blockId=radio_datagram_rssi block="radio received signal strength" shim=radio::receivedSignalStrength
|
||||
function receivedSignalStrength(): number;
|
||||
|
||||
/**
|
||||
@ -88,8 +88,8 @@ declare namespace radio {
|
||||
* @ param id the group id between ``0`` and ``255``, 1 eg
|
||||
*/
|
||||
//% help=radio/set-group
|
||||
//% weight=10
|
||||
//% blockId=radio_set_group block="set group %ID" shim=radio::setGroup
|
||||
//% weight=10 blockGap=8
|
||||
//% blockId=radio_set_group block="radio set group %ID" shim=radio::setGroup
|
||||
function setGroup(id: number): void;
|
||||
|
||||
/**
|
||||
@ -97,16 +97,16 @@ declare namespace radio {
|
||||
* @param power a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7
|
||||
*/
|
||||
//% help=radio/set-transmit-power
|
||||
//% weight=9
|
||||
//% blockId=radio_set_transmit_power block="set transmit power %power" shim=radio::setTransmitPower
|
||||
//% weight=9 blockGap=8
|
||||
//% blockId=radio_set_transmit_power block="radio set transmit power %power" shim=radio::setTransmitPower
|
||||
function setTransmitPower(power: number): void;
|
||||
|
||||
/**
|
||||
* Set the radio to transmit the serial number in each message.
|
||||
*/
|
||||
//% help=radio/set-transmit-serial-number
|
||||
//% weight=8
|
||||
//% block=radio_set_transmit_serial_number block="set tranmist serial number %transmit" shim=radio::setTransmitSerialNumber
|
||||
//% weight=8 blockGap=8
|
||||
//% blockId=radio_set_transmit_serial_number block="radio set transmit serial number %transmit" shim=radio::setTransmitSerialNumber
|
||||
function setTransmitSerialNumber(transmit: boolean): void;
|
||||
}
|
||||
|
||||
|
166
libs/microbit/_locales/fr/microbit-jsdoc-strings.json
Normal file
166
libs/microbit/_locales/fr/microbit-jsdoc-strings.json
Normal file
@ -0,0 +1,166 @@
|
||||
{
|
||||
"Math.randomBoolean":"Génère une valeur « true » ou « false » au hasard, tout comme le retournement d’une pièce de monnaie.",
|
||||
"String.fromCharCode":"Faire une chaîne de la donnée code de caractères ASCII.",
|
||||
"basic":"Permet d’accéder aux fonctionnalités de base micro : bit.",
|
||||
"basic.clearScreen":"Désactiver toutes les LEDs",
|
||||
"basic.forever":"Répète le code pour toujours en arrière-plan. À chaque itération, permet aux autres codes d’exécuter.",
|
||||
"basic.pause":"Pause pendant la durée spécifiée en millisecondes",
|
||||
"basic.pause|param|ms":"Combien de temps pour faire une pause pour, par exemple : 100, 200, 500, 1000, 2000",
|
||||
"basic.plotLeds":"Dessine une image sur l’écran LED.",
|
||||
"basic.plotLeds|param|leds":"modèle de LED à allumer\/éteindre",
|
||||
"basic.showAnimation":"Montre une séquence d’écrans LED comme une animation.",
|
||||
"basic.showAnimation|param|interval":"temps en millisecondes entre chaque rafraîchissement",
|
||||
"basic.showAnimation|param|leds":"modèle de LED à allumer\/éteindre",
|
||||
"basic.showLeds":"Dessine une image sur l’écran LED.",
|
||||
"basic.showLeds|param|interval":"temps en millisecondes pour faire une pause après dessin",
|
||||
"basic.showLeds|param|leds":"le modèle de LED pour activer\/désactiver",
|
||||
"basic.showNumber":"Mettez en surbrillance un numéro sur l’écran. Si le numéro s’inscrit sur l’écran (c'est-à-dire un seul chiffre), ne défilent pas.",
|
||||
"basic.showNumber|param|interval":"Vitesse de défilement ; par exemple : -100, 200, 100, 150",
|
||||
"basic.showString":"Afficher du texte à l’écran, un caractère à la fois. Si la chaîne s’inscrit sur l’écran (c'est-à-dire une lettre), ne défile pas.",
|
||||
"basic.showString|param|interval":"quelle vitesse de déplacement des personnages ; par exemple : -100, 200, 100, 150",
|
||||
"basic.showString|param|text":"le texte à faire défiler sur l’écran, par exemple : « Bonjour ! »",
|
||||
"control":"Utilitaires d’exécution et événements.",
|
||||
"control.inBackground":"Horaires du code qui s’exécutent en arrière-plan.",
|
||||
"control.reset":"Réinitialise le BBC micro : bit.",
|
||||
"game":"Un moteur de jeu unique-LED sprite",
|
||||
"game.addScore":"Ajoute des points pour le score actuel",
|
||||
"game.addScore|param|points":"nombre de points à changer, par exemple : 1",
|
||||
"game.gameOver":"Affiche un jeu au dessus de l’animation.",
|
||||
"game.score":"Obtient le score actuel",
|
||||
"game.setScore":"Définit la valeur actuelle de la partition",
|
||||
"game.setScore|param|value":"TODO",
|
||||
"game.startCountdown":"Commence un compte à rebours jeu",
|
||||
"game.startCountdown|param|ms":"durée du compte à rebours en millisecondes, par exemple : 10000",
|
||||
"images":"Création, manipulation et affichage d’images LED.",
|
||||
"images.createBigImage":"Crée une image avec 2 images.",
|
||||
"images.createImage":"Crée une image qui s’adapte à l’écran LED.",
|
||||
"input":"Événements et des données provenant de capteurs",
|
||||
"input.acceleration":"Obtenir la valeur de l’accélération en milli-gravitys (lorsque le jury pose plat avec l’écran vers le haut, x = 0, y = 0 et z =-1024)",
|
||||
"input.acceleration|param|dimension":"TODO",
|
||||
"input.buttonIsPressed":"Obtenir l’état du bouton (pressé ou non) pour '' A'' et '' B''.",
|
||||
"input.calibrate":"Obsolète, boussole de calibrage est automatique.",
|
||||
"input.compassHeading":"Obtenir le cap compas boussole actuel en degrés.",
|
||||
"input.lightLevel":"Lit le niveau de lumière appliqué à l’écran LED dans une gamme de '' 0'' (noir) à 255 '''' lumineux.",
|
||||
"input.magneticForce":"Obtenir la valeur de la force magnétique dans '' micro-Teslas'' ('' µT''). Cette fonction n’est pas pris en charge dans le simulateur.",
|
||||
"input.magneticForce|param|dimension":"TODO",
|
||||
"input.onButtonPressed":"Faire quelque chose quand vous appuyez sur un bouton ('' A'', '' B'' ou les deux '' A + B'')",
|
||||
"input.onButtonPressed|param|body":"TODO",
|
||||
"input.onButtonPressed|param|button":"TODO",
|
||||
"input.onGesture":"Attache le code à exécuter lorsque l’écran vers le haut.",
|
||||
"input.onGesture|param|body":"TODO",
|
||||
"input.onLogoDown":"Attache le code à exécuter lorsque le logo est orienté vers le bas et le jury est vertical.",
|
||||
"input.onLogoDown|param|body":"TODO",
|
||||
"input.onLogoUp":"Attache le code à exécuter lorsque le logo est orienté vers le haut et le jury est vertical.",
|
||||
"input.onLogoUp|param|body":"TODO",
|
||||
"input.onPinPressed":"Faire quelque chose lorsque vous appuyez sur une broche ('' P0'', '' P1'' ou les deux '' P2'').",
|
||||
"input.onPinPressed|param|body":"TODO",
|
||||
"input.onPinPressed|param|name":"TODO",
|
||||
"input.onScreenDown":"Attache le code à exécuter lorsque l’écran vers le bas.",
|
||||
"input.onScreenDown|param|body":"TODO",
|
||||
"input.onScreenUp":"Attache le code à exécuter lorsque l’écran vers le haut.",
|
||||
"input.onScreenUp|param|body":"TODO",
|
||||
"input.onShake":"Attache le code à exécuter lorsque l’appareil est secoué.",
|
||||
"input.onShake|param|body":"TODO",
|
||||
"input.pinIsPressed":"Obtenir l’état de la broche (pressé ou non). Nécessite de tenir au sol pour fermer le circuit.",
|
||||
"input.pinIsPressed|param|name":"broche utilisée pour détecter le toucher",
|
||||
"input.rotation":"La hauteur de l’appareil, rotation sur axe le '' x '', en degrés.",
|
||||
"input.rotation|param|kind":"TODO",
|
||||
"input.runningTime":"Obtient le nombre de millisecondes écoulées depuis le pouvoir sur.",
|
||||
"input.setAccelerometerRange":"Définit la plage d’échantillon accéléromètre de gravités.",
|
||||
"input.setAccelerometerRange|param|range":"une valeur décrivent l’assurer une rigidité maximale d’accélération mesurée",
|
||||
"input.temperature":"Obtient la température en Celsius degrés (° C).",
|
||||
"led":"Contrôle de l’écran LED.",
|
||||
"led.brightness":"Descendre la luminosité de l’écran de 0 () à 255 (pleine intensité).",
|
||||
"led.fadeIn":"Fondu dans l’affichage à l’écran.",
|
||||
"led.fadeIn|param|ms":"TODO",
|
||||
"led.fadeOut":"S’évanouit la luminosité de l’écran.",
|
||||
"led.fadeOut|param|ms":"TODO",
|
||||
"led.plot":"Allumer la LED spécifiée par x, y coordonnées (x est horizontal, y est verticale). (0,0) est en haut à gauche.",
|
||||
"led.plotAll":"Tous les voyants s’allume",
|
||||
"led.plotBarGraph":"Affiche un graphique à barres vertical basé sur la « valeur » et la valeur « élevée ».\nSi « élevé » est 0, le tableau s’ajuste automatiquement.",
|
||||
"led.plotBarGraph|param|high":"valeur maximale. Si 0, la valeur maximale ramenée automatiquement, par exemple : 0",
|
||||
"led.plotBarGraph|param|value":"valeur actuelle pour tracer",
|
||||
"led.plot|param|x":"TODO",
|
||||
"led.plot|param|y":"TODO",
|
||||
"led.point":"Obtenir l’État marche\/arrêt de la LED spécifiée par x, y coordonnées. (0,0) est en haut à gauche.",
|
||||
"led.point|param|x":"TODO",
|
||||
"led.point|param|y":"TODO",
|
||||
"led.screenshot":"Prend une capture d’écran de l’écran LED et renvoie une image.",
|
||||
"led.setBrightness":"Régler la luminosité de l’écran de 0 (off) à 255 (pleine intensité).",
|
||||
"led.setBrightness|param|value":"valeur de la luminosité, par exemple : 255, 127, 0",
|
||||
"led.setDisplayMode":"Définit le mode d’affichage entre noir et blanc et gris pour le rendu des LEDs.",
|
||||
"led.setDisplayMode|param|mode":"TODO",
|
||||
"led.stopAnimation":"Annule l’animation actuelle et efface les autres en attente d’animations.",
|
||||
"led.toggle":"Active\/désactive un pixel particulier",
|
||||
"led.toggleAll":"Inverse l’affichage actuel",
|
||||
"led.toggle|param|x":"TODO",
|
||||
"led.toggle|param|y":"TODO",
|
||||
"led.unplot":"Éteindre la LED spécifiée par x, y coordonnées (x est horizontal, y est verticale). (0,0) est en haut à gauche.",
|
||||
"led.unplot|param|x":"TODO",
|
||||
"led.unplot|param|y":"TODO",
|
||||
"music":"Génération de sonneries musicales via broche '' P0''.",
|
||||
"music.beat":"Retourne la durée d’un battement en milli-secondes",
|
||||
"music.changeTempoBy":"Changer le tempo de la quantité spécifiée",
|
||||
"music.changeTempoBy|param|bpm":"Le changement en battements par minute au tempo, par exemple : 20",
|
||||
"music.noteFrequency":"Obtient la fréquence d’une note.",
|
||||
"music.noteFrequency|param|name":"le nom de la note",
|
||||
"music.playTone":"Joue une tonalité via broche '' P0'' pour la durée donnée.",
|
||||
"music.playTone|param|frequency":"hauteur de la tonalité pour jouer en Hertz (Hz)",
|
||||
"music.playTone|param|ms":"durée de la tonalité en millisecondes (ms)",
|
||||
"music.rest":"Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
|
||||
"music.rest|param|ms":"reposer la durée en millisecondes (ms)",
|
||||
"music.ringTone":"Joue une tonalité via broche '' P0''.",
|
||||
"music.ringTone|param|frequency":"hauteur de la tonalité pour jouer en Hertz (Hz)",
|
||||
"music.setTempo":"Définit le tempo à la quantité spécifiée",
|
||||
"music.setTempo|param|bpm":"Le nouveau tempo en battements par minute, par exemple : 120",
|
||||
"music.tempo":"Retourne le tempo en battements par minute. Tempo est la vitesse (bpm = battements par minute) à qui jouent des notes. Plus la valeur du tempo, plus vite les notes jouera.",
|
||||
"pins":"Contrôle des courants à Pins pour signaux analogiques\/numériques, servos, i2c...",
|
||||
"pins.analogPitch":"Émet un signal de modulation (PWM) de largeur d’impulsion à l’axe de tangage actuelle. Utilisez « analog set axe de tangage » pour définir l’axe de tangage.",
|
||||
"pins.analogPitch|param|frequency":"TODO",
|
||||
"pins.analogPitch|param|ms":"TODO",
|
||||
"pins.analogReadPin":"Lire la valeur de connecteur analogique, c'est-à-dire comme une valeur comprise entre 0 et 1023.",
|
||||
"pins.analogReadPin|param|name":"broche d’écrire à",
|
||||
"pins.analogSetPeriod":"Configure la modulation de largeur d’impulsion (PWM) de la sortie à la valeur donnée en analogique ** microsecondes ** ou « 1\/1000' millisecondes.\nSi cette broche n’est pas configurée comme un analogue de sortie (en utilisant « écriture analogique pin »), l’opération n’a aucun effet.",
|
||||
"pins.analogSetPeriod|param|micros":"période en micro secondes. par exemple : 20000",
|
||||
"pins.analogSetPeriod|param|name":"broche analogique pour définir le délai",
|
||||
"pins.analogSetPitchPin":"Définit l’axe utilisé lors de l’utilisation de « pins-> pitch analogique ».",
|
||||
"pins.analogSetPitchPin|param|name":"TODO",
|
||||
"pins.analogWritePin":"Définissez la valeur de connecteur analogique. Valeur doit être comprise entre 0 et 1023.",
|
||||
"pins.analogWritePin|param|name":"nom de la broche d’écrire à",
|
||||
"pins.analogWritePin|param|value":"valeur à écrire sur la broche entre '' 0'' et '' 1023''. par exemple : 1023, 0",
|
||||
"pins.digitalReadPin":"Lire la broche spécifié ou le connecteur comme 0 ou 1",
|
||||
"pins.digitalReadPin|param|name":"broche pour lire à partir",
|
||||
"pins.digitalWritePin":"Définir une valeur de code pin ou le connecteur à 0 ou 1.",
|
||||
"pins.digitalWritePin|param|name":"broche d’écrire à",
|
||||
"pins.digitalWritePin|param|value":"valeur à définir sur la broche, 1 par exemple, 0",
|
||||
"pins.i2cReadNumber":"Lire un numéro de 7-bit I2C adresse.",
|
||||
"pins.i2cWriteNumber":"Écrire un nombre à une adresse I2C de 7 bits.",
|
||||
"pins.map":"Remappe un nombre d’une plage à l’autre. Autrement dit, une valeur '' de faible '' serait sont mappée aux '' à faible '', une valeur de '' de haut '' à '' à haute '', valeurs intermédiaires à etc in-between, de valeurs.",
|
||||
"pins.map|param|fromHigh":"limite la supérieure de la gamme actuelle de la valeur, par exemple : 1023",
|
||||
"pins.map|param|fromLow":"la limite inférieure de la gamme actuelle de la valeur",
|
||||
"pins.map|param|toHigh":"la limite supérieure de la cible de la valeur du rang, par exemple : 4",
|
||||
"pins.map|param|toLow":"la limite inférieure de la fourchette cible de la valeur",
|
||||
"pins.map|param|value":"valeur à la carte dans les rangs",
|
||||
"pins.onPulsed":"Configure cette broche pour une entrée numérique et génère des événements où l’horodatage est la durée pendant laquelle cette broche a été '' élevé '' ou '' faible ''.",
|
||||
"pins.pulseDuration":"Obtient la durée de la dernière impulsion en microsecondes. Cette fonction doit être appelée à partir d’un gestionnaire de '' onPulsed''.",
|
||||
"pins.servoSetPulse":"Configure cette broche e\/s comme une sortie analogique\/pwm, configure le laps de temps pour être 20 ms et définit la largeur d’impulsion, basée sur la valeur, il est donné ** microsecondes ** ou « 1\/1000' millisecondes.",
|
||||
"pins.servoSetPulse|param|micros":"durée de l’impulsion en micro secondes, par exemple : 1500",
|
||||
"pins.servoSetPulse|param|name":"nom de code PIN",
|
||||
"pins.servoWritePin":"Écrit une valeur à l’asservissement, contrôle de l’arbre en conséquence. Sur un servo standard, cette fonction définira l’angle de l’arbre (en degrés), déplacer l’arbre à cette orientation. Sur un servo de rotation continue, cette fonction définira la vitesse du servo (avec '' 0'' en pleine vitesse dans une seule direction, '' 180'' en pleine vitesse dans l’autre et une valeur de près de 90 '''' aucun mouvement).",
|
||||
"pins.servoWritePin|param|name":"broche d’écrire à",
|
||||
"pins.servoWritePin|param|value":"angle ou rotation à vitesse, par exemple : 0, 90 et 180",
|
||||
"pins.setPull":"Configure l’attraction de cette broche.",
|
||||
"pins.setPull|param|name":"broche pour définir le mode de traction sur",
|
||||
"pins.setPull|param|pull":"une des configurations mbed pull : PullUp, menu déroulant, PullNone ",
|
||||
"serial":"Lire et écrire des données sur une connexion série.",
|
||||
"serial.readLine":"Lit une ligne de texte à partir du port série.",
|
||||
"serial.redirect":"Configuration dynamique de l’instance de série pour utiliser des épingles autres que USBTX et USBRX.",
|
||||
"serial.redirect|param|rx":"le nouveau NIP de réception",
|
||||
"serial.redirect|param|tx":"les nouvelles goupilles de transmission",
|
||||
"serial.writeLine":"Imprime une ligne de texte pour le numéro de série",
|
||||
"serial.writeNumber":"Imprime une valeur numérique de la série",
|
||||
"serial.writeString":"Envoie un morceau de texte via la connexion série.",
|
||||
"serial.writeValue":"Écrit un « nom : valeur '' paire de ligne de la série.",
|
||||
"serial.writeValue|param|name":"nom de la valeur stream, par exemple : x",
|
||||
"serial.writeValue|param|value":"Écrire"
|
||||
}
|
@ -1,240 +0,0 @@
|
||||
{
|
||||
"Math.randomBoolean":"Génère une valeur « true » ou « false » au hasard, tout comme le retournement d’une pièce de monnaie.",
|
||||
"Math.randomBoolean|block":"choisir au hasard vrai ou faux",
|
||||
"Math|block":"Math",
|
||||
"String.fromCharCode":"Faire une chaîne de la donnée code de caractères ASCII.",
|
||||
"String.fromCharCode|block":"texte de char code %code",
|
||||
"String|block":"Chaîne",
|
||||
"basic":"Permet d'accéder aux fonctionnalités de base micro : bit.",
|
||||
"basic.clearScreen":"Désactiver toutes les LEDs",
|
||||
"basic.clearScreen|block":"effacer l’écran",
|
||||
"basic.forever":"Répète le code pour toujours en arrière-plan. À chaque itération, permet aux autres codes d'exécuter.",
|
||||
"basic.forever|block":"pour toujours",
|
||||
"basic.pause":"Pause pendant la durée spécifiée en millisecondes",
|
||||
"basic.pause|block":"pause (ms) %pause",
|
||||
"basic.pause|param|ms":"Combien de temps pour faire une pause pour, par exemple: 100, 200, 500, 1000, 2000",
|
||||
"basic.plotLeds":"Dessine une image sur l'écran LED.",
|
||||
"basic.plotLeds|param|leds":"modèle de LED à allumer\/éteindre",
|
||||
"basic.showAnimation":"Montre une séquence d'écrans LED comme une animation.",
|
||||
"basic.showAnimation|param|interval":"temps en millisecondes entre chaque rafraîchissement",
|
||||
"basic.showAnimation|param|leds":"modèle de LED à allumer\/éteindre",
|
||||
"basic.showLeds":"Dessine une image sur l'écran LED.",
|
||||
"basic.showLeds|block":"montrer les leds",
|
||||
"basic.showLeds|param|interval":"temps en millisecondes pour faire une pause après dessin",
|
||||
"basic.showLeds|param|leds":"le modèle de LED pour activer\/désactiver",
|
||||
"basic.showNumber":"Mettez en surbrillance un numéro sur l'écran. Si le numéro s'inscrit sur l'écran (c'est-à-dire un seul chiffre), ne défilent pas.",
|
||||
"basic.showNumber|block":"montrer|numéro %number",
|
||||
"basic.showNumber|param|interval":"Vitesse de défilement ; par exemple: -100, 200, 100, 150",
|
||||
"basic.showString":"Afficher du texte à l'écran, un caractère à la fois. Si la chaîne s'inscrit sur l'écran (c'est-à-dire une lettre), ne défile pas.",
|
||||
"basic.showString|block":"Show|String %text",
|
||||
"basic.showString|param|interval":"quelle vitesse de déplacement des personnages ; par exemple: -100, 200, 100, 150",
|
||||
"basic.showString|param|text":"le texte à faire défiler sur l’écran, par exemple: « Bonjour! »",
|
||||
"basic|block":"base",
|
||||
"control":"Utilitaires d'exécution et événements.",
|
||||
"control.inBackground":"Horaires du code qui s'exécutent en arrière-plan.",
|
||||
"control.inBackground|block":"exécuter en arrière-plan",
|
||||
"control.reset":"Réinitialise le BBC micro : bit.",
|
||||
"control.reset|block":"remise à zéro",
|
||||
"control|block":"contrôle",
|
||||
"game":"Un moteur de jeu unique-LED sprite",
|
||||
"game.addScore":"Ajoute des points pour le score actuel",
|
||||
"game.addScore|block":"changer le score par|%points",
|
||||
"game.addScore|param|points":"nombre de points à changer, par exemple: 1",
|
||||
"game.gameOver":"Affiche un jeu au dessus de l'animation.",
|
||||
"game.gameOver|block":"fin du jeu",
|
||||
"game.score":"Obtient le score actuel",
|
||||
"game.score|block":"score",
|
||||
"game.setScore":"Définit la valeur actuelle de la partition",
|
||||
"game.setScore|param|value":"TODO",
|
||||
"game.startCountdown":"Commence un compte à rebours jeu",
|
||||
"game.startCountdown|block":"commencer compte à rebours|(ms) %duration",
|
||||
"game.startCountdown|param|ms":"durée du compte à rebours en millisecondes, par exemple: 10000",
|
||||
"game|block":"jeu",
|
||||
"images":"Création, manipulation et affichage d'images LED.",
|
||||
"images.createBigImage":"Crée une image avec 2 images.",
|
||||
"images.createBigImage|block":"créer grande image",
|
||||
"images.createImage":"Crée une image qui s'adapte à l'écran LED.",
|
||||
"images.createImage|block":"créer image",
|
||||
"images|block":"images",
|
||||
"input":"Événements et des données provenant de capteurs",
|
||||
"input.acceleration":"Obtenir la valeur de l'accélération en milli-gravitys (lorsque le jury pose plat avec l'écran vers le haut, x = 0, y = 0 et z =-1024)",
|
||||
"input.acceleration|block":"accélération (mg) |%NAME",
|
||||
"input.acceleration|param|dimension":"TODO",
|
||||
"input.buttonIsPressed":"Obtenir l'état du bouton (pressé ou non) pour '' A'' et '' B''.",
|
||||
"input.buttonIsPressed|block":"button|%NAME|est pressé",
|
||||
"input.calibrate":"Obsolète, boussole de calibrage est automatique.",
|
||||
"input.compassHeading":"Obtenir le cap compas boussole actuel en degrés.",
|
||||
"input.compassHeading|block":"Compas de rubrique (°)",
|
||||
"input.lightLevel":"Lit le niveau de lumière appliqué à l'écran LED dans une gamme de '' 0'' (noir) à 255 '''' lumineux.",
|
||||
"input.lightLevel|block":"niveau d’intensité lumineuse",
|
||||
"input.magneticForce":"Obtenir la valeur de la force magnétique dans '' micro-Teslas'' ('' µT''). Cette fonction n'est pas pris en charge dans le simulateur.",
|
||||
"input.magneticForce|block":"force magnétique (µT) |%NAME",
|
||||
"input.magneticForce|param|dimension":"TODO",
|
||||
"input.onButtonPressed":"Faire quelque chose quand vous appuyez sur un bouton ('' A'', '' B'' ou les deux '' A + B'')",
|
||||
"input.onButtonPressed|block":"sur button|%NAME|pressed",
|
||||
"input.onButtonPressed|param|body":"TODO",
|
||||
"input.onButtonPressed|param|button":"TODO",
|
||||
"input.onGesture":"Attache le code à exécuter lorsque l'écran vers le haut.",
|
||||
"input.onGesture|block":"sur |%NAME",
|
||||
"input.onGesture|param|body":"TODO",
|
||||
"input.onLogoDown":"Attache le code à exécuter lorsque le logo est orienté vers le bas et le jury est vertical.",
|
||||
"input.onLogoDown|param|body":"TODO",
|
||||
"input.onLogoUp":"Attache le code à exécuter lorsque le logo est orienté vers le haut et le jury est vertical.",
|
||||
"input.onLogoUp|param|body":"TODO",
|
||||
"input.onPinPressed":"Faire quelque chose lorsque vous appuyez sur une broche ('' P0'', '' P1'' ou les deux '' P2'').",
|
||||
"input.onPinPressed|block":"sur pin|%NAME|pressed",
|
||||
"input.onPinPressed|param|body":"TODO",
|
||||
"input.onPinPressed|param|name":"TODO",
|
||||
"input.onScreenDown":"Attache le code à exécuter lorsque l'écran vers le bas.",
|
||||
"input.onScreenDown|param|body":"TODO",
|
||||
"input.onScreenUp":"Attache le code à exécuter lorsque l'écran vers le haut.",
|
||||
"input.onScreenUp|param|body":"TODO",
|
||||
"input.onShake":"Attache le code à exécuter lorsque l'appareil est secoué.",
|
||||
"input.onShake|param|body":"TODO",
|
||||
"input.pinIsPressed":"Obtenir l'état de la broche (pressé ou non). Nécessite de tenir au sol pour fermer le circuit.",
|
||||
"input.pinIsPressed|block":"pin|%NAME|is pressée",
|
||||
"input.pinIsPressed|param|name":"broche utilisée pour détecter le toucher",
|
||||
"input.rotation":"La hauteur de l'appareil, rotation sur axe le '' x '', en degrés.",
|
||||
"input.rotation|block":"rotation (°) |%NAME",
|
||||
"input.rotation|param|kind":"TODO",
|
||||
"input.runningTime":"Obtient le nombre de millisecondes écoulées depuis le pouvoir sur.",
|
||||
"input.runningTime|block":"temps d’exécution (ms)",
|
||||
"input.setAccelerometerRange":"Définit la plage d'échantillon accéléromètre de gravités.",
|
||||
"input.setAccelerometerRange|block":"Définissez accelerometer|range % plage",
|
||||
"input.setAccelerometerRange|param|range":"une valeur décrivent l’assurer une rigidité maximale d’accélération mesurée",
|
||||
"input.temperature":"Obtient la température en Celsius degrés (° C).",
|
||||
"input.temperature|block":"température (° C)",
|
||||
"input|block":"entrée",
|
||||
"led":"Contrôle de l'écran LED.",
|
||||
"led.brightness":"Descendre la luminosité de l'écran de 0 () à 255 (pleine intensité).",
|
||||
"led.brightness|block":"luminosité",
|
||||
"led.fadeIn":"Fondu dans l'affichage à l'écran.",
|
||||
"led.fadeIn|param|ms":"TODO",
|
||||
"led.fadeOut":"S'évanouit la luminosité de l'écran.",
|
||||
"led.fadeOut|param|ms":"TODO",
|
||||
"led.plot":"Allumer la LED spécifiée par x, y coordonnées (x est horizontal, y est verticale). (0,0) est en haut à gauche.",
|
||||
"led.plotAll":"Tous les voyants s'allume",
|
||||
"led.plotBarGraph":"Affiche un graphique à barres vertical basé sur la « valeur » et la valeur « élevée ».\nSi « élevé » est 0, le tableau s'ajuste automatiquement.",
|
||||
"led.plotBarGraph|block":"tracer le graphe de % valeur |à %high",
|
||||
"led.plotBarGraph|param|high":"valeur maximale. Si 0, la valeur maximale ramenée automatiquement, par exemple: 0",
|
||||
"led.plotBarGraph|param|value":"valeur actuelle pour tracer",
|
||||
"led.plot|block":"allumer|x %x|y %y",
|
||||
"led.plot|param|x":"TODO",
|
||||
"led.plot|param|y":"TODO",
|
||||
"led.point":"Obtenir l'État marche\/arrêt de la LED spécifiée par x, y coordonnées. (0,0) est en haut à gauche.",
|
||||
"led.point|block":"point|x %x|y %y",
|
||||
"led.point|param|x":"TODO",
|
||||
"led.point|param|y":"TODO",
|
||||
"led.screenshot":"Prend une capture d'écran de l'écran LED et renvoie une image.",
|
||||
"led.setBrightness":"Régler la luminosité de l'écran de 0 (off) à 255 (pleine intensité).",
|
||||
"led.setBrightness|block":"spécifier la luminosité %value",
|
||||
"led.setBrightness|param|value":"valeur de la luminosité, par exemple: 255, 127, 0",
|
||||
"led.setDisplayMode":"Définit le mode d'affichage entre noir et blanc et gris pour le rendu des LEDs.",
|
||||
"led.setDisplayMode|param|mode":"TODO",
|
||||
"led.stopAnimation":"Annule l'animation actuelle et efface les autres en attente d'animations.",
|
||||
"led.stopAnimation|block":"arrêter l’animation",
|
||||
"led.toggle":"Active\/désactive un pixel particulier",
|
||||
"led.toggleAll":"Inverse l'affichage actuel",
|
||||
"led.toggle|param|x":"TODO",
|
||||
"led.toggle|param|y":"TODO",
|
||||
"led.unplot":"Éteindre la LED spécifiée par x, y coordonnées (x est horizontal, y est verticale). (0,0) est en haut à gauche.",
|
||||
"led.unplot|block":"éteindre|x %x|y %y",
|
||||
"led.unplot|param|x":"TODO",
|
||||
"led.unplot|param|y":"TODO",
|
||||
"led|block":"écran",
|
||||
"music":"Génération de sonneries musicales via broche '' P0''.",
|
||||
"music.beat":"Retourne la durée d'un battement en milli-secondes",
|
||||
"music.beat|block":"%fraction|beat",
|
||||
"music.changeTempoBy":"Changer le tempo de la quantité spécifiée",
|
||||
"music.changeTempoBy|block":"changer le tempo par (bpm) | % valeur",
|
||||
"music.changeTempoBy|param|bpm":"Le changement en battements par minute au tempo, par exemple: 20",
|
||||
"music.noteFrequency":"Obtient la fréquence d'une note.",
|
||||
"music.noteFrequency|block":"%note",
|
||||
"music.noteFrequency|param|name":"le nom de la note",
|
||||
"music.playTone":"Joue une tonalité via broche '' P0'' pour la durée donnée.",
|
||||
"music.playTone|block":"jouer|ton %note=device_note|pendant %duration=device_beat",
|
||||
"music.playTone|param|frequency":"hauteur de la tonalité pour jouer en Hertz (Hz)",
|
||||
"music.playTone|param|ms":"durée de la tonalité en millisecondes (ms)",
|
||||
"music.rest":"Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
|
||||
"music.rest|block":"repos (ms) |%duration = device_beat",
|
||||
"music.rest|param|ms":"reposer la durée en millisecondes (ms)",
|
||||
"music.ringTone":"Joue une tonalité via broche '' P0''.",
|
||||
"music.ringTone|block":"buzz (Hz)|%note=device_note",
|
||||
"music.ringTone|param|frequency":"hauteur de la tonalité pour jouer en Hertz (Hz)",
|
||||
"music.setTempo":"Définit le tempo à la quantité spécifiée",
|
||||
"music.setTempo|block":"réglage de tempo pour (bpm) | % valeur",
|
||||
"music.setTempo|param|bpm":"Le nouveau tempo en battements par minute, par exemple: 120",
|
||||
"music.tempo":"Retourne le tempo en battements par minute. Tempo est la vitesse (bpm = battements par minute) à qui jouent des notes. Plus la valeur du tempo, plus vite les notes jouera.",
|
||||
"music.tempo|block":"tempo (bpm)",
|
||||
"music|block":"musique",
|
||||
"pins":"Contrôle des courants à Pins pour signaux analogiques\/numériques, servos, i2c...",
|
||||
"pins.analogPitch":"Émet un signal de modulation (PWM) de largeur d'impulsion à l'axe de tangage actuelle. Utilisez « analog set axe de tangage » pour définir l'axe de tangage.",
|
||||
"pins.analogPitch|param|frequency":"TODO",
|
||||
"pins.analogPitch|param|ms":"TODO",
|
||||
"pins.analogReadPin":"Lire la valeur de connecteur analogique, c'est-à-dire comme une valeur comprise entre 0 et 1023.",
|
||||
"pins.analogReadPin|block":"read|pin analogique %name",
|
||||
"pins.analogReadPin|param|name":"broche d’écrire à",
|
||||
"pins.analogSetPeriod":"Configure la modulation de largeur d'impulsion (PWM) de la sortie à la valeur donnée en analogique ** microsecondes ** ou « 1\/1000' millisecondes.\nSi cette broche n'est pas configurée comme un analogue de sortie (en utilisant « écriture analogique pin »), l'opération n'a aucun effet.",
|
||||
"pins.analogSetPeriod|block":"Analog set period|pin %pin|to micros % (µs)",
|
||||
"pins.analogSetPeriod|param|micros":"période en micro secondes. par exemple: 20000",
|
||||
"pins.analogSetPeriod|param|name":"broche analogique pour définir le délai",
|
||||
"pins.analogSetPitchPin":"Définit l'axe utilisé lors de l'utilisation de \"pins-> pitch analogique\".",
|
||||
"pins.analogSetPitchPin|param|name":"TODO",
|
||||
"pins.analogWritePin":"Définissez la valeur de connecteur analogique. Valeur doit être comprise entre 0 et 1023.",
|
||||
"pins.analogWritePin|block":"write|pin analogique %name|to % valeur",
|
||||
"pins.analogWritePin|param|name":"nom de la broche d’écrire à",
|
||||
"pins.analogWritePin|param|value":"valeur à écrire sur la broche entre '' 0'' et '' 1023''. par exemple: 1023, 0",
|
||||
"pins.digitalReadPin":"Lire la broche spécifié ou le connecteur comme 0 ou 1",
|
||||
"pins.digitalReadPin|block":"read|pin numérique %name",
|
||||
"pins.digitalReadPin|param|name":"broche pour lire à partir",
|
||||
"pins.digitalWritePin":"Définir une valeur de code pin ou le connecteur à 0 ou 1.",
|
||||
"pins.digitalWritePin|block":"write|pin numérique %name|to % valeur",
|
||||
"pins.digitalWritePin|param|name":"broche d’écrire à",
|
||||
"pins.digitalWritePin|param|value":"valeur à définir sur la broche, 1 par exemple, 0",
|
||||
"pins.i2cReadNumber":"Lire un numéro de 7-bit I2C adresse.",
|
||||
"pins.i2cReadNumber|block":"I2C lire number|at adresse %address|of format %format = i2c_sizeof",
|
||||
"pins.i2cWriteNumber":"Écrire un nombre à une adresse I2C de 7 bits.",
|
||||
"pins.i2cWriteNumber|block":"I2C écrire number|at adresse %address|with valeur % value|of format %format = i2c_sizeof",
|
||||
"pins.map":"Remappe un nombre d'une plage à l'autre. Autrement dit, une valeur '' de faible '' serait sont mappée aux '' à faible '', une valeur de '' de haut '' à '' à haute '', valeurs intermédiaires à etc in-between, de valeurs.",
|
||||
"pins.map|block":"carte % value|from %fromLow|from basse %fromHigh|to haute basse %toLow|to haute %toHigh",
|
||||
"pins.map|param|fromHigh":"limite la supérieure de la gamme actuelle de la valeur, par exemple: 1023",
|
||||
"pins.map|param|fromLow":"la limite inférieure de la gamme actuelle de la valeur",
|
||||
"pins.map|param|toHigh":"la limite supérieure de la cible de la valeur du rang, par exemple: 4",
|
||||
"pins.map|param|toLow":"la limite inférieure de la fourchette cible de la valeur",
|
||||
"pins.map|param|value":"valeur à la carte dans les rangs",
|
||||
"pins.onPulsed":"Configure cette broche pour une entrée numérique et génère des événements où l’horodatage est la durée pendant laquelle cette broche a été '' élevé '' ou '' faible ''.",
|
||||
"pins.onPulsed|block":"on|pin %pin|pulsed %pulse",
|
||||
"pins.pulseDuration":"Obtient la durée de la dernière impulsion en microsecondes. Cette fonction doit être appelée à partir d’un gestionnaire de '' onPulsed''.",
|
||||
"pins.pulseDuration|block":"durée de l’impulsion (µs)",
|
||||
"pins.servoSetPulse":"Configure cette broche e\/s comme une sortie analogique\/pwm, configure le laps de temps pour être 20 ms et définit la largeur d'impulsion, basée sur la valeur, il est donné ** microsecondes ** ou « 1\/1000' millisecondes.",
|
||||
"pins.servoSetPulse|block":"servo set pulse|pin % value|to (µs) % micros",
|
||||
"pins.servoSetPulse|param|micros":"durée de l’impulsion en micro secondes, par exemple: 1500",
|
||||
"pins.servoSetPulse|param|name":"nom de code PIN",
|
||||
"pins.servoWritePin":"Écrit une valeur à l'asservissement, contrôle de l'arbre en conséquence. Sur un servo standard, cette fonction définira l'angle de l'arbre (en degrés), déplacer l'arbre à cette orientation. Sur un servo de rotation continue, cette fonction définira la vitesse du servo (avec '' 0'' en pleine vitesse dans une seule direction, '' 180 cm en pleine vitesse dans l'autre et une valeur de près de 90 '''' aucun mouvement).",
|
||||
"pins.servoWritePin|block":"servo write|pin %name|to % de la valeur",
|
||||
"pins.servoWritePin|param|name":"broche d’écrire à",
|
||||
"pins.servoWritePin|param|value":"angle ou rotation à vitesse, par exemple: 0, 90 et 180",
|
||||
"pins.setPull":"Configure l’attraction de cette broche.",
|
||||
"pins.setPull|block":"Set pull|pin %pin|to %pull",
|
||||
"pins.setPull|param|name":"broche pour définir le mode de traction sur",
|
||||
"pins.setPull|param|pull":"une des configurations mbed pull : PullUp, menu déroulant, PullNone ",
|
||||
"pins|block":"broches",
|
||||
"serial":"Lire et écrire des données sur une connexion série.",
|
||||
"serial.readLine":"Lit une ligne de texte à partir du port série.",
|
||||
"serial.readLine|block":"série lire ligne",
|
||||
"serial.redirect":"Configuration dynamique de l’instance de série pour utiliser des épingles autres que USBTX et USBRX.",
|
||||
"serial.redirect|block":"redirection série to| TX %tx| Taux % du taux de baud rx|at RX %",
|
||||
"serial.redirect|param|rx":"le nouveau NIP de réception",
|
||||
"serial.redirect|param|tx":"les nouvelles goupilles de transmission",
|
||||
"serial.writeLine":"Imprime une ligne de texte pour le numéro de série",
|
||||
"serial.writeLine|block":"Serial|Write ligne %text",
|
||||
"serial.writeNumber":"Imprime une valeur numérique de la série",
|
||||
"serial.writeNumber|block":"% valeur Serial|Write",
|
||||
"serial.writeString":"Envoie un morceau de texte via la connexion série.",
|
||||
"serial.writeString|block":"%text chaîne série écriture",
|
||||
"serial.writeValue":"Écrit un « nom : valeur '' paire de ligne de la série.",
|
||||
"serial.writeValue|block":"serial|écrire valeur %name|= %valeur",
|
||||
"serial.writeValue|param|name":"nom de la valeur stream, par exemple: x",
|
||||
"serial.writeValue|param|value":"Écrire",
|
||||
"serial|block":"Serial"
|
||||
}
|
166
libs/microbit/_locales/microbit-jsdoc-strings.json
Normal file
166
libs/microbit/_locales/microbit-jsdoc-strings.json
Normal file
@ -0,0 +1,166 @@
|
||||
{
|
||||
"Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.",
|
||||
"String.fromCharCode": "Make a string from the given ASCII character code.",
|
||||
"basic": "Provides access to basic micro:bit functionality.",
|
||||
"basic.clearScreen": "Turn off all LEDs",
|
||||
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||
"basic.pause": "Pause for the specified time in milliseconds",
|
||||
"basic.pause|param|ms": "how long to pause for, eg: 100, 200, 500, 1000, 2000",
|
||||
"basic.plotLeds": "Draws an image on the LED screen.",
|
||||
"basic.plotLeds|param|leds": "pattern of LEDs to turn on/off",
|
||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
||||
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
||||
"basic.showLeds": "Draws an image on the LED screen.",
|
||||
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
||||
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
||||
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
|
||||
"basic.showNumber|param|interval": "speed of scroll; eg: 150, 100, 200, -100",
|
||||
"basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
|
||||
"basic.showString|param|interval": "how fast to shift characters; eg: 150, 100, 200, -100",
|
||||
"basic.showString|param|text": "the text to scroll on the screen, eg: \"Hello!\"",
|
||||
"control": "Runtime and event utilities.",
|
||||
"control.inBackground": "Schedules code that run in the background.",
|
||||
"control.reset": "Resets the BBC micro:bit.",
|
||||
"game": "A single-LED sprite game engine",
|
||||
"game.addScore": "Adds points to the current score",
|
||||
"game.addScore|param|points": "amount of points to change, eg: 1",
|
||||
"game.gameOver": "Displays a game over animation.",
|
||||
"game.score": "Gets the current score",
|
||||
"game.setScore": "Sets the current score value",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.startCountdown": "Starts a game countdown timer",
|
||||
"game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000",
|
||||
"images": "Creation, manipulation and display of LED images.",
|
||||
"images.createBigImage": "Creates an image with 2 frames.",
|
||||
"images.createImage": "Creates an image that fits on the LED screen.",
|
||||
"input": "Events and data from sensors",
|
||||
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||
"input.compassHeading": "Get the current compass compass heading in degrees.",
|
||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture": "Attaches code to run when the screen is facing up.",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.onPinPressed": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.",
|
||||
"input.onPinPressed|param|body": "TODO",
|
||||
"input.onPinPressed|param|name": "TODO",
|
||||
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||
"input.onScreenUp|param|body": "TODO",
|
||||
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||
"input.pinIsPressed|param|name": "pin used to detect the touch",
|
||||
"input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
|
||||
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||
"led": "Control of the LED screen.",
|
||||
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.fadeIn": "Fades in the screen display.",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut": "Fades out the screen brightness.",
|
||||
"led.fadeOut|param|ms": "TODO",
|
||||
"led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.plotAll": "Turns all LEDS on",
|
||||
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
||||
"led.plotBarGraph|param|high": "maximum value. If 0, maximum value adjusted automatically, eg: 0",
|
||||
"led.plotBarGraph|param|value": "current value to plot",
|
||||
"led.plot|param|x": "TODO",
|
||||
"led.plot|param|y": "TODO",
|
||||
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
||||
"led.point|param|x": "TODO",
|
||||
"led.point|param|y": "TODO",
|
||||
"led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
|
||||
"led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.setBrightness|param|value": "the brightness value, eg:255, 127, 0",
|
||||
"led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
|
||||
"led.setDisplayMode|param|mode": "TODO",
|
||||
"led.stopAnimation": "Cancels the current animation and clears other pending animations.",
|
||||
"led.toggle": "Toggles a particular pixel",
|
||||
"led.toggleAll": "Inverts the current LED display",
|
||||
"led.toggle|param|x": "TODO",
|
||||
"led.toggle|param|y": "TODO",
|
||||
"led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.unplot|param|x": "TODO",
|
||||
"led.unplot|param|y": "TODO",
|
||||
"music": "Generation of music tones through pin ``P0``.",
|
||||
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||
"music.noteFrequency": "Gets the frequency of a note.",
|
||||
"music.noteFrequency|param|name": "the note name",
|
||||
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
||||
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
||||
"music.rest|param|ms": "rest duration in milliseconds (ms)",
|
||||
"music.ringTone": "Plays a tone through pin ``P0``.",
|
||||
"music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.setTempo": "Sets the tempo to the specified amount",
|
||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
||||
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
||||
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
||||
"pins.analogPitch|param|frequency": "TODO",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||
"pins.analogReadPin|param|name": "pin to write to",
|
||||
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
|
||||
"pins.analogSetPeriod|param|name": "analog pin to set period to",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
||||
"pins.analogSetPitchPin|param|name": "TODO",
|
||||
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||
"pins.analogWritePin|param|name": "pin name to write to",
|
||||
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
||||
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||
"pins.digitalReadPin|param|name": "pin to read from",
|
||||
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||
"pins.digitalWritePin|param|name": "pin to write to",
|
||||
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
|
||||
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
||||
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
|
||||
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
|
||||
"pins.map|param|fromHigh": "the upper bound of the value's current range, eg: 1023",
|
||||
"pins.map|param|fromLow": "the lower bound of the value's current range",
|
||||
"pins.map|param|toHigh": "the upper bound of the value's target range, eg: 4",
|
||||
"pins.map|param|toLow": "the lower bound of the value's target range",
|
||||
"pins.map|param|value": "value to map in ranges",
|
||||
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
||||
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
|
||||
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
|
||||
"pins.servoSetPulse|param|name": "pin name",
|
||||
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||
"pins.servoWritePin|param|name": "pin to write to",
|
||||
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
|
||||
"pins.setPull": "Configures the pull of this pin.",
|
||||
"pins.setPull|param|name": "pin to set the pull mode on",
|
||||
"pins.setPull|param|pull": "one of the mbed pull configurations: PullUp, PullDown, PullNone ",
|
||||
"serial": "Reading and writing data over a serial connection.",
|
||||
"serial.readLine": "Reads a line of text from the serial port.",
|
||||
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",
|
||||
"serial.redirect|param|rx": "the new reception pin",
|
||||
"serial.redirect|param|tx": "the new transmission pins",
|
||||
"serial.writeLine": "Prints a line of text to the serial",
|
||||
"serial.writeNumber": "Prints a numeric value to the serial",
|
||||
"serial.writeString": "Sends a piece of text through Serial connection.",
|
||||
"serial.writeValue": "Writes a ``name: value`` pair line to the serial.",
|
||||
"serial.writeValue|param|name": "name of the value stream, eg: x",
|
||||
"serial.writeValue|param|value": "to write"
|
||||
}
|
@ -1,240 +1,76 @@
|
||||
{
|
||||
"Math.randomBoolean": "Generates a `true` or `false` value randomly, just like flipping a coin.",
|
||||
"Math.randomBoolean|block": "pick random true or false",
|
||||
"Math|block": "Math",
|
||||
"String.fromCharCode": "Make a string from the given ASCII character code.",
|
||||
"String.fromCharCode|block": "text from char code %code",
|
||||
"String|block": "String",
|
||||
"basic": "Provides access to basic micro:bit functionality.",
|
||||
"basic.clearScreen": "Turn off all LEDs",
|
||||
"basic.clearScreen|block": "clear screen",
|
||||
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||
"basic.forever|block": "forever",
|
||||
"basic.pause": "Pause for the specified time in milliseconds",
|
||||
"basic.pause|block": "pause (ms) %pause",
|
||||
"basic.pause|param|ms": "how long to pause for, eg: 100, 200, 500, 1000, 2000",
|
||||
"basic.plotLeds": "Draws an image on the LED screen.",
|
||||
"basic.plotLeds|param|leds": "pattern of LEDs to turn on/off",
|
||||
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||
"basic.showAnimation|param|interval": "time in milliseconds between each redraw",
|
||||
"basic.showAnimation|param|leds": "pattern of LEDs to turn on/off",
|
||||
"basic.showLeds": "Draws an image on the LED screen.",
|
||||
"basic.showLeds|block": "show leds",
|
||||
"basic.showLeds|param|interval": "time in milliseconds to pause after drawing",
|
||||
"basic.showLeds|param|leds": "the pattern of LED to turn on/off",
|
||||
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
|
||||
"basic.showNumber|block": "show|number %number",
|
||||
"basic.showNumber|param|interval": "speed of scroll; eg: 150, 100, 200, -100",
|
||||
"basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
|
||||
"basic.showString|block": "show|string %text",
|
||||
"basic.showString|param|interval": "how fast to shift characters; eg: 150, 100, 200, -100",
|
||||
"basic.showString|param|text": "the text to scroll on the screen, eg: \"Hello!\"",
|
||||
"basic|block": "basic",
|
||||
"control": "Runtime and event utilities.",
|
||||
"control.inBackground": "Schedules code that run in the background.",
|
||||
"control.inBackground|block": "run in background",
|
||||
"control.reset": "Resets the BBC micro:bit.",
|
||||
"control.reset|block": "reset",
|
||||
"control|block": "control",
|
||||
"game": "A single-LED sprite game engine",
|
||||
"game.addScore": "Adds points to the current score",
|
||||
"game.addScore|block": "change score by|%points",
|
||||
"game.addScore|param|points": "amount of points to change, eg: 1",
|
||||
"game.gameOver": "Displays a game over animation.",
|
||||
"game.gameOver|block": "game over",
|
||||
"game.score": "Gets the current score",
|
||||
"game.score|block": "score",
|
||||
"game.setScore": "Sets the current score value",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.startCountdown": "Starts a game countdown timer",
|
||||
"game.startCountdown|block": "start countdown|(ms) %duration",
|
||||
"game.startCountdown|param|ms": "countdown duration in milliseconds, eg: 10000",
|
||||
"game|block": "game",
|
||||
"images": "Creation, manipulation and display of LED images.",
|
||||
"images.createBigImage": "Creates an image with 2 frames.",
|
||||
"images.createBigImage|block": "create big image",
|
||||
"images.createImage": "Creates an image that fits on the LED screen.",
|
||||
"images.createImage|block": "create image",
|
||||
"images|block": "images",
|
||||
"input": "Events and data from sensors",
|
||||
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||
"input.acceleration|block": "acceleration (mg)|%NAME",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||
"input.buttonIsPressed|block": "button|%NAME|is pressed",
|
||||
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||
"input.compassHeading": "Get the current compass compass heading in degrees.",
|
||||
"input.compassHeading|block": "compass heading (°)",
|
||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||
"input.lightLevel|block": "light level",
|
||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||
"input.magneticForce|block": "magnetic force (µT)|%NAME",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||
"input.onButtonPressed|block": "on button|%NAME|pressed",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture": "Attaches code to run when the screen is facing up.",
|
||||
"input.onGesture|block": "on |%NAME",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.onPinPressed": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.",
|
||||
"input.onPinPressed|block": "on pin|%NAME|pressed",
|
||||
"input.onPinPressed|param|body": "TODO",
|
||||
"input.onPinPressed|param|name": "TODO",
|
||||
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||
"input.onScreenUp|param|body": "TODO",
|
||||
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||
"input.pinIsPressed|block": "pin|%NAME|is pressed",
|
||||
"input.pinIsPressed|param|name": "pin used to detect the touch",
|
||||
"input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
|
||||
"input.pinIsPressed|block": "pin %NAME|is pressed",
|
||||
"input.rotation|block": "rotation (°)|%NAME",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||
"input.runningTime|block": "running time (ms)",
|
||||
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||
"input.setAccelerometerRange|block": "set accelerometer|range %range",
|
||||
"input.setAccelerometerRange|param|range": "a value describe the maximum strengh of acceleration measured",
|
||||
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||
"input.temperature|block": "temperature (°C)",
|
||||
"input|block": "input",
|
||||
"led": "Control of the LED screen.",
|
||||
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.brightness|block": "brightness",
|
||||
"led.fadeIn": "Fades in the screen display.",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut": "Fades out the screen brightness.",
|
||||
"led.fadeOut|param|ms": "TODO",
|
||||
"led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.plotAll": "Turns all LEDS on",
|
||||
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
||||
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
|
||||
"led.plotBarGraph|param|high": "maximum value. If 0, maximum value adjusted automatically, eg: 0",
|
||||
"led.plotBarGraph|param|value": "current value to plot",
|
||||
"led.plot|block": "plot|x %x|y %y",
|
||||
"led.plot|param|x": "TODO",
|
||||
"led.plot|param|y": "TODO",
|
||||
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
||||
"led.point|block": "point|x %x|y %y",
|
||||
"led.point|param|x": "TODO",
|
||||
"led.point|param|y": "TODO",
|
||||
"led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
|
||||
"led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
|
||||
"led.setBrightness|block": "set brightness %value",
|
||||
"led.setBrightness|param|value": "the brightness value, eg:255, 127, 0",
|
||||
"led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
|
||||
"led.setDisplayMode|param|mode": "TODO",
|
||||
"led.stopAnimation": "Cancels the current animation and clears other pending animations.",
|
||||
"led.stopAnimation|block": "stop animation",
|
||||
"led.toggle": "Toggles a particular pixel",
|
||||
"led.toggleAll": "Inverts the current LED display",
|
||||
"led.toggle|param|x": "TODO",
|
||||
"led.toggle|param|y": "TODO",
|
||||
"led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||
"led.unplot|block": "unplot|x %x|y %y",
|
||||
"led.unplot|param|x": "TODO",
|
||||
"led.unplot|param|y": "TODO",
|
||||
"led|block": "led",
|
||||
"music": "Generation of music tones through pin ``P0``.",
|
||||
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||
"music.beat|block": "%fraction|beat",
|
||||
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
|
||||
"music.changeTempoBy|param|bpm": "The change in beats per minute to the tempo, eg: 20",
|
||||
"music.noteFrequency": "Gets the frequency of a note.",
|
||||
"music.noteFrequency|block": "%note",
|
||||
"music.noteFrequency|param|name": "the note name",
|
||||
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
|
||||
"music.playTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.playTone|param|ms": "tone duration in milliseconds (ms)",
|
||||
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
||||
"music.rest|block": "rest(ms)|%duration=device_beat",
|
||||
"music.rest|param|ms": "rest duration in milliseconds (ms)",
|
||||
"music.ringTone": "Plays a tone through pin ``P0``.",
|
||||
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
|
||||
"music.ringTone|param|frequency": "pitch of the tone to play in Hertz (Hz)",
|
||||
"music.setTempo": "Sets the tempo to the specified amount",
|
||||
"music.setTempo|block": "set tempo to (bpm)|%value",
|
||||
"music.setTempo|param|bpm": "The new tempo in beats per minute, eg: 120",
|
||||
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
||||
"music.tempo|block": "tempo (bpm)",
|
||||
"music|block": "music",
|
||||
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
||||
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
||||
"pins.analogPitch|param|frequency": "TODO",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||
"pins.analogReadPin|block": "analog read|pin %name",
|
||||
"pins.analogReadPin|param|name": "pin to write to",
|
||||
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
|
||||
"pins.analogSetPeriod|param|micros": "period in micro seconds. eg:20000",
|
||||
"pins.analogSetPeriod|param|name": "analog pin to set period to",
|
||||
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
||||
"pins.analogSetPitchPin|param|name": "TODO",
|
||||
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||
"pins.analogWritePin|block": "analog write|pin %name|to %value",
|
||||
"pins.analogWritePin|param|name": "pin name to write to",
|
||||
"pins.analogWritePin|param|value": "value to write to the pin between ``0`` and ``1023``. eg:1023,0",
|
||||
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||
"pins.digitalReadPin|block": "digital read|pin %name",
|
||||
"pins.digitalReadPin|param|name": "pin to read from",
|
||||
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
|
||||
"pins.digitalWritePin|param|name": "pin to write to",
|
||||
"pins.digitalWritePin|param|value": "value to set on the pin, 1 eg,0",
|
||||
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
|
||||
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
|
||||
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
|
||||
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
|
||||
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
|
||||
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
|
||||
"pins.map|param|fromHigh": "the upper bound of the value's current range, eg: 1023",
|
||||
"pins.map|param|fromLow": "the lower bound of the value's current range",
|
||||
"pins.map|param|toHigh": "the upper bound of the value's target range, eg: 4",
|
||||
"pins.map|param|toLow": "the lower bound of the value's target range",
|
||||
"pins.map|param|value": "value to map in ranges",
|
||||
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
|
||||
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
|
||||
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulsed`` handler.",
|
||||
"pins.pulseDuration|block": "pulse duration (µs)",
|
||||
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
|
||||
"pins.servoSetPulse|param|micros": "pulse duration in micro seconds, eg:1500",
|
||||
"pins.servoSetPulse|param|name": "pin name",
|
||||
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||
"pins.servoWritePin|block": "servo write|pin %name|to %value",
|
||||
"pins.servoWritePin|param|name": "pin to write to",
|
||||
"pins.servoWritePin|param|value": "angle or rotation speed, eg:180,90,0",
|
||||
"pins.setPull": "Configures the pull of this pin.",
|
||||
"pins.setPull|block": "set pull|pin %pin|to %pull",
|
||||
"pins.setPull|param|name": "pin to set the pull mode on",
|
||||
"pins.setPull|param|pull": "one of the mbed pull configurations: PullUp, PullDown, PullNone ",
|
||||
"pins|block": "pins",
|
||||
"serial": "Reading and writing data over a serial connection.",
|
||||
"serial.readLine": "Reads a line of text from the serial port.",
|
||||
"serial.readLine|block": "serial read line",
|
||||
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",
|
||||
"serial.redirect|block": "serial redirect to|TX %tx|RX %rx|at baud rate %rate",
|
||||
"serial.redirect|param|rx": "the new reception pin",
|
||||
"serial.redirect|param|tx": "the new transmission pins",
|
||||
"serial.writeLine": "Prints a line of text to the serial",
|
||||
"serial.writeLine|block": "serial|write line %text",
|
||||
"serial.writeNumber": "Prints a numeric value to the serial",
|
||||
"serial.writeNumber|block": "serial|write number %value",
|
||||
"serial.writeString": "Sends a piece of text through Serial connection.",
|
||||
"serial.writeString|block": "serial write string %text",
|
||||
"serial.writeValue": "Writes a ``name: value`` pair line to the serial.",
|
||||
"serial.writeValue|block": "serial|write value %name|= %value",
|
||||
"serial.writeValue|param|name": "name of the value stream, eg: x",
|
||||
"serial.writeValue|param|value": "to write",
|
||||
"serial|block": "serial"
|
||||
}
|
@ -23,7 +23,7 @@ namespace basic {
|
||||
if (value < 0 || value >= 10) {
|
||||
uBit.display.scroll(t, interval);
|
||||
} else {
|
||||
uBit.display.print(t.charAt(0), interval * 5);
|
||||
uBit.display.printChar(t.charAt(0), interval * 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,21 +123,25 @@ namespace BufferMethods {
|
||||
/**
|
||||
* Shift buffer left in place, with zero padding.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//%
|
||||
void shift(Buffer buf, int offset)
|
||||
void shift(Buffer buf, int offset, int start = 0, int length = -1)
|
||||
{
|
||||
ManagedBuffer(buf).shift(offset);
|
||||
ManagedBuffer(buf).shift(offset, start, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate buffer left in place.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//%
|
||||
void rotate(Buffer buf, int offset)
|
||||
void rotate(Buffer buf, int offset, int start = 0, int length = -1)
|
||||
{
|
||||
ManagedBuffer(buf).rotate(offset);
|
||||
ManagedBuffer(buf).rotate(offset, start, length);
|
||||
}
|
||||
|
||||
// int readBytes(uint8_t *dst, int offset, int length, bool swapBytes = false) const;
|
||||
|
@ -135,12 +135,12 @@ namespace input {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
* Do something when a pin is pressed.
|
||||
* @param name the pin that needs to be pressed
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin|%NAME|pressed" icon="\uf094"
|
||||
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094"
|
||||
void onPinPressed(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
@ -150,6 +150,22 @@ namespace input {
|
||||
registerWithDal((int)name, MICROBIT_BUTTON_EVT_CLICK, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param name the pin that needs to be released
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||
void onPinReleased(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
|
||||
// Forces the PIN to switch to makey-makey style detection.
|
||||
pin->isTouched();
|
||||
registerWithDal((int)name, MICROBIT_BUTTON_EVT_UP, body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
*/
|
||||
@ -167,6 +183,17 @@ namespace input {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=56
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockGap=8
|
||||
bool pinIsPressed(TouchPin name) {
|
||||
auto pin = getPin((int)name);
|
||||
return pin && pin->isTouched();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current compass compass heading in degrees.
|
||||
@ -270,16 +297,6 @@ namespace input {
|
||||
//% help=input/calibrate weight=0
|
||||
void calibrate() { }
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58 block="pin|%NAME|is pressed" icon="\uf094"
|
||||
bool pinIsPressed(TouchPin name) {
|
||||
auto pin = getPin((int)name);
|
||||
return pin && pin->isTouched();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the accelerometer sample range in gravities.
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
|
@ -23,7 +23,7 @@
|
||||
value = Math.abs(value);
|
||||
|
||||
if (high != 0) barGraphHigh = high;
|
||||
else if (value > barGraphHigh || now - barGraphHighLast > 5000) {
|
||||
else if (value > barGraphHigh || now - barGraphHighLast > 10000) {
|
||||
barGraphHigh = value;
|
||||
barGraphHighLast = now;
|
||||
}
|
||||
@ -51,7 +51,8 @@
|
||||
* @param x TODO
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/toggle
|
||||
//% help=led/toggle weight=77
|
||||
//% blockId=device_led_toggle block="toggle|x %x|y %y" icon="\uf204" blockGap=8
|
||||
export function toggle(x: number, y: number): void {
|
||||
if (led.point(x, y)) {
|
||||
led.unplot(x, y);
|
||||
|
@ -26,7 +26,8 @@
|
||||
"pins.ts",
|
||||
"serial.cpp",
|
||||
"serial.ts",
|
||||
"buffer.cpp"
|
||||
"buffer.cpp",
|
||||
"_locales/fr/microbit-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
|
45
libs/microbit/shims.d.ts
vendored
45
libs/microbit/shims.d.ts
vendored
@ -213,14 +213,23 @@ declare namespace input {
|
||||
function onGesture(gesture: Gesture, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.
|
||||
* @param name TODO
|
||||
* @param body TODO
|
||||
* Do something when a pin is pressed.
|
||||
* @param name the pin that needs to be pressed
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin|%NAME|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
//% blockId=device_pin_event block="on pin %NAME|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Do something when a pin is released.
|
||||
* @param name the pin that needs to be released
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094" shim=input::onPinReleased
|
||||
function onPinReleased(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
* Get the button state (pressed or not) for ``A`` and ``B``.
|
||||
*/
|
||||
@ -230,6 +239,15 @@ declare namespace input {
|
||||
//% icon="\uf192" blockGap=8 shim=input::buttonIsPressed
|
||||
function buttonIsPressed(button: Button): boolean;
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=56
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockGap=8 shim=input::pinIsPressed
|
||||
function pinIsPressed(name: TouchPin): boolean;
|
||||
|
||||
/**
|
||||
* Get the current compass compass heading in degrees.
|
||||
*/
|
||||
@ -290,13 +308,6 @@ declare namespace input {
|
||||
//% help=input/calibrate weight=0 shim=input::calibrate
|
||||
function calibrate(): void;
|
||||
|
||||
/**
|
||||
* Get the pin state (pressed or not). Requires to hold the ground to close the circuit.
|
||||
* @param name pin used to detect the touch
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58 block="pin|%NAME|is pressed" icon="\uf094" shim=input::pinIsPressed
|
||||
function pinIsPressed(name: TouchPin): boolean;
|
||||
|
||||
/**
|
||||
* Sets the accelerometer sample range in gravities.
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
@ -633,16 +644,20 @@ declare interface Buffer {
|
||||
/**
|
||||
* Shift buffer left in place, with zero padding.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//% shim=BufferMethods::shift
|
||||
shift(offset: number): void;
|
||||
//% start.defl=0 length.defl=-1 shim=BufferMethods::shift
|
||||
shift(offset: number, start?: number, length?: number): void;
|
||||
|
||||
/**
|
||||
* Rotate buffer left in place.
|
||||
* @param offset number of bytes to shift; use negative value to shift right
|
||||
* @param start start offset in buffer. Default is 0.
|
||||
* @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1
|
||||
*/
|
||||
//% shim=BufferMethods::rotate
|
||||
rotate(offset: number): void;
|
||||
//% start.defl=0 length.defl=-1 shim=BufferMethods::rotate
|
||||
rotate(offset: number, start?: number, length?: number): void;
|
||||
|
||||
/**
|
||||
* Write contents of `src` at `dstOffset` in current buffer.
|
||||
|
@ -185,7 +185,6 @@ Functions in this category require to be connected to a remote device.
|
||||
|
||||
### Libraries
|
||||
|
||||
* [game library](/js/game-library)
|
||||
* [serial library](/js/serial-library)
|
||||
|
||||
### ~
|
||||
|
@ -47,7 +47,6 @@ Learn how to create a guessing game with **global variables** `var str: "this is
|
||||
* **on screen down** [read more...](/functions/on-screen-down)
|
||||
* **on screen up** [read more...](/functions/on-screen-up)
|
||||
* **math random** : [read more...](/js/math)
|
||||
* **game library** [read more...](/js/game-library)
|
||||
|
||||
## Resources
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.3.1",
|
||||
"version": "0.3.15",
|
||||
"description": "BBC micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -29,6 +29,6 @@
|
||||
"typescript": "^1.8.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.3.1"
|
||||
"pxt-core": "0.3.19"
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
"compile": {
|
||||
"isNative": false,
|
||||
"hasHex": true,
|
||||
"deployDrives": "^MICROBIT",
|
||||
"deployDrives": "(MICROBIT|MBED)",
|
||||
"driveName": "MICROBIT",
|
||||
"hexMimeType": "application/x-microbit-hex"
|
||||
},
|
||||
@ -70,7 +70,7 @@
|
||||
"yottaTarget": "bbc-microbit-classic-gcc",
|
||||
"yottaCorePackage": "pxt-microbit-core",
|
||||
"githubCorePackage": "microsoft/pxt-microbit-core",
|
||||
"gittag": "v0.1.11",
|
||||
"gittag": "v0.2.2",
|
||||
"serviceId": "ws"
|
||||
},
|
||||
"serial": {
|
||||
@ -124,5 +124,9 @@
|
||||
}
|
||||
],
|
||||
"sideDoc": "getting-started"
|
||||
},
|
||||
"analytics": {
|
||||
"userVoiceApiKey": "WEkkIGaj1WtJnSUF59iwaA",
|
||||
"userVoiceForumId": 402381
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ namespace pxsim.basic {
|
||||
clearScreen();
|
||||
pause(interval * 5);
|
||||
} else {
|
||||
if (s.length == 1) showLeds(createImageFromString(s), interval * 5)
|
||||
if (s.length == 1) showLeds(createImageFromString(s + " "), interval * 5)
|
||||
else ImageMethods.scrollImage(createImageFromString(s + " "), 1, interval);
|
||||
}
|
||||
}
|
||||
@ -294,7 +294,14 @@ namespace pxsim.input {
|
||||
let pin = getPin(pinId);
|
||||
if (!pin) return;
|
||||
pin.isTouched();
|
||||
input.onButtonPressed(pin.id, handler);
|
||||
pxt.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_CLICK, handler);
|
||||
}
|
||||
|
||||
export function onPinReleased(pinId: number, handler: RefAction) {
|
||||
let pin = getPin(pinId);
|
||||
if (!pin) return;
|
||||
pin.isTouched();
|
||||
pxt.registerWithDal(pin.id, DAL.MICROBIT_BUTTON_EVT_UP, handler);
|
||||
}
|
||||
|
||||
export function pinIsPressed(pinId: number): boolean {
|
||||
@ -510,6 +517,7 @@ namespace pxsim.radio {
|
||||
|
||||
export function onDataReceived(handler: RefAction): void {
|
||||
pxt.registerWithDal(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM, handler);
|
||||
radio.receiveNumber();
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,6 +733,7 @@ namespace pxsim.ImageMethods {
|
||||
board().animationQ.enqueue({
|
||||
interval: interval,
|
||||
frame: () => {
|
||||
//TODO: support right to left.
|
||||
if (off >= leds.width || off < 0) return false;
|
||||
stride > 0 ? display.shiftLeft(stride) : display.shiftRight(-stride);
|
||||
let c = Math.min(stride, leds.width - off);
|
||||
|
@ -612,9 +612,9 @@ svg.sim.grayscale {
|
||||
|
||||
private attachEvents() {
|
||||
Runtime.messagePosted = (msg) => {
|
||||
switch (msg.type || '') {
|
||||
case 'serial': this.flashSystemLed(); break;
|
||||
case 'radiopacket': this.flashAntenna(); break;
|
||||
switch (msg.type || "") {
|
||||
case "serial": this.flashSystemLed(); break;
|
||||
case "radiopacket": this.flashAntenna(); break;
|
||||
}
|
||||
}
|
||||
let tiltDecayer = 0;
|
||||
@ -716,6 +716,7 @@ svg.sim.grayscale {
|
||||
let state = this.board;
|
||||
state.pins[index].touched = false;
|
||||
this.updatePin(state.pins[index], index);
|
||||
this.board.bus.queue(state.pins[index].id, DAL.MICROBIT_BUTTON_EVT_UP);
|
||||
this.board.bus.queue(state.pins[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
||||
})
|
||||
})
|
||||
@ -734,7 +735,7 @@ svg.sim.grayscale {
|
||||
let state = this.board;
|
||||
state.buttons[index].pressed = false;
|
||||
svg.fill(this.buttons[index], this.props.theme.buttonUp);
|
||||
|
||||
this.board.bus.queue(state.buttons[index].id, DAL.MICROBIT_BUTTON_EVT_UP);
|
||||
this.board.bus.queue(state.buttons[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
||||
})
|
||||
})
|
||||
@ -765,6 +766,7 @@ svg.sim.grayscale {
|
||||
svg.fill(this.buttons[1], this.props.theme.buttonUp);
|
||||
svg.fill(this.buttons[2], this.props.theme.virtualButtonUp);
|
||||
|
||||
this.board.bus.queue(state.buttons[2].id, DAL.MICROBIT_BUTTON_EVT_UP);
|
||||
this.board.bus.queue(state.buttons[2].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
||||
})
|
||||
}
|
||||
|
@ -72,10 +72,9 @@ namespace pxsim {
|
||||
}
|
||||
|
||||
queue(packet: PacketBuffer) {
|
||||
if (this.datagram.length < 5) {
|
||||
if (this.datagram.length < 4)
|
||||
this.datagram.push(packet);
|
||||
(<Board>runtime.board).bus.queue(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM);
|
||||
}
|
||||
(<Board>runtime.board).bus.queue(DAL.MICROBIT_ID_RADIO, DAL.MICROBIT_RADIO_EVT_DATAGRAM);
|
||||
}
|
||||
|
||||
send(buffer: number[] | string) {
|
||||
@ -600,7 +599,8 @@ namespace pxsim {
|
||||
Runtime.postMessage(<SimulatorSerialMessage>{
|
||||
type: "serial",
|
||||
data: this.serialOutBuffer,
|
||||
id: runtime.id
|
||||
id: runtime.id,
|
||||
sim: true
|
||||
})
|
||||
this.serialOutBuffer = ""
|
||||
break;
|
||||
|
Reference in New Issue
Block a user