Compare commits
84 Commits
Author | SHA1 | Date | |
---|---|---|---|
a58f67064f | |||
efe784441f | |||
05174f094a | |||
42773a1a0a | |||
32f96d09d4 | |||
05d88cb4ba | |||
7fe8dad1f6 | |||
858766ea3e | |||
81fe9afbb7 | |||
65c615f256 | |||
9c5c699fe7 | |||
dcede1703a | |||
5d33ab019d | |||
f7ec452ea0 | |||
20260e8933 | |||
d7704934e8 | |||
f1eafb0a6e | |||
27d6a8281a | |||
c5128aa497 | |||
a59394646c | |||
6851169dbe | |||
36b3486194 | |||
5d8ccd1d6d | |||
c713fe9bf4 | |||
f682e5e694 | |||
d2d776fd01 | |||
641a5e9673 | |||
93d90a2bde | |||
a54504f31c | |||
03111368e0 | |||
a973b2aec6 | |||
a7adf0e6c6 | |||
c10761128e | |||
9965f169b2 | |||
8bf755c15c | |||
d0b2a7db62 | |||
780192da3b | |||
07c1f08d18 | |||
25ac847266 | |||
63c8342b86 | |||
ea2bd7ba10 | |||
cec2d1e8af | |||
1b289b688b | |||
0cf91580cb | |||
392ebc8d07 | |||
9068aab12b | |||
85327a4e69 | |||
021260b3a4 | |||
4def93d7c5 | |||
9aca0c19fc | |||
3fcbdbdd82 | |||
4b7b6eebca | |||
2da0cf1178 | |||
141cb24e3d | |||
35483487af | |||
ec3a805326 | |||
780d8bcf8d | |||
f9a12cac64 | |||
03c2df3277 | |||
a7e98ccb3d | |||
1014d2f361 | |||
89f20a64d5 | |||
fae36a74af | |||
7e57c59b6f | |||
3141e12f4c | |||
4ebe9f595a | |||
50f0e85884 | |||
e28b5d48d4 | |||
562e96e09e | |||
6c5088f811 | |||
d5ccb7ad02 | |||
ade5176d21 | |||
d2f6d51c19 | |||
92b60a251d | |||
de9f2d7e67 | |||
4de5e3bd11 | |||
86a33e8f65 | |||
89010b6a8a | |||
48d4668a7a | |||
a2755dc4d2 | |||
52e67c6bfc | |||
5a6f23a7d0 | |||
d1b36f2022 | |||
284579181b |
2
.gitignore
vendored
@ -15,7 +15,7 @@ clients/win10/app/bld
|
||||
clients/win10/*.opendb
|
||||
clients/**/bin/**
|
||||
clients/**/obj/**
|
||||
clients/electron/projects
|
||||
electron-out
|
||||
hexcache
|
||||
|
||||
*.user
|
||||
|
@ -1,4 +1,4 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/node/node.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/node/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
||||
|
||||
import * as path from "path";
|
||||
|
@ -11,4 +11,4 @@ Math.random(5);
|
||||
|
||||
## See Also
|
||||
|
||||
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables)
|
||||
[logic](/blocks/logic), [loops](/blocks/loops), [math](/blocks/math), [variables](/blocks/variables), [on-start](/blocks/on-start)
|
@ -86,12 +86,14 @@ if (led.point(1,1) && led.point(2,2)) {
|
||||
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
|
||||
|
||||
```blocks
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
basic.showString("high");
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let x = Math.random(5)
|
||||
if(x < 5) {
|
||||
basic.showString("low");
|
||||
} else {
|
||||
basic.showString("high");
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function.
|
||||
|
@ -14,13 +14,15 @@ Click on the dark blue gear icon (see above) to add an *else* or *if* to the cur
|
||||
|
||||
### Example: adjusting screen brightness
|
||||
|
||||
```blocks
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
```
|
||||
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed:
|
||||
|
||||
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255`:
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
if(input.lightLevel()<100){
|
||||
led.setBrightness(255);
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -4,14 +4,21 @@
|
||||
|
||||
Run part of the program the number of times you say.
|
||||
|
||||
```block
|
||||
for(let i = 0; i <= 4; ++i) {
|
||||
}
|
||||
```
|
||||
|
||||
### Example: Count to 4
|
||||
|
||||
This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen.
|
||||
|
||||
```blocks
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
for(let i = 0; i < 5; ++i) {
|
||||
basic.showNumber(i)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Repeat code while a [Boolean](/blocks/logic/boolean) `condition` is true.
|
||||
|
||||
```blocks
|
||||
```block
|
||||
while(true) {
|
||||
}
|
||||
```
|
||||
@ -16,11 +16,13 @@ The condition is tested before any code runs. Which means that if the condition
|
||||
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
|
||||
|
||||
```blocks
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let index = 4;
|
||||
while(index >= 0) {
|
||||
led.plot(index, index);
|
||||
index--;
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
|
22
docs/blocks/on-start.md
Normal file
@ -0,0 +1,22 @@
|
||||
# On Start
|
||||
|
||||
An event that runs when the program starts.
|
||||
|
||||
The ``on start`` is a special event that runs when the program starts, before any other event.
|
||||
Use this event to initialize your program.
|
||||
|
||||
## Example
|
||||
|
||||
In this example, ``on start`` sets a dimmer brightness on the screen and the button handler shows a string.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Hello!")
|
||||
})
|
||||
led.setBrightness(50)
|
||||
```
|
||||
|
||||
|
||||
## What about JavaScript?
|
||||
|
||||
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.
|
@ -33,7 +33,7 @@ basic.forever(() => {
|
||||
|
||||
When this program runs, you will see a smiley face, then a blank
|
||||
screen, then a smiley again -- it never stops! (That's because of the
|
||||
``forever`` block.)
|
||||
`[basic.forever(() => {})]` block.)
|
||||
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
Make sure to follow the instructions.
|
||||
|
@ -17,7 +17,7 @@ input.onButtonPressed(Button.A, () => {
|
||||
|
||||
#### ~hint
|
||||
|
||||
The ``showString`` block can show letters, numbers, and punctuation
|
||||
The `[basic.showString("HI")]` block can show letters, numbers, and punctuation
|
||||
on the @boardname@ screen.
|
||||
|
||||
#### ~
|
||||
@ -33,7 +33,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
#### ~hint
|
||||
|
||||
You can find the letter `B` by clicking the letter `A` on the
|
||||
``onButtonPressed`` block.
|
||||
`[input.onButtonPressed(Button.A, () => {})]` block.
|
||||
|
||||
#### ~
|
||||
|
||||
|
@ -23,8 +23,8 @@ input.onButtonPressed(Button.B, () => {
|
||||
```
|
||||
### ~hint
|
||||
|
||||
The ``pick random true or false`` block randomly tells the ``if``
|
||||
block `true` or `false`. If the ``pick`` block picked `true`, the
|
||||
The `[Math.randomBoolean()]` block randomly tells the ``if``
|
||||
block `true` or `false`. If value picked is `true`, the
|
||||
``if`` block shows the letter `H`. Otherwise, it shows the letter `T`.
|
||||
|
||||
That's it!
|
||||
|
@ -9,7 +9,7 @@ There are 25 bright LEDs on the @boardname@ screen. Let's use them to create som
|
||||
### Happy unhappy face
|
||||
|
||||
Draw an unhappy face instead of the blank screen. Click on the dots
|
||||
in the second ``show leds`` block until it matches the blocks below.
|
||||
in the second `[basic.showLeds("")]` block until it matches the blocks below.
|
||||
Now you have an **animation** (cartoon) that shows a happy face,
|
||||
then an unhappy one, then a happy one again, forever (or until
|
||||
you turn off your @boardname@)!
|
||||
@ -36,7 +36,7 @@ Click **Download** to move your program to the @boardname@!
|
||||
|
||||
### Your turn!
|
||||
|
||||
Pile up more ``show leds`` blocks to create an animation! Create an
|
||||
Pile up more `[basic.showLeds("")]` blocks to create an animation! Create an
|
||||
animation with at least 5 pictures. What does this animation show?
|
||||
|
||||
```blocks
|
||||
@ -87,12 +87,6 @@ basic.forever(() => {
|
||||
```
|
||||
Click **Download** to move your program to the @boardname@!
|
||||
|
||||
#### ~hint
|
||||
|
||||
You can find the ``show leds`` block in the **Basic** part of the editor.
|
||||
|
||||
#### ~
|
||||
|
||||
### ~button /getting-started/buttons
|
||||
NEXT: BUTTONS
|
||||
### ~
|
@ -66,6 +66,10 @@ Fun games to build with your @boardname@.
|
||||
|
||||
```codecard
|
||||
[{
|
||||
"name": "Inchworm",
|
||||
"url":"/projects/inchworm",
|
||||
"imageUrl":"/static/mb/projects/inchworm.jpg"
|
||||
}, {
|
||||
"name": "Timing gates",
|
||||
"url":"/projects/timing-gates",
|
||||
"imageUrl":"/static/mb/projects/timing-gates.jpg"
|
||||
|
@ -10,7 +10,9 @@ Let's start by adding a variable where you can store data. Then rename the varia
|
||||
|
||||
|
||||
```blocks
|
||||
let light = input.lightLevel();
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
let light = input.lightLevel();
|
||||
});
|
||||
```
|
||||
|
||||
We want to play music on button pressed in order to register an event handler that will execute whenever when you run a script and click on button pressed on the simulator. We must start by opening the Input drawer and adding `on button pressed` A. Then add a block `rest` to plays nothing for a `1/16` beat. Modify your code so that your code looks like this.
|
||||
|
40
docs/projects/inchworm.md
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
# Inchworm
|
||||
|
||||
### @description A inchworm like robot built with the micro:bit
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Make a funny inchworm robot!
|
||||
|
||||
### ~
|
||||
|
||||
https://youtu.be/BiZLjugXMbM
|
||||
|
||||
## Duration
|
||||
|
||||
3 Activities, approx 30-45 min each based on familiarity with the coding concepts
|
||||
|
||||
## Materials
|
||||
|
||||
* Cardboard pieces (recycle!)
|
||||
* Glue gun or Tape (masking, duct tape, and/or packing tape)
|
||||
* Scissors that can cut cardboard
|
||||
* 1 @boardname@, battery holder and 2 AAA batteries
|
||||
* 3 Crocodile clips
|
||||
* 1 micro servo 9g SG90
|
||||
* 1 paper clip
|
||||
|
||||

|
||||
|
||||
## Activities
|
||||
|
||||
* [Servo](/projects/inchworm/servo)
|
||||
* [Chassis](/projects/inchworm/chassis)
|
||||
* [Code](/projects/inchworm/code)
|
||||
|
||||
### ~button /projects/inchworm/servo
|
||||
|
||||
Let's get started!
|
||||
|
||||
### ~
|
88
docs/projects/inchworm/chassis.md
Normal file
@ -0,0 +1,88 @@
|
||||
# Chassis
|
||||
### @description Building the cardboard inchworm
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Turn a piece of cardboard into an inchworm!
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~45 minutes
|
||||
|
||||
## Materials
|
||||
* Cardboard
|
||||
* Scissors or cutters
|
||||
* glue gun or tape
|
||||
* 1 paper clip
|
||||
|
||||
## Step 1: cardboard
|
||||
|
||||
Cutout a cardboard rectangle. You can use the @boardname@ as a ruler to figure out the size.
|
||||
|
||||

|
||||
|
||||
## Step 2: center fold
|
||||
|
||||
Fold the cardboard in half over the short edge.
|
||||
|
||||

|
||||
|
||||
## Step 3: legs
|
||||
|
||||
Fold each end so they rest flat on the ground.
|
||||
|
||||

|
||||
|
||||
## Step 4: front teeth
|
||||
|
||||
Fold each corners on one end of the cardbard. This will be the front of the inchworm which is supposed to grip the ground.
|
||||
|
||||

|
||||
|
||||
## Step 5: back teeth
|
||||
|
||||
Using a scissor or a cutter (watch the fingers!), cut out various strips in the other edge. Fold one after the other.
|
||||
|
||||

|
||||
|
||||
## Step 6: mounting the board
|
||||
|
||||
Using tape or a glue gun, mount the @boardname@ on one side and the microservo on the cardobard.
|
||||
|
||||

|
||||
|
||||
## Step 7: mounting the servo
|
||||
|
||||
Attach the servo on the **edge** of the other cardboard side.
|
||||
|
||||

|
||||
|
||||
## Step 8: Cable clean up (optional)
|
||||
|
||||
Use tape to route the cables nicely on the inchworm.
|
||||
|
||||

|
||||
|
||||
## Step 9: attaching paper clip to servo
|
||||
|
||||
Unfold a paper clip and attach it to the servo arm.
|
||||
|
||||

|
||||
|
||||
## Step 10: attaching paper clip to cardboard
|
||||
|
||||
Slide the folder paper clip into the cardboard, and use tape to secure it.
|
||||
You might need to toy around with the size of the clip so that the servo rotation opens the inchworm sufficiently.
|
||||
|
||||

|
||||
|
||||
|
||||
## Step 11: it's ready!
|
||||
|
||||
Your inchworm is ready!
|
||||
|
||||

|
||||
|
||||
### ~button /projects/inchworm/code
|
||||
NEXT: Code
|
||||
### ~
|
48
docs/projects/inchworm/code.md
Normal file
@ -0,0 +1,48 @@
|
||||
# Code
|
||||
### @description code to make the inchworm alive
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Add code to make the inchworm move.
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~30 minutes
|
||||
|
||||
## Step 1: walk forever
|
||||
|
||||
In order for the inchworm to move, the @boardname@ needs to command the servo to go between ``0`` and ``180`` degrees
|
||||
at a certain pace. In the code below, the user pressed button ``A`` to launch the inchworm.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
pins.servoWritePin(AnalogPin.P0, 0)
|
||||
basic.pause(500)
|
||||
pins.servoWritePin(AnalogPin.P0, 180)
|
||||
basic.pause(500)
|
||||
});
|
||||
```
|
||||
|
||||
### ~ hint
|
||||
|
||||
You may have noticed that the inchworm can be rather slow or simply won't move. Try to improve the design of your legs, teeth
|
||||
so that the inchworm goes as fast as possible. Trying it on carpet also great helps avoiding skidding.
|
||||
|
||||
### ~
|
||||
|
||||
## Step 2: radio controlled inchworm
|
||||
|
||||
You will need 2 @boardname@ for this part. By using the radio, we can make the inchworm controlled by another @boardname@.
|
||||
Download the code below to the @boardname@ on the inchworm and another "controller" @boardname@. Whenere A is pressed, the inchworm will move once.
|
||||
|
||||
```blocks
|
||||
radio.onDataPacketReceived(({receivedNumber}) => {
|
||||
pins.servoWritePin(AnalogPin.P0, 0)
|
||||
basic.pause(500)
|
||||
pins.servoWritePin(AnalogPin.P0, 180)
|
||||
basic.pause(500)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
radio.sendNumber(0)
|
||||
})
|
||||
```
|
130
docs/projects/inchworm/servo.md
Normal file
@ -0,0 +1,130 @@
|
||||
# Preparing the servo
|
||||
### @description Connecting the servo to crocodile clips
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
Equip the microservo with crocodile clips.
|
||||
|
||||
### ~
|
||||
|
||||
## Duration: ~30 minutes
|
||||
|
||||
## Materials
|
||||
* Cutting pliers or wire cutter
|
||||
* Tape (masking, duct tape, and/or packing tape)
|
||||
* 3 crocodile clips, yellow, red and black.
|
||||
* 1 micro servo 9g (SG90)
|
||||
|
||||
## Using a microservo with the @boardname@
|
||||
|
||||
The @boardname@ provides just enough current to operate the SG90 microservo.
|
||||
The servo requires 3 connections: GND, 3V and a logic pin.
|
||||
In this tutorial, we will equip the servo with crocodile clips to make it easier to use.
|
||||
However, you could also use a shield or female to crocodile clips to acheive the same effect.
|
||||
|
||||
If you are running a class or activity, you should consider preparing all servos before hand.
|
||||
|
||||
### ~ hint
|
||||
|
||||
Kitronik wrote an excellent in-depth guide about using servos with the @boardname@.
|
||||
Check it out at https://www.kitronik.co.uk/blog/using-bbc-microbit-control-servo/ .
|
||||
|
||||
### ~
|
||||
|
||||
## Step 1: cutout the connector
|
||||
|
||||
Using the cutting pliers, cut out the dark plastic connector.
|
||||
|
||||

|
||||
|
||||
## Step 2: strip out cables
|
||||
|
||||
Using the plier or a wire stripper, strip the plastic from the cables.
|
||||
|
||||

|
||||
|
||||
## Step 3: threading the servo cablers
|
||||
|
||||
Thread the servo cables.
|
||||
|
||||

|
||||
|
||||
## Step 4: crocobile clip claps
|
||||
|
||||
Cut a crocodile cable in two and strip out the casing.
|
||||
If possible try to use the same cable colors as the servo!
|
||||
|
||||

|
||||
|
||||
## Step 5: thread cables together
|
||||
|
||||
Place the cables next to each other
|
||||
|
||||

|
||||
|
||||
... and thread them together.
|
||||
|
||||

|
||||
|
||||
### ~ hint
|
||||
|
||||
It is very **important** to ensure that there is a good connection between the 2 cables.
|
||||
If the connection is weak, the microservo will not receive enough current and it will not work.
|
||||
If you have access to a soldering iron, we strongly recommend to solver this connection.
|
||||
|
||||
### ~
|
||||
|
||||
## Step 4: protect the connection
|
||||
|
||||
Protect the connection with electrical or duct tape.
|
||||
|
||||

|
||||
|
||||
## Step 5: repeat for all cables
|
||||
|
||||
Repeat the same process until all cables are connected.
|
||||
|
||||

|
||||
|
||||
## Step 6: testing!
|
||||
|
||||
It's time to test that your connection are all proper and that the servo will function **when the @boardname@ is powered by battery**.
|
||||
|
||||
* Connect the microservo to the @boardname@. Black cable on ``GND``, red cable on ``3V`` and remaining cable on ``P0``.
|
||||
|
||||

|
||||
|
||||
### ~ hint
|
||||
|
||||
When attaching the crocodile clips to the pins, don't hesitate to grab the side of the board with the jaws.
|
||||
|
||||

|
||||
|
||||
### ~
|
||||
|
||||
* Download the following code to your @boardname@
|
||||
|
||||
```blocks
|
||||
let a = 0
|
||||
basic.forever(() => {
|
||||
a = input.acceleration(Dimension.X)
|
||||
pins.servoWritePin(AnalogPin.P0, pins.map(
|
||||
a,
|
||||
-512,
|
||||
512,
|
||||
0,
|
||||
180
|
||||
))
|
||||
})
|
||||
```
|
||||
|
||||
* When powered by USB, make sure that the servo moves when you tilt the board.
|
||||
* When powered by batteries **only**, make sure that the servo moves when you tilt the board.
|
||||
|
||||
If your servo seems to sutter and stay stuck at a particular position, it means that it is not receiving enough power.
|
||||
This is probably due to a weak connection or low battery level. Check each connection and check your batteries.
|
||||
|
||||
|
||||
### ~button /projects/inchworm/chassis
|
||||
NEXT: Chassis
|
||||
### ~
|
@ -37,7 +37,7 @@ input.onButtonPressed(Button.B, () => {
|
||||
|
||||
We will use the @boardname@'s compass to detect the magnet. Compass's tell us what direction we are pointing by detecting the Earth's magnetic field but they can also detect any other magnet nearby. We will use that to check if our magnet is next to the @boardname@ by using the [magnetic force](/reference/input/magnetic-force) block found in the input menu's 'more' section. As we only want to measure the strength we change the drop down to select 'strength':
|
||||
|
||||
```blocks
|
||||
```block
|
||||
input.magneticForce(Dimension.Strength)
|
||||
```
|
||||
|
||||
@ -50,16 +50,19 @@ If you have ever played with magnets you know they have two ends, often called a
|
||||
So in the code below we will check if the absolute value of our magnetic field strength reading is more than 100 and save the result of that check in a new variable called 'isSwitched':
|
||||
|
||||
```blocks
|
||||
let isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
|
||||
let force = Math.abs(input.magneticForce(Dimension.Strength));
|
||||
let isSwitched = force > 100
|
||||
```
|
||||
## Step 4: running our 'magnet nearby' check all the time
|
||||
|
||||
At the moment our code to detect the magnet being nearby will only run once so we need to put it into a [forever](/reference/basic/forever) block so that it keeps getting run again and again checking for the magnet to come near to the @boardname@. We should also make sure 'isSwitched' is false when our program starts.
|
||||
|
||||
```blocks
|
||||
let force = 0;
|
||||
let isSwitched = false;
|
||||
basic.forever(() => {
|
||||
let isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
|
||||
force = Math.abs(input.magneticForce(Dimension.Strength));
|
||||
isSwitched = force > 100
|
||||
})
|
||||
```
|
||||
|
||||
@ -68,10 +71,11 @@ basic.forever(() => {
|
||||
Now we can check the value of our variable 'isSwitched' whenever we want and we will know that the magnet is nearby if it's value is 'true'. Let's use that to change how the buttons work and complete the code for our trick. We will add an 'if, else' block to each button's code and check if we should swap over what each button displays because 'isSwitched' is equal to true:
|
||||
|
||||
```blocks
|
||||
|
||||
let force = 0;
|
||||
let isSwitched = false;
|
||||
basic.forever(() => {
|
||||
isSwitched = Math.abs(input.magneticForce(Dimension.Strength)) > 100
|
||||
force = Math.abs(input.magneticForce(Dimension.Strength));
|
||||
isSwitched = force > 100
|
||||
})
|
||||
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
|
@ -18,15 +18,15 @@ and updates the screen with the direction.
|
||||
basic.forever(() => {
|
||||
let heading = input.compassHeading()
|
||||
if (heading < 45) {
|
||||
basic.showString("N", 100)
|
||||
basic.showString("N")
|
||||
} else if (heading < 135) {
|
||||
basic.showString("E", 100)
|
||||
basic.showString("E")
|
||||
}
|
||||
else if (heading < 225) {
|
||||
basic.showString("S", 100)
|
||||
basic.showString("S")
|
||||
}
|
||||
else {
|
||||
basic.showString("W", 100)
|
||||
basic.showString("W")
|
||||
}
|
||||
})
|
||||
```
|
||||
@ -40,7 +40,7 @@ You can use a program like this to count things with your @boardname@.
|
||||
```blocks
|
||||
let num = 0
|
||||
basic.forever(() => {
|
||||
basic.showNumber(num, 150)
|
||||
basic.showNumber(num)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
num = num + 1
|
||||
@ -56,10 +56,10 @@ Try this on your @boardname@:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showNumber(6789, 150)
|
||||
basic.showNumber(6789)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showNumber(2, 150)
|
||||
basic.showNumber(2)
|
||||
})
|
||||
```
|
||||
|
||||
|
@ -35,7 +35,8 @@ bluetooth.uartWriteValue("", 0);
|
||||
## Eddystone
|
||||
|
||||
```cards
|
||||
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7);
|
||||
bluetooth.advertiseUid(42, 1, 7, true);
|
||||
bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
|
||||
bluetooth.stopAdvertising();
|
||||
```
|
||||
|
||||
|
37
docs/reference/bluetooth/advertise-uid-buffer.md
Normal file
@ -0,0 +1,37 @@
|
||||
# Avertise UID Buffer
|
||||
|
||||
Advertises a UID via the Eddystone protocol over Bluetooth.
|
||||
|
||||
## ~hint
|
||||
|
||||
### Eddystone
|
||||
|
||||
Bluetooth beacons are used to indicate proximity to a place or object of interest.
|
||||
Beacons use Bluetooth advertising to broadcast a small amount of data,
|
||||
which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.
|
||||
|
||||
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
|
||||
iBeacon is Apple's beacon message format. Eddystone comes from Google.
|
||||
|
||||
Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ .
|
||||
|
||||
## ~
|
||||
|
||||
```sig
|
||||
bluetooth.advertiseUidBuffer(pins.createBuffer(16), 7, true);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes).
|
||||
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
|
||||
* ``connectable`` - a [boolean](/reference/type/boolean) indicating whether or not the micro:bit should accept connections.
|
||||
|
||||
|
||||
## See Also
|
||||
|
||||
[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid)
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
```
|
46
docs/reference/bluetooth/advertise-uid.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Avertise UID
|
||||
|
||||
Advertises a UID via the Eddystone protocol over Bluetooth.
|
||||
|
||||
## ~hint
|
||||
|
||||
### Eddystone
|
||||
|
||||
Bluetooth beacons are used to indicate proximity to a place or object of interest.
|
||||
Beacons use Bluetooth advertising to broadcast a small amount of data,
|
||||
which can be received and acted upon by anyone in range with a suitable device and software, typically a smartphone and application.
|
||||
|
||||
There are various beacon message formats, which define the way Bluetooth advertising packets are used as containers for beacon data.
|
||||
iBeacon is Apple's beacon message format. Eddystone comes from Google.
|
||||
|
||||
Read more at https://lancaster-university.github.io/microbit-docs/ble/eddystone/ .
|
||||
|
||||
## ~
|
||||
|
||||
```sig
|
||||
bluetooth.advertiseUid(42, 1, 7, true);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``namespace`` last 4 bytes of the namespace uid (6 to 9)
|
||||
* ``instance`` last 4 bytes of the instance (2 to 5)
|
||||
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
|
||||
* ``connectable`` - a [boolean](/reference/type/boolean) indicating whether or not the micro:bit should accept connections.
|
||||
|
||||
## Encoding
|
||||
|
||||
The bytes of ``namespace`` and ``instance`` are encoded to generate the 10 bytes UID namespace and 6 bytes UID instance.
|
||||
|
||||
```
|
||||
UID namespace: [0, ..., namespace]
|
||||
UID instance: [0, ..., instance]
|
||||
```
|
||||
|
||||
## See Also
|
||||
|
||||
[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid-buffer](/reference/bluetooth/advertise-uid-buffer)
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
```
|
@ -25,6 +25,7 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
|
||||
|
||||
* ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 17 characters long, excluding the protocol (eg: ``https://``) which gets encoded as 1 byte.
|
||||
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
|
||||
* ``connectable`` - a [boolean](/reference/type/boolean) indicating whether or not the micro:bit should accept connections.
|
||||
|
||||
### Example: Broadcast a secret code
|
||||
|
||||
@ -34,7 +35,7 @@ bluetooth.advertiseUrl("https://pxt.io?secret=42", 7, true);
|
||||
|
||||
## See Also
|
||||
|
||||
[stop-advertising](/reference/bluetooth/stop-advertising)
|
||||
[stop-advertising](/reference/bluetooth/stop-advertising), [advertise-uid](/reference/bluetooth/advertise-uid)
|
||||
|
||||
```package
|
||||
bluetooth
|
||||
|
BIN
docs/static/mb/projects/inchworm.jpg
vendored
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
docs/static/mb/projects/inchworm/chassis1.jpg
vendored
Normal file
After Width: | Height: | Size: 83 KiB |
BIN
docs/static/mb/projects/inchworm/chassis2.jpg
vendored
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
docs/static/mb/projects/inchworm/chassis3.jpg
vendored
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
docs/static/mb/projects/inchworm/chassis4.jpg
vendored
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
docs/static/mb/projects/inchworm/chassis5.jpg
vendored
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
docs/static/mb/projects/inchworm/chassis6.jpg
vendored
Normal file
After Width: | Height: | Size: 70 KiB |
BIN
docs/static/mb/projects/inchworm/chassis7.jpg
vendored
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
docs/static/mb/projects/inchworm/chassis8.jpg
vendored
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
docs/static/mb/projects/inchworm/circuit1.jpg
vendored
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
docs/static/mb/projects/inchworm/circuit2.jpg
vendored
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
docs/static/mb/projects/inchworm/clip1.jpg
vendored
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
docs/static/mb/projects/inchworm/clip2.jpg
vendored
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
docs/static/mb/projects/inchworm/clip3.jpg
vendored
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
docs/static/mb/projects/inchworm/materials.jpg
vendored
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
docs/static/mb/projects/inchworm/ready.jpg
vendored
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
docs/static/mb/projects/inchworm/servo1.jpg
vendored
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
docs/static/mb/projects/inchworm/servo2.JPG
vendored
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
docs/static/mb/projects/inchworm/servo3.jpg
vendored
Normal file
After Width: | Height: | Size: 54 KiB |
BIN
docs/static/mb/projects/inchworm/servo4.jpg
vendored
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
docs/static/mb/projects/inchworm/servo5.jpg
vendored
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
docs/static/mb/projects/inchworm/servo6.jpg
vendored
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
docs/static/mb/projects/inchworm/servo7.jpg
vendored
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
docs/static/mb/projects/inchworm/servo8.jpg
vendored
Normal file
After Width: | Height: | Size: 93 KiB |
67
docs/tutorials/getting-started.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Getting started
|
||||
|
||||
### Step 1
|
||||
|
||||
Place blocks in the workspace to scroll text on the screen.
|
||||
|
||||
```blocks
|
||||
basic.showString("Hi!")
|
||||
```
|
||||
|
||||
### Step 2
|
||||
|
||||
Transfer your code in your @boardname@! Click the **Download** button
|
||||
and follow the instructions.
|
||||
|
||||
ANIMATEDGIF
|
||||
|
||||
### Step 3
|
||||
|
||||
Great, the text scrolled! But then it stopped.
|
||||
Let's make it scroll when button **A** is pressed.
|
||||
|
||||
```block
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showString("Hi!")
|
||||
});
|
||||
```
|
||||
|
||||
### Step 4
|
||||
|
||||
Transfer your code in your @boardname@ and try pressing **A**.
|
||||
|
||||
ANIMATEDGIF
|
||||
|
||||
### Step 5
|
||||
|
||||
Place more blocks to display a smiley when button **B** is pressed.
|
||||
Download your code and try it!
|
||||
|
||||
```block
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
basic.showLeds(`
|
||||
# # . # #
|
||||
# # . # #
|
||||
. . . . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
})
|
||||
```
|
||||
|
||||
### Step 6
|
||||
|
||||
Drag more blocks to display a frownie when @boardname@ is shaken.
|
||||
Download your code and try it!
|
||||
|
||||
```block
|
||||
input.onGesture(Gesture.Shake, () => {
|
||||
basic.showLeds(`
|
||||
# # . # #
|
||||
# # . # #
|
||||
. . . . .
|
||||
. # # # .
|
||||
# . . . #
|
||||
`)
|
||||
})
|
||||
```
|
@ -1,14 +1,14 @@
|
||||
{
|
||||
"applicationName": "pxt-microbit-oss",
|
||||
"dataFolderName": ".pxt-microbit-oss",
|
||||
"darwinBundleIdentifier": "com.microsoft.pxtoss",
|
||||
"nameShort": "PXT Microbit - OSS",
|
||||
"nameLong": "PXT Microbit - OSS",
|
||||
"darwinBundleIdentifier": "com.microsoft.pxtmicrobitoss",
|
||||
"nameShort": "PXT microbit - OSS",
|
||||
"nameLong": "PXT micro:bit - OSS",
|
||||
"targetId": "pxt-microbit",
|
||||
"win32AppId": "{{92db071a-6f58-4938-8c97-13c873f4da13}",
|
||||
"win32AppUserModelId": "Microsoft.PXTMicrobitOss",
|
||||
"win32DirName": "Microsoft PXT-Microbit - OSS",
|
||||
"win32AppUserModelId": "Microsoft.PXTmicrobitOss",
|
||||
"win32DirName": "Microsoft PXT microbit - OSS",
|
||||
"win32MutexName": "pxtmicrobitoss",
|
||||
"win32NameVersion": "Microsoft PXT-Microbit-OSS",
|
||||
"win32RegValueName": "PXTMicrobitOss"
|
||||
"win32NameVersion": "Microsoft PXT microbit-OSS",
|
||||
"win32RegValueName": "PXTmicrobitOss"
|
||||
}
|
9
electron/release.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"versions": {
|
||||
"0": {
|
||||
"latest": "v0.6.45",
|
||||
"banned": [],
|
||||
"prompt": "v0.0.0"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,62 +1,3 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<block type="device_forever">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">TRUE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">TRUE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">TRUE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">TRUE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">TRUE</field>
|
||||
<field name="LED24">TRUE</field>
|
||||
<field name="LED34">TRUE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
<next>
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">FALSE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">FALSE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">FALSE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">FALSE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">FALSE</field>
|
||||
<field name="LED24">FALSE</field>
|
||||
<field name="LED34">FALSE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="pxt-on-start"></block>
|
||||
</xml>
|
@ -1,16 +1 @@
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
})
|
||||
|
||||
|
@ -1,5 +1,14 @@
|
||||
{
|
||||
"bluetooth": "Support for additional Bluetooth services.",
|
||||
"bluetooth": "Support for additional Bluetooth services.\n\nSupport for additional Bluetooth services.",
|
||||
"bluetooth.advertiseUid": "Advertise an Eddystone UID",
|
||||
"bluetooth.advertiseUidBuffer": "Advertise an Eddystone UID",
|
||||
"bluetooth.advertiseUidBuffer|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||
"bluetooth.advertiseUidBuffer|param|nsAndInstance": "16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)",
|
||||
"bluetooth.advertiseUidBuffer|param|power": "power level between 0 and 7, eg: 7",
|
||||
"bluetooth.advertiseUid|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||
"bluetooth.advertiseUid|param|instance": "4 last bytes of the instance uid",
|
||||
"bluetooth.advertiseUid|param|ns": "4 last bytes of the namespace uid",
|
||||
"bluetooth.advertiseUid|param|power": "power level between 0 and 7, eg: 7",
|
||||
"bluetooth.advertiseUrl": "Advertise an Eddystone URL",
|
||||
"bluetooth.advertiseUrl|param|connectable": "true to keep bluetooth connectable for other services, false otherwise.",
|
||||
"bluetooth.advertiseUrl|param|power": "power level between 0 and 7, eg: 7",
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"bluetooth.advertiseUid|block": "bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable",
|
||||
"bluetooth.advertiseUrl|block": "bluetooth advertise url %url|with power %power|connectable %connectable",
|
||||
"bluetooth.onBluetoothConnected|block": "on bluetooth connected",
|
||||
"bluetooth.onBluetoothDisconnected|block": "on bluetooth disconnected",
|
||||
|
@ -7,7 +7,7 @@ using namespace pxt;
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=96 icon="\uf294"
|
||||
namespace bluetooth {
|
||||
MicroBitUARTService *uart = NULL;
|
||||
|
||||
@ -137,6 +137,24 @@ namespace bluetooth {
|
||||
uBit.bleManager.setTransmitPower(power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Advertise an Eddystone UID
|
||||
* @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)
|
||||
* @param power power level between 0 and 7, eg: 7
|
||||
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||
*/
|
||||
//% parts=bluetooth weight=12 advanced=true
|
||||
void advertiseUidBuffer(Buffer nsAndInstance, int power, bool connectable) {
|
||||
ManagedBuffer buf(nsAndInstance);
|
||||
if (buf.length() != 16) return;
|
||||
|
||||
power = min(MICROBIT_BLE_POWER_LEVELS-1, max(0, power));
|
||||
int8_t level = CALIBRATED_POWERS[power];
|
||||
uint8_t uidNs[10]; buf.readBytes(uidNs, 0, 10);
|
||||
uint8_t uidInst[6]; buf.readBytes(uidInst, 10, 6);
|
||||
uBit.bleManager.advertiseEddystoneUid((const char*)uidNs, (const char*)uidInst, level, connectable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
|
||||
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=96 icon="\uf294"
|
||||
namespace bluetooth {
|
||||
/**
|
||||
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
|
||||
@ -46,4 +46,21 @@ namespace bluetooth {
|
||||
// dummy implementation for simulator
|
||||
return "???"
|
||||
}
|
||||
|
||||
/**
|
||||
* Advertise an Eddystone UID
|
||||
* @param ns 4 last bytes of the namespace uid
|
||||
* @param instance 4 last bytes of the instance uid
|
||||
* @param power power level between 0 and 7, eg: 7
|
||||
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||
*/
|
||||
//% blockId=eddystone_advertise_uid block="bluetooth advertise UID|namespace (bytes 6-9)%ns|instance (bytes 2-6)%instance|with power %power|connectable %connectable"
|
||||
//% parts=bluetooth weight=12 blockGap=8
|
||||
//% help=bluetooth/advertise-uid blockExternalInputs=1
|
||||
export function advertiseUid(ns: number, instance: number, power: number, connectable: boolean) {
|
||||
const buf = pins.createBuffer(16);
|
||||
buf.setNumber(NumberFormat.Int32BE, 6, ns);
|
||||
buf.setNumber(NumberFormat.Int32BE, 12, instance);
|
||||
bluetooth.advertiseUidBuffer(buf, power, connectable);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,8 @@
|
||||
"enums.d.ts",
|
||||
"shims.d.ts",
|
||||
"bluetooth.ts",
|
||||
"bluetooth.cpp"
|
||||
"bluetooth.cpp",
|
||||
"_locales/de/bluetooth-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
@ -30,14 +31,14 @@
|
||||
"event_service": 1,
|
||||
"device_info_service": 1,
|
||||
"eddystone_url": 1,
|
||||
"eddystone_uid": 0,
|
||||
"eddystone_uid": 1,
|
||||
"open": 0,
|
||||
"pairing_mode": 1,
|
||||
"whitelist": 1,
|
||||
"security_level": "SECURITY_MODE_ENCRYPTION_NO_MITM"
|
||||
}
|
||||
},
|
||||
"gatt_table_size": "0x700"
|
||||
},
|
||||
"gatt_table_size": "0x700"
|
||||
}
|
||||
},
|
||||
"userConfigs": [
|
||||
{
|
||||
@ -46,7 +47,7 @@
|
||||
"microbit-dal": {
|
||||
"bluetooth": {
|
||||
"open": 1,
|
||||
"pairing_mode": 0,
|
||||
"pairing_mode": 0,
|
||||
"whitelist": 0,
|
||||
"security_level": null
|
||||
}
|
||||
|
11
libs/bluetooth/shims.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Support for additional Bluetooth services.
|
||||
*/
|
||||
//% color=#0082FB weight=20
|
||||
//% color=#0082FB weight=96 icon="\uf294"
|
||||
declare namespace bluetooth {
|
||||
|
||||
/**
|
||||
@ -92,6 +92,15 @@ declare namespace bluetooth {
|
||||
//% help=bluetooth/advertise-url blockExternalInputs=1 shim=bluetooth::advertiseUrl
|
||||
function advertiseUrl(url: string, power: number, connectable: boolean): void;
|
||||
|
||||
/**
|
||||
* Advertise an Eddystone UID
|
||||
* @param nsAndInstance 16 bytes buffer of namespace (bytes 0-9) and instance (bytes 10-15)
|
||||
* @param power power level between 0 and 7, eg: 7
|
||||
* @param connectable true to keep bluetooth connectable for other services, false otherwise.
|
||||
*/
|
||||
//% parts=bluetooth weight=12 advanced=true shim=bluetooth::advertiseUidBuffer
|
||||
function advertiseUidBuffer(nsAndInstance: Buffer, power: number, connectable: boolean): void;
|
||||
|
||||
/**
|
||||
* Sets the bluetooth transmit power between 0 (minimal) and 7 (maximum).
|
||||
* @param power power level between 0 (minimal) and 7 (maximum), eg: 7.
|
||||
|
@ -1,62 +1,3 @@
|
||||
<xml xmlns="http://www.w3.org/1999/xhtml">
|
||||
<block type="device_forever">
|
||||
<statement name="HANDLER">
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">TRUE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">TRUE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">TRUE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">TRUE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">TRUE</field>
|
||||
<field name="LED24">TRUE</field>
|
||||
<field name="LED34">TRUE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
<next>
|
||||
<block type="device_show_leds">
|
||||
<field name="LED00">FALSE</field>
|
||||
<field name="LED10">FALSE</field>
|
||||
<field name="LED20">FALSE</field>
|
||||
<field name="LED30">FALSE</field>
|
||||
<field name="LED40">FALSE</field>
|
||||
<field name="LED01">FALSE</field>
|
||||
<field name="LED11">FALSE</field>
|
||||
<field name="LED21">FALSE</field>
|
||||
<field name="LED31">FALSE</field>
|
||||
<field name="LED41">FALSE</field>
|
||||
<field name="LED02">FALSE</field>
|
||||
<field name="LED12">FALSE</field>
|
||||
<field name="LED22">FALSE</field>
|
||||
<field name="LED32">FALSE</field>
|
||||
<field name="LED42">FALSE</field>
|
||||
<field name="LED03">FALSE</field>
|
||||
<field name="LED13">FALSE</field>
|
||||
<field name="LED23">FALSE</field>
|
||||
<field name="LED33">FALSE</field>
|
||||
<field name="LED43">FALSE</field>
|
||||
<field name="LED04">FALSE</field>
|
||||
<field name="LED14">FALSE</field>
|
||||
<field name="LED24">FALSE</field>
|
||||
<field name="LED34">FALSE</field>
|
||||
<field name="LED44">FALSE</field>
|
||||
</block>
|
||||
</next>
|
||||
</block>
|
||||
</statement>
|
||||
</block>
|
||||
<block type="pxt-on-start"></block>
|
||||
</xml>
|
@ -1,16 +1 @@
|
||||
basic.forever(() => {
|
||||
basic.showLeds(`
|
||||
. # . # .
|
||||
# . # . #
|
||||
# . . . #
|
||||
. # . # .
|
||||
. . # . .
|
||||
`)
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
. . . . .
|
||||
`)
|
||||
})
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
"DisplayMode.Greyscale|block": "greyscale",
|
||||
"EventCreationMode.CreateAndFire": "MicroBitEvent is initialised, and its event handlers are immediately fired (not suitable for use in interrupts!).",
|
||||
"EventCreationMode.CreateOnly": "MicroBitEvent is initialised, and no further processing takes place.",
|
||||
"Gesture.EightG": "Raised when a 8G shock is detected",
|
||||
"Gesture.EightG|block": "8g",
|
||||
"Gesture.FreeFall": "Raised when the board is falling!",
|
||||
"Gesture.FreeFall|block": "free fall",
|
||||
"Gesture.LogoDown": "Raised when the logo is downward and the screen is vertical",
|
||||
|
@ -64,7 +64,6 @@
|
||||
"control.waitMicros|param|micros": "Anzahl der Mikrosekunden, die gewartet werden soll, z.B.: 4",
|
||||
"game": "Eine Einzel-LED-Sprite-Spielumgebung",
|
||||
"game.addLife": "Fügt Leben zum aktuellen Spielstand hinzu",
|
||||
"game.addLife|param|lives": "TODO",
|
||||
"game.addScore": "Fügt zum aktuellen Spielstand Punkte hinzu",
|
||||
"game.addScore|param|points": "Anzahl von zu verändernden Punkten, z.B.: 1",
|
||||
"game.createSprite": "Erzeugt einen neuen LED-Sprite, der nach rechts zeigt.",
|
||||
@ -79,12 +78,9 @@
|
||||
"game.levelUp": "Erhöht das Level und zeigt eine Nachricht an.",
|
||||
"game.life": "Ruft das aktuelle Leben ab",
|
||||
"game.removeLife": "Entfernt ein Leben",
|
||||
"game.removeLife|param|life": "TODO",
|
||||
"game.score": "Ruft den aktuellen Punktestand ab",
|
||||
"game.setLife": "Setzt den aktuellen Wert der Leben",
|
||||
"game.setLife|param|value": "TODO",
|
||||
"game.setScore": "Setzt den aktuellen Wert des Spielstands",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.showScore": "Zeigt den Spielstand auf dem Display.",
|
||||
"game.startCountdown": "Startet einen Spiel-Countdown",
|
||||
"game.startCountdown|param|ms": "Countdown-Dauer in Millisekunden, z.B.: 10000",
|
||||
@ -94,38 +90,24 @@
|
||||
"images.createImage": "Erstellt ein Bild, das auf den LED-Bildschirm passt.",
|
||||
"input": "Ereignisse und Daten der Sensoren",
|
||||
"input.acceleration": "Holt den Beschleunigungswert in Milli-Erdanziehung (wenn das Board flach mit dem Display nach oben liegt, X = 0, y = 0 und Z =-1024)",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.buttonIsPressed": "Erhalte den Sie den Tastenstatus (gepresst oder nicht) für ``A`` und ``B``.",
|
||||
"input.calibrate": "Veraltet, Kompasskalibrierung erfolgt automatisch.",
|
||||
"input.compassHeading": "Holt die aktuelle Kompassrichtung in Grad.",
|
||||
"input.lightLevel": "Liest die Lichtintensität auf dem LED-Bildschirm im Bereich von ``0`` (dunkel) und `` 255`` (hell).",
|
||||
"input.magneticForce": "Ruft den Wert der Magnetkraft in ``Mikro-Tesla`` (``µT``) ab. Diese Funktion wird im Simulator nicht unterstützt.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed": "Tue etwas, wenn eine Taste (``A``, ``B`` oder ``A + B``) gedrückt wird",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture": "Mache etwas, wenn eine Geste gemacht wird (wie den mini zu schütteln).",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach unten zeigt und das Board vertikal ausgerichtet ist.",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp": "Fügt Code hinzu, der ausgeführt wird, wenn das Logo nach oben zeigt und das Board vertikal ausgerichtet ist.",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.onPinPressed": "Mache etwas, wenn eine Pin gehalten wird.",
|
||||
"input.onPinPressed|param|body": "Code, der ausführt wird, wenn ein Pin gehalten wird",
|
||||
"input.onPinPressed|param|name": "Der Pin, der gehalten werden muss",
|
||||
"input.onPinReleased": "Mache etwas, wenn der Pin losgelassen wird.",
|
||||
"input.onPinReleased|param|body": "Code, der ausgeführt werden soll, wenn der Pin losgelassen wird",
|
||||
"input.onPinReleased|param|name": "Der Pin, der losgelassen werden muss",
|
||||
"input.onScreenDown": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach unten zeigt.",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp": "Hängt Code an, der ausgeführt wird, wenn der Bildschirm nach oben zeigt.",
|
||||
"input.onScreenUp|param|body": "TODO",
|
||||
"input.onShake": "Hängt Code an, der ausgeführt wird, wenn der mini geschüttelt wird.",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed": "Ruft den Pin-Zustand (gehalten oder nicht) ab. Die Erdung muss gehalten werden, um den Stromkreis zu schließen.",
|
||||
"input.pinIsPressed|param|name": "Pin, der verwendet wird, um eine Berührung zu erkennen",
|
||||
"input.rotation": "Die Neigung und Drehung des mini Drehung auf ``X-Achse``oder ``Y-Achse``, in Grad.",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.runningTime": "Ruft die Anzahl der Millisekunden auf, die seit dem Einschalten vergangen sind.",
|
||||
"input.setAccelerometerRange": "Legt die Stichprobenbereich des Beschleunigungssensors in Schwerkraft fest.",
|
||||
"input.setAccelerometerRange|param|range": "Ein Wert, der die maximale Stärke der gemessenen Beschleunigung beschreibt",
|
||||
@ -134,19 +116,13 @@
|
||||
"led.brightness": "Ruft die Helligkeit des Bildschirms ab, von 0 (aus) bis 255 (volle Helligkeit).",
|
||||
"led.enable": "Schaltet das Display an und aus",
|
||||
"led.fadeIn": "Blendet die Bildschirmanzeige ein.",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut": "Blendet die Bildschirmhelligkeit aus.",
|
||||
"led.fadeOut|param|ms": "TODO",
|
||||
"led.plot": "Schalte die angegebene LED mit Hilfe von X- und Y-Koordinaten ein (X ist horizontal, Y ist vertikal). (0,0) ist die obere linke Ecke.",
|
||||
"led.plotAll": "Schaltet alle LEDs an",
|
||||
"led.plotBarGraph": "Zeigt ein vertikales Balkendiagramm an, basierend auf dem `Wert`und dem `Hoch`-Wert. Wenn `Hoch`0 ist, wird das Diagramm automatisch angepasst.",
|
||||
"led.plotBarGraph|param|high": "maximalen Wert. Wenn dieser 0 ist, wird der Maximalwert automatisch angepasst, z.B.: 0",
|
||||
"led.plotBarGraph|param|value": "aktueller Wert zum Darstellen",
|
||||
"led.plot|param|x": "TODO",
|
||||
"led.plot|param|y": "TODO",
|
||||
"led.point": "Ruft den An/Aus-Status einer vorgegebenen LED mittels X-/Y-Koordinaten ab. (0,0) ist oben links.",
|
||||
"led.point|param|x": "TODO",
|
||||
"led.point|param|y": "TODO",
|
||||
"led.screenshot": "Macht einen Screenshot vom LED-Bildschirm und gibt ein Bild aus.",
|
||||
"led.setBrightness": "Lege die Helligkeit des Bildschirms fest, von 0 (aus) bis 255 (volle Helligkeit).",
|
||||
"led.setBrightness|param|value": "Helligkeitswert, z.B.: 255, 127, 0",
|
||||
@ -155,17 +131,12 @@
|
||||
"led.stopAnimation": "Bricht die aktuelle Animation ab und löscht andere ausstehende Animationen.",
|
||||
"led.toggle": "Schaltet ein bestimmtes Pixel ein",
|
||||
"led.toggleAll": "Invertiert die aktuelle LED-Anzeige",
|
||||
"led.toggle|param|x": "TODO",
|
||||
"led.toggle|param|y": "TODO",
|
||||
"led.unplot": "Schalte die angegebene LED mit x-und y-Koordinaten ab (X ist horizontal, y ist vertikal). (0,0) ist oben links.",
|
||||
"led.unplot|param|x": "TODO",
|
||||
"led.unplot|param|y": "TODO",
|
||||
"music": "Generierung von von Musik durch Pin ``P0``.",
|
||||
"music.beat": "Gibt die Dauer eines Taktes in Milli-Sekunden aus",
|
||||
"music.changeTempoBy": "Ändere die Geschwindigkeit um den angegebenen Betrag",
|
||||
"music.changeTempoBy|param|bpm": "Die Änderung in Schlägen pro Minute auf das Tempo, z.B.: 20",
|
||||
"music.noteFrequency": "Ruft die Frequenz einer Note ab.",
|
||||
"music.noteFrequency|param|name": "der Name der Notiz",
|
||||
"music.playTone": "Spielt einen Ton für den angegebenen Zeitraum über Pin ``P0`` ab.",
|
||||
"music.playTone|param|frequency": "Tonhöhe des abzuspielenden Tones in Hertz (Hz)",
|
||||
"music.playTone|param|ms": "Tondauer in Millisekunden (ms)",
|
||||
@ -181,21 +152,15 @@
|
||||
"pins.analogPitch|param|frequency": "TODO",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
"pins.analogReadPin": "Lese den Anschlusswert als Analog aus, d. h. als einen Wert zwischen 0 und 1023.",
|
||||
"pins.analogReadPin|param|name": "Pin, auf den geschrieben werden soll",
|
||||
"pins.analogSetPeriod": "Stellt die Pulsweite Modulation (PWM) des Analogausganges auf den angegebenen Wert in ** Mikrosekunden ** oder `1/1000` Millisekunden ein.\nWenn dieser Pin nicht als einen Analogausgang (mit `analog write pin`) konfiguriert ist, hat der Vorgang keine Auswirkungen.",
|
||||
"pins.analogSetPeriod|param|micros": "Zeit in Mikrosekunden. z.B.: 20000",
|
||||
"pins.analogSetPeriod|param|name": "analoger Pin, der zeitlich festgelegt werden soll",
|
||||
"pins.analogSetPitchPin": "Setzt den genutzten Pin, wenn `pins->analog pitch`angewendet wird.",
|
||||
"pins.analogSetPitchPin|param|name": "TODO",
|
||||
"pins.analogWritePin": "Legt den Wert des Verbinders auf analog fest. Der Wert muss zwischen 0 und 1023 liegen.",
|
||||
"pins.analogWritePin|param|name": "PIN-Name, auf den geschrieben werden soll",
|
||||
"pins.analogWritePin|param|value": "Wert, der auf den Pin geschrieben werden soll, zwischen ``0`` und ``1023`` z.B.: 1023,0",
|
||||
"pins.createBuffer": "Erstellt einen Null-initialisierten Zwischenspeicher.",
|
||||
"pins.createBuffer|param|size": "Anzahl der Bytes im Zwischenspeicher",
|
||||
"pins.digitalReadPin": "Lese den angegebene Pin oder Verbinder als 0 oder 1",
|
||||
"pins.digitalReadPin|param|name": "Pin, aus dem gelesen werden soll",
|
||||
"pins.digitalWritePin": "Setzt einen Pin- oder Verbinder-Wert auf 0 oder 1.",
|
||||
"pins.digitalWritePin|param|name": "Pin, auf den geschrieben werden soll",
|
||||
"pins.digitalWritePin|param|value": "Wert, der auf dem Pin 1 gesetzt werden soll, z.B. 0",
|
||||
"pins.i2cReadBuffer": "Lese `Größe`bytes aus einer 7-bit I2C-Adresse.",
|
||||
"pins.i2cReadNumber": "Lese eine Nummer aus einer 7-bit I2C-Adresse.",
|
||||
@ -210,17 +175,12 @@
|
||||
"pins.onPulsed": "Stellt diesen Pin als einen Digitaleingang ein und generiert Ereignisse, deren Zeitstempel die Dauer darstellt, in der der Pin entweder ``hoch``oder ``niedrig``war.",
|
||||
"pins.pulseDuration": "Ruft die Dauer des letzten Impulses in Mikrosendungen ab. Diese Funktion soll von einem `onPulsed`-Handler aufgerufen werden.",
|
||||
"pins.pulseIn": "Gibt die Dauer eines Pulses in Mikrosekunden an",
|
||||
"pins.pulseIn|param|name": "der Pin, der den Puls misst",
|
||||
"pins.pulseIn|param|value": "der Wert des Pulses (Standard hoch)",
|
||||
"pins.servoSetPulse": "Konfiguriert diesen IO-Pin als einen analogen/PWM-Ausgang, stellt den Zeitraum auf 20 ms ein und setzt die Pulsweite fest, basieren auf dem angegeben Wert **Mikrosekunden** oder `1/1000`Millisekunden.",
|
||||
"pins.servoSetPulse|param|micros": "Impulsdauer in Mikrosekunden, z.B.: 1500",
|
||||
"pins.servoSetPulse|param|name": "PIN-Name",
|
||||
"pins.servoWritePin": "Schreibt einen Wert in den Servo, der die Welle entsprechend kontroliert. Auf einem Standard-Servo wird so der Winkel der Welle (in Grad) eingestellt, sodass sich die Welle entsprechend anpasst. Auf einem kontinuierlich drehenden Servo wird dadurch die Geschwindigkeit des Servos festgelegt, wobei ``0``die volle Geschwindigkeit in eine Richtung darstellt, ``180``die volle Geschwindigkeit in die andere, und ein Wert von ``90`` einen Stillstand erzeugt.",
|
||||
"pins.servoWritePin|param|name": "Pin, auf den geschrieben werden soll",
|
||||
"pins.servoWritePin|param|value": "Winkel oder Rotationsbeschleunigung, z.B.: 180,90,0",
|
||||
"pins.setPull": "Stellt die Anziehungskraft des Pins ein.",
|
||||
"pins.setPull|param|name": "Pin, auf dem der Pull-Modus aktiviert wird",
|
||||
"pins.setPull|param|pull": "eine der mbed-Pull-Konfigurationen: PullUp, PullDown, PullNone",
|
||||
"pins.sizeOf": "Ruft die Bytegröße im spezifierten Nummernformat ab.",
|
||||
"pins.spiWrite": "Schreibe in den SPI-Slave und gebe die Antwort aus",
|
||||
"pins.spiWrite|param|value": "Daten, die an den SPI-Slave geschickt werden sollen",
|
||||
@ -231,8 +191,6 @@
|
||||
"serial.readUntil": "Liest aus eine Textzeile aus dem seriellen Anschluss und gibt den Puffer aus, wenn die Begrenzung erreicht wurde.",
|
||||
"serial.readUntil|param|delimiter": "Text-Begrenzung, die die Textblöcke voneinander trennt",
|
||||
"serial.redirect": "Konfiguriert dynamisch die serielle Instanz, damit sie andere Pins als USBTX und USBRX benutzt.",
|
||||
"serial.redirect|param|rx": "der neue Empfangs-Pin",
|
||||
"serial.redirect|param|tx": "Der neue Übertragungs-Pin",
|
||||
"serial.writeLine": "Gibt eine Zeile des Textes an die serielle",
|
||||
"serial.writeNumber": "Gibt einen numerischen Wert an die serielle",
|
||||
"serial.writeString": "Sendet ein Stück Text über serielle Verbindung.",
|
||||
|
@ -7,12 +7,71 @@
|
||||
"AcceleratorRange.OneG|block": "1g",
|
||||
"AcceleratorRange.TwoG": "Der Bewegungssensor misst Kräfte bis 2g",
|
||||
"AcceleratorRange.TwoG|block": "2g",
|
||||
"BaudRate.BaudRate115200|block": "11520",
|
||||
"BaudRate.BaudRate9600|block": "9600",
|
||||
"BeatFraction.Eighth|block": "1/8",
|
||||
"BeatFraction.Half|block": "1/2",
|
||||
"BeatFraction.Quarter|block": "1/4",
|
||||
"BeatFraction.Sixteenth|block": "1/16",
|
||||
"BeatFraction.Whole|block": "1",
|
||||
"Button.AB|block": "A+B",
|
||||
"Delimiters.Dollar|block": "$",
|
||||
"Delimiters.Hash|block": "#",
|
||||
"Delimiters.NewLine|block": "Neue Zeile",
|
||||
"Dimension.Strength|block": "Stärke",
|
||||
"Dimension.X|block": "x",
|
||||
"Dimension.Y|block": "y",
|
||||
"Dimension.Z|block": "z",
|
||||
"Direction.Left|block": "links",
|
||||
"Direction.Right|block": "rechts",
|
||||
"DisplayMode.BackAndWhite|block": "Schwarz-Weiß",
|
||||
"DisplayMode.Greyscale|block": "Graustufen",
|
||||
"EventCreationMode.CreateAndFire": "Calliope mini-Event wurde initialisiert, seine Event-Handler werden unverzüglich ausgeführt (nicht geeignet für die Nutzung bei Unterbrechungen!).",
|
||||
"EventCreationMode.CreateOnly": "Calliope mini-Event wurde initialisiert, es wird keine weitere Verarbeitung vorgenommen.",
|
||||
"Gesture.EightG|block": "8g",
|
||||
"Gesture.FreeFall": "Wird ausgeführt, wenn das Board fällt!",
|
||||
"Gesture.FreeFall|block": "freier Fall",
|
||||
"Gesture.LogoDown": "Wird ausgeführt, wenn das Logo nach unten zeigt und das Display vertikal ist.",
|
||||
"Gesture.LogoDown|block": "Logo nach unten",
|
||||
"Gesture.LogoUp": "Wird ausgeführt, wenn das Logo nach oben zeigt und das Display vertikal ist.",
|
||||
"Gesture.LogoUp|block": "Logo oben",
|
||||
"Gesture.ScreenDown": "Wird ausgeführt, wenn das Display nach oben zeigt und das Board horizontal ist.",
|
||||
"Gesture.ScreenDown|block": "Display nach unten",
|
||||
"Gesture.ScreenUp": "Wird ausgeführt, wenn das Display nach unten zeigt und das Board horizontal ist.",
|
||||
"Gesture.ScreenUp|block": "Display nach oben",
|
||||
"Gesture.Shake": "Wird erhöht, wenn geschüttelt",
|
||||
"Gesture.Shake|block": "geschüttelt",
|
||||
"Gesture.SixG": "Wird ausgeführt, ein 6g starker Stoß erkannt wird",
|
||||
"Gesture.SixG|block": "6g",
|
||||
"Gesture.ThreeG": "Wird ausgeführt, ein 3g starker Stoß erkannt wird",
|
||||
"Gesture.ThreeG|block": "3g",
|
||||
"Gesture.TiltLeft": "Wird ausgeführt, wenn das Display nach links zeigt",
|
||||
"Gesture.TiltLeft|block": "nach links neigen",
|
||||
"Gesture.TiltRight": "Wird ausgeführt, wenn das Display nach rechts zeigt",
|
||||
"Gesture.TiltRight|block": "nach rechts neigen",
|
||||
"LedSpriteProperty.Blink|block": "blinken",
|
||||
"LedSpriteProperty.Brightness|block": "Helligkeit",
|
||||
"LedSpriteProperty.Direction|block": "Richtung",
|
||||
"LedSpriteProperty.X|block": "x",
|
||||
"LedSpriteProperty.Y|block": "y",
|
||||
"Math.randomBoolean|block": "wähle zufälligen Wahr- oder Falsch-Wert",
|
||||
"Math|block": "Mathematik",
|
||||
"Note.CSharp3|block": "C#3",
|
||||
"Note.CSharp4|block": "C#4",
|
||||
"Note.CSharp5|block": "C#5",
|
||||
"Note.CSharp|block": "C#",
|
||||
"Note.FSharp3|block": "F#3",
|
||||
"Note.FSharp4|block": "F#4",
|
||||
"Note.FSharp5|block": "F#5",
|
||||
"Note.FSharp|block": "F#",
|
||||
"Note.GSharp3|block": "G#3",
|
||||
"Note.GSharp4|block": "G#4",
|
||||
"Note.GSharp5|block": "G#5",
|
||||
"Note.GSharp|block": "G#",
|
||||
"PinPullMode.PullDown|block": "nach unten",
|
||||
"PinPullMode.PullUp|block": "nach oben",
|
||||
"Rotation.Pitch|block": "Winkel",
|
||||
"Rotation.Roll|block": "rollen",
|
||||
"String.charAt|block": "Zeichen an Position %pos aus|%this",
|
||||
"String.compare|block": "vergleiche %this| mit %that",
|
||||
"String.concat|block": "hänge %this| mit %other aneinander",
|
||||
@ -23,10 +82,10 @@
|
||||
"String|block": "Zeichenfolge",
|
||||
"basic.clearScreen|block": "Bildschirminhalt löschen",
|
||||
"basic.forever|block": "dauerhaft",
|
||||
"basic.pause|block": "Pausiere (ms) %pause",
|
||||
"basic.pause|block": "pausiere (ms) %pause",
|
||||
"basic.showLeds|block": "zeige LEDs",
|
||||
"basic.showNumber|block": "zeige|Nummer %number",
|
||||
"basic.showString|block": "Zeige|Zeichenfolge %text",
|
||||
"basic.showString|block": "zeige|Zeichenfolge %text",
|
||||
"basic|block": "Grundlagen",
|
||||
"control.deviceName|block": "Gerätename",
|
||||
"control.deviceSerialNumber|block": "Seriennnummer",
|
||||
@ -56,7 +115,6 @@
|
||||
"input.magneticForce|block": "Magnetkraft (µT) |%NAME",
|
||||
"input.onButtonPressed|block": "wenn Knopf|%NAME|gedrückt",
|
||||
"input.onGesture|block": "wenn |%NAME",
|
||||
"input.onPinPressed|block": "wenn Pin %NAME|gedrückt",
|
||||
"input.onPinReleased|block": "wenn Pin %NAME|losgelassen",
|
||||
"input.pinIsPressed|block": "Pin %NAME|ist gedrückt",
|
||||
"input.rotation|block": "Rotation (°)|%NAME",
|
||||
@ -71,7 +129,7 @@
|
||||
"led.setBrightness|block": "Setze Helligkeit auf %value",
|
||||
"led.stopAnimation|block": "Halte Animation an",
|
||||
"led.toggle|block": "Schalte zwischen|x %x|y %y",
|
||||
"led.unplot|block": "Unplot|x %x|y %y",
|
||||
"led.unplot|block": "schalte Pixel|x %x|y %y aus",
|
||||
"led|block": "LED",
|
||||
"music.beat|block": "%fraction|Takt",
|
||||
"music.changeTempoBy|block": "ändere die Geschwindigkeit (bpm)|%value",
|
||||
|
@ -21,59 +21,40 @@
|
||||
"basic.showString|param|text": "le texte à faire défiler sur l’écran, par exemple : « Bonjour ! »",
|
||||
"control.inBackground": "Planifie le code qui s’exécute en arrière-plan.",
|
||||
"control.reset": "Réinitialise le micro:bit de BBC.",
|
||||
"control.waitMicros": "Bloque la fibre courante pour le nombre de microsecondes donné",
|
||||
"control.waitMicros|param|micros": "nombre de microsecondes à attendre. par ex. : 4",
|
||||
"game": "Un moteur de jeu avec une unique LED",
|
||||
"game.addLife|param|lives": "TODO",
|
||||
"game.addScore": "Ajoute des points au score actuel",
|
||||
"game.addScore|param|points": "nombre de points à changer, par ex. : 1",
|
||||
"game.gameOver": "Affiche un animation de fin de jeu.",
|
||||
"game.removeLife|param|life": "TODO",
|
||||
"game.score": "Obtient le score actuel",
|
||||
"game.setLife|param|value": "TODO",
|
||||
"game.setScore": "Définit la valeur du score actuel",
|
||||
"game.setScore|param|value": "TODO",
|
||||
"game.startCountdown": "Démarre un compte à rebours de jeu",
|
||||
"game.startCountdown|param|ms": "durée du compte à rebours en millisecondes, par ex. : 10000",
|
||||
"images": "Création, manipulation et affichage d’images LED.",
|
||||
"images.createBigImage": "Crée une image à partir de 2 images.",
|
||||
"images.createImage": "Crée une image qui s’adapte aux dimensions de l’écran LED.",
|
||||
"input": "Événements et des données provenant de capteurs",
|
||||
"input.acceleration|param|dimension": "TODO",
|
||||
"input.acceleration": "Donne la valeur de l'accélération en milli-g (quand la carte est à plat avec l'écran vers le haut, x=0, y=0 et z=-1024)",
|
||||
"input.buttonIsPressed": "Donne l'état du bouton (appuyé ou non) pour ``A`` et ``B``.",
|
||||
"input.calibrate": "Obsolète, le calibrage de la boussole est automatique.",
|
||||
"input.compassHeading": "Obtient la direction actuelle du compas en degrés.",
|
||||
"input.magneticForce|param|dimension": "TODO",
|
||||
"input.onButtonPressed|param|body": "TODO",
|
||||
"input.onButtonPressed|param|button": "TODO",
|
||||
"input.onGesture|param|body": "TODO",
|
||||
"input.onLogoDown|param|body": "TODO",
|
||||
"input.onLogoUp|param|body": "TODO",
|
||||
"input.lightLevel": "Lit le niveau de lumière appliqué à l'écran LED de ``0`` (sombre) à ``255`` lumineux.",
|
||||
"input.magneticForce": "Obtenir la valeur de la force magnétique en ``micro-Teslas`` (``µT``). Cette fonction n’est pas supportée par le simulateur.",
|
||||
"input.onButtonPressed": "Faire quelque chose quand un bouton (``A``, ``B`` ou les deux ``A+B``) est appuyé",
|
||||
"input.onGesture": "Faire quelque chose lorsque lorsqu’un geste est fait (par exemple secouer le micro:bit).",
|
||||
"input.onPinPressed": "Faire quelque chose lorsque vous appuyez sur une broche.",
|
||||
"input.onPinPressed|param|body": "code à exécuter lorsque la broche est enfoncée",
|
||||
"input.onPinPressed|param|name": "la broche qui doit être pressée",
|
||||
"input.onPinReleased": "Faire quelque chose quand une broche est relâchée.",
|
||||
"input.onPinReleased|param|body": "le code à exécuter lorsque la broche est relâchée",
|
||||
"input.onPinReleased|param|name": "la broche qui doit être relâchée",
|
||||
"input.onScreenDown|param|body": "TODO",
|
||||
"input.onScreenUp|param|body": "TODO",
|
||||
"input.onShake|param|body": "TODO",
|
||||
"input.pinIsPressed|param|name": "broche utilisée pour détecter le contact",
|
||||
"input.rotation|param|kind": "TODO",
|
||||
"input.pinIsPressed": "Donne l’état de la broche (pressée ou non). Nécessite de tenir la masse pour fermer le circuit.",
|
||||
"input.runningTime": "Donne le nombre de millisecondes écoulées depuis la mise en route.",
|
||||
"input.temperature": "Obtient la température en degrés Celsius (°C).",
|
||||
"led": "Contrôle de l’écran LED.",
|
||||
"led.enable": "Active ou désactive l’affichage",
|
||||
"led.fadeIn|param|ms": "TODO",
|
||||
"led.fadeOut|param|ms": "TODO",
|
||||
"led.plotAll": "Allume toutes les LEDS",
|
||||
"led.plotBarGraph|param|value": "valeur actuelle à tracer",
|
||||
"led.plot|param|x": "TODO",
|
||||
"led.plot|param|y": "TODO",
|
||||
"led.point|param|x": "TODO",
|
||||
"led.point|param|y": "TODO",
|
||||
"led.setBrightness|param|value": "valeur de la luminosité, par ex. : 255, 127, 0",
|
||||
"led.toggle|param|x": "TODO",
|
||||
"led.toggle|param|y": "TODO",
|
||||
"led.unplot|param|x": "TODO",
|
||||
"led.unplot|param|y": "TODO",
|
||||
"music.rest": "Repose (joue rien) pendant une durée spécifiée via broche '' P0''.",
|
||||
"pins.analogPitch|param|frequency": "TODO",
|
||||
"pins.analogPitch|param|ms": "TODO",
|
||||
|
@ -30,7 +30,6 @@
|
||||
"input.magneticForce|block": "force magnétique (µT) |%NAME",
|
||||
"input.onButtonPressed|block": "lorsque le button|%NAME|est pressé",
|
||||
"input.onGesture|block": "lorsque|%NAME",
|
||||
"input.onPinPressed|block": "lorsque le pin %NAME|est pressé",
|
||||
"input.onPinReleased|block": "lorsque la broche %NAME|est lachée",
|
||||
"input.pinIsPressed|block": "broche %NAME| est pressée",
|
||||
"input.rotation|block": "rotation (°)|%NAME",
|
||||
|
82
libs/core/_locales/ja/core-strings.json
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"AcceleratorRange.EightG": "8Gまでの加速度を測ります。",
|
||||
"AcceleratorRange.EightG|block": "8G",
|
||||
"AcceleratorRange.FourG": "4Gまでの加速度を測ります。",
|
||||
"AcceleratorRange.FourG|block": "4G",
|
||||
"AcceleratorRange.OneG": "1Gまでの加速度を測ります。",
|
||||
"AcceleratorRange.OneG|block": "1G",
|
||||
"AcceleratorRange.TwoG": "2Gまでの加速度を測ります。",
|
||||
"AcceleratorRange.TwoG|block": "2G",
|
||||
"BaudRate.BaudRate115200|block": "115200",
|
||||
"BaudRate.BaudRate9600|block": "9600",
|
||||
"BeatFraction.Breve|block": "4",
|
||||
"BeatFraction.Double|block": "2",
|
||||
"BeatFraction.Eighth|block": "1/8",
|
||||
"BeatFraction.Half|block": "1/2",
|
||||
"BeatFraction.Quarter|block": "1/4",
|
||||
"BeatFraction.Sixteenth|block": "1/16",
|
||||
"BeatFraction.Whole|block": "1",
|
||||
"Button.AB|block": "A+B",
|
||||
"Delimiters.Dollar|block": "$",
|
||||
"Delimiters.Hash|block": "#",
|
||||
"Delimiters.NewLine|block": "改行",
|
||||
"Gesture.EightG": "8Gの衝撃があったときに発生します。",
|
||||
"Gesture.EightG|block": "8G",
|
||||
"Gesture.FreeFall": "ボードを落としたときに発生します。",
|
||||
"Gesture.FreeFall|block": "落とした",
|
||||
"Gesture.LogoDown": "画面が垂直で、ロゴの位置が下になったときに発生します。",
|
||||
"Gesture.LogoDown|block": "ロゴが下になった",
|
||||
"Gesture.LogoUp": "画面が垂直で、ロゴの位置が上になったときに発生します。",
|
||||
"Gesture.LogoUp|block": "ロゴが上になった",
|
||||
"Gesture.ScreenDown": "ボードが水平で、画面が下向きになったときに発生します。",
|
||||
"Gesture.ScreenDown|block": "画面が下になった",
|
||||
"Gesture.ScreenUp": "ボードが水平で、画面が上向きになったときに発生します。",
|
||||
"Gesture.ScreenUp|block": "画面が上になった",
|
||||
"Gesture.Shake": "ボードがゆさぶられたときに発生します。",
|
||||
"Gesture.Shake|block": "ゆさぶられた",
|
||||
"Gesture.SixG": "6Gの衝撃があったときに発生します。",
|
||||
"Gesture.SixG|block": "6G",
|
||||
"Gesture.ThreeG": "3Gの衝撃があったときに発生します。",
|
||||
"Gesture.ThreeG|block": "3G",
|
||||
"Gesture.TiltLeft": "画面を左に傾けたときに発生します。",
|
||||
"Gesture.TiltLeft|block": "左に傾けた",
|
||||
"Gesture.TiltRight": "画面を右に傾けたときに発生します。",
|
||||
"Gesture.TiltRight|block": "右に傾けた",
|
||||
"LedSpriteProperty.Brightness|block": "明るさ",
|
||||
"Math.randomBoolean|block": "真または偽をランダムに選ぶ",
|
||||
"Math|block": "計算",
|
||||
"String.fromCharCode|block": "文字コード %code|の文字",
|
||||
"basic.clearScreen|block": "表示を消す",
|
||||
"basic.forever|block": "ずっと",
|
||||
"basic.pause|block": "ひと休み(ミリ秒) %pause",
|
||||
"basic.showLeds|block": "LEDに表示",
|
||||
"basic.showNumber|block": "数を表示|%number",
|
||||
"basic.showString|block": "文字列を表示|%text",
|
||||
"basic|block": "基本",
|
||||
"control.inBackground|block": "バックグラウンドで実行する",
|
||||
"control.reset|block": "リセット",
|
||||
"control|block": "制御",
|
||||
"game.gameOver|block": "ゲームオーバー",
|
||||
"game|block": "ゲーム",
|
||||
"images.createBigImage|block": "大きな画像を作成",
|
||||
"images.createImage|block": "画像を作成",
|
||||
"images|block": "画像",
|
||||
"input.acceleration|block": "加速度(ミリG)|%NAME",
|
||||
"input.onPinPressed|block": "端子 %name|がタッチされたとき",
|
||||
"input.onPinReleased|block": "端子 %NAME|がタッチされなくなったとき",
|
||||
"input.pinIsPressed|block": "端子 %NAME|がタッチされている",
|
||||
"input.rotation|block": "傾斜(°)|%NAME",
|
||||
"input.runningTime|block": "稼働時間(ミリ秒)",
|
||||
"input.setAccelerometerRange|block": "加速度センサの計測範囲を設定する %range",
|
||||
"input.temperature|block": "温度(℃)",
|
||||
"led.brightness|block": "明るさ",
|
||||
"led.enable|block": "表示をオンまたはオフにする %on",
|
||||
"led.plot|block": "点灯|x %x|y %y",
|
||||
"led|block": "LED",
|
||||
"music.setTempo|block": "テンポを設定する(bpm)|%value",
|
||||
"music.tempo|block": "テンポ(bpm)",
|
||||
"music|block": "音楽",
|
||||
"{id:category}Basic": "基本",
|
||||
"{id:category}Led": "LED",
|
||||
"{id:category}Math": "計算"
|
||||
}
|
9
libs/core/_locales/no/core-jsdoc-strings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Math.abs": "Gir absoluttverdien av et tall (størrelsen av tallet, uavhengig av om det er positivt eller negativt).\nFor eksempel er absoluttverdien av -5 og absoluttverdien av 5 begge lik 5.",
|
||||
"Math.abs|param|x": "Et tall eller matematisk uttrykk som vi ønsker absoluttverdien av.",
|
||||
"Math.max": "Gir verdien til det største av to tall eller matematiske uttrykk.",
|
||||
"Math.randomBoolean": "Gir en tilfeldig logisk verdi, \"sann\" eller \"usann\".",
|
||||
"String.fromCharCode": "Lag en tekst som består av tegnet med den angitte ASCII-koden.",
|
||||
"basic": "Blokker for grunnleggende mikro:bit-funksjonalitet.",
|
||||
"basic.clearScreen": "Slå av alle lysene på skjermen"
|
||||
}
|
3
libs/core/_locales/no/core-strings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"serial|block": "føljetong"
|
||||
}
|
5
libs/core/_locales/sv-SE/core-jsdoc-strings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"Math.abs": "Returnerar absolutbeloppet av ett tal (värdet utan hänsyn till huruvida det är positivt eller negativt). \nTill exempel är absolutbeloppet av -5 detsamma som absolutbeloppet av 5.",
|
||||
"Math.max": "Returnerar det större av två givna numeriska uttryck.",
|
||||
"Math.min": "Returnerar det mindre av två givna numeriska uttryck."
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
//% color=#0078D7 weight=100 icon="\uf00a"
|
||||
namespace basic {
|
||||
|
||||
/**
|
||||
@ -13,7 +13,7 @@ namespace basic {
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix"
|
||||
void showNumber(int value, int interval = 150) {
|
||||
@ -50,7 +50,7 @@ namespace basic {
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% block="show|string %text"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% parts="ledmatrix"
|
||||
@ -73,7 +73,7 @@ namespace basic {
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
//% blockId=device_clear_display block="clear screen"
|
||||
//% parts="ledmatrix"
|
||||
void clearScreen() {
|
||||
uBit.display.image.clear();
|
||||
@ -112,7 +112,7 @@ namespace basic {
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1
|
||||
//% blockId=device_forever block="forever" icon="\uf01e"
|
||||
void forever(Action a) {
|
||||
if (a != 0) {
|
||||
|
@ -121,7 +121,7 @@ namespace control {
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% help=control/in-background blockAllowMultiple=1
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8
|
||||
void inBackground(Action a) {
|
||||
runInBackground(a);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Runtime and event utilities.
|
||||
*/
|
||||
//% weight=1 color="#333333"
|
||||
//% weight=1 color="#333333" icon="\uf233"
|
||||
//% advanced=true
|
||||
namespace control {
|
||||
|
||||
@ -31,7 +31,7 @@ namespace control {
|
||||
/**
|
||||
* If the condition is false, display msg on serial console, and panic with code 098.
|
||||
*/
|
||||
export function assert(condition: boolean, msg ?: string) {
|
||||
export function assert(condition: boolean, msg?: string) {
|
||||
if (!condition) {
|
||||
console.log("ASSERTION FAILED")
|
||||
if (msg != null) {
|
||||
|
@ -153,13 +153,19 @@ namespace Array_ {
|
||||
//%
|
||||
int length(RefCollection *c) { return c->length(); }
|
||||
//%
|
||||
void setLength(RefCollection *c, int newLength) { c->setLength(newLength); }
|
||||
//%
|
||||
void push(RefCollection *c, uint32_t x) { c->push(x); }
|
||||
//%
|
||||
uint32_t pop(RefCollection *c) { return c->pop(); }
|
||||
//%
|
||||
uint32_t getAt(RefCollection *c, int x) { return c->getAt(x); }
|
||||
//%
|
||||
void removeAt(RefCollection *c, int x) { c->removeAt(x); }
|
||||
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
|
||||
//%
|
||||
void setAt(RefCollection *c, int x, uint32_t y) { c->setAt(x, y); }
|
||||
uint32_t removeAt(RefCollection *c, int x) { return c->removeAt(x); }
|
||||
//%
|
||||
void insertAt(RefCollection *c, int x, uint32_t value) { c->insertAt(x, value); }
|
||||
//%
|
||||
int indexOf(RefCollection *c, uint32_t x, int start) { return c->indexOf(x, start); }
|
||||
//%
|
||||
|
5
libs/core/enums.d.ts
vendored
@ -115,6 +115,11 @@ declare namespace basic {
|
||||
*/
|
||||
//% block="6g"
|
||||
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_6G
|
||||
/**
|
||||
* Raised when a 8G shock is detected
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = 10, // MICROBIT_ACCELEROMETER_EVT_8G
|
||||
}
|
||||
declare namespace input {
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ enum LedSpriteProperty {
|
||||
/**
|
||||
* A single-LED sprite game engine
|
||||
*/
|
||||
//% color=#008272 weight=32
|
||||
//% color=#008272 weight=32 icon="\uf11b"
|
||||
//% advanced=true
|
||||
namespace game {
|
||||
let _score: number = 0;
|
||||
|
@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
*/
|
||||
//% color=#5C2D91 weight=31
|
||||
//% color=#5C2D91 weight=31 icon="\uf03e"
|
||||
//% advanced=true
|
||||
namespace images {
|
||||
/**
|
||||
|
@ -104,10 +104,15 @@ enum class Gesture {
|
||||
* Raised when a 6G shock is detected
|
||||
*/
|
||||
//% block="6g"
|
||||
SixG = MICROBIT_ACCELEROMETER_EVT_6G
|
||||
SixG = MICROBIT_ACCELEROMETER_EVT_6G,
|
||||
/**
|
||||
* Raised when a 8G shock is detected
|
||||
*/
|
||||
//% block="8g"
|
||||
EightG = MICROBIT_ACCELEROMETER_EVT_8G
|
||||
};
|
||||
|
||||
//% color=300 weight=99
|
||||
//% color=300 weight=99 icon="\uf192"
|
||||
namespace input {
|
||||
/**
|
||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
||||
@ -115,7 +120,7 @@ namespace input {
|
||||
* @param body code to run when event is raised
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed"
|
||||
//% parts="buttonpair"
|
||||
void onButtonPressed(Button button, Action body) {
|
||||
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
|
||||
@ -127,14 +132,15 @@ namespace input {
|
||||
* @param body code to run when gesture is raised
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
//% blockId=device_gesture_event block="on |%NAME"
|
||||
//% parts="accelerometer"
|
||||
void onGesture(Gesture gesture, Action body) {
|
||||
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||
int gi = (int)gesture;
|
||||
if (gi == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
|
||||
uBit.accelerometer.setRange(4);
|
||||
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
|
||||
else if ((gi == MICROBIT_ACCELEROMETER_EVT_6G || gi == MICROBIT_ACCELEROMETER_EVT_8G) && uBit.accelerometer.getRange() < 6)
|
||||
uBit.accelerometer.setRange(8);
|
||||
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
|
||||
registerWithDal(MICROBIT_ID_GESTURE, gi, body);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,7 +149,7 @@ namespace input {
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094"
|
||||
//% blockId=device_pin_event block="on pin %name|pressed"
|
||||
void onPinPressed(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
if (!pin) return;
|
||||
@ -159,7 +165,7 @@ namespace input {
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||
//% blockId=device_pin_released block="on pin %NAME|released"
|
||||
//% advanced=true
|
||||
void onPinReleased(TouchPin name, Action body) {
|
||||
auto pin = getPin((int)name);
|
||||
@ -194,7 +200,7 @@ namespace input {
|
||||
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
||||
//% blockGap=8
|
||||
bool pinIsPressed(TouchPin name) {
|
||||
auto pin = getPin((int)name);
|
||||
@ -212,7 +218,7 @@ namespace input {
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/acceleration weight=58 icon="\uf135"
|
||||
//% help=input/acceleration weight=58
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
//% parts="accelerometer"
|
||||
int acceleration(Dimension dimension) {
|
||||
@ -229,7 +235,7 @@ namespace input {
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||
*/
|
||||
//% help=input/light-level weight=57
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
int lightLevel() {
|
||||
return uBit.display.readLightLevel();
|
||||
@ -239,7 +245,7 @@ namespace input {
|
||||
* Get the current compass heading in degrees.
|
||||
*/
|
||||
//% help=input/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% weight=56
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
//% parts="compass"
|
||||
int compassHeading() {
|
||||
@ -250,7 +256,7 @@ namespace input {
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% weight=55
|
||||
//% help=input/temperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
//% parts="thermometer"
|
||||
@ -263,7 +269,7 @@ namespace input {
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=input/rotation weight=52
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" advanced=true
|
||||
int rotation(Rotation kind) {
|
||||
switch (kind) {
|
||||
@ -278,7 +284,7 @@ namespace input {
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/magnetic-force weight=51
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
|
||||
//% parts="compass"
|
||||
//% advanced=true
|
||||
int magneticForce(Dimension dimension) {
|
||||
@ -298,7 +304,7 @@ namespace input {
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||
//% blockId=device_get_running_time block="running time (ms)"
|
||||
//% advanced=true
|
||||
int runningTime() {
|
||||
return system_timer_current_time();
|
||||
@ -315,7 +321,7 @@ namespace input {
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
*/
|
||||
//% help=input/set-accelerometer-range
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
|
||||
//% weight=5
|
||||
//% parts="accelerometer"
|
||||
//% advanced=true
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Events and data from sensors
|
||||
*/
|
||||
//% color=#B4009E weight=99
|
||||
//% color=#B4009E weight=99 icon="\uf192"
|
||||
namespace input {
|
||||
/**
|
||||
* Attaches code to run when the screen is facing up.
|
||||
|
@ -8,7 +8,7 @@ enum class DisplayMode_ {
|
||||
// TODO DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE
|
||||
};
|
||||
|
||||
//% color=3 weight=35
|
||||
//% color=3 weight=35 icon="\uf205"
|
||||
namespace led {
|
||||
|
||||
/**
|
||||
@ -17,7 +17,7 @@ namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/plot weight=78
|
||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void plot(int x, int y) {
|
||||
uBit.display.image.setPixelValue(x, y, 1);
|
||||
@ -29,7 +29,7 @@ namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/unplot weight=77
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
void unplot(int x, int y) {
|
||||
uBit.display.image.setPixelValue(x, y, 0);
|
||||
@ -41,7 +41,7 @@ namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/point weight=76
|
||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||
//% blockId=device_point block="point|x %x|y %y"
|
||||
//% parts="ledmatrix"
|
||||
bool point(int x, int y) {
|
||||
int pix = uBit.display.image.getPixelValue(x, y);
|
||||
@ -52,7 +52,7 @@ namespace led {
|
||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||
*/
|
||||
//% help=led/brightness weight=60
|
||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||
//% blockId=device_get_brightness block="brightness" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
int brightness() {
|
||||
@ -64,7 +64,7 @@ namespace led {
|
||||
* @param value the brightness value, eg:255, 127, 0
|
||||
*/
|
||||
//% help=led/set-brightness weight=59
|
||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||
//% blockId=device_set_brightness block="set brightness %value"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
void setBrightness(int value) {
|
||||
@ -75,7 +75,7 @@ namespace led {
|
||||
* Cancels the current animation and clears other pending animations.
|
||||
*/
|
||||
//% weight=50 help=led/stop-animation
|
||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||
//% blockId=device_stop_animation block="stop animation"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true
|
||||
void stopAnimation() {
|
||||
@ -95,7 +95,7 @@ namespace led {
|
||||
/**
|
||||
* Turns on or off the display
|
||||
*/
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||
//% advanced=true parts="ledmatrix"
|
||||
void enable(bool on) {
|
||||
if (on) uBit.display.enable();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Control of the LED screen.
|
||||
*/
|
||||
//% color=#5C2D91 weight=97
|
||||
//% color=#5C2D91 weight=97 icon="\uf205"
|
||||
namespace led {
|
||||
|
||||
// what's the current high value
|
||||
|
@ -129,7 +129,7 @@ enum BeatFraction {
|
||||
/**
|
||||
* Generation of music tones through pin ``P0``.
|
||||
*/
|
||||
//% color=#D83B01 weight=98
|
||||
//% color=#D83B01 weight=98 icon="\uf025"
|
||||
namespace music {
|
||||
let beatsPerMinute: number = 120;
|
||||
|
||||
@ -139,7 +139,7 @@ namespace music {
|
||||
* @param ms tone duration in milliseconds (ms)
|
||||
*/
|
||||
//% help=music/play-tone weight=90
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
|
||||
//% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function playTone(frequency: number, ms: number): void {
|
||||
pins.analogPitch(frequency, ms);
|
||||
@ -150,7 +150,7 @@ namespace music {
|
||||
* @param frequency pitch of the tone to play in Hertz (Hz)
|
||||
*/
|
||||
//% help=music/ring-tone weight=80
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
|
||||
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" blockGap=8
|
||||
//% parts="headphone"
|
||||
export function ringTone(frequency: number): void {
|
||||
pins.analogPitch(frequency, 0);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Control currents in Pins for analog/digital signals, servos, i2c, ...
|
||||
*/
|
||||
//% color=#A80000 weight=30
|
||||
//% color=#A80000 weight=30 icon="\uf140"
|
||||
//% advanced=true
|
||||
namespace pins {
|
||||
/**
|
||||
|
@ -141,63 +141,373 @@ namespace pxt {
|
||||
printf("RefRecord %p r=%d size=%d bytes\n", r, r->refcnt, r->getVTable()->numbytes);
|
||||
}
|
||||
|
||||
void RefCollection::push(uint32_t x) {
|
||||
if (isRef()) incr(x);
|
||||
data.push_back(x);
|
||||
uint32_t Segment::get(uint32_t i)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::get index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
|
||||
if (i < length)
|
||||
{
|
||||
if (data[i] != Segment::MissingValue)
|
||||
{
|
||||
return data[i];
|
||||
}
|
||||
error(ERR_MISSING_VALUE);
|
||||
return 0;
|
||||
}
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t RefCollection::getAt(int x) {
|
||||
if (in_range(x)) {
|
||||
uint32_t tmp = data.at(x);
|
||||
if (isRef()) incr(tmp);
|
||||
void Segment::set(uint32_t i, uint32_t value)
|
||||
{
|
||||
if (i < size)
|
||||
{
|
||||
data[i] = value;
|
||||
}
|
||||
else if (i < Segment::MaxSize)
|
||||
{
|
||||
growByMin(i + 1);
|
||||
data[i] = value;
|
||||
}
|
||||
if (length <= i)
|
||||
{
|
||||
length = i + 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::set\n");
|
||||
this->print();
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t Segment::growthFactor(uint16_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
if (size < 64)
|
||||
{
|
||||
return size * 2; // Double
|
||||
}
|
||||
if (size < 512)
|
||||
{
|
||||
return size * 5/3; //Grow by 1.66 rate
|
||||
}
|
||||
return size + 256; //Grow by constant rate
|
||||
}
|
||||
|
||||
void Segment::growByMin(uint16_t minSize)
|
||||
{
|
||||
growBy(max(minSize, growthFactor(size)));
|
||||
}
|
||||
|
||||
void Segment::growBy(uint16_t newSize)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("growBy: %d\n", newSize);
|
||||
this->print();
|
||||
#endif
|
||||
if (size < newSize)
|
||||
{
|
||||
//this will throw if unable to allocate
|
||||
uint32_t *tmp = (uint32_t*)(::operator new(newSize * sizeof(uint32_t)));
|
||||
|
||||
//Copy existing data
|
||||
if (size)
|
||||
{
|
||||
memcpy(tmp, data, size * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
//fill the rest with missing values;
|
||||
for(uint16_t i = size; i < newSize; i++)
|
||||
{
|
||||
tmp[i] = Segment::MissingValue;
|
||||
}
|
||||
|
||||
//free older segment;
|
||||
::operator delete(data);
|
||||
|
||||
data = tmp;
|
||||
size = newSize;
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("growBy - after reallocation\n");
|
||||
this->print();
|
||||
#endif
|
||||
|
||||
}
|
||||
//else { no shrinking yet; }
|
||||
return;
|
||||
}
|
||||
|
||||
void Segment::ensure(uint16_t newSize)
|
||||
{
|
||||
if (newSize < size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
growByMin(newSize);
|
||||
}
|
||||
|
||||
void Segment::setLength(uint32_t newLength)
|
||||
{
|
||||
if (newLength > size)
|
||||
{
|
||||
ensure(length);
|
||||
}
|
||||
length = newLength;
|
||||
return;
|
||||
}
|
||||
|
||||
void Segment::push(uint32_t value)
|
||||
{
|
||||
this->set(length, value);
|
||||
}
|
||||
|
||||
uint32_t Segment::pop()
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::pop\n");
|
||||
this->print();
|
||||
#endif
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
uint32_t value = data[length];
|
||||
data[length] = Segment::MissingValue;
|
||||
--length;
|
||||
return value;
|
||||
}
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//this function removes an element at index i and shifts the rest of the elements to
|
||||
//left to fill the gap
|
||||
uint32_t Segment::remove(uint32_t i)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::remove index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
if (i < length)
|
||||
{
|
||||
//value to return
|
||||
uint32_t ret = data[i];
|
||||
if (i + 1 < length)
|
||||
{
|
||||
//Move the rest of the elements to fill in the gap.
|
||||
memmove(data + i, data + i + 1, (length - i - 1) * sizeof(uint32_t));
|
||||
}
|
||||
length--;
|
||||
data[length] = Segment::MissingValue;
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("After Segment::remove index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//this function inserts element value at index i by shifting the rest of the elements right.
|
||||
void Segment::insert(uint32_t i, uint32_t value)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::insert index:%u value:%u\n", i, value);
|
||||
this->print();
|
||||
#endif
|
||||
|
||||
if (i < length)
|
||||
{
|
||||
ensure(length + 1);
|
||||
if (i + 1 < length)
|
||||
{
|
||||
//Move the rest of the elements to fill in the gap.
|
||||
memmove(data + i + 1, data + i, (length - i) * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
data[i] = value;
|
||||
length++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//This is insert beyond the length, just call set which will adjust the length
|
||||
set(i, value);
|
||||
}
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("After Segment::insert index:%u\n", i);
|
||||
this->print();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Segment::print()
|
||||
{
|
||||
printf("Segment: %x, length: %u, size: %u\n", data, (uint)length, (uint)size);
|
||||
for(uint i = 0; i < size; i++)
|
||||
{
|
||||
printf("%d ",(uint)data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
bool Segment::isValidIndex(uint32_t i)
|
||||
{
|
||||
if (i > length || data[i] == Segment::MissingValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Segment::getNextValidIndex(uint32_t i, uint32_t *result)
|
||||
{
|
||||
while (i < length)
|
||||
{
|
||||
if (data[i] != Segment::MissingValue)
|
||||
{
|
||||
*result = i;
|
||||
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::getNextValidIndex result=%u\n",i);
|
||||
this->print();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Segment::destroy()
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
printf("In Segment::destroy\n");
|
||||
this->print();
|
||||
#endif
|
||||
length = size = 0;
|
||||
::operator delete(data);
|
||||
data = nullptr;
|
||||
}
|
||||
|
||||
void RefCollection::push(uint32_t x)
|
||||
{
|
||||
if (isRef()) incr(x);
|
||||
head.push(x);
|
||||
}
|
||||
|
||||
uint32_t RefCollection::pop()
|
||||
{
|
||||
uint32_t ret = head.pop();
|
||||
if (isRef())
|
||||
{
|
||||
incr(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t RefCollection::getAt(int i)
|
||||
{
|
||||
if (head.isValidIndex(i))
|
||||
{
|
||||
uint32_t tmp = head.get(i);
|
||||
if (isRef())
|
||||
{
|
||||
incr(tmp);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void RefCollection::removeAt(int x) {
|
||||
if (!in_range(x))
|
||||
return;
|
||||
|
||||
if (isRef()) decr(data.at(x));
|
||||
data.erase(data.begin()+x);
|
||||
}
|
||||
|
||||
void RefCollection::setAt(int x, uint32_t y) {
|
||||
if (!in_range(x))
|
||||
return;
|
||||
|
||||
if (isRef()) {
|
||||
decr(data.at(x));
|
||||
incr(y);
|
||||
uint32_t RefCollection::removeAt(int i)
|
||||
{
|
||||
if (!head.isValidIndex((uint32_t)i))
|
||||
{
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
return 0;
|
||||
}
|
||||
data.at(x) = y;
|
||||
if (isRef())
|
||||
{
|
||||
decr(head.get(i));
|
||||
}
|
||||
return head.remove(i);
|
||||
}
|
||||
|
||||
int RefCollection::indexOf(uint32_t x, int start) {
|
||||
if (!in_range(start))
|
||||
return -1;
|
||||
void RefCollection::insertAt(int i, uint32_t value)
|
||||
{
|
||||
if (i < length())
|
||||
{
|
||||
head.insert(i, value);
|
||||
if (isRef())
|
||||
{
|
||||
incr(value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error(ERR_OUT_OF_BOUNDS);
|
||||
}
|
||||
}
|
||||
|
||||
if (isString()) {
|
||||
StringData *xx = (StringData*)x;
|
||||
for (uint32_t i = start; i < data.size(); ++i) {
|
||||
StringData *ee = (StringData*)data.at(i);
|
||||
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
|
||||
return (int)i;
|
||||
void RefCollection::setAt(int i, uint32_t value)
|
||||
{
|
||||
if (isRef())
|
||||
{
|
||||
if (head.isValidIndex((uint32_t)i))
|
||||
{
|
||||
decr(head.get(i));
|
||||
}
|
||||
} else {
|
||||
for (uint32_t i = start; i < data.size(); ++i)
|
||||
if (data.at(i) == x)
|
||||
incr(value);
|
||||
}
|
||||
head.set(i, value);
|
||||
}
|
||||
|
||||
int RefCollection::indexOf(uint32_t x, int start)
|
||||
{
|
||||
if (isString())
|
||||
{
|
||||
StringData *xx = (StringData*)x;
|
||||
uint32_t i = start;
|
||||
while(head.getNextValidIndex(start, &i))
|
||||
{
|
||||
StringData *ee = (StringData*)head.get(i);
|
||||
if (xx->len == ee->len && memcmp(xx->data, ee->data, xx->len) == 0)
|
||||
{
|
||||
return (int)i;
|
||||
}
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t i = start;
|
||||
while(head.getNextValidIndex(start, &i))
|
||||
{
|
||||
if (head.get(i) == x)
|
||||
{
|
||||
return (int)i;
|
||||
}
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int RefCollection::removeElement(uint32_t x) {
|
||||
int RefCollection::removeElement(uint32_t x)
|
||||
{
|
||||
int idx = indexOf(x, 0);
|
||||
if (idx >= 0) {
|
||||
removeAt(idx);
|
||||
@ -239,17 +549,23 @@ namespace pxt {
|
||||
void RefCollection::destroy()
|
||||
{
|
||||
if (this->isRef())
|
||||
for (uint32_t i = 0; i < this->data.size(); ++i) {
|
||||
decr(this->data[i]);
|
||||
this->data[i] = 0;
|
||||
{
|
||||
uint32_t start = 0;
|
||||
uint32_t i = 0;
|
||||
while(head.getNextValidIndex(start, &i))
|
||||
{
|
||||
decr(this->head.get(i));
|
||||
start = i;
|
||||
}
|
||||
this->data.resize(0);
|
||||
}
|
||||
this->head.destroy();
|
||||
delete this;
|
||||
}
|
||||
|
||||
void RefCollection::print()
|
||||
{
|
||||
printf("RefCollection %p r=%d flags=%d size=%d [%p, ...]\n", this, refcnt, getFlags(), data.size(), data.size() > 0 ? data[0] : 0);
|
||||
printf("RefCollection %p r=%d flags=%d size=%d\n", this, refcnt, getFlags(), head.getLength());
|
||||
head.print();
|
||||
}
|
||||
|
||||
PXT_VTABLE_CTOR(RefAction) {}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __PXT_H
|
||||
#define __PXT_H
|
||||
|
||||
// #define DEBUG_MEMLEAKS 1
|
||||
//#define DEBUG_MEMLEAKS 1
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
@ -38,6 +38,7 @@ namespace pxt {
|
||||
ERR_OUT_OF_BOUNDS = 8,
|
||||
ERR_REF_DELETED = 7,
|
||||
ERR_SIZE = 9,
|
||||
ERR_MISSING_VALUE = 10,
|
||||
} ERROR;
|
||||
|
||||
extern const uint32_t functionsAndBytecode[];
|
||||
@ -167,11 +168,53 @@ namespace pxt {
|
||||
}
|
||||
};
|
||||
|
||||
class Segment {
|
||||
private:
|
||||
uint32_t* data;
|
||||
uint16_t length;
|
||||
uint16_t size;
|
||||
|
||||
static const uint16_t MaxSize = 0xFFFF;
|
||||
static const uint32_t MissingValue = 0x80000000;
|
||||
|
||||
static uint16_t growthFactor(uint16_t size);
|
||||
void growByMin(uint16_t minSize);
|
||||
void growBy(uint16_t newSize);
|
||||
void ensure(uint16_t newSize);
|
||||
|
||||
public:
|
||||
Segment() : data (nullptr), length(0), size(0) {};
|
||||
|
||||
uint32_t get(uint32_t i);
|
||||
void set(uint32_t i, uint32_t value);
|
||||
|
||||
uint32_t getLength() { return length;};
|
||||
void setLength(uint32_t newLength);
|
||||
|
||||
void push(uint32_t value);
|
||||
uint32_t pop();
|
||||
|
||||
uint32_t remove(uint32_t i);
|
||||
void insert(uint32_t i, uint32_t value);
|
||||
|
||||
//Returns true if there is a valid index greater than or equal to 'i', returns false otherwise
|
||||
//If 'i' is valid returns it in 'result', if not tries to find the next valid
|
||||
//index < length which is valid.
|
||||
bool getNextValidIndex(uint32_t i, uint32_t *result);
|
||||
bool isValidIndex(uint32_t i);
|
||||
|
||||
void destroy();
|
||||
|
||||
void print();
|
||||
};
|
||||
|
||||
// A ref-counted collection of either primitive or ref-counted objects (String, Image,
|
||||
// user-defined record, another collection)
|
||||
class RefCollection
|
||||
: public RefObject
|
||||
{
|
||||
private:
|
||||
Segment head;
|
||||
public:
|
||||
// 1 - collection of refs (need decr)
|
||||
// 2 - collection of strings (in fact we always have 3, never 2 alone)
|
||||
@ -179,23 +222,23 @@ namespace pxt {
|
||||
inline bool isRef() { return getFlags() & 1; }
|
||||
inline bool isString() { return getFlags() & 2; }
|
||||
|
||||
std::vector<uint32_t> data;
|
||||
|
||||
RefCollection(uint16_t f);
|
||||
|
||||
inline bool in_range(int x) {
|
||||
return (0 <= x && x < (int)data.size());
|
||||
}
|
||||
|
||||
inline int length() { return data.size(); }
|
||||
|
||||
void destroy();
|
||||
void print();
|
||||
|
||||
uint32_t length() { return head.getLength();}
|
||||
void setLength(uint32_t newLength) { head.setLength(newLength); }
|
||||
|
||||
void push(uint32_t x);
|
||||
uint32_t getAt(int x);
|
||||
void removeAt(int x);
|
||||
void setAt(int x, uint32_t y);
|
||||
uint32_t pop();
|
||||
uint32_t getAt(int i);
|
||||
void setAt(int i, uint32_t x);
|
||||
//removes the element at index i and shifts the other elements left
|
||||
uint32_t removeAt(int i);
|
||||
//inserts the element at index i and moves the other elements right.
|
||||
void insertAt(int i, uint32_t x);
|
||||
|
||||
int indexOf(uint32_t x, int start);
|
||||
int removeElement(uint32_t x);
|
||||
};
|
||||
|
@ -37,7 +37,11 @@
|
||||
"_locales/fr/core-jsdoc-strings.json",
|
||||
"_locales/fr/core-strings.json",
|
||||
"_locales/de/core-jsdoc-strings.json",
|
||||
"_locales/de/core-strings.json"
|
||||
"_locales/de/core-strings.json",
|
||||
"_locales/no/core-strings.json",
|
||||
"_locales/ja/core-strings.json",
|
||||
"_locales/sv-SE/core-jsdoc-strings.json",
|
||||
"_locales/no/core-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {},
|
||||
@ -50,4 +54,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ enum Delimiters {
|
||||
Hash = 6,
|
||||
};
|
||||
|
||||
//% weight=2 color=30
|
||||
//% weight=2 color=30 icon="\uf287"
|
||||
//% advanced=true
|
||||
namespace serial {
|
||||
// note that at least one // followed by % is needed per declaration!
|
||||
@ -92,7 +92,10 @@ namespace serial {
|
||||
//% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
|
||||
//% blockExternalInputs=1
|
||||
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
|
||||
uBit.serial.redirect((PinName)tx, (PinName)rx);
|
||||
MicroBitPin* txp = getPin(tx); if (!tx) return;
|
||||
MicroBitPin* rxp = getPin(rx); if (!rx) return;
|
||||
|
||||
uBit.serial.redirect(txp->name, rxp->name);
|
||||
uBit.serial.baud((int)rate);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Reading and writing data over a serial connection.
|
||||
*/
|
||||
//% weight=2 color=#002050
|
||||
//% weight=2 color=#002050 icon="\uf287"
|
||||
//% advanced=true
|
||||
namespace serial {
|
||||
/**
|
||||
|
60
libs/core/shims.d.ts
vendored
@ -4,7 +4,7 @@
|
||||
/**
|
||||
* Creation, manipulation and display of LED images.
|
||||
*/
|
||||
//% color=#5C2D91 weight=31
|
||||
//% color=#5C2D91 weight=31 icon="\uf03e"
|
||||
//% advanced=true
|
||||
declare namespace images {
|
||||
|
||||
@ -126,7 +126,7 @@ declare interface Image {
|
||||
/**
|
||||
* Provides access to basic micro:bit functionality.
|
||||
*/
|
||||
//% color=#0078D7 weight=100
|
||||
//% color=#0078D7 weight=100 icon="\uf00a"
|
||||
declare namespace basic {
|
||||
|
||||
/**
|
||||
@ -135,7 +135,7 @@ declare namespace basic {
|
||||
*/
|
||||
//% help=basic/show-number
|
||||
//% weight=96
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8 icon="\uf1ec"
|
||||
//% blockId=device_show_number block="show|number %number" blockGap=8
|
||||
//% async
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showNumber
|
||||
function showNumber(value: number, interval?: number): void;
|
||||
@ -160,7 +160,7 @@ declare namespace basic {
|
||||
*/
|
||||
//% help=basic/show-string
|
||||
//% weight=87 blockGap=8
|
||||
//% block="show|string %text" icon="\uf031"
|
||||
//% block="show|string %text"
|
||||
//% async
|
||||
//% blockId=device_print_message
|
||||
//% parts="ledmatrix" interval.defl=150 shim=basic::showString
|
||||
@ -170,7 +170,7 @@ declare namespace basic {
|
||||
* Turn off all LEDs
|
||||
*/
|
||||
//% help=basic/clear-screen weight=79
|
||||
//% blockId=device_clear_display block="clear screen" icon="\uf12d"
|
||||
//% blockId=device_clear_display block="clear screen"
|
||||
//% parts="ledmatrix" shim=basic::clearScreen
|
||||
function clearScreen(): void;
|
||||
|
||||
@ -195,7 +195,7 @@ declare namespace basic {
|
||||
* Repeats the code forever in the background. On each iteration, allows other codes to run.
|
||||
* @param body code to execute
|
||||
*/
|
||||
//% help=basic/forever weight=55 blockGap=8
|
||||
//% help=basic/forever weight=55 blockGap=8 blockAllowMultiple=1
|
||||
//% blockId=device_forever block="forever" icon="\uf01e" shim=basic::forever
|
||||
function forever(a: () => void): void;
|
||||
|
||||
@ -211,7 +211,7 @@ declare namespace basic {
|
||||
|
||||
|
||||
|
||||
//% color=300 weight=99
|
||||
//% color=300 weight=99 icon="\uf192"
|
||||
declare namespace input {
|
||||
|
||||
/**
|
||||
@ -220,7 +220,7 @@ declare namespace input {
|
||||
* @param body code to run when event is raised
|
||||
*/
|
||||
//% help=input/on-button-pressed weight=85 blockGap=8
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
|
||||
//% blockId=device_button_event block="on button|%NAME|pressed"
|
||||
//% parts="buttonpair" shim=input::onButtonPressed
|
||||
function onButtonPressed(button: Button, body: () => void): void;
|
||||
|
||||
@ -230,7 +230,7 @@ declare namespace input {
|
||||
* @param body code to run when gesture is raised
|
||||
*/
|
||||
//% help=input/on-gesture weight=84 blockGap=8
|
||||
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
|
||||
//% blockId=device_gesture_event block="on |%NAME"
|
||||
//% parts="accelerometer" shim=input::onGesture
|
||||
function onGesture(gesture: Gesture, body: () => void): void;
|
||||
|
||||
@ -240,7 +240,7 @@ declare namespace input {
|
||||
* @param body the code to run when the pin is pressed
|
||||
*/
|
||||
//% help=input/on-pin-pressed weight=83
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" icon="\uf094" shim=input::onPinPressed
|
||||
//% blockId=device_pin_event block="on pin %name|pressed" shim=input::onPinPressed
|
||||
function onPinPressed(name: TouchPin, body: () => void): void;
|
||||
|
||||
/**
|
||||
@ -249,7 +249,7 @@ declare namespace input {
|
||||
* @param body the code to run when the pin is released
|
||||
*/
|
||||
//% help=input/on-pin-released weight=6 blockGap=8
|
||||
//% blockId=device_pin_released block="on pin %NAME|released" icon="\uf094"
|
||||
//% blockId=device_pin_released block="on pin %NAME|released"
|
||||
//% advanced=true shim=input::onPinReleased
|
||||
function onPinReleased(name: TouchPin, body: () => void): void;
|
||||
|
||||
@ -269,7 +269,7 @@ declare namespace input {
|
||||
* @param name pin used to detect the touch, eg: TouchPin.P0
|
||||
*/
|
||||
//% help=input/pin-is-pressed weight=58
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed" icon="\uf094"
|
||||
//% blockId="device_pin_is_pressed" block="pin %NAME|is pressed"
|
||||
//% blockGap=8 shim=input::pinIsPressed
|
||||
function pinIsPressed(name: TouchPin): boolean;
|
||||
|
||||
@ -277,7 +277,7 @@ declare namespace input {
|
||||
* Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/acceleration weight=58 icon="\uf135"
|
||||
//% help=input/acceleration weight=58
|
||||
//% blockId=device_acceleration block="acceleration (mg)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" shim=input::acceleration
|
||||
function acceleration(dimension: Dimension): number;
|
||||
@ -286,7 +286,7 @@ declare namespace input {
|
||||
* Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.
|
||||
*/
|
||||
//% help=input/light-level weight=57
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8 icon="\uf185"
|
||||
//% blockId=device_get_light_level block="light level" blockGap=8
|
||||
//% parts="ledmatrix" shim=input::lightLevel
|
||||
function lightLevel(): number;
|
||||
|
||||
@ -294,7 +294,7 @@ declare namespace input {
|
||||
* Get the current compass heading in degrees.
|
||||
*/
|
||||
//% help=input/compass-heading
|
||||
//% weight=56 icon="\uf14e"
|
||||
//% weight=56
|
||||
//% blockId=device_heading block="compass heading (°)" blockGap=8
|
||||
//% parts="compass" shim=input::compassHeading
|
||||
function compassHeading(): number;
|
||||
@ -302,7 +302,7 @@ declare namespace input {
|
||||
/**
|
||||
* Gets the temperature in Celsius degrees (°C).
|
||||
*/
|
||||
//% weight=55 icon="\uf06d"
|
||||
//% weight=55
|
||||
//% help=input/temperature
|
||||
//% blockId=device_temperature block="temperature (°C)" blockGap=8
|
||||
//% parts="thermometer" shim=input::temperature
|
||||
@ -313,7 +313,7 @@ declare namespace input {
|
||||
* @param kind TODO
|
||||
*/
|
||||
//% help=input/rotation weight=52
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8 icon="\uf197"
|
||||
//% blockId=device_get_rotation block="rotation (°)|%NAME" blockGap=8
|
||||
//% parts="accelerometer" advanced=true shim=input::rotation
|
||||
function rotation(kind: Rotation): number;
|
||||
|
||||
@ -322,7 +322,7 @@ declare namespace input {
|
||||
* @param dimension TODO
|
||||
*/
|
||||
//% help=input/magnetic-force weight=51
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8 icon="\uf076"
|
||||
//% blockId=device_get_magnetic_force block="magnetic force (µT)|%NAME" blockGap=8
|
||||
//% parts="compass"
|
||||
//% advanced=true shim=input::magneticForce
|
||||
function magneticForce(dimension: Dimension): number;
|
||||
@ -331,7 +331,7 @@ declare namespace input {
|
||||
* Gets the number of milliseconds elapsed since power on.
|
||||
*/
|
||||
//% help=input/running-time weight=50
|
||||
//% blockId=device_get_running_time block="running time (ms)" icon="\uf017"
|
||||
//% blockId=device_get_running_time block="running time (ms)"
|
||||
//% advanced=true shim=input::runningTime
|
||||
function runningTime(): number;
|
||||
|
||||
@ -346,7 +346,7 @@ declare namespace input {
|
||||
* @param range a value describe the maximum strengh of acceleration measured
|
||||
*/
|
||||
//% help=input/set-accelerometer-range
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range" icon="\uf135"
|
||||
//% blockId=device_set_accelerometer_range block="set accelerometer|range %range"
|
||||
//% weight=5
|
||||
//% parts="accelerometer"
|
||||
//% advanced=true shim=input::setAccelerometerRange
|
||||
@ -362,7 +362,7 @@ declare namespace control {
|
||||
/**
|
||||
* Schedules code that run in the background.
|
||||
*/
|
||||
//% help=control/in-background
|
||||
//% help=control/in-background blockAllowMultiple=1
|
||||
//% blockId="control_in_background" block="run in background" blockGap=8 shim=control::inBackground
|
||||
function inBackground(a: () => void): void;
|
||||
|
||||
@ -427,7 +427,7 @@ declare namespace control {
|
||||
|
||||
|
||||
|
||||
//% color=3 weight=35
|
||||
//% color=3 weight=35 icon="\uf205"
|
||||
declare namespace led {
|
||||
|
||||
/**
|
||||
@ -436,7 +436,7 @@ declare namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/plot weight=78
|
||||
//% blockId=device_plot block="plot|x %x|y %y" icon="\uf205" blockGap=8
|
||||
//% blockId=device_plot block="plot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::plot
|
||||
function plot(x: number, y: number): void;
|
||||
|
||||
@ -446,7 +446,7 @@ declare namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/unplot weight=77
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" icon="\uf204" blockGap=8
|
||||
//% blockId=device_unplot block="unplot|x %x|y %y" blockGap=8
|
||||
//% parts="ledmatrix" shim=led::unplot
|
||||
function unplot(x: number, y: number): void;
|
||||
|
||||
@ -456,7 +456,7 @@ declare namespace led {
|
||||
* @param y TODO
|
||||
*/
|
||||
//% help=led/point weight=76
|
||||
//% blockId=device_point block="point|x %x|y %y" icon="\uf10c"
|
||||
//% blockId=device_point block="point|x %x|y %y"
|
||||
//% parts="ledmatrix" shim=led::point
|
||||
function point(x: number, y: number): boolean;
|
||||
|
||||
@ -464,7 +464,7 @@ declare namespace led {
|
||||
* Get the screen brightness from 0 (off) to 255 (full bright).
|
||||
*/
|
||||
//% help=led/brightness weight=60
|
||||
//% blockId=device_get_brightness block="brightness" icon="\uf042" blockGap=8
|
||||
//% blockId=device_get_brightness block="brightness" blockGap=8
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true shim=led::brightness
|
||||
function brightness(): number;
|
||||
@ -474,7 +474,7 @@ declare namespace led {
|
||||
* @param value the brightness value, eg:255, 127, 0
|
||||
*/
|
||||
//% help=led/set-brightness weight=59
|
||||
//% blockId=device_set_brightness block="set brightness %value" icon="\uf042"
|
||||
//% blockId=device_set_brightness block="set brightness %value"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true shim=led::setBrightness
|
||||
function setBrightness(value: number): void;
|
||||
@ -483,7 +483,7 @@ declare namespace led {
|
||||
* Cancels the current animation and clears other pending animations.
|
||||
*/
|
||||
//% weight=50 help=led/stop-animation
|
||||
//% blockId=device_stop_animation block="stop animation" icon="\uf04d"
|
||||
//% blockId=device_stop_animation block="stop animation"
|
||||
//% parts="ledmatrix"
|
||||
//% advanced=true shim=led::stopAnimation
|
||||
function stopAnimation(): void;
|
||||
@ -499,7 +499,7 @@ declare namespace led {
|
||||
/**
|
||||
* Turns on or off the display
|
||||
*/
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on" icon="\uf04d"
|
||||
//% help=led/enable blockId=device_led_enable block="led enable %on"
|
||||
//% advanced=true parts="ledmatrix" shim=led::enable
|
||||
function enable(on: boolean): void;
|
||||
|
||||
@ -658,7 +658,7 @@ declare namespace pins {
|
||||
|
||||
|
||||
|
||||
//% weight=2 color=30
|
||||
//% weight=2 color=30 icon="\uf287"
|
||||
//% advanced=true
|
||||
declare namespace serial {
|
||||
|
||||
|
3
libs/devices/_locales/fr/devices-jsdoc-strings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"devices": "Contrôler un téléphone avec le BBC micro : bit via Bluetooth."
|
||||
}
|
@ -5,7 +5,8 @@
|
||||
"README.md",
|
||||
"enums.d.ts",
|
||||
"shims.d.ts",
|
||||
"devices.cpp"
|
||||
"devices.cpp",
|
||||
"_locales/fr/devices-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
@ -13,4 +14,4 @@
|
||||
"bluetooth": "file:../bluetooth"
|
||||
},
|
||||
"installedVersion": "ljipgq"
|
||||
}
|
||||
}
|
24
libs/radio/_locales/de/radio-jsdoc-strings.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"radio": "Daten mithilfe von Funk-Paketen übertragen",
|
||||
"radio.onDataPacketReceived": "Registriert Funktionen, die ausgeführt werden, wenn das Radio ein Datenpaket empfängt. Entnimmt das empfangene Paket aus der Warteschlange des Radios.",
|
||||
"radio.onDataReceived": "Registriert Code der ausgeführt wird, wenn ein Paket über Funk empfangen wird.",
|
||||
"radio.receiveNumber": "Liest das nächste Paket aus der Funk-Warteschlange und gibt die Paketnummer oder 0 aus, wenn das Paket keine Nummer enthält.",
|
||||
"radio.receiveString": "Liest das nächste Paket aus der Funk-Warteschlange und gibt die enthaltene Zeichenfolge oder die leere Zeichenfolge aus, wenn das Paket keine Zeichenfolge enthält.",
|
||||
"radio.receivedNumber": "Extrahiert eine Zahl aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios (via ``Zahl empfangen``, ``Zeichenkette empfangen``, etc) entnommen wurde oder eine 0, wenn das Paket keine Zahl enthält.",
|
||||
"radio.receivedSerial": "Extrahiert die Seriennummer des Calliope mini Senders aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios entnommen wurde oder eine 0, wenn der Absender keine Seriennummer gesendet hat.",
|
||||
"radio.receivedSignalStrength": "Ruft den empfangenen Signalstärkeindikator (RSSI) aus dem letzten Paket aus der Funk-Warteschlange aus (via ``receiveNumber``, ``receiveString``, etc). Wird im Simulator nicht unterstützt.\nnamespace=radio",
|
||||
"radio.receivedString": "Extrahiert die Zeichenkette aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios (via ``Zahl empfangen``, ``Zeichenkette empfangen``, etc) entnommen wurde oder eine leere Zeichenkette, wenn das Paket keine Zeichenkette enthält.",
|
||||
"radio.receivedTime": "Extrahiert die Systemzeit des Absenders aus dem Inhalt des letzten Datenpakets, welches aus der Warteschlange des Radios (via ``Zahl empfangen``, ``Zeichenkette empfangen``, etc) entnommen wurde.",
|
||||
"radio.sendNumber": "Überträgt eine Nummer über Funk an jeden angeschlossenen mini in der Gruppe.",
|
||||
"radio.sendString": "Überträgt eine Zeichenfolge über Funk mit Seriennummer des Geräts und Laufzeit an jeden angeschlossenen mini in der Gruppe.",
|
||||
"radio.sendValue": "Sendet ein Name / Wert-Paar zusammen mit der Seriennummer des Geräts und die Laufzeit auf alle angeschlossenen minis in der Gruppe.",
|
||||
"radio.sendValue|param|name": "die Feldnamen (max. 12 Zeichen), z.B.: \"Daten\"",
|
||||
"radio.sendValue|param|value": "der numerische Wert",
|
||||
"radio.setGroup": "Setzt die Gruppen-ID für Funkverbindungen. Ein mini kann nur ein Gruppen-ID hören.\nDie Gruppen-ID zwischen liegt zwischen 0 und 255, z.B. 1",
|
||||
"radio.setTransmitPower": "Ändere die Ausgabeleistung des Senders auf den angegebenen Wert.",
|
||||
"radio.setTransmitPower|param|power": "ein Wert im Bereich 0.. 7, wo 0 die niedrigste Leistung und 7 ist ist die höchste. z.B. 7",
|
||||
"radio.setTransmitSerialNumber": "Stelle den Dunk so ein, dass die Seriennummer in jeder Nachricht übertragen wird.",
|
||||
"radio.setTransmitSerialNumber|param|transmit": "Wert, der anzeigt, ob die Seriennummer übertragen wird, z.B. wahr",
|
||||
"radio.writeReceivedPacketToSerial": "Schreibt das letzte empfangene Paket als JSON auf Seriell. Sollte in einem ´´onDataPacketReceived``-Callback aufgerufen werden.",
|
||||
"radio.writeValueToSerial": "Liest das nächste Paket aus der Funk-Warteschlange und schreibt dieses als JSON auf Seriell."
|
||||
}
|
17
libs/radio/_locales/de/radio-strings.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"radio.onDataPacketReceived|block": "wenn Datenpaket empfangen",
|
||||
"radio.onDataReceived|block": "über Funk empfangene Daten",
|
||||
"radio.receiveNumber|block": "über Funk empfangene Zahl",
|
||||
"radio.receiveString|block": "über Funk empfangene Zeichenfolge",
|
||||
"radio.receivedSignalStrength|block": "über Funk empfangene Signalstärke",
|
||||
"radio.sendNumber|block": "sende Zahl %value über Funk",
|
||||
"radio.sendString|block": "sende Zeichenfolge %msg über Funk",
|
||||
"radio.sendValue|block": "schicke | Wert %name |=%value über Funk",
|
||||
"radio.setGroup|block": "setze Gruppe %ID über Funk",
|
||||
"radio.setTransmitPower|block": "lege Übertragungsstärke %power über Funk fest",
|
||||
"radio.setTransmitSerialNumber|block": "übertrage Übertragungs-Seriennummer %transmit über Funk",
|
||||
"radio.writeReceivedPacketToSerial|block": "schreibe das über Funk emfangene Paket auf Seriell",
|
||||
"radio.writeValueToSerial|block": "schreibe Wert auf Seriell über Funk",
|
||||
"radio|block": "Funk",
|
||||
"{id:category}Radio": "Funk"
|
||||
}
|
@ -6,7 +6,9 @@
|
||||
"shims.d.ts",
|
||||
"enums.d.ts",
|
||||
"radio.cpp",
|
||||
"radio.ts"
|
||||
"radio.ts",
|
||||
"_locales/de/radio-strings.json",
|
||||
"_locales/de/radio-jsdoc-strings.json"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
|
@ -24,7 +24,7 @@ using namespace pxt;
|
||||
// payload: string length (9), string (10 ... 28)
|
||||
#define PACKET_TYPE_STRING 2
|
||||
|
||||
//% color=270 weight=34
|
||||
//% color=270 weight=96 icon="\uf012"
|
||||
namespace radio {
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Communicate data using radio packets
|
||||
*/
|
||||
//% color=#E3008C weight=34
|
||||
//% color=#E3008C weight=96 icon="\uf012"
|
||||
namespace radio {
|
||||
export class Packet {
|
||||
/**
|
||||
|
2
libs/radio/shims.d.ts
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
//% color=270 weight=34
|
||||
//% color=270 weight=96 icon="\uf012"
|
||||
declare namespace radio {
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-microbit",
|
||||
"version": "0.6.41",
|
||||
"version": "0.7.19",
|
||||
"description": "micro:bit target for PXT",
|
||||
"keywords": [
|
||||
"JavaScript",
|
||||
@ -34,6 +34,6 @@
|
||||
"semantic-ui-less": "^2.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-core": "0.6.3"
|
||||
"pxt-core": "0.8.7"
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,12 @@
|
||||
"bluetooth\\s*\\.uartRead\\s*\\((.*?)\\)": "bluetooth.uartReadUntil($1)",
|
||||
"bluetooth\\s*\\.uartWrite\\s*\\((.*?)\\)": "bluetooth.uartWriteUntil($1)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "blockId",
|
||||
"map": {
|
||||
"device_get_acceleration": "device_acceleration"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -64,7 +70,9 @@
|
||||
"mathBlocks": true,
|
||||
"loopsBlocks": true,
|
||||
"logicBlocks": true,
|
||||
"variablesBlocks": true
|
||||
"variablesBlocks": true,
|
||||
"onStartColor": "#0078D7",
|
||||
"onStartNamespace": "basic"
|
||||
},
|
||||
"simulator": {
|
||||
"autoRun": true,
|
||||
@ -199,7 +207,7 @@
|
||||
"projectGallery": "projects",
|
||||
"crowdinProject": "kindscript",
|
||||
"boardName": "micro:bit",
|
||||
"sideDoc": "getting-started",
|
||||
"sideDoc": "tutorials/getting-started",
|
||||
"browserSupport": [
|
||||
{
|
||||
"name": "unsupported",
|
||||
@ -232,10 +240,6 @@
|
||||
"name": "Support",
|
||||
"path": "https://support.microbit.org/"
|
||||
},
|
||||
{
|
||||
"name": "Getting Started",
|
||||
"path": "/getting-started"
|
||||
},
|
||||
{
|
||||
"name": "Projects",
|
||||
"path": "/projects"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/// <reference path="../node_modules/pxt-core/typings/bluebird/bluebird.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/typings/globals/bluebird/index.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
|
||||
/// <reference path="../node_modules/pxt-core/built/pxtrunner.d.ts"/>
|
||||
|
||||
|