Compare commits

...

67 Commits

Author SHA1 Message Date
a667467bbd 0.2.119 2016-05-13 06:25:57 -07:00
ada2583e17 removing browserconfig.xml / favicon.ico until cloud supports it 2016-05-13 06:18:15 -07:00
c04538313d 0.2.118 2016-05-13 05:44:48 -07:00
1039dc560e Bump pxt-core to 0.2.129 2016-05-13 05:44:46 -07:00
957c7ad848 0.2.117 2016-05-13 05:08:07 -07:00
5e7351a481 Bump pxt-core to 0.2.127 2016-05-13 05:08:05 -07:00
f0c089373b updated mobile icons 2016-05-13 04:55:28 -07:00
879a85bdbb exposing i2c blocks in pins 2016-05-13 03:38:52 -07:00
7a9c2e0fe4 0.2.116 2016-05-12 22:23:46 -07:00
9656c1159a Bump pxt-core to 0.2.125 2016-05-12 22:23:45 -07:00
801117d6b0 remove head from simulator 2016-05-12 22:23:23 -07:00
c084bff334 remove logo in simulator 2016-05-12 21:56:22 -07:00
18bf35f179 updated camp 2016-05-12 13:56:03 -07:00
7e7dc91947 updated camp 2016-05-12 13:50:27 -07:00
da79f643dc 0.2.115 2016-05-12 13:41:34 -07:00
ea10cde3eb added camp 2016-05-12 13:41:15 -07:00
0a60b0ee37 0.2.114 2016-05-12 12:37:57 -07:00
b4bc985068 upgraded to lancaster 2.0.0.rc3 (core 0.1.9)
added radio.send/receive string
2016-05-12 12:35:40 -07:00
78f9af5bc2 0.2.113 2016-05-11 12:05:13 -07:00
e9410d17a6 0.2.112 2016-05-11 11:42:51 -07:00
ca8ef260d5 Bump pxt-core to 0.2.124 2016-05-11 11:42:49 -07:00
5ea5e9bb5b added accent color 2016-05-11 11:39:45 -07:00
19c689a8c4 added microsoft logo 2016-05-11 09:18:29 -07:00
72226cd4e5 0.2.111 2016-05-11 08:49:33 -07:00
0d3af60892 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-11 06:46:05 -07:00
f88cda8244 added privacy/tou urls 2016-05-11 06:45:45 -07:00
f71925fdd2 Simplify logo some more 2016-05-11 15:39:20 +02:00
bfeda371a9 Add simplified logo (more suitable for small size) 2016-05-11 15:33:55 +02:00
eb09530391 Fix typo 2016-05-11 14:12:09 +02:00
346d1e77da 0.2.110 2016-05-10 21:49:16 -07:00
bf384355c4 Bump pxt-core to 0.2.122 2016-05-10 21:49:15 -07:00
3801e52370 fixed build instructions 2016-05-10 21:43:41 -07:00
99574f1ec8 added link to live editor 2016-05-10 21:43:12 -07:00
12705eed06 removed some ids 2016-05-10 21:40:39 -07:00
a62f2b00b4 updated radio apis to support key/value pair 2016-05-10 21:13:16 -07:00
7d0101af25 marking various radio functions as debug until API is stable 2016-05-10 16:42:18 -07:00
60c3f1f427 0.2.109 2016-05-10 12:41:37 -07:00
8552a2de52 fixing docs icon size 2016-05-10 12:41:20 -07:00
b0d4fdb009 0.2.108 2016-05-10 11:42:14 -07:00
d3294ee99e 0.2.107 2016-05-10 11:34:59 -07:00
00d23f8437 updated windows 10 app 2016-05-10 11:34:41 -07:00
1c6c749dad 0.2.106 2016-05-10 11:08:46 -07:00
2803c00814 Bump pxt-core to 0.2.121 2016-05-10 11:08:44 -07:00
f150d93070 removing old logos 2016-05-10 10:51:47 -07:00
7f284b2a57 0.2.105 2016-05-10 10:44:52 -07:00
0e5c30ec7c updated logo 2016-05-10 10:44:40 -07:00
2cc6f864a8 remove logging 2016-05-10 10:26:36 -07:00
d428a2cd1f Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-10 10:15:25 -07:00
47f9362e5f read radio values 2016-05-10 10:14:51 -07:00
38b197bc03 0.2.104 2016-05-10 19:03:50 +02:00
9a404854e7 Rename target 2016-05-10 19:03:31 +02:00
d17a8de72d Use shorter domain name 2016-05-10 19:01:36 +02:00
9d1f2e024b missing shim 2016-05-10 09:28:05 -07:00
e7d8559fe3 Cache test scripts 2016-05-10 13:18:35 +02:00
fcfdbcc7e4 moving block down category 2016-05-09 23:03:42 -07:00
5884231399 null terminated name 2016-05-09 23:01:20 -07:00
e8887f5904 radio blocks to read/stream value pairs 2016-05-09 22:55:37 -07:00
07e8610e5d 0.2.103 2016-05-09 14:13:15 -07:00
37fb907f04 Bump pxt-core to 0.2.120 2016-05-09 14:13:13 -07:00
13f42f5892 added various tutorials 2016-05-09 10:32:02 -07:00
5fcf9165ea magic 8 tutorial 2016-05-09 09:45:57 -07:00
b33d0ba470 updated strings 2016-05-06 14:17:39 -07:00
b9f66c5c6b 0.2.102 2016-05-06 11:31:55 -07:00
9848409283 Bump pxt-core to 0.2.117 2016-05-06 11:31:53 -07:00
ce16e64660 added shuffled lessons 2016-05-06 11:31:25 -07:00
4d056e0c23 lessons updates 2016-05-06 09:32:29 -07:00
70b2827cf0 fixing various lessons menu 2016-05-06 09:28:26 -07:00
106 changed files with 937 additions and 555 deletions

View File

@ -13,4 +13,5 @@ notifications:
cache: cache:
directories: directories:
- node_modules - node_modules
- built/cache

View File

@ -3,6 +3,8 @@
This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using
[Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt). [Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt).
* [Try it live](https://m.pxt.io)
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit) [![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
# Getting started # Getting started
@ -12,7 +14,7 @@ Please follow instructions at https://github.com/Microsoft/pxt#running-a-target-
## Universal Windows App ## Universal Windows App
The Windows 10 app is a [Universal Windows Hosted Web App](https://microsoftedge.github.io/WebAppsDocs/en-US/win10/CreateHWA.htm) The Windows 10 app is a [Universal Windows Hosted Web App](https://microsoftedge.github.io/WebAppsDocs/en-US/win10/CreateHWA.htm)
that wraps codemicrobit.com and provides additional features. that wraps m.pxt.io and provides additional features.
### Sideloading ### Sideloading
@ -23,4 +25,4 @@ that wraps codemicrobit.com and provides additional features.
### Building ### Building
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed. * Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
* open the ``win10/app.sln`` solution and launch the ``codemicrobit`` project. * open the ``win10/app.sln`` solution and launch the ``m.pxt.io`` project.

171
docs/camp.md Normal file
View File

@ -0,0 +1,171 @@
# Getting started
Are you ready to build cool BBC micro:bit programs? For each challenge, reorder the blocks to recreate the program.
* If you haven't done so, open [https://m.pxt.io](/) and create a new **Blocks Editor** project
## Basic
### Show leds
Use the blocks below to draw a figure on the screen. You can redo the smiley face or try something else!
```shuffle
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
```
To transfer your code to the BBC micro:bit,
* connect your micro:bit to the computer using the USB cable
* click on **Download**
* drag&drop the **.hex** file into the **MICROBIT** drive
* wait till the yellow light is done blinking!
### Show animation Forever
Show one image after the other to create an animation.,
Reorder the blocks to make the micro:bit show a happy, then unhappy face.
```shuffle
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
```
### Repeat forever
Use the ``forever`` block to repeat your code and have a continuous animation.
Unsuffle the blocks to create a happy, unhappy animation.... or changes the image to make it your own!
```shuffle
basic.forever(() => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
});
```
### Your turn now!
Use the blocks ``show leds`` and ``forever``
to create your own custom awesome animation!
## Inputs
### Button A and B
Unshuffle the blocks so that the micro:bit shows "YES" when button A is pressed, and "NO" when B is pressed.
The key idea is that all the blocks nested under `on button ... pressed` will run when that button is pressed.
```blocks
input.onButtonPressed(Button.A, () => {
basic.showString("AAAAA");
});
```
Try to unshuffle those blocks:
```shuffle
input.onButtonPressed(Button.A, () => {
basic.showString("YES");
});
input.onButtonPressed(Button.B, () => {
basic.showString("NO");
});
```
### Shake
Using the data from the **accelerometer**, it is possible to detect that the BBC micro:bit is being shaken.
Unshuffle the code to display a frownie when shaken.
```shuffle
input.onGesture(Gesture.Shake, () => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #`);
});
```
### Tilting
Aside from shake, it is also possible to detect tilt left and right, logo up and down or face up and down.
Let's build a rock paper scissors game where you turn the micro:bit left to display paper, right to display scissors and down to display rock.
Unshuffle and try this code on the micro:bit itself!
```shuffle
input.onGesture(Gesture.TiltLeft, () => {
basic.showLeds(`
# # # # #
# . . . #
# . . . #
# . . . #
# # # # #`);
});
input.onGesture(Gesture.LogoDown, () => {
basic.showLeds(`
. . . . .
. # # # .
. # # # .
. # # # .
. . . . .`);
});
input.onGesture(Gesture.TiltRight, () => {
basic.showLeds(`
# # . . #
# # . # .
. . # . .
# # . # .
# # . . #`);
});
```
### Pins
It is possible to use the pins (big metal bar at the bottom of the board) as button. Hold the ``GND`` button with one hand and press the ``0`` pin
(called ``P0``) with the other hand to trigger a pin pressed.
Unshuffle the blocks to display a smiley when pin ``P0`` is pressed.
```shuffle
input.onPinPressed(TouchPin.P0, () => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .`);
});
```
### Your turn now!
Use the scree, buttons, gestures, pins to create a fun game using the micro:bit.

View File

@ -5,9 +5,6 @@
### ~column ### ~column
## O365 Integration
* [Science Experiments: Chart](/lessons/charting), create an app for simulating and measuring sensor data of acceleration, temperature, light level, and rotation
## Beginner ## Beginner
* [Beautiful Image](/lessons/beautiful-image), show a beautiful image with show LEDs * [Beautiful Image](/lessons/beautiful-image), show a beautiful image with show LEDs
@ -60,6 +57,9 @@
* [Telegraph](/lessons/telegraph), play the telegraph game between two BBC micro:bits * [Telegraph](/lessons/telegraph), play the telegraph game between two BBC micro:bits
* [Pogo](/lessons/pogo), create a pogo game to test your jumping abilities * [Pogo](/lessons/pogo), create a pogo game to test your jumping abilities
## Science
* [Charting](/lessons/charting), measure and chart acceleration
## Advanced ## Advanced
* [Prank WiFi](/lessons/prank-wifi), create fake WiFi to trick your friends * [Prank WiFi](/lessons/prank-wifi), create fake WiFi to trick your friends
* [Speed Button](/lessons/speed-button), code a speed game with running time * [Speed Button](/lessons/speed-button), code a speed game with running time
@ -71,4 +71,3 @@
### @section full ### @section full
The lessons promote computational thinking and computer science literacy[ read more...](/lessons/teach) The lessons promote computational thinking and computer science literacy[ read more...](/lessons/teach)

View File

@ -21,7 +21,6 @@ basic.showString("ASK ME A QUESTION")
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
basic.showString("Yes") basic.showString("Yes")
}) })
``` ```
* `Run` the code to see if it works as expected. * `Run` the code to see if it works as expected.
@ -45,7 +44,6 @@ input.onButtonPressed(Button.B, () => {
* `Run` the code to see if it works as expected. * `Run` the code to see if it works as expected.
**Challenge 3** ### Challenge 3
When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `MAYBE`. When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `MAYBE`.

View File

@ -12,7 +12,6 @@ Answers may vary. This is a function that will show a string on the LED screen o
```blocks ```blocks
basic.showString("Y") basic.showString("Y")
``` ```
![](/static/mb/lessons/answering-machine-0.png) ![](/static/mb/lessons/answering-machine-0.png)
@ -22,7 +21,6 @@ basic.showString("Y")
```blocks ```blocks
basic.showString("Hi") basic.showString("Hi")
``` ```
![](/static/mb/lessons/answering-machine-1.png) ![](/static/mb/lessons/answering-machine-1.png)
@ -35,7 +33,6 @@ basic.showString("Hi")
```blocks ```blocks
basic.showString("Z") basic.showString("Z")
``` ```

View File

@ -39,9 +39,9 @@ basic.showLeds(`
`) `)
``` ```
* *Run* your code to see if it works as expected. * Does your code work as expected?
### Challenge 2 ### Challenge 2
Nice job! Why don't we create a third image that will show after the other two? Remember to add a pause before you create and show the image. Nice job! Why don't we create a third image that will show after the other two?

View File

@ -12,17 +12,14 @@ Answer the questions while completing the tutorial. Pay attention to the dialogu
## 1. Write the code that will store the global variable named 'action' and returns a random number between 0 and 2 ## 1. Write the code that will store the global variable named 'action' and returns a random number between 0 and 2
<br/> ```blocks
let action = Math.random(3)
```
action = Math.random(3)
``` ```
## 2. Write the code that will display the string, "PUSH A" if the global variable called 'action' is equal to 0 ## 2. Write the code that will display the string, "PUSH A" if the global variable called 'action' is equal to 0
<br /> ```blocks
let action = Math.random(3)
```
if (action == 0) { if (action == 0) {
basic.showString("PUSH A", 150) basic.showString("PUSH A", 150)
} }
@ -30,10 +27,9 @@ if (action == 0) {
## 3. Write the code that increments the score if button A is pressed when the global variable called 'action' is equal to 1 ## 3. Write the code that increments the score if button A is pressed when the global variable called 'action' is equal to 1
<br /> ```blocks
```
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
let action = Math.random(3)
if (action == 0) { if (action == 0) {
game.addScore(1) game.addScore(1)
} }
@ -42,9 +38,8 @@ input.onButtonPressed(Button.A, () => {
## 4. Write the code that will display the string "LOGO DOWN" if the global variable called 'action' is equal to 1 ## 4. Write the code that will display the string "LOGO DOWN" if the global variable called 'action' is equal to 1
<br /> ```blocks
let action = Math.random(3)
```
if (action == 1) { if (action == 1) {
basic.showString("LOGO DOWN", 150) basic.showString("LOGO DOWN", 150)
} }
@ -52,10 +47,9 @@ if (action == 1) {
## 5. Write the code that increments the score if the BBC micro:bit logo is tilted down when the global variable called 'action' is equal to 1 ## 5. Write the code that increments the score if the BBC micro:bit logo is tilted down when the global variable called 'action' is equal to 1
<br /> ```blocks
```
input.onLogoDown(() => { input.onLogoDown(() => {
let action = Math.random(3)
if (action == 1) { if (action == 1) {
game.addScore(1) game.addScore(1)
} }
@ -64,9 +58,8 @@ input.onLogoDown(() => {
## 6. Write the code that will display the string "SHAKE" if the global variable called 'action' is equal to 2 ## 6. Write the code that will display the string "SHAKE" if the global variable called 'action' is equal to 2
<br /> ```blocks
let action = Math.random(3)
```
if (action == 2) { if (action == 2) {
basic.showString("SHAKE", 150) basic.showString("SHAKE", 150)
} }
@ -74,13 +67,11 @@ if (action == 2) {
## 7. Write the code that increments the score if the BBC micro:bit is shaken when the global variable called 'action' is equal to 2 ## 7. Write the code that increments the score if the BBC micro:bit is shaken when the global variable called 'action' is equal to 2
<br/> ```blocks
```
input.onLogoDown(() => { input.onLogoDown(() => {
let action = Math.random(3)
if (action == 1) { if (action == 1) {
game.addScore(1) game.addScore(1)
} }
}) })
``` ```

View File

@ -11,6 +11,7 @@ Variables
## Quick Links ## Quick Links
* [activity](/lessons/catch-the-egg-game/activity) * [activity](/lessons/catch-the-egg-game/activity)
* [tutorial](/lessons/catch-the-egg-game/tutorial)
* [quiz](/lessons/catch-the-egg-game/quiz) * [quiz](/lessons/catch-the-egg-game/quiz)
* [quiz answers](/lessons/catch-the-egg-game/quiz-answers) * [quiz answers](/lessons/catch-the-egg-game/quiz-answers)
@ -20,18 +21,21 @@ Learn how to create a catch the egg game game with **plot**, `led->plot` , **unp
## Documentation ## Documentation
* **variables** : [read more...](/reference/variables/var) ```cards
* **forever** : [read more...](/reference/basic/forever) let x = 2;
* **unplot** : [read more...](/reference/led/unplot) led.unplot(0, 0);
* **plot** : [read more...](/reference/led/plot) basic.forever(() => {});
* **if** : [read more...](/reference/logic/if) x += 1;
* **acceleration** : [read more...](/reference/input/acceleration) led.plot(0, 0);
* **math minimum number** : [read more...](/reference/math) basic.pause(300);
* **math maximum number** : [read more...](/reference/math) input.acceleration(Dimension.X);
* **math random number** : [read more...](/reference/math) Math.min(0,0);
* **math modulus** : [read more...](/reference/math) Math.max(0,1);
* **show number** : [read more...](/reference/basic/show-number) Math.random(5);
* **pause** : [read more...](/reference/basic/pause) game.addScore(1);
game.score();
game.removeLife(1);
```
## Objectives ## Objectives

View File

@ -1,7 +1,5 @@
# catch the egg game challenges # catch the egg game challenges
Coding challenges for catch the egg game.
## Before we get started ## Before we get started
Your starting code should look like this: Your starting code should look like this:

View File

@ -0,0 +1,29 @@
# catch the egg game tutorial
### Rebuild the game!
The blocks have been shuffled! Put them back together so that...
* an egg LED falls from the top of the screen, row by row.
* a basket LED is on the bottom row and can be moved by using the accelerometer `X` data.
* if the egg LED reaches the last row, reset the egg position to the first row.
```shuffle
let basketX = 2
let eggX = 2
let eggY = 0
basic.forever(() => {
led.unplot(basketX, 4)
led.unplot(eggX, eggY)
eggY = eggY + 1
led.plot(eggX, eggY)
basic.pause(300)
let accX = input.acceleration(Dimension.X)
basketX = 2 + Math.min(2, Math.max(-2, accX / 200))
led.plot(basketX, 4)
if (eggY > 4) {
eggY = -1
eggX = Math.random(5)
}
basic.pause(300)
})
```

View File

@ -17,7 +17,7 @@ input.onPinPressed(TouchPin.P1, () => {
}) })
``` ```
**Challenge 1** ### Challenge 1
Let's include a second sound `on pin pressed` *P2*. To do this, you need to add the same blocks as the banana keyboard activity. However, you must change alter `on pin pressed` from P1 to P2. Additionally, you must *decrease* the frequency of the variable "sound" by 25. Modify your code so that your code looks like this Let's include a second sound `on pin pressed` *P2*. To do this, you need to add the same blocks as the banana keyboard activity. However, you must change alter `on pin pressed` from P1 to P2. Additionally, you must *decrease* the frequency of the variable "sound" by 25. Modify your code so that your code looks like this
@ -42,7 +42,7 @@ input.onPinPressed(TouchPin.P2, () => {
* click *run* to see if the code works as expected. * click *run* to see if the code works as expected.
**Challenge 2** ### Challenge 2
Finally, we want images to be displayed with sounds `on pin pressed`. Add `show LEDs` blocks under `on pin pressed` P1 and P2. Finally, we want images to be displayed with sounds `on pin pressed`. Add `show LEDs` blocks under `on pin pressed` P1 and P2.

View File

@ -42,7 +42,7 @@ input.onButtonPressed(Button.B, () => {
* `Run` the code to see if it works as expected. * `Run` the code to see if it works as expected.
**Challenge 3** ### Challenge 3
When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `TRY AGAIN`. When you are asked a yes or no question, do you always say yes or no? Add a condition for `on shake` that displays `TRY AGAIN`.

View File

@ -9,6 +9,7 @@ Acceleration
## Quick Links ## Quick Links
* [activity](/lessons/glowing-pendulum/activity) * [activity](/lessons/glowing-pendulum/activity)
* [tutorial](/lessons/glowing-pendulum/tutorial)
* [challenges](/lessons/glowing-pendulum/challenges) * [challenges](/lessons/glowing-pendulum/challenges)
* [quiz](/lessons/glowing-pendulum/quiz) * [quiz](/lessons/glowing-pendulum/quiz)
* [quiz answers](/lessons/glowing-pendulum/quiz-answers) * [quiz answers](/lessons/glowing-pendulum/quiz-answers)

View File

@ -4,10 +4,29 @@ Construct a pendulum that glows using acceleration.
Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started! Welcome! This activity will teach how to construct a pendulum that glows using acceleration. Let's get started!
Turn on all the LEDs.
```blocks
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
```
Create a **forever** loop that will constantly display the appropriate brightness on the LED display. Create a **forever** loop that will constantly display the appropriate brightness on the LED display.
```blocks ```blocks
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.forever(() => { basic.forever(() => {
}) })
@ -16,6 +35,13 @@ basic.forever(() => {
Now let's measure the acceleration on the `y` axis and store that value in a variable. The `acceleration(y)` function will provide the value. Now let's measure the acceleration on the `y` axis and store that value in a variable. The `acceleration(y)` function will provide the value.
```blocks ```blocks
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.forever(() => { basic.forever(() => {
let acceleration = input.acceleration(Dimension.Y); let acceleration = input.acceleration(Dimension.Y);
}); });
@ -25,9 +51,15 @@ Since the micro:bit will be swinging back and forth, the acceleration will only
```blocks ```blocks
let acceleration = 0; basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.forever(() => { basic.forever(() => {
acceleration = input.acceleration(Dimension.Y); let acceleration = input.acceleration(Dimension.Y);
acceleration = Math.abs(acceleration) acceleration = Math.abs(acceleration)
}); });
``` ```
@ -35,6 +67,13 @@ basic.forever(() => {
The function `acceleration(y)` returns a number between 0 and 1024. We want to use this value for the brightness of the micro:bit, but the `set brightness()` only accepts a value between 0 and 256. Thus, we need to divide the acceleration by 4 to ensure we will be in the appropriate range. The function `acceleration(y)` returns a number between 0 and 1024. We want to use this value for the brightness of the micro:bit, but the `set brightness()` only accepts a value between 0 and 256. Thus, we need to divide the acceleration by 4 to ensure we will be in the appropriate range.
```blocks ```blocks
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.forever(() => { basic.forever(() => {
let acceleration = input.acceleration(Dimension.Y); let acceleration = input.acceleration(Dimension.Y);
acceleration = Math.abs(acceleration); acceleration = Math.abs(acceleration);
@ -46,27 +85,6 @@ basic.forever(() => {
Now let's use our acceleration value to set the brightness on the micro:bit. Now let's use our acceleration value to set the brightness on the micro:bit.
```blocks ```blocks
basic.forever(() => {
let acceleration = input.acceleration(Dimension.Y);
acceleration = Math.abs(acceleration);
acceleration = acceleration / 4;
led.setBrightness(acceleration)
});
```
Let's show what the brightness of the micro:bit is by turning all the LEDs on!
```blocks
basic.forever(() => {
let acceleration = input.acceleration(Dimension.Y);
acceleration = Math.abs(acceleration);
acceleration = acceleration / 4;
led.setBrightness(acceleration)
basic.showLeds(` basic.showLeds(`
# # # # # # # # # #
# # # # # # # # # #
@ -74,9 +92,12 @@ basic.forever(() => {
# # # # # # # # # #
# # # # # # # # # #
`) `)
basic.forever(() => {
let acceleration = input.acceleration(Dimension.Y);
acceleration = Math.abs(acceleration);
acceleration = acceleration / 4;
led.setBrightness(acceleration)
}); });
``` ```
### ~avatar avatar ### ~avatar avatar

View File

@ -24,13 +24,13 @@ basic.forever(() => {
``` ```
**Challenge 1** ### Challenge 1
![](/static/mb/lessons/glowing-pendulum-0.jpg) ![](/static/mb/lessons/glowing-pendulum-0.jpg)
Hold the micro:bit in your hand in a dark room. Move the micro:bit like a pendulum and produce a slow image that captures the pattern of the micro:bit LEDs. Hold the micro:bit in your hand in a dark room. Move the micro:bit like a pendulum and produce a slow image that captures the pattern of the micro:bit LEDs.
**Challenge 2** ### Challenge 2
Replace "y" in `acceleration(y)` with "x" or "z". Changing the axis will cause the micro:bit to measure the force in a different direction. What differences in the resulting pattern does this replacement make? Replace "y" in `acceleration(y)` with "x" or "z". Changing the axis will cause the micro:bit to measure the force in a different direction. What differences in the resulting pattern does this replacement make?

View File

@ -0,0 +1,29 @@
# glowing pendulum block tutorial
The glowing pendulum changes the screen brightness based on the acceleration measured on the BBC micro:bit.
### Rebuild the game!
The blocks have been shuffled! Put them back together so that...
* all LEDs are turned on
* the BBC micro:bit repeats code **forever** that
* reads the acceleration along the ``y`` axis,
* calculate the absolute value of the acceleration
* scales down the acceleration value by a factor of `4`
* uses the scaled value to set the screen **brightness**
```blocks
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.forever(() => {
let acceleration = input.acceleration(Dimension.Y);
acceleration = Math.abs(acceleration);
acceleration = acceleration / 4;
led.setBrightness(acceleration)
});
```

View File

@ -11,6 +11,7 @@ Math - Pick Random
## Quick links ## Quick links
* [activity](/lessons/guess-the-number/activity) * [activity](/lessons/guess-the-number/activity)
* [tutorial](/lessons/guess-the-number/tutorial)
* [challenges](/lessons/guess-the-number/challenges) * [challenges](/lessons/guess-the-number/challenges)
* [quiz](/lessons/guess-the-number/quiz) * [quiz](/lessons/guess-the-number/quiz)
* [quiz answers](/lessons/guess-the-number/quiz-answers) * [quiz answers](/lessons/guess-the-number/quiz-answers)

View File

@ -19,12 +19,11 @@ input.onButtonPressed(Button.A, () => {
``` ```
Create a local variable of type number `x` and set it to a random number using `pick random`. `pick random` 9 generates a random number between `0` and `09`. Create a local variable of type number `x` and set it to a random number using `pick random`. `pick random` 9 generates a random number between `0` and `9`.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
let x = Math.random(9) let x = Math.random(10)
}) })
``` ```
@ -34,7 +33,7 @@ Show the random number on the screen.
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
let x = Math.random(9) let x = Math.random(10)
basic.showNumber(x) basic.showNumber(x)
}) })

View File

@ -0,0 +1,25 @@
# guess the number tutorial
### ~avatar avatar
### @video td/videos/guess-the-number-0
This tutorial will help you create a guess the number game! Let's get started!
### ~
### Rebuild the game!
The blocks have been shuffled! Put them back together so that...
* when the user presses button ``A``,
* generate a random number
* show the number on screen
```shuffle
input.onButtonPressed(Button.A, () => {
let x = Math.random(10)
basic.showNumber(x)
})
```

View File

@ -35,5 +35,5 @@ basic.showNumber(14)
### Challenge 3 ### Challenge 3
Keep displaying multiples of 7 such as 21 and 28, but don't forget to add pauses between the numbers! Keep displaying multiples of 7 such as 21 and 28...

View File

@ -9,6 +9,7 @@ If (Conditionals)
## Quick Links ## Quick Links
* [activity](/lessons/magic-8/activity) * [activity](/lessons/magic-8/activity)
* [tutorial](/lessons/magic-8/tutorial)
* [challenges](/lessons/magic-8/challenges) * [challenges](/lessons/magic-8/challenges)
* [quiz](/lessons/magic-8/quiz) * [quiz](/lessons/magic-8/quiz)
* [quiz answers](/lessons/magic-8/quiz-answers) * [quiz answers](/lessons/magic-8/quiz-answers)

View File

@ -1,8 +1,6 @@
# magic 8 activity # magic 8 activity
A fortune teller game on the micro:bit Welcome! This activity will help you create a magic 8 ball on the micro:bit. Let's get started!
Welcome! This tutorial will help you create a magic 8 ball on the micro:bit. Let's get started!
Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer true or false questions. Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer true or false questions.
@ -32,16 +30,13 @@ input.onGesture(Gesture.Shake, () => {
Create a variable of type number called **randomNumber**. Set **randomNumber** to a random number with a limit of 2. Remember the random function in the math library, picks a random number from 0 to the limit, but not including the limit unless it is 0. Create a variable of type number called **randomNumber**. Set **randomNumber** to a random number with a limit of 2. Remember the random function in the math library, picks a random number from 0 to the limit, but not including the limit unless it is 0.
```blocks ```blocks
basic.showString("ASK A QUESTION") basic.showString("ASK A QUESTION")
basic.showNumber(8) basic.showNumber(8)
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
basic.clearScreen() basic.clearScreen()
let randomNumber = Math.random(2) let randomNumber = Math.random(3)
}); });
``` ```
Create an if statement for the condition `if randomNumber = 2`. If **randomNumber** is 2, display the string 'Yes' Create an if statement for the condition `if randomNumber = 2`. If **randomNumber** is 2, display the string 'Yes'
@ -52,7 +47,7 @@ basic.showString("ASK A QUESTION")
basic.showNumber(8) basic.showNumber(8)
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
basic.clearScreen(); basic.clearScreen();
let randomNumber = Math.random(2); let randomNumber = Math.random(3);
if (randomNumber == 2) { if (randomNumber == 2) {
basic.showString("YES"); basic.showString("YES");
} }
@ -68,7 +63,7 @@ basic.showString("ASK A QUESTION")
basic.showNumber(8) basic.showNumber(8)
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
basic.clearScreen() basic.clearScreen()
let randomNumber = Math.random(2) let randomNumber = Math.random(3)
if (randomNumber == 2) { if (randomNumber == 2) {
basic.showString("YES") basic.showString("YES")
} else if (randomNumber == 1) { } else if (randomNumber == 1) {
@ -84,7 +79,7 @@ basic.showString("ASK A QUESTION")
basic.showNumber(8) basic.showNumber(8)
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
basic.clearScreen() basic.clearScreen()
let randomNumber = Math.random(2) let randomNumber = Math.random(3)
if (randomNumber == 2) { if (randomNumber == 2) {
basic.showString("YES") basic.showString("YES")
} else if (randomNumber == 1) { } else if (randomNumber == 1) {
@ -106,14 +101,13 @@ basic.showString("ASK A QUESTION")
basic.showNumber(8) basic.showNumber(8)
input.onGesture(Gesture.Shake, () => { input.onGesture(Gesture.Shake, () => {
basic.clearScreen() basic.clearScreen()
let randomNumber = Math.random(2) let randomNumber = Math.random(3)
if (randomNumber == 2) { if (randomNumber == 2) {
basic.showString("YES") basic.showString("YES")
} else if (randomNumber == 1) { } else if (randomNumber == 1) {
basic.showString("NO") basic.showString("NO")
} else { } else {
basic.showString("I DON'T KNOW") basic.showString("I DON'T KNOW")
} }
basic.showNumber(8) basic.showNumber(8)

View File

@ -26,7 +26,7 @@ input.onGesture(Gesture.Shake, () => {
``` ```
**Challenge 1** ### Challenge 1
Now let's increase the number of responses the magic 8 ball can give. How about 5 responses instead? Let's change the limit of `pick random` to 4. Now let's increase the number of responses the magic 8 ball can give. How about 5 responses instead? Let's change the limit of `pick random` to 4.
@ -49,7 +49,7 @@ input.onGesture(Gesture.Shake, () => {
}) })
``` ```
**Challenge 2** ### Challenge 2
Now have the magic 8 ball respond "Try again" if **randomNumber** is 3. Now have the magic 8 ball respond "Try again" if **randomNumber** is 3.
@ -73,7 +73,7 @@ input.onGesture(Gesture.Shake, () => {
}) })
``` ```
**Challenge 3** ### Challenge 3
Now what about if **randomNumber** is 4? Let's have the magic 8 ball respond "Definitely!". Now what about if **randomNumber** is 4? Let's have the magic 8 ball respond "Definitely!".

View File

@ -0,0 +1,27 @@
# Magic 8 tutorial
Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer questions with "YES", "NO", or "MAYBE"...
### Rebuild the game!
The blocks have been shuffled! Put them back together so that...
* show "ASK A QUESTION" on the screen
* when the micro:bit is shaken,
* generate a random number between 0 and 2.
* if the number is `2`, show "YES"
* if the number is `1`, show "NO"
* otherwise show "MAYBE"...
```shuffle
basic.showString("ASK A QUESTION")
input.onGesture(Gesture.Shake, () => {
let randomNumber = Math.random(3)
if (randomNumber == 2) {
basic.showString("YES")
} else if (randomNumber == 1) {
basic.showString("NO")
} else {
basic.showString("MAYBE")
}
})
```

View File

@ -30,8 +30,6 @@ input.onGesture(Gesture.LogoUp, () => {
. . # . . . . # . .
`) `)
}) })
``` ```
Run your code and try to turn around the micro:bit to see the **logo up** event in action! Run your code and try to turn around the micro:bit to see the **logo up** event in action!

View File

@ -46,7 +46,7 @@ input.onButtonPressed(Button.B, () => {
``` ```
**Challenge 3** ### Challenge 3
Add an event handler with `on shake` to change the LED brightness back to a `255`. Add an event handler with `on shake` to change the LED brightness back to a `255`.

View File

@ -88,7 +88,7 @@ input.onButtonPressed(Button.B, () => {
* Run the code to see if it works as expected. * Run the code to see if it works as expected.
**Challenge 3** ### Challenge 3
Now make sure the image does not go off the left side and if it does, prompt the user to push button `A`. Now make sure the image does not go off the left side and if it does, prompt the user to push button `A`.

View File

@ -42,7 +42,7 @@ basic.forever(() => {
``` ```
**Challenge 1** ### Challenge 1
What if wanted to show the maximum connectivity of wifi instead of just 1, 3, or 4 bars? What if wanted to show the maximum connectivity of wifi instead of just 1, 3, or 4 bars?
@ -86,7 +86,7 @@ basic.forever(() => {
}) })
``` ```
**Challenge 2** ### Challenge 2
Let's add an **IF** at the bottom of your code that checks to see if `sum >= to 1200` **and** if `sum <1400` Let's add an **IF** at the bottom of your code that checks to see if `sum >= to 1200` **and** if `sum <1400`
@ -135,7 +135,7 @@ basic.forever(() => {
}) })
``` ```
**Challenge 3** ### Challenge 3
Now it's your turn! Be creative and change the Wifi meter images to your own wifi image you're sure will prank your friends by editing the lines that call `showLeds()`. Now it's your turn! Be creative and change the Wifi meter images to your own wifi image you're sure will prank your friends by editing the lines that call `showLeds()`.

View File

@ -41,7 +41,7 @@ input.onButtonPressed(Button.A, () => {
``` ```
**Challenge 1** ### Challenge 1
Create an event handler for Button B. Create an event handler for Button B.
@ -83,7 +83,7 @@ input.onButtonPressed(Button.B, () => {
``` ```
**Challenge 2** ### Challenge 2
### @video td/videos/screen-wipe-2 ### @video td/videos/screen-wipe-2
@ -155,7 +155,7 @@ basic.showLeds(`
``` ```
**Challenge 3** ### Challenge 3
Show an animation that scrolls back up when you press button "B". Show an animation that scrolls back up when you press button "B".

View File

@ -11,6 +11,7 @@ If (Conditionals)
## Quick Links ## Quick Links
* [activity](/lessons/truth-or-dare/activity) * [activity](/lessons/truth-or-dare/activity)
* [tutorial](/lessons/truth-or-dare/tutorial)
* [challenges](/lessons/truth-or-dare/challenges) * [challenges](/lessons/truth-or-dare/challenges)
* [quiz](/lessons/truth-or-dare/quiz) * [quiz](/lessons/truth-or-dare/quiz)
* [quiz answers](/lessons/truth-or-dare/quiz-answers) * [quiz answers](/lessons/truth-or-dare/quiz-answers)

View File

@ -0,0 +1,63 @@
# truth or dare tutorial
### ~avatar avatar
### @video td/videos/truth-or-dare-0
The *Truth or dare!* game works as follows: a player spins the BBC micro:bit on the table.
When the micro:bit stops spinning, the player pointed by the arrow (displayed on screen) must press the button "A"
to see if she has to provide a *truth* or a *dare*.
### ~
### Rebuild the game!
The blocks have been shuffled! Put them back together so that...
* an up arrow is displayed when the micro:bit is powered on.
* on button `A` is pressed,
* randomly display "TRUTH" or "DARE" on the screen
* show the up arrow again.
```shuffle
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
input.onButtonPressed(Button.A, () => {
let random = Math.random(2)
if (random == 0) {
basic.showString("TRUTH")
} else {
basic.showString("DARE")
}
basic.showLeds(`
. . # . .
. # # # .
# # # # #
. . # . .
. . # . .
`)
})
```
### Hints and tips
Cut out these documentation cards to help you!
```cards
basic.showLeds(`
. . # . .
. # # # .
# . # . #
. . # . .
. . # . .
`);
Math.random(2);
basic.showString("TRUTH");
if (true) {} else {}
"TRUTH";
0;
input.onButtonPressed(Button.A, () => {});
```

View File

@ -24,4 +24,4 @@ serial.writeValue(x, 0);
control.inBackground(() => { control.inBackground(() => {
}); });
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1 +0,0 @@
<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' width='193.50101' height='32.755001' version='1.1'><g transform='translate(-1.3555,0.63251107)'><title>micro:bit logo</title><path d='m 38.7185,20.11349 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 m -22.311,-6.077 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.03,-4.053 -9.03,-9.031 -0.001,-4.98 4.053,-9.027 9.03,-9.027 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 c -8.299,0 -15.049,6.752 -15.049,15.051 0,8.299 6.75,15.049 15.049,15.049 l 22.576,0 m 112.099,-21.953 c 0,-1.453 -1.195,-2.633 -2.662,-2.633 -1.455,0 -2.639,1.18 -2.639,2.633 0,1.471 1.184,2.672 2.639,2.672 1.466,0 2.662,-1.202 2.662,-2.672 z m -66.786,5.445 c 0,-4.764 -2.893,-8.093 -7.031,-8.093 -2.027,0 -3.814,0.851 -5.223,2.47 -1.467,-1.661 -3.152,-2.47 -5.127,-2.47 -4.162,0 -7.066,3.329 -7.066,8.093 l 0,10.466 3.812,0 0,-10.644 c 0,-2.416 1.336,-4.104 3.254,-4.104 1.617,0 3.25,1.409 3.25,4.104 l 0,10.645 3.848,0 0,-10.645 c 0,-2.416 1.338,-4.104 3.252,-4.104 1.863,0 3.217,1.727 3.217,4.104 l 0,10.645 3.814,0 0,-10.467 z m 6.953,-7.632 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.569,-5.128 c 0,-1.377 -1.096,-2.454 -2.492,-2.454 -1.4,0 -2.453,1.054 -2.453,2.454 0,1.398 1.078,2.494 2.453,2.494 1.375,0 2.492,-1.117 2.492,-2.494 z m 18.328,20.914 0.576,-0.521 -2.828,-2.658 -0.488,0.455 c -1.252,1.149 -2.504,1.686 -3.945,1.686 -3.064,0 -5.557,-2.557 -5.557,-5.699 0,-3.121 2.492,-5.66 5.557,-5.66 1.432,0 2.646,0.521 3.949,1.693 l 0.512,0.46 2.748,-2.802 -0.49,-0.502 c -1.754,-1.793 -4.016,-2.696 -6.719,-2.696 -2.459,0 -4.869,1.022 -6.605,2.798 -1.738,1.734 -2.691,4.119 -2.691,6.709 0,2.596 0.953,4.979 2.684,6.705 1.771,1.811 4.117,2.811 6.615,2.811 2.401,-0.003 4.647,-0.937 6.682,-2.779 z m 7.25,-6.947 c 0,-3.322 1.145,-4.686 4.217,-5.029 l 0.641,-0.07 0,-3.797 -0.777,0.058 c -5.629,0.458 -8.143,3.247 -8.143,9.048 l 0,9.051 4.062,0 0,-9.261 0,0 z m 21.998,6.923 c 1.762,-1.756 2.729,-4.146 2.729,-6.715 0,-2.565 -0.967,-4.951 -2.723,-6.702 -1.77,-1.809 -4.105,-2.806 -6.576,-2.806 -2.492,0 -4.84,0.997 -6.613,2.806 -1.752,1.792 -2.721,4.174 -2.721,6.702 0,2.53 0.969,4.916 2.721,6.707 1.771,1.81 4.121,2.808 6.613,2.808 2.472,0 4.808,-0.998 6.57,-2.8 z m -1.229,-6.714 c 0,3.18 -2.361,5.665 -5.377,5.665 -2.945,0 -5.346,-2.541 -5.346,-5.665 0,-3.137 2.398,-5.695 5.346,-5.695 2.963,-0.002 5.377,2.558 5.377,5.695 z m 12.917,6.418 c 0,-1.468 -1.195,-2.667 -2.662,-2.667 -1.455,0 -2.639,1.199 -2.639,2.667 0,1.453 1.184,2.632 2.639,2.632 1.466,0 2.662,-1.179 2.662,-2.632 z m 19.507,0.296 c 1.76,-1.756 2.73,-4.146 2.73,-6.715 0,-2.528 -0.973,-4.911 -2.729,-6.702 -1.746,-1.787 -4.08,-2.77 -6.574,-2.77 -2.035,0 -3.84,0.572 -5.484,1.744 l 0,-9.934 -3.816,0 0.008,15.582 c -0.037,0.411 -0.037,0.821 -0.037,1.198 0,6.119 3.836,10.396 9.33,10.396 2.475,0.001 4.807,-0.997 6.572,-2.799 z m -1.013,-6.677 c 0,3.123 -2.494,5.66 -5.559,5.66 -3.115,0 -5.557,-2.484 -5.557,-5.66 0,-3.143 2.494,-5.698 5.557,-5.698 3.065,0 5.559,2.556 5.559,5.698 z m 10.881,-9.085 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.572,-5.128 c 0,-1.377 -1.098,-2.454 -2.492,-2.454 -1.4,0 -2.457,1.054 -2.457,2.454 0,1.398 1.076,2.494 2.457,2.494 1.373,0 2.492,-1.117 2.492,-2.494 z m 13.83,19.759 -0.619,-0.089 c -2.855,-0.409 -4.133,-2.104 -4.133,-5.495 l 0,-5.126 4.752,0 0,-3.674 -4.752,0 0,-4.006 -3.887,0 0,4.006 -1.662,0 0,3.674 1.662,0 0,4.525 c 0,6.215 2.113,8.932 7.783,10.029 l 0.855,0.164 0,-4.008 0.001,0 z' style='fill:#ffffff' /></g></svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -1 +0,0 @@
<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' width='193.50101' height='32.755001' version='1.1'><g transform='translate(-1.3555,0.63251107)'><title>micro:bit logo</title><path d='m 38.7185,20.11349 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 m -22.311,-6.077 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.03,-4.053 -9.03,-9.031 -0.001,-4.98 4.053,-9.027 9.03,-9.027 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 c -8.299,0 -15.049,6.752 -15.049,15.051 0,8.299 6.75,15.049 15.049,15.049 l 22.576,0 m 112.099,-21.953 c 0,-1.453 -1.195,-2.633 -2.662,-2.633 -1.455,0 -2.639,1.18 -2.639,2.633 0,1.471 1.184,2.672 2.639,2.672 1.466,0 2.662,-1.202 2.662,-2.672 z m -66.786,5.445 c 0,-4.764 -2.893,-8.093 -7.031,-8.093 -2.027,0 -3.814,0.851 -5.223,2.47 -1.467,-1.661 -3.152,-2.47 -5.127,-2.47 -4.162,0 -7.066,3.329 -7.066,8.093 l 0,10.466 3.812,0 0,-10.644 c 0,-2.416 1.336,-4.104 3.254,-4.104 1.617,0 3.25,1.409 3.25,4.104 l 0,10.645 3.848,0 0,-10.645 c 0,-2.416 1.338,-4.104 3.252,-4.104 1.863,0 3.217,1.727 3.217,4.104 l 0,10.645 3.814,0 0,-10.467 z m 6.953,-7.632 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.569,-5.128 c 0,-1.377 -1.096,-2.454 -2.492,-2.454 -1.4,0 -2.453,1.054 -2.453,2.454 0,1.398 1.078,2.494 2.453,2.494 1.375,0 2.492,-1.117 2.492,-2.494 z m 18.328,20.914 0.576,-0.521 -2.828,-2.658 -0.488,0.455 c -1.252,1.149 -2.504,1.686 -3.945,1.686 -3.064,0 -5.557,-2.557 -5.557,-5.699 0,-3.121 2.492,-5.66 5.557,-5.66 1.432,0 2.646,0.521 3.949,1.693 l 0.512,0.46 2.748,-2.802 -0.49,-0.502 c -1.754,-1.793 -4.016,-2.696 -6.719,-2.696 -2.459,0 -4.869,1.022 -6.605,2.798 -1.738,1.734 -2.691,4.119 -2.691,6.709 0,2.596 0.953,4.979 2.684,6.705 1.771,1.811 4.117,2.811 6.615,2.811 2.401,-0.003 4.647,-0.937 6.682,-2.779 z m 7.25,-6.947 c 0,-3.322 1.145,-4.686 4.217,-5.029 l 0.641,-0.07 0,-3.797 -0.777,0.058 c -5.629,0.458 -8.143,3.247 -8.143,9.048 l 0,9.051 4.062,0 0,-9.261 0,0 z m 21.998,6.923 c 1.762,-1.756 2.729,-4.146 2.729,-6.715 0,-2.565 -0.967,-4.951 -2.723,-6.702 -1.77,-1.809 -4.105,-2.806 -6.576,-2.806 -2.492,0 -4.84,0.997 -6.613,2.806 -1.752,1.792 -2.721,4.174 -2.721,6.702 0,2.53 0.969,4.916 2.721,6.707 1.771,1.81 4.121,2.808 6.613,2.808 2.472,0 4.808,-0.998 6.57,-2.8 z m -1.229,-6.714 c 0,3.18 -2.361,5.665 -5.377,5.665 -2.945,0 -5.346,-2.541 -5.346,-5.665 0,-3.137 2.398,-5.695 5.346,-5.695 2.963,-0.002 5.377,2.558 5.377,5.695 z m 12.917,6.418 c 0,-1.468 -1.195,-2.667 -2.662,-2.667 -1.455,0 -2.639,1.199 -2.639,2.667 0,1.453 1.184,2.632 2.639,2.632 1.466,0 2.662,-1.179 2.662,-2.632 z m 19.507,0.296 c 1.76,-1.756 2.73,-4.146 2.73,-6.715 0,-2.528 -0.973,-4.911 -2.729,-6.702 -1.746,-1.787 -4.08,-2.77 -6.574,-2.77 -2.035,0 -3.84,0.572 -5.484,1.744 l 0,-9.934 -3.816,0 0.008,15.582 c -0.037,0.411 -0.037,0.821 -0.037,1.198 0,6.119 3.836,10.396 9.33,10.396 2.475,0.001 4.807,-0.997 6.572,-2.799 z m -1.013,-6.677 c 0,3.123 -2.494,5.66 -5.559,5.66 -3.115,0 -5.557,-2.484 -5.557,-5.66 0,-3.143 2.494,-5.698 5.557,-5.698 3.065,0 5.559,2.556 5.559,5.698 z m 10.881,-9.085 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.572,-5.128 c 0,-1.377 -1.098,-2.454 -2.492,-2.454 -1.4,0 -2.457,1.054 -2.457,2.454 0,1.398 1.076,2.494 2.457,2.494 1.373,0 2.492,-1.117 2.492,-2.494 z m 13.83,19.759 -0.619,-0.089 c -2.855,-0.409 -4.133,-2.104 -4.133,-5.495 l 0,-5.126 4.752,0 0,-3.674 -4.752,0 0,-4.006 -3.887,0 0,4.006 -1.662,0 0,3.674 1.662,0 0,4.525 c 0,6.215 2.113,8.932 7.783,10.029 l 0.855,0.164 0,-4.008 0.001,0 z' style='fill:#000000' /></g></svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
docs/static/icons/apple-touch-icon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
docs/static/icons/favicon-16x16.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

BIN
docs/static/icons/favicon-32x32.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

BIN
docs/static/icons/favicon-96x96.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

BIN
docs/static/icons/mstile-144x144.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

BIN
docs/static/icons/mstile-150x150.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

BIN
docs/static/icons/mstile-310x150.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

BIN
docs/static/icons/mstile-310x310.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
docs/static/icons/mstile-70x70.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

59
docs/static/icons/safari-pinned-tab.svg vendored Normal file
View File

@ -0,0 +1,59 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="319.000000pt" height="319.000000pt" viewBox="0 0 319.000000 319.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,319.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M145 2888 c-49 -17 -92 -55 -114 -101 -21 -43 -21 -46 -21 -1110 l0
-1067 40 0 40 0 0 -135 c0 -78 4 -135 9 -135 6 0 11 90 13 218 3 207 4 218 26
249 28 40 98 68 147 59 46 -9 102 -59 112 -99 5 -18 7 -127 5 -244 l-3 -212
-107 -4 -107 -3 120 0 120 1 3 158 3 158 142 -3 142 -3 3 -157 c1 -87 7 -158
12 -158 5 0 10 100 12 227 3 254 8 274 78 320 60 41 143 20 187 -46 22 -33 23
-41 23 -267 0 -149 4 -234 10 -234 6 0 10 60 10 160 l0 160 190 0 190 0 0
-161 c0 -104 3 -158 10 -154 6 4 10 93 10 233 0 207 2 230 20 259 40 67 112
88 182 54 78 -38 83 -53 86 -319 2 -135 7 -232 13 -232 5 0 9 68 9 160 l0 160
185 0 185 0 0 -154 c0 -93 4 -157 10 -161 7 -4 10 66 10 202 0 114 5 225 10
245 34 121 169 154 249 63 l31 -36 0 -234 c0 -145 4 -236 10 -240 7 -4 10 50
10 154 l0 161 150 0 150 0 0 -160 c0 -100 4 -160 10 -160 6 0 10 83 10 228 0
263 4 280 81 320 51 27 104 24 151 -9 54 -39 58 -58 58 -294 0 -137 4 -215 10
-215 6 0 10 53 10 140 l0 140 45 0 44 0 4 -77 c1 -43 4 435 5 1062 1 1092 1
1142 -17 1180 -24 53 -55 83 -105 106 -39 18 -96 19 -1466 18 -967 0 -1435 -4
-1455 -11z m1203 -635 l3 -73 -41 0 -40 0 0 76 0 75 38 -3 37 -3 3 -72z m587
2 l0 -70 -37 -3 -38 -3 0 76 0 76 38 -3 37 -3 0 -70z m-880 -280 l0 -70 -40 0
-40 0 -3 49 c-2 27 -1 60 3 73 5 21 11 24 43 21 l37 -3 0 -70z m589 59 c9 -23
7 -107 -3 -122 -5 -8 -22 -12 -42 -10 l-34 3 -3 59 c-2 32 -1 65 2 72 8 20 72
18 80 -2z m584 -61 l3 -73 -41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4
l30 -3 3 -72z m-880 -5 l-3 -73 -35 0 -35 0 -3 73 -3 72 41 0 41 0 -3 -72z
m570 -5 l3 -73 -41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z
m-1388 -363 l0 -180 -185 0 -185 0 0 180 0 180 185 0 185 0 0 -180z m2500 0
l0 -180 -180 0 -180 0 0 180 0 180 180 0 180 0 0 -180z m-1982 161 c9 -5 12
-27 10 -72 l-3 -64 -40 0 -40 0 -3 58 c-2 35 2 64 9 73 13 15 47 18 67 5z
m307 -66 l0 -70 -37 -3 -38 -3 0 76 0 76 38 -3 37 -3 0 -70z m873 -2 l3 -73
-41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z m-590 -10 l3
-73 -41 0 -40 0 0 68 c0 38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z m280 68 c9
-5 12 -27 10 -72 l-3 -64 -40 0 -40 0 -3 64 c-3 67 4 81 43 81 11 0 26 -4 33
-9z m-568 -341 l0 -70 -40 0 -40 0 0 70 0 70 40 0 40 0 0 -70z m590 0 l0 -70
-40 0 -40 0 0 70 0 70 40 0 40 0 0 -70z m-292 -27 l3 -73 -41 0 -40 0 0 68 c0
38 3 72 7 76 4 4 21 6 38 4 l30 -3 3 -72z m-3 -253 l0 -65 -42 -3 -43 -3 0 71
0 71 43 -3 42 -3 0 -65z"/>
<path d="M294 1689 c-25 -13 -54 -60 -54 -89 0 -55 47 -100 105 -100 42 0 75
20 94 57 15 29 14 49 -4 88 -24 49 -88 69 -141 44z"/>
<path d="M2779 1671 c-23 -23 -29 -38 -29 -71 0 -91 106 -135 171 -71 64 65
20 171 -71 171 -33 0 -48 -6 -71 -29z"/>
<path d="M845 836 c-88 -40 -106 -150 -34 -210 24 -20 41 -26 81 -26 44 0 54
4 84 34 32 32 40 56 34 111 -7 70 -99 121 -165 91z"/>
<path d="M1543 836 c-89 -40 -97 -178 -13 -221 66 -34 141 -10 175 55 19 37
19 64 -1 105 -28 60 -101 87 -161 61z"/>
<path d="M2255 836 c-86 -38 -105 -146 -35 -208 24 -23 40 -28 79 -28 143 0
173 188 38 239 -36 14 -45 13 -82 -3z"/>
<path d="M192 820 c-118 -72 -38 -255 98 -225 45 10 90 67 90 116 0 105 -99
163 -188 109z"/>
<path d="M2875 831 c-90 -40 -97 -169 -12 -221 122 -75 250 92 149 193 -32 31
-98 45 -137 28z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1 +0,0 @@
<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' width='193.50101' height='32.755001' version='1.1'><g transform='translate(-1.3555,0.63251107)'><title>micro:bit logo</title><path d='m 38.7185,20.11349 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.678 1.357,-3.038 3.035,-3.038 1.684,0 3.039,1.36 3.039,3.038 0,1.678 -1.355,3.042 -3.039,3.042 m -22.311,-6.077 c -1.677,0 -3.042,1.357 -3.042,3.035 0,1.678 1.363,3.042 3.042,3.042 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.678 -1.363,-3.035 -3.036,-3.035 m -0.003,-5.99 22.576,0 c 4.979,0 9.027,4.047 9.027,9.027 0,4.979 -4.049,9.031 -9.027,9.031 l -22.576,0 c -4.977,0 -9.03,-4.053 -9.03,-9.031 -0.001,-4.98 4.053,-9.027 9.03,-9.027 m 22.576,24.076 c 8.299,0 15.047,-6.75 15.047,-15.049 0,-8.299 -6.748,-15.051 -15.047,-15.051 l -22.576,0 c -8.299,0 -15.049,6.752 -15.049,15.051 0,8.299 6.75,15.049 15.049,15.049 l 22.576,0 m 112.099,-21.953 c 0,-1.453 -1.195,-2.633 -2.662,-2.633 -1.455,0 -2.639,1.18 -2.639,2.633 0,1.471 1.184,2.672 2.639,2.672 1.466,0 2.662,-1.202 2.662,-2.672 z m -66.786,5.445 c 0,-4.764 -2.893,-8.093 -7.031,-8.093 -2.027,0 -3.814,0.851 -5.223,2.47 -1.467,-1.661 -3.152,-2.47 -5.127,-2.47 -4.162,0 -7.066,3.329 -7.066,8.093 l 0,10.466 3.812,0 0,-10.644 c 0,-2.416 1.336,-4.104 3.254,-4.104 1.617,0 3.25,1.409 3.25,4.104 l 0,10.645 3.848,0 0,-10.645 c 0,-2.416 1.338,-4.104 3.252,-4.104 1.863,0 3.217,1.727 3.217,4.104 l 0,10.645 3.814,0 0,-10.467 z m 6.953,-7.632 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.569,-5.128 c 0,-1.377 -1.096,-2.454 -2.492,-2.454 -1.4,0 -2.453,1.054 -2.453,2.454 0,1.398 1.078,2.494 2.453,2.494 1.375,0 2.492,-1.117 2.492,-2.494 z m 18.328,20.914 0.576,-0.521 -2.828,-2.658 -0.488,0.455 c -1.252,1.149 -2.504,1.686 -3.945,1.686 -3.064,0 -5.557,-2.557 -5.557,-5.699 0,-3.121 2.492,-5.66 5.557,-5.66 1.432,0 2.646,0.521 3.949,1.693 l 0.512,0.46 2.748,-2.802 -0.49,-0.502 c -1.754,-1.793 -4.016,-2.696 -6.719,-2.696 -2.459,0 -4.869,1.022 -6.605,2.798 -1.738,1.734 -2.691,4.119 -2.691,6.709 0,2.596 0.953,4.979 2.684,6.705 1.771,1.811 4.117,2.811 6.615,2.811 2.401,-0.003 4.647,-0.937 6.682,-2.779 z m 7.25,-6.947 c 0,-3.322 1.145,-4.686 4.217,-5.029 l 0.641,-0.07 0,-3.797 -0.777,0.058 c -5.629,0.458 -8.143,3.247 -8.143,9.048 l 0,9.051 4.062,0 0,-9.261 0,0 z m 21.998,6.923 c 1.762,-1.756 2.729,-4.146 2.729,-6.715 0,-2.565 -0.967,-4.951 -2.723,-6.702 -1.77,-1.809 -4.105,-2.806 -6.576,-2.806 -2.492,0 -4.84,0.997 -6.613,2.806 -1.752,1.792 -2.721,4.174 -2.721,6.702 0,2.53 0.969,4.916 2.721,6.707 1.771,1.81 4.121,2.808 6.613,2.808 2.472,0 4.808,-0.998 6.57,-2.8 z m -1.229,-6.714 c 0,3.18 -2.361,5.665 -5.377,5.665 -2.945,0 -5.346,-2.541 -5.346,-5.665 0,-3.137 2.398,-5.695 5.346,-5.695 2.963,-0.002 5.377,2.558 5.377,5.695 z m 12.917,6.418 c 0,-1.468 -1.195,-2.667 -2.662,-2.667 -1.455,0 -2.639,1.199 -2.639,2.667 0,1.453 1.184,2.632 2.639,2.632 1.466,0 2.662,-1.179 2.662,-2.632 z m 19.507,0.296 c 1.76,-1.756 2.73,-4.146 2.73,-6.715 0,-2.528 -0.973,-4.911 -2.729,-6.702 -1.746,-1.787 -4.08,-2.77 -6.574,-2.77 -2.035,0 -3.84,0.572 -5.484,1.744 l 0,-9.934 -3.816,0 0.008,15.582 c -0.037,0.411 -0.037,0.821 -0.037,1.198 0,6.119 3.836,10.396 9.33,10.396 2.475,0.001 4.807,-0.997 6.572,-2.799 z m -1.013,-6.677 c 0,3.123 -2.494,5.66 -5.559,5.66 -3.115,0 -5.557,-2.484 -5.557,-5.66 0,-3.143 2.494,-5.698 5.557,-5.698 3.065,0 5.559,2.556 5.559,5.698 z m 10.881,-9.085 -3.846,0 0,18.099 3.846,0 0,-18.099 z m 0.572,-5.128 c 0,-1.377 -1.098,-2.454 -2.492,-2.454 -1.4,0 -2.457,1.054 -2.457,2.454 0,1.398 1.076,2.494 2.457,2.494 1.373,0 2.492,-1.117 2.492,-2.494 z m 13.83,19.759 -0.619,-0.089 c -2.855,-0.409 -4.133,-2.104 -4.133,-5.495 l 0,-5.126 4.752,0 0,-3.674 -4.752,0 0,-4.006 -3.887,0 0,4.006 -1.662,0 0,3.674 1.662,0 0,4.525 c 0,6.215 2.113,8.932 7.783,10.029 l 0.855,0.164 0,-4.008 0.001,0 z' style='fill:#000000' /></g></svg>

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

BIN
docs/static/logo32.png vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

1
docs/static/microbit.docs.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

BIN
docs/static/microbit.red.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
docs/static/microbit.red.square.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

1
docs/static/microbit.red.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

1
docs/static/microbit.simplified.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1 +0,0 @@
<svg xmlns='http://www.w3.org/2000/svg' width='52.672' height='30.1' viewBox='0 0 52.672003 30.1'><g transform='translate(-1.355 -2.023)'><title>micro:bit logo</title><path d='M38.718 20.113c-1.677 0-3.035-1.364-3.035-3.042 0-1.677 1.357-3.037 3.035-3.037 1.684 0 3.04 1.36 3.04 3.038 0 1.68-1.356 3.043-3.04 3.043m-22.31-6.077c-1.678 0-3.043 1.357-3.043 3.035 0 1.68 1.363 3.043 3.042 3.043 1.674 0 3.036-1.364 3.036-3.042 0-1.677-1.363-3.034-3.036-3.034m-.003-5.99H38.98c4.98 0 9.027 4.047 9.027 9.027 0 4.98-4.05 9.03-9.027 9.03H16.404c-4.977 0-9.03-4.052-9.03-9.03 0-4.98 4.053-9.027 9.03-9.027M38.98 32.122c8.3 0 15.047-6.75 15.047-15.05 0-8.298-6.748-15.05-15.047-15.05H16.404c-8.3 0-15.05 6.752-15.05 15.05 0 8.3 6.75 15.05 15.05 15.05H38.98'/></g></svg>

Before

Width:  |  Height:  |  Size: 761 B

View File

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1240"
height="600"
viewBox="0 0 1240 599.99999"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="splashscreen.svg"
inkscape:export-filename="C:\gh\pxt-microbit\win10\app\images\Square44x44Logo.targetsize-24_altform-unplated.png"
inkscape:export-xdpi="41.008503"
inkscape:export-ydpi="41.008503">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="837"
id="namedview10"
showgrid="false"
inkscape:zoom="0.7546704"
inkscape:cx="528.17059"
inkscape:cy="263.58903"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<g
transform="matrix(15.144568,0,0,15.144568,200.63934,41.451935)"
id="g4">
<title
id="title6">micro:bit logo</title>
<path
d="m 38.718,20.113 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.677 1.357,-3.037 3.035,-3.037 1.684,0 3.04,1.36 3.04,3.038 0,1.68 -1.356,3.043 -3.04,3.043 m -22.31,-6.077 c -1.678,0 -3.043,1.357 -3.043,3.035 0,1.68 1.363,3.043 3.042,3.043 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.677 -1.363,-3.034 -3.036,-3.034 m -0.003,-5.99 22.576,0 c 4.98,0 9.027,4.047 9.027,9.027 0,4.98 -4.05,9.03 -9.027,9.03 l -22.576,0 c -4.977,0 -9.03,-4.052 -9.03,-9.03 0,-4.98 4.053,-9.027 9.03,-9.027 M 38.98,32.122 c 8.3,0 15.047,-6.75 15.047,-15.05 0,-8.298 -6.748,-15.05 -15.047,-15.05 l -22.576,0 c -8.3,0 -15.05,6.752 -15.05,15.05 0,8.3 6.75,15.05 15.05,15.05 l 22.576,0"
id="path8"
inkscape:connector-curvature="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="52.672001"
height="52.672001"
viewBox="0 0 52.672003 52.672"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="squarelogo.svg">
<metadata
id="metadata14">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs12" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="640"
inkscape:window-height="480"
id="namedview10"
showgrid="false"
inkscape:zoom="6.0373632"
inkscape:cx="26.336"
inkscape:cy="21.675409"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<g
transform="translate(-1.355,9.2400005)"
id="g4">
<title
id="title6">micro:bit logo</title>
<path
d="m 38.718,20.113 c -1.677,0 -3.035,-1.364 -3.035,-3.042 0,-1.677 1.357,-3.037 3.035,-3.037 1.684,0 3.04,1.36 3.04,3.038 0,1.68 -1.356,3.043 -3.04,3.043 m -22.31,-6.077 c -1.678,0 -3.043,1.357 -3.043,3.035 0,1.68 1.363,3.043 3.042,3.043 1.674,0 3.036,-1.364 3.036,-3.042 0,-1.677 -1.363,-3.034 -3.036,-3.034 m -0.003,-5.99 22.576,0 c 4.98,0 9.027,4.047 9.027,9.027 0,4.98 -4.05,9.03 -9.027,9.03 l -22.576,0 c -4.977,0 -9.03,-4.052 -9.03,-9.03 0,-4.98 4.053,-9.027 9.03,-9.027 M 38.98,32.122 c 8.3,0 15.047,-6.75 15.047,-15.05 0,-8.298 -6.748,-15.05 -15.047,-15.05 l -22.576,0 c -8.3,0 -15.05,6.752 -15.05,15.05 0,8.3 6.75,15.05 15.05,15.05 l 22.576,0"
id="path8"
inkscape:connector-curvature="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -2,6 +2,8 @@
using namespace pxt; using namespace pxt;
#define MAX_FIELD_NAME_LENGTH 12
//% color=270 weight=34 //% color=270 weight=34
namespace radio { namespace radio {
@ -9,6 +11,8 @@ namespace radio {
// Radio // Radio
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool radioEnabled = false; bool radioEnabled = false;
bool transmitSerialNumber = false;
PacketBuffer packet; PacketBuffer packet;
int radioEnable() { int radioEnable() {
@ -34,17 +38,100 @@ namespace radio {
registerWithDal(MES_BROADCAST_GENERAL_ID, message, f); registerWithDal(MES_BROADCAST_GENERAL_ID, message, f);
} }
/**
* Broadcasts a number over radio to any connected micro:bit in the group.
*/
//% help=radio/send-number
//% weight=60
//% blockId=radio_datagram_send block="send number %value" blockGap=8
void sendNumber(int value) {
if (radioEnable() != MICROBIT_OK) return;
uint32_t t = system_timer_current_time();
uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0;
uint32_t buf[] = { (uint32_t)value, t, sn };
uBit.radio.datagram.send((uint8_t*)buf, 3*sizeof(uint32_t));
}
/** /**
* Broadcasts 4 numbers over radio to any connected micro:bit in the group. * Broadcasts a name / value pair along with the device serial number
* and running time to any connected BBC micro:bit in the group.
* @param name the field name (max 12 characters), eg: "data"
* @param value the numberic value
*/ */
//% help=radio/send-numbers //% help=radio/send-value
//% weight=59 //% weight=59
//% blockId=radio_datagram_send_numbers block="send numbers|0: %VALUE0|1: %VALUE1|2: %VALUE2|3: %VALUE3" //% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8
void sendNumbers(int value_0, int value_1, int value_2, int value_3) { void sendValue(StringData* name, int value) {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
int buf[] = { value_0, value_1, value_2, value_3 };
uBit.radio.datagram.send((uint8_t*)buf, 4*sizeof(int)); ManagedString n(name);
uint32_t t = system_timer_current_time();
uint32_t sn = transmitSerialNumber ? microbit_serial_number() : 0;
uint8_t buf[32];
uint32_t* buf32 = (uint32_t*)buf;
memset(buf, 32, 0);
buf32[0] = value; // 4 bytes: value
buf32[1] = t; // 4 bytes: running time
buf32[2] = sn; // 4 bytes: serial number
uint8_t len = min(MAX_FIELD_NAME_LENGTH, n.length()); // 1 byte: string length
if (len > 0) {
buf[12] = len; //
memcpy(buf + 13, n.toCharArray(), len); // 13-25: field name
}
uBit.radio.datagram.send(buf, 13 + len);
}
/**
* Broadcasts a number over radio to any connected micro:bit in the group.
*/
//% help=radio/send-string
//% weight=58
//% blockId=radio_datagram_send_string block="send string %msg"
void sendString(StringData* msg) {
if (radioEnable() != MICROBIT_OK) return;
ManagedString s(msg);
if (s.length() > MICROBIT_RADIO_MAX_PACKET_SIZE)
s = s.substring(0, MICROBIT_RADIO_MAX_PACKET_SIZE);
uBit.radio.datagram.send(s);
}
/**
* Reads a value sent with `stream value` and writes it
* to the serial stream as JSON
*/
//% help=radio/write-value-to-serial
//% weight=3
//% blockId=radio_write_value_serial block="write value to serial"
void writeValueToSerial() {
if (radioEnable() != MICROBIT_OK) return;
PacketBuffer p = uBit.radio.datagram.recv();
int length = p.length();
uint8_t* bytes = p.getBytes();
int value;
uBit.serial.send("{");
if (length >= 4) {
memcpy(&value, bytes, 4);
uBit.serial.send("v:"); uBit.serial.send(value);
if(length >= 8) {
memcpy(&value, bytes + 4, 4);
uBit.serial.send(",t:"); uBit.serial.send(value);
if (length >= 12) {
memcpy(&value, bytes + 8, 4);
uBit.serial.send(",s:"); uBit.serial.send(value);
if (length >= 13) {
char name[MAX_FIELD_NAME_LENGTH+1];
uint8_t len = min(MAX_FIELD_NAME_LENGTH, bytes[12]);
memcpy(name, bytes + 13, len);
name[len] = 0;
uBit.serial.send(",n:\""); uBit.serial.send(name); uBit.serial.send("\"");
}
}
}
}
uBit.serial.send("}\r\n");
} }
/** /**
@ -63,7 +150,7 @@ namespace radio {
* @param index index of the number to read from 0 to 3. 1 eg * @param index index of the number to read from 0 to 3. 1 eg
*/ */
//% help=radio/received-number-at //% help=radio/received-number-at
//% weight=45 //% weight=45 debug=true
//% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8 //% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8
int receivedNumberAt(int index) { int receivedNumberAt(int index) {
if (radioEnable() != MICROBIT_OK) return 0; if (radioEnable() != MICROBIT_OK) return 0;
@ -89,6 +176,18 @@ namespace radio {
return receivedNumberAt(0); return receivedNumberAt(0);
} }
/**
* Reads the next packet as a string and returns it.
*/
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
//% weight=44
//% help=radio/receive-string
StringData* receiveString() {
if (radioEnable() != MICROBIT_OK) return ManagedString().leakData();
packet = uBit.radio.datagram.recv();
return ManagedString(packet).leakData();
}
/** /**
* Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator. * Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.
* namespace=radio * namespace=radio
@ -124,4 +223,14 @@ namespace radio {
if (radioEnable() != MICROBIT_OK) return; if (radioEnable() != MICROBIT_OK) return;
uBit.radio.setTransmitPower(power); uBit.radio.setTransmitPower(power);
} }
/**
* Set the radio to transmit the serial number in each message.
*/
//% help=radio/set-transmit-serial-number
//% weight=8
//% block=radio_set_transmit_serial_number block="set tranmist serial number %transmit"
void setTransmitSerialNumber(bool transmit) {
transmitSerialNumber = transmit;
}
} }

View File

@ -3,13 +3,4 @@
*/ */
//% color=270 weight=34 //% color=270 weight=34
namespace radio { namespace radio {
/**
* Broadcasts a number over radio to any connected micro:bit in the group.
*/
//% help=radio/send-number
//% weight=60
//% blockId=radio_datagram_send block="send number %MESSAGE" blockGap=8
export function sendNumber(value: number) : void {
sendNumbers(value, 0, 0, 0);
}
} }

View File

@ -6,12 +6,40 @@
declare namespace radio { declare namespace radio {
/** /**
* Broadcasts 4 numbers over radio to any connected micro:bit in the group. * Broadcasts a number over radio to any connected micro:bit in the group.
*/ */
//% help=radio/send-numbers //% help=radio/send-number
//% weight=60
//% blockId=radio_datagram_send block="send number %value" blockGap=8 shim=radio::sendNumber
function sendNumber(value: number): void;
/**
* Broadcasts a name / value pair along with the device serial number
* and running time to any connected BBC micro:bit in the group.
* @param name the field name (max 12 characters), eg: "data"
* @param value the numberic value
*/
//% help=radio/send-value
//% weight=59 //% weight=59
//% blockId=radio_datagram_send_numbers block="send numbers|0: %VALUE0|1: %VALUE1|2: %VALUE2|3: %VALUE3" shim=radio::sendNumbers //% blockId=radio_datagram_send_value block="send|value %name|= %value" blockGap=8 shim=radio::sendValue
function sendNumbers(value_0: number, value_1: number, value_2: number, value_3: number): void; function sendValue(name: string, value: number): void;
/**
* Broadcasts a number over radio to any connected micro:bit in the group.
*/
//% help=radio/send-string
//% weight=58
//% blockId=radio_datagram_send_string block="send string %msg" shim=radio::sendString
function sendString(msg: string): void;
/**
* Reads a value sent with `stream value` and writes it
* to the serial stream as JSON
*/
//% help=radio/write-value-to-serial
//% weight=3
//% blockId=radio_write_value_serial block="write value to serial" shim=radio::writeValueToSerial
function writeValueToSerial(): void;
/** /**
* Registers code to run when a packet is received over radio. * Registers code to run when a packet is received over radio.
@ -26,7 +54,7 @@ declare namespace radio {
* @param index index of the number to read from 0 to 3. 1 eg * @param index index of the number to read from 0 to 3. 1 eg
*/ */
//% help=radio/received-number-at //% help=radio/received-number-at
//% weight=45 //% weight=45 debug=true
//% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt //% blockId=radio_datagram_received_number_at block="receive number|at %VALUE" blockGap=8 shim=radio::receivedNumberAt
function receivedNumberAt(index: number): number; function receivedNumberAt(index: number): number;
@ -38,6 +66,14 @@ declare namespace radio {
//% blockId=radio_datagram_receive block="receive number" blockGap=8 shim=radio::receiveNumber //% blockId=radio_datagram_receive block="receive number" blockGap=8 shim=radio::receiveNumber
function receiveNumber(): number; function receiveNumber(): number;
/**
* Reads the next packet as a string and returns it.
*/
//% blockId=radio_datagram_receive_string block="receive string" blockGap=8
//% weight=44
//% help=radio/receive-string shim=radio::receiveString
function receiveString(): string;
/** /**
* Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator. * Gets the received signal strength indicator (RSSI) from the packet received by ``receive number``. Not supported in simulator.
* namespace=radio * namespace=radio
@ -64,6 +100,14 @@ declare namespace radio {
//% weight=9 //% weight=9
//% blockId=radio_set_transmit_power block="set transmit power %power" shim=radio::setTransmitPower //% blockId=radio_set_transmit_power block="set transmit power %power" shim=radio::setTransmitPower
function setTransmitPower(power: number): void; function setTransmitPower(power: number): void;
/**
* Set the radio to transmit the serial number in each message.
*/
//% help=radio/set-transmit-serial-number
//% weight=8
//% block=radio_set_transmit_serial_number block="set tranmist serial number %transmit" shim=radio::setTransmitSerialNumber
function setTransmitSerialNumber(transmit: boolean): void;
} }
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -1,79 +1,81 @@
{ {
"A single-LED sprite game engine": "A single-LED sprite game engine", "basic": "Provides access to basic micro:bit functionality.",
"Adds points to the current score": "Adds points to the current score", "basic.clearScreen": "Turn off all LEDs",
"Attaches code to run when the device is shaken.": "Attaches code to run when the device is shaken.", "basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
"Attaches code to run when the logo is oriented downwards and the board is vertical.": "Attaches code to run when the logo is oriented downwards and the board is vertical.", "basic.pause": "Pause for the specified time in milliseconds",
"Attaches code to run when the logo is oriented upwards and the board is vertical.": "Attaches code to run when the logo is oriented upwards and the board is vertical.", "basic.plotLeds": "Draws an image on the LED screen.",
"Attaches code to run when the screen is facing down.": "Attaches code to run when the screen is facing down.", "basic.showAnimation": "Shows a sequence of LED screens as an animation.",
"Attaches code to run when the screen is facing up.": "Attaches code to run when the screen is facing up.", "basic.showLeds": "Draws an image on the LED screen.",
"Cancels the current animation and clears other pending animations.": "Cancels the current animation and clears other pending animations.", "basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
"Change the tempo by the specified amount": "Change the tempo by the specified amount", "basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
"Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.", "control": "Runtime and event utilities.",
"Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.", "control.inBackground": "Schedules code that run in the background.",
"Control currents in Pins for analog/digital signals, servos, i2c, ...": "Control currents in Pins for analog/digital signals, servos, i2c, ...", "control.reset": "Resets the BBC micro:bit.",
"Control of the LED screen.": "Control of the LED screen.", "game": "A single-LED sprite game engine",
"Creates an image that fits on the LED screen.": "Creates an image that fits on the LED screen.", "game.addScore": "Adds points to the current score",
"Creates an image with 2 frames.": "Creates an image with 2 frames.", "game.gameOver": "Displays a game over animation.",
"Creation, manipulation and display of LED images.": "Creation, manipulation and display of LED images.", "game.score": "Gets the current score",
"Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.", "game.setScore": "Sets the current score value",
"Displays a game over animation.": "Displays a game over animation.", "game.startCountdown": "Starts a game countdown timer",
"Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.", "images": "Creation, manipulation and display of LED images.",
"Do something when a button (``A``, ``B`` or both ``A+B``) is pressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed", "images.createBigImage": "Creates an image with 2 frames.",
"Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.", "images.createImage": "Creates an image that fits on the LED screen.",
"Draws an image on the LED screen.": "Draws an image on the LED screen.", "input": "Events and data from sensors",
"Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.", "input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
"Events and data from sensors": "Events and data from sensors", "input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
"Fades in the screen display.": "Fades in the screen display.", "input.calibrate": "Obsolete, compass calibration is automatic.",
"Fades out the screen brightness.": "Fades out the screen brightness.", "input.compassHeading": "Get the current compass compass heading in degrees.",
"Generation of music tones through pin ``P0``.": "Generation of music tones through pin ``P0``.", "input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
"Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)", "input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
"Get the button state (pressed or not) for ``A`` and ``B``.": "Get the button state (pressed or not) for ``A`` and ``B``.", "input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
"Get the current compass compass heading in degrees.": "Get the current compass compass heading in degrees.", "input.onGesture": "Attaches code to run when the screen is facing up.",
"Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.", "input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
"Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.", "input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
"Get the pin state (pressed or not). Requires to hold the ground to close the circuit.": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.", "input.onPinPressed": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.",
"Get the screen brightness from 0 (off) to 255 (full bright).": "Get the screen brightness from 0 (off) to 255 (full bright).", "input.onScreenDown": "Attaches code to run when the screen is facing down.",
"Gets the current score": "Gets the current score", "input.onScreenUp": "Attaches code to run when the screen is facing up.",
"Gets the frequency of a note.": "Gets the frequency of a note.", "input.onShake": "Attaches code to run when the device is shaken.",
"Gets the number of milliseconds elapsed since power on.": "Gets the number of milliseconds elapsed since power on.", "input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
"Gets the temperature in Celsius degrees (°C).": "Gets the temperature in Celsius degrees (°C).", "input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
"Inverts the current LED display": "Inverts the current LED display", "input.runningTime": "Gets the number of milliseconds elapsed since power on.",
"Obsolete, compass calibration is automatic.": "Obsolete, compass calibration is automatic.", "input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
"Pause for the specified time in milliseconds": "Pause for the specified time in milliseconds", "input.temperature": "Gets the temperature in Celsius degrees (°C).",
"Plays a tone through pin ``P0`` for the given duration.": "Plays a tone through pin ``P0`` for the given duration.", "led": "Control of the LED screen.",
"Plays a tone through pin ``P0``.": "Plays a tone through pin ``P0``.", "led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
"Prints a line of text to the serial": "Prints a line of text to the serial", "led.fadeIn": "Fades in the screen display.",
"Provides access to basic micro:bit functionality.": "Provides access to basic micro:bit functionality.", "led.fadeOut": "Fades out the screen brightness.",
"Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.", "led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
"Read the connector value as analog, that is, as a value comprised between 0 and 1023.": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.", "led.plotAll": "Turns all LEDS on",
"Read the specified pin or connector as either 0 or 1": "Read the specified pin or connector as either 0 or 1", "led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
"Reading and writing data over a serial connection.": "Reading and writing data over a serial connection.", "led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
"Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.", "led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
"Repeats the code forever in the background. On each iteration, allows other codes to run.": "Repeats the code forever in the background. On each iteration, allows other codes to run.", "led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
"Resets the BBC micro:bit.": "Resets the BBC micro:bit.", "led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
"Rests (plays nothing) for a specified time through pin ``P0``.": "Rests (plays nothing) for a specified time through pin ``P0``.", "led.stopAnimation": "Cancels the current animation and clears other pending animations.",
"Returns the duration of a beat in milli-seconds": "Returns the duration of a beat in milli-seconds", "led.toggle": "Toggles a particular pixel",
"Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.", "led.toggleAll": "Inverts the current LED display",
"Runtime and event utilities.": "Runtime and event utilities.", "led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
"Schedules code that run in the background.": "Schedules code that run in the background.", "music": "Generation of music tones through pin ``P0``.",
"Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.", "music.beat": "Returns the duration of a beat in milli-seconds",
"Set a pin or connector value to either 0 or 1.": "Set a pin or connector value to either 0 or 1.", "music.changeTempoBy": "Change the tempo by the specified amount",
"Set the connector value as analog. Value must be comprised between 0 and 1023.": "Set the connector value as analog. Value must be comprised between 0 and 1023.", "music.noteFrequency": "Gets the frequency of a note.",
"Set the screen brightness from 0 (off) to 255 (full bright).": "Set the screen brightness from 0 (off) to 255 (full bright).", "music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
"Sets the accelerometer sample range in gravities.": "Sets the accelerometer sample range in gravities.", "music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
"Sets the current score value": "Sets the current score value", "music.ringTone": "Plays a tone through pin ``P0``.",
"Sets the display mode between black and white and greyscale for rendering LEDs.": "Sets the display mode between black and white and greyscale for rendering LEDs.", "music.setTempo": "Sets the tempo to the specified amount",
"Sets the pin used when using `pins->analog pitch`.": "Sets the pin used when using `pins->analog pitch`.", "music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
"Sets the tempo to the specified amount": "Sets the tempo to the specified amount", "pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
"Shows a sequence of LED screens as an animation.": "Shows a sequence of LED screens as an animation.", "pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
"Starts a game countdown timer": "Starts a game countdown timer", "pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
"Takes a screenshot of the LED screen and returns an image.": "Takes a screenshot of the LED screen and returns an image.", "pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
"The pitch of the device, rotation along the ``x-axis``, in degrees.": "The pitch of the device, rotation along the ``x-axis``, in degrees.", "pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
"Toggles a particular pixel": "Toggles a particular pixel", "pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
"Turn off all LEDs": "Turn off all LEDs", "pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
"Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.", "pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
"Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.", "pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
"Turns all LEDS on": "Turns all LEDS on", "pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
"Writes a ``name: value`` pair line to the serial.": "Writes a ``name: value`` pair line to the serial.", "pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
"Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement)." "serial": "Reading and writing data over a serial connection.",
"serial.writeLine": "Prints a line of text to the serial",
"serial.writeValue": "Writes a ``name: value`` pair line to the serial."
} }

View File

@ -86,7 +86,7 @@ declare const enum DAL {
MICROBIT_DFU_HISTOGRAM_HEIGHT = 5, MICROBIT_DFU_HISTOGRAM_HEIGHT = 5,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitEventService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitEventService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 20, MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10, MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20, MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
@ -208,6 +208,7 @@ declare const enum DAL {
MMA8653_SAMPLE_RANGES = 3, MMA8653_SAMPLE_RANGES = 3,
MMA8653_SAMPLE_RATES = 8, MMA8653_SAMPLE_RATES = 8,
MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1, MICROBIT_ACCELEROMETER_EVT_DATA_UPDATE = 1,
MICROBIT_ACCELEROMETER_EVT_NONE = 0,
MICROBIT_ACCELEROMETER_EVT_TILT_UP = 1, MICROBIT_ACCELEROMETER_EVT_TILT_UP = 1,
MICROBIT_ACCELEROMETER_EVT_TILT_DOWN = 2, MICROBIT_ACCELEROMETER_EVT_TILT_DOWN = 2,
MICROBIT_ACCELEROMETER_EVT_TILT_LEFT = 3, MICROBIT_ACCELEROMETER_EVT_TILT_LEFT = 3,
@ -229,18 +230,6 @@ declare const enum DAL {
MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 10, MICROBIT_ACCELEROMETER_GESTURE_DAMPING = 10,
MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10, MICROBIT_ACCELEROMETER_SHAKE_DAMPING = 10,
MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4, MICROBIT_ACCELEROMETER_SHAKE_COUNT_THRESHOLD = 4,
GESTURE_NONE = 0,
GESTURE_UP = 1,
GESTURE_DOWN = 2,
GESTURE_LEFT = 3,
GESTURE_RIGHT = 4,
GESTURE_FACE_UP = 5,
GESTURE_FACE_DOWN = 6,
GESTURE_FREEFALL = 7,
GESTURE_3G = 8,
GESTURE_6G = 9,
GESTURE_8G = 10,
GESTURE_SHAKE = 11,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h // built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitButton.h
MICROBIT_BUTTON_EVT_DOWN = 1, MICROBIT_BUTTON_EVT_DOWN = 1,
MICROBIT_BUTTON_EVT_UP = 2, MICROBIT_BUTTON_EVT_UP = 2,
@ -343,14 +332,22 @@ declare const enum DAL {
IO_STATUS_ANALOG_IN = 0x04, IO_STATUS_ANALOG_IN = 0x04,
IO_STATUS_ANALOG_OUT = 0x08, IO_STATUS_ANALOG_OUT = 0x08,
IO_STATUS_TOUCH_IN = 0x10, IO_STATUS_TOUCH_IN = 0x10,
IO_STATUS_EVENTBUS_ENABLED = 0x80, IO_STATUS_EVENT_ON_EDGE = 0x20,
IO_STATUS_EVENT_PULSE_ON_EDGE = 0x40,
MICROBIT_PIN_MAX_OUTPUT = 1023, MICROBIT_PIN_MAX_OUTPUT = 1023,
MICROBIT_PIN_MAX_SERVO_RANGE = 180, MICROBIT_PIN_MAX_SERVO_RANGE = 180,
MICROBIT_PIN_DEFAULT_SERVO_RANGE = 2000, MICROBIT_PIN_DEFAULT_SERVO_RANGE = 2000,
MICROBIT_PIN_DEFAULT_SERVO_CENTER = 1500, MICROBIT_PIN_DEFAULT_SERVO_CENTER = 1500,
MICROBIT_PIN_EVENT_NONE = 0,
MICROBIT_PIN_EVENT_ON_EDGE = 1,
MICROBIT_PIN_EVENT_ON_PULSE = 2,
MICROBIT_PIN_EVENT_ON_TOUCH = 3,
MICROBIT_PIN_EVT_RISE = 2,
MICROBIT_PIN_EVT_FALL = 3,
MICROBIT_PIN_EVT_PULSE_HI = 4,
MICROBIT_PIN_EVT_PULSE_LO = 5,
PIN_CAPABILITY_DIGITAL = 0x01, PIN_CAPABILITY_DIGITAL = 0x01,
PIN_CAPABILITY_ANALOG = 0x02, PIN_CAPABILITY_ANALOG = 0x02,
PIN_CAPABILITY_TOUCH = 0x04,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadio.h // built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitRadio.h
MICROBIT_RADIO_STATUS_INITIALISED = 0x0001, MICROBIT_RADIO_STATUS_INITIALISED = 0x0001,
MICROBIT_RADIO_BASE_ADDRESS = 0x75626974, MICROBIT_RADIO_BASE_ADDRESS = 0x75626974,
@ -388,6 +385,7 @@ declare const enum DAL {
MICROBIT_THERMOMETER_PERIOD = 1000, MICROBIT_THERMOMETER_PERIOD = 1000,
MICROBIT_THERMOMETER_EVT_UPDATE = 1, MICROBIT_THERMOMETER_EVT_UPDATE = 1,
MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2, MICROBIT_THERMOMETER_ADDED_TO_IDLE = 2,
// built/yt/yotta_modules/microbit-dal/inc//drivers/TimedInterruptIn.h
// built/yt/yotta_modules/microbit-dal/inc//platform/yotta_cfg_mappings.h // built/yt/yotta_modules/microbit-dal/inc//platform/yotta_cfg_mappings.h
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h // built/yt/yotta_modules/microbit-dal/inc//types/ManagedString.h
// built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h // built/yt/yotta_modules/microbit-dal/inc//types/ManagedType.h

View File

@ -69,42 +69,42 @@ declare namespace basic {
* Raised when shaken * Raised when shaken
*/ */
//% block=shake //% block=shake
Shake = 11, // GESTURE_SHAKE Shake = 11, // MICROBIT_ACCELEROMETER_EVT_SHAKE
/** /**
* Raised when the logo is upward and the screen is vertical * Raised when the logo is upward and the screen is vertical
*/ */
//% block="logo up" //% block="logo up"
LogoUp = 1, // GESTURE_UP LogoUp = 1, // MICROBIT_ACCELEROMETER_EVT_TILT_UP
/** /**
* Raised when the logo is downward and the screen is vertical * Raised when the logo is downward and the screen is vertical
*/ */
//% block="logo down" //% block="logo down"
LogoDown = 2, // GESTURE_DOWN LogoDown = 2, // MICROBIT_ACCELEROMETER_EVT_TILT_DOWN
/** /**
* Raised when the screen is pointing down and the board is horizontal * Raised when the screen is pointing down and the board is horizontal
*/ */
//% block="screen up" //% block="screen up"
ScreenUp = 5, // GESTURE_FACE_UP ScreenUp = 5, // MICROBIT_ACCELEROMETER_EVT_FACE_UP
/** /**
* Raised when the screen is pointing up and the board is horizontal * Raised when the screen is pointing up and the board is horizontal
*/ */
//% block="screen down" //% block="screen down"
ScreenDown = 6, // GESTURE_FACE_DOWN ScreenDown = 6, // MICROBIT_ACCELEROMETER_EVT_FACE_DOWN
/** /**
* Raised when the screen is pointing left * Raised when the screen is pointing left
*/ */
//% block="tilt left" //% block="tilt left"
TiltLeft = 3, // GESTURE_LEFT TiltLeft = 3, // MICROBIT_ACCELEROMETER_EVT_TILT_LEFT
/** /**
* Raised when the screen is pointing right * Raised when the screen is pointing right
*/ */
//% block="tilt right" //% block="tilt right"
TiltRight = 4, // GESTURE_RIGHT TiltRight = 4, // MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT
/** /**
* Raised when the board is falling! * Raised when the board is falling!
*/ */
//% block="free fall" //% block="free fall"
FreeFall = 7, // GESTURE_FREEFALL FreeFall = 7, // MICROBIT_ACCELEROMETER_EVT_FREEFALL
} }
declare namespace input { declare namespace input {
} }
@ -281,7 +281,5 @@ declare namespace serial {
Int32BE = 10, Int32BE = 10,
// UInt32, // UInt32,
} }
declare namespace storage {
}
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -59,42 +59,42 @@ enum class Gesture {
* Raised when shaken * Raised when shaken
*/ */
//% block=shake //% block=shake
Shake = GESTURE_SHAKE, Shake = MICROBIT_ACCELEROMETER_EVT_SHAKE,
/** /**
* Raised when the logo is upward and the screen is vertical * Raised when the logo is upward and the screen is vertical
*/ */
//% block="logo up" //% block="logo up"
LogoUp = GESTURE_UP, LogoUp = MICROBIT_ACCELEROMETER_EVT_TILT_UP,
/** /**
* Raised when the logo is downward and the screen is vertical * Raised when the logo is downward and the screen is vertical
*/ */
//% block="logo down" //% block="logo down"
LogoDown = GESTURE_DOWN, LogoDown = MICROBIT_ACCELEROMETER_EVT_TILT_DOWN,
/** /**
* Raised when the screen is pointing down and the board is horizontal * Raised when the screen is pointing down and the board is horizontal
*/ */
//% block="screen up" //% block="screen up"
ScreenUp = GESTURE_FACE_UP, ScreenUp = MICROBIT_ACCELEROMETER_EVT_FACE_UP,
/** /**
* Raised when the screen is pointing up and the board is horizontal * Raised when the screen is pointing up and the board is horizontal
*/ */
//% block="screen down" //% block="screen down"
ScreenDown = GESTURE_FACE_DOWN, ScreenDown = MICROBIT_ACCELEROMETER_EVT_FACE_DOWN,
/** /**
* Raised when the screen is pointing left * Raised when the screen is pointing left
*/ */
//% block="tilt left" //% block="tilt left"
TiltLeft = GESTURE_LEFT, TiltLeft = MICROBIT_ACCELEROMETER_EVT_TILT_LEFT,
/** /**
* Raised when the screen is pointing right * Raised when the screen is pointing right
*/ */
//% block="tilt right" //% block="tilt right"
TiltRight = GESTURE_RIGHT, TiltRight = MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT,
/** /**
* Raised when the board is falling! * Raised when the board is falling!
*/ */
//% block="free fall" //% block="free fall"
FreeFall = GESTURE_FREEFALL FreeFall = MICROBIT_ACCELEROMETER_EVT_FREEFALL
}; };
//% color=300 weight=99 //% color=300 weight=99

View File

@ -11,7 +11,7 @@ namespace pins {
* @param toLow the lower bound of the value's target range * @param toLow the lower bound of the value's target range
* @param toHigh the upper bound of the value's target range, eg: 4 * @param toHigh the upper bound of the value's target range, eg: 4
*/ */
//% help=pins/map weight=15 //% help=pins/map weight=3
//% blockId=math_map block="map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh" //% blockId=math_map block="map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh"
export function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number { export function map(value: number, fromLow: number, fromHigh: number, toLow: number, toHigh: number): number {
return ((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow) + toLow; return ((value - fromLow) * (toHigh - toLow)) / (fromHigh - fromLow) + toLow;
@ -20,6 +20,8 @@ namespace pins {
/** /**
* Read one number from 7-bit I2C address. * Read one number from 7-bit I2C address.
*/ */
//% help=pins/i2c-read-number
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7
export function i2cReadNumber(address: number, format: NumberFormat): number { export function i2cReadNumber(address: number, format: NumberFormat): number {
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format)) let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))
return buf.getNumber(format, 0) return buf.getNumber(format, 0)
@ -28,6 +30,8 @@ namespace pins {
/** /**
* Write one number to a 7-bit I2C address. * Write one number to a 7-bit I2C address.
*/ */
//% help=pins/i2c-write-number
//% blockId=i2c_writenumber block="i2c write number|at address %address|with value %value|of format %format=i2c_sizeof" weight=6
export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void { export function i2cWriteNumber(address: number, value: number, format: NumberFormat): void {
let buf = createBuffer(pins.sizeOf(format)) let buf = createBuffer(pins.sizeOf(format))
buf.setNumber(format, 0, value) buf.setNumber(format, 0, value)
@ -37,6 +41,7 @@ namespace pins {
/** /**
* Get the size in bytes of specified number format. * Get the size in bytes of specified number format.
*/ */
//%
export function sizeOf(format: NumberFormat) { export function sizeOf(format: NumberFormat) {
switch (format) { switch (format) {
case NumberFormat.Int8LE: case NumberFormat.Int8LE:

View File

@ -26,8 +26,7 @@
"pins.ts", "pins.ts",
"serial.cpp", "serial.cpp",
"serial.ts", "serial.ts",
"buffer.cpp", "buffer.cpp"
"storage.cpp"
], ],
"public": true, "public": true,
"dependencies": {}, "dependencies": {},

View File

@ -597,37 +597,4 @@ declare interface Buffer {
write(dstOffset: number, src: Buffer): void; write(dstOffset: number, src: Buffer): void;
} }
/**
* This allows reading and writing of small blocks of data to FLASH memory.
*/
//% weight=10 color=#cc6600
declare namespace storage {
/**
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
* have to be rewritten as well.
*/
//% shim=storage::putBuffer
function putBuffer(key: string, buffer: Buffer): void;
/**
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
*/
//% shim=storage::getBuffer
function getBuffer(key: string): Buffer;
/**
* Removes an entry identified by the key.
*/
//% shim=storage::remove
function remove(key: string): void;
/**
* The number of entries in the key value store
*/
//% shim=storage::size
function size(): number;
}
// Auto-generated. Do not edit. Really. // Auto-generated. Do not edit. Really.

View File

@ -1,43 +0,0 @@
#include "ksbit.h"
/**
* This allows reading and writing of small blocks of data to FLASH memory.
*/
//% weight=10 color=#cc6600
namespace storage {
/**
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
* have to be rewritten as well.
*/
//%
void putBuffer(StringData* key, Buffer buffer) {
uBit.storage.put(ManagedString(key), ManagedBuffer(buffer).getBytes());
}
/**
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
*/
//%
Buffer getBuffer(StringData* key) {
KeyValuePair* pv = uBit.storage.get(ManagedString(key));
if (pv == NULL) return ManagedBuffer().leakData();
return ManagedBuffer(pv->value, sizeof(pv->value)).leakData();
}
/**
* Removes an entry identified by the key.
*/
//%
void remove(StringData * key) {
uBit.storage.remove(ManagedString(key));
}
/**
* The number of entries in the key value store
*/
//%
int size() {
return uBit.storage.size();
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.2.101", "version": "0.2.119",
"description": "BBC micro:bit target for PXT", "description": "BBC micro:bit target for PXT",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7" "typescript": "^1.8.7"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.2.114" "pxt-core": "0.2.129"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "microbit", "id": "microbit",
"name": "code micro:bit", "name": "m.pxt.io",
"title": "code micro:bit", "title": "m.pxt.io",
"corepkg": "microbit", "corepkg": "microbit",
"bundleddirs": [ "bundleddirs": [
"libs/microbit", "libs/microbit",
@ -63,7 +63,7 @@
"aspectRatio": 1.22 "aspectRatio": 1.22
}, },
"compileService": { "compileService": {
"gittag": "v0.1.8", "gittag": "v0.1.9",
"serviceId": "ws" "serviceId": "ws"
}, },
"serial": { "serial": {
@ -72,14 +72,18 @@
"log": true "log": true
}, },
"appTheme": { "appTheme": {
"logoUrl": "https://codemicrobit.com/about", "accentColor": "#5C2D91",
"logo": "./static/logo.svg", "logoUrl": "https://m.pxt.io/about",
"docsLogo": "./static/docslogo.svg", "logo": "./static/microbit.simplified.svg",
"portraitLogo":"./static/portraitlogo.svg", "docsLogo": "./static/microbit.simplified.svg",
"footerLogo": "./static/footerlogo.svg", "portraitLogo": "./static/microbit.simplified.svg",
"homeUrl": "https://codemicrobit.com/", "footerLogo": "./static/microbit.simplified.svg",
"embedUrl": "https://codemicrobit.com/", "organizationLogo": "./static/Microsoft-logo_rgb_c-gray.png",
"homeUrl": "https://m.pxt.io/",
"embedUrl": "https://m.pxt.io/",
"koduUrl": "https://www.kodugamelab.com/bbc-microbit/", "koduUrl": "https://www.kodugamelab.com/bbc-microbit/",
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
"visualStudioCode": true, "visualStudioCode": true,
"docMenu": [ "docMenu": [
{ {

View File

@ -449,16 +449,46 @@ namespace pxsim.radio {
board().radio.setTransmitPower(power); board().radio.setTransmitPower(power);
} }
export function sendNumbers(value0: number, value1: number, value2: number, value3: number): void { export function setTransmitSerialNumber(transmit: boolean): void {
board().radio.datagram.send([value0, value1, value2, value3]); board().radio.setTransmitSerialNumber(transmit);
}
export function sendNumber(value: number): void {
board().radio.datagram.send([value]);
}
export function sendString(msg: string): void {
board().radio.datagram.send(msg);
}
export function writeValueToSerial(): void {
let b = board();
let v = b.radio.datagram.recv().data[0];
b.writeSerial(`{v:${v}}`);
}
export function sendValue(name: string, value: number) {
board().radio.datagram.send([value]);
} }
export function receiveNumber(): number { export function receiveNumber(): number {
return board().radio.datagram.recv().data[0]; let buffer = board().radio.datagram.recv().data;
if (buffer instanceof Array) return buffer[0];
return 0;
}
export function receiveString(): string {
let buffer = board().radio.datagram.recv().data;
if (typeof buffer === "string") return <string>buffer;
return "";
} }
export function receivedNumberAt(index: number): number { export function receivedNumberAt(index: number): number {
return board().radio.datagram.lastReceived.data[index] || 0; let buffer = board().radio.datagram.recv().data;
if (buffer instanceof Array) return buffer[index] || 0;
return 0;
} }
export function receivedSignalStrength(): number { export function receivedSignalStrength(): number {

View File

@ -244,8 +244,9 @@ namespace pxsim.micro_bit {
let state = this.board; let state = this.board;
if (!state || !state.usesHeading) return; if (!state || !state.usesHeading) return;
if (!this.headInitialized) { if (!this.headInitialized) {
let p = this.head.firstChild.nextSibling as SVGPathElement; let p = svg.path(this.head, "sim-theme", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
p.setAttribute("d", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z"); this.logos.push(p);
this.updateTheme();
let pt = this.element.createSVGPoint(); let pt = this.element.createSVGPoint();
svg.buttonEvents( svg.buttonEvents(
this.head, this.head,
@ -253,13 +254,12 @@ namespace pxsim.micro_bit {
let cur = svg.cursorPoint(pt, this.element, ev); let cur = svg.cursorPoint(pt, this.element, ev);
state.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI + 90); state.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI + 90);
if (state.heading < 0) state.heading += 360; if (state.heading < 0) state.heading += 360;
console.log('heading: ' + state.heading)
this.updateHeading(); this.updateHeading();
}); });
this.headInitialized = true; this.headInitialized = true;
} }
let txt = state.heading.toString() + '°'; let txt = state.heading.toString() + "°";
if (txt != this.headText.textContent) { if (txt != this.headText.textContent) {
svg.rotateElement(this.head, xc, yc, state.heading + 180); svg.rotateElement(this.head, xc, yc, state.heading + 180);
this.headText.textContent = txt; this.headText.textContent = txt;
@ -273,7 +273,7 @@ namespace pxsim.micro_bit {
let now = Date.now(); let now = Date.now();
if (now - this.lastFlashTime > 150) { if (now - this.lastFlashTime > 150) {
this.lastFlashTime = now; this.lastFlashTime = now;
svg.animate(this.systemLed, 'sim-flash') svg.animate(this.systemLed, "sim-flash")
} }
} }
@ -452,6 +452,9 @@ svg.sim.grayscale {
animation-duration: 0.4s; animation-duration: 0.4s;
animation-timing-function: ease-in; animation-timing-function: ease-in;
} }
.sim-button-label {
fill:#fff;
}
@keyframes sim-flash-stroke-animation { @keyframes sim-flash-stroke-animation {
from { stroke: yellow; } from { stroke: yellow; }
@ -478,11 +481,11 @@ svg.sim.grayscale {
this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z"); this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z");
this.logos = []; this.logos = [];
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" }));
this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z")); //this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z"));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" }));
this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" })); //this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" }));
// leds // leds
this.leds = []; this.leds = [];
@ -501,9 +504,9 @@ svg.sim.grayscale {
// head // head
this.head = <SVGGElement>svg.child(this.g, "g", {}); this.head = <SVGGElement>svg.child(this.g, "g", {});
svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" }) svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" })
this.logos.push(svg.path(this.head, "sim-theme", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2")); //this.logos.push(svg.path(this.head, "sim-theme", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2"));
this.logos.push(svg.path(this.head, "sim-theme", "M230.6,69.7c-2.9,0-5.3,2.4-5.3,5.3c0,2.9,2.4,5.3,5.3,5.3c2.9,0,5.3-2.4,5.3-5.3C235.9,72.1,233.5,69.7,230.6,69.7")); //this.logos.push(svg.path(this.head, "sim-theme", "M230.6,69.7c-2.9,0-5.3,2.4-5.3,5.3c0,2.9,2.4,5.3,5.3,5.3c2.9,0,5.3-2.4,5.3-5.3C235.9,72.1,233.5,69.7,230.6,69.7"));
this.logos.push(svg.path(this.head, "sim-theme", "M269.7,80.3c2.9,0,5.3-2.4,5.3-5.3c0-2.9-2.4-5.3-5.3-5.3c-2.9,0-5.3,2.4-5.3,5.3C264.4,77.9,266.8,80.3,269.7,80.3")); //this.logos.push(svg.path(this.head, "sim-theme", "M269.7,80.3c2.9,0,5.3-2.4,5.3-5.3c0-2.9-2.4-5.3-5.3-5.3c-2.9,0-5.3,2.4-5.3,5.3C264.4,77.9,266.8,80.3,269.7,80.3"));
this.headText = <SVGTextElement>svg.child(this.g, "text", { x: 310, y: 100, class: "sim-text" }) this.headText = <SVGTextElement>svg.child(this.g, "text", { x: 310, y: 100, class: "sim-text" })
// https://www.microbit.co.uk/device/pins // https://www.microbit.co.uk/device/pins
@ -567,9 +570,10 @@ svg.sim.grayscale {
svg.path(this.g, "sim-label", "M35.7,376.4c0-2.8,2.1-5.1,5.5-5.1c3.3,0,5.5,2.4,5.5,5.1v4.7c0,2.8-2.2,5.1-5.5,5.1c-3.3,0-5.5-2.4-5.5-5.1V376.4zM43.3,376.4c0-1.3-0.8-2.3-2.2-2.3c-1.3,0-2.1,1.1-2.1,2.3v4.7c0,1.2,0.8,2.3,2.1,2.3c1.3,0,2.2-1.1,2.2-2.3V376.4z"); svg.path(this.g, "sim-label", "M35.7,376.4c0-2.8,2.1-5.1,5.5-5.1c3.3,0,5.5,2.4,5.5,5.1v4.7c0,2.8-2.2,5.1-5.5,5.1c-3.3,0-5.5-2.4-5.5-5.1V376.4zM43.3,376.4c0-1.3-0.8-2.3-2.2-2.3c-1.3,0-2.1,1.1-2.1,2.3v4.7c0,1.2,0.8,2.3,2.1,2.3c1.3,0,2.2-1.1,2.2-2.3V376.4z");
svg.path(this.g, "sim-label", "M136.2,374.1c2.8,0,3.4-0.8,3.4-2.5h2.9v14.3h-3.4v-9.5h-3V374.1z"); svg.path(this.g, "sim-label", "M136.2,374.1c2.8,0,3.4-0.8,3.4-2.5h2.9v14.3h-3.4v-9.5h-3V374.1z");
svg.path(this.g, "sim-label", "M248.6,378.5c1.7-1,3-1.7,3-3.1c0-1.1-0.7-1.6-1.6-1.6c-1,0-1.8,0.6-1.8,2.1h-3.3c0-2.6,1.8-4.6,5.1-4.6c2.6,0,4.9,1.3,4.9,4.3c0,2.4-2.3,3.9-3.8,4.7c-2,1.3-2.5,1.8-2.5,2.9h6.1v2.7h-10C244.8,381.2,246.4,379.9,248.6,378.5z"); svg.path(this.g, "sim-label", "M248.6,378.5c1.7-1,3-1.7,3-3.1c0-1.1-0.7-1.6-1.6-1.6c-1,0-1.8,0.6-1.8,2.1h-3.3c0-2.6,1.8-4.6,5.1-4.6c2.6,0,4.9,1.3,4.9,4.3c0,2.4-2.3,3.9-3.8,4.7c-2,1.3-2.5,1.8-2.5,2.9h6.1v2.7h-10C244.8,381.2,246.4,379.9,248.6,378.5z");
svg.path(this.g, "sim-label", "M48.1,270.9l-0.6-1.7h-5.1l-0.6,1.7h-3.5l5.1-14.3h3.1l5.2,14.3H48.1z M45,260.7l-1.8,5.9h3.5L45,260.7z");
svg.path(this.g, "sim-label", "M449.1,135.8h5.9c3.9,0,4.7,2.4,4.7,3.9c0,1.8-1.4,2.9-2.5,3.2c0.9,0,2.6,1.1,2.6,3.3c0,1.5-0.8,4-4.7,4h-6V135.8zM454.4,141.7c1.6,0,2-1,2-1.7c0-0.6-0.3-1.7-2-1.7h-2v3.4H454.4z M452.4,144.1v3.5h2.1c1.6,0,2-1,2-1.8c0-0.7-0.4-1.8-2-1.8H452.4z") svg.path(this.g, "sim-button-label", "M48.1,270.9l-0.6-1.7h-5.1l-0.6,1.7h-3.5l5.1-14.3h3.1l5.2,14.3H48.1z M45,260.7l-1.8,5.9h3.5L45,260.7z");
svg.path(this.g, "sim-button-label", "M449.1,135.8h5.9c3.9,0,4.7,2.4,4.7,3.9c0,1.8-1.4,2.9-2.5,3.2c0.9,0,2.6,1.1,2.6,3.3c0,1.5-0.8,4-4.7,4h-6V135.8zM454.4,141.7c1.6,0,2-1,2-1.7c0-0.6-0.3-1.7-2-1.7h-2v3.4H454.4z M452.4,144.1v3.5h2.1c1.6,0,2-1,2-1.8c0-0.7-0.4-1.8-2-1.8H452.4z")
svg.path(this.g, "sim-label", "M352.1,381.1c0,1.6,0.9,2.5,2.2,2.5c1.2,0,1.9-0.9,1.9-1.9c0-1.2-0.6-2-2.1-2h-1.3v-2.6h1.3c1.5,0,1.9-0.7,1.9-1.8c0-1.1-0.7-1.6-1.6-1.6c-1.4,0-1.8,0.8-1.8,2.1h-3.3c0-2.4,1.5-4.6,5.1-4.6c2.6,0,5,1.3,5,4c0,1.6-1,2.8-2.1,3.2c1.3,0.5,2.3,1.6,2.3,3.5c0,2.7-2.4,4.3-5.2,4.3c-3.5,0-5.5-2.1-5.5-5.1H352.1z") svg.path(this.g, "sim-label", "M352.1,381.1c0,1.6,0.9,2.5,2.2,2.5c1.2,0,1.9-0.9,1.9-1.9c0-1.2-0.6-2-2.1-2h-1.3v-2.6h1.3c1.5,0,1.9-0.7,1.9-1.8c0-1.1-0.7-1.6-1.6-1.6c-1.4,0-1.8,0.8-1.8,2.1h-3.3c0-2.4,1.5-4.6,5.1-4.6c2.6,0,5,1.3,5,4c0,1.6-1,2.8-2.1,3.2c1.3,0.5,2.3,1.6,2.3,3.5c0,2.7-2.4,4.3-5.2,4.3c-3.5,0-5.5-2.1-5.5-5.1H352.1z")
svg.path(this.g, "sim-label", "M368.5,385.9h-3.1l-5.1-14.3h3.5l3.1,10.1l3.1-10.1h3.6L368.5,385.9z") svg.path(this.g, "sim-label", "M368.5,385.9h-3.1l-5.1-14.3h3.5l3.1,10.1l3.1-10.1h3.6L368.5,385.9z")
svg.path(this.g, "sim-label", "M444.4,378.3h7.4v2.5h-1.5c-0.6,3.3-3,5.5-7.1,5.5c-4.8,0-7.5-3.5-7.5-7.5c0-3.9,2.8-7.5,7.5-7.5c3.8,0,6.4,2.3,6.6,5h-3.5c-0.2-1.1-1.4-2.2-3.1-2.2c-2.7,0-4.1,2.3-4.1,4.7c0,2.5,1.4,4.7,4.4,4.7c2,0,3.2-1.2,3.4-2.7h-2.5V378.3z") svg.path(this.g, "sim-label", "M444.4,378.3h7.4v2.5h-1.5c-0.6,3.3-3,5.5-7.1,5.5c-4.8,0-7.5-3.5-7.5-7.5c0-3.9,2.8-7.5,7.5-7.5c3.8,0,6.4,2.3,6.6,5h-3.5c-0.2-1.1-1.4-2.2-3.1-2.2c-2.7,0-4.1,2.3-4.1,4.7c0,2.5,1.4,4.7,4.4,4.7c2,0,3.2-1.2,3.4-2.7h-2.5V378.3z")

View File

@ -56,7 +56,7 @@ namespace pxsim {
} }
export interface PacketBuffer { export interface PacketBuffer {
data: number[]; data: number[] | string;
rssi?: number; rssi?: number;
} }
@ -77,15 +77,18 @@ namespace pxsim {
} }
} }
send(buffer: number[]) { send(buffer: number[] | string) {
if (buffer instanceof String) buffer = buffer.slice(0, 32);
else buffer = buffer.slice(0, 8);
Runtime.postMessage(<SimulatorRadioPacketMessage>{ Runtime.postMessage(<SimulatorRadioPacketMessage>{
type: 'radiopacket', type: "radiopacket",
data: buffer.slice(0, 8) data: buffer
}) })
} }
recv(): PacketBuffer { recv(): PacketBuffer {
var r = this.datagram.shift(); let r = this.datagram.shift();
if (!r) r = { if (!r) r = {
data: [0, 0, 0, 0], data: [0, 0, 0, 0],
rssi: -1 rssi: -1
@ -98,6 +101,7 @@ namespace pxsim {
// uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP; // uint8_t radioDefaultGroup = MICROBIT_RADIO_DEFAULT_GROUP;
groupId = 0; // todo groupId = 0; // todo
power = 0; power = 0;
transmitSerialNumber = false;
datagram: RadioDatagram; datagram: RadioDatagram;
constructor(private runtime: Runtime) { constructor(private runtime: Runtime) {
@ -112,6 +116,10 @@ namespace pxsim {
this.power = Math.max(0, Math.min(7, power)); this.power = Math.max(0, Math.min(7, power));
} }
setTransmitSerialNumber(sn: boolean) {
this.transmitSerialNumber = !!sn;
}
broadcast(msg: number) { broadcast(msg: number) {
Runtime.postMessage(<SimulatorEventBusMessage>{ Runtime.postMessage(<SimulatorEventBusMessage>{
type: 'eventbus', type: 'eventbus',
@ -123,21 +131,6 @@ namespace pxsim {
} }
} }
export enum BasicGesture {
GESTURE_NONE,
GESTURE_UP,
GESTURE_DOWN,
GESTURE_LEFT,
GESTURE_RIGHT,
GESTURE_FACE_UP,
GESTURE_FACE_DOWN,
GESTURE_FREEFALL,
GESTURE_3G,
GESTURE_6G,
GESTURE_8G,
GESTURE_SHAKE
};
interface AccelerometerSample { interface AccelerometerSample {
x: number; x: number;
y: number; y: number;
@ -191,8 +184,8 @@ namespace pxsim {
export class Accelerometer { export class Accelerometer {
private sigma: number = 0; // the number of ticks that the instantaneous gesture has been stable. private sigma: number = 0; // the number of ticks that the instantaneous gesture has been stable.
private lastGesture: BasicGesture = BasicGesture.GESTURE_NONE; // the last, stable gesture recorded. private lastGesture: number = 0; // the last, stable gesture recorded.
private currentGesture: BasicGesture = BasicGesture.GESTURE_NONE; // the instantaneous, unfiltered gesture detected. private currentGesture: number = 0 // the instantaneous, unfiltered gesture detected.
private sample: AccelerometerSample = { x: 0, y: 0, z: -1023 } private sample: AccelerometerSample = { x: 0, y: 0, z: -1023 }
private shake: ShakeHistory = { x: false, y: false, z: false, count: 0, shaken: 0, timer: 0 }; // State information needed to detect shake events. private shake: ShakeHistory = { x: false, y: false, z: false, count: 0, shaken: 0, timer: 0 }; // State information needed to detect shake events.
private pitch: number; private pitch: number;
@ -245,7 +238,7 @@ namespace pxsim {
* *
* @return A best guess of the current posture of the device, based on instantaneous data. * @return A best guess of the current posture of the device, based on instantaneous data.
*/ */
private instantaneousPosture(): BasicGesture { private instantaneousPosture(): number {
let force = this.instantaneousAccelerationSquared(); let force = this.instantaneousAccelerationSquared();
let shakeDetected = false; let shakeDetected = false;
@ -282,42 +275,42 @@ namespace pxsim {
} }
if (this.shake.shaken) if (this.shake.shaken)
return BasicGesture.GESTURE_SHAKE; return DAL.MICROBIT_ACCELEROMETER_EVT_SHAKE;
let sq = (n: number) => n * n let sq = (n: number) => n * n
if (force < sq(DAL.MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE)) if (force < sq(DAL.MICROBIT_ACCELEROMETER_FREEFALL_TOLERANCE))
return BasicGesture.GESTURE_FREEFALL; return DAL.MICROBIT_ACCELEROMETER_EVT_FREEFALL;
if (force > sq(DAL.MICROBIT_ACCELEROMETER_3G_TOLERANCE)) if (force > sq(DAL.MICROBIT_ACCELEROMETER_3G_TOLERANCE))
return BasicGesture.GESTURE_3G; return DAL.MICROBIT_ACCELEROMETER_EVT_3G;
if (force > sq(DAL.MICROBIT_ACCELEROMETER_6G_TOLERANCE)) if (force > sq(DAL.MICROBIT_ACCELEROMETER_6G_TOLERANCE))
return BasicGesture.GESTURE_6G; return DAL.MICROBIT_ACCELEROMETER_EVT_6G;
if (force > sq(DAL.MICROBIT_ACCELEROMETER_8G_TOLERANCE)) if (force > sq(DAL.MICROBIT_ACCELEROMETER_8G_TOLERANCE))
return BasicGesture.GESTURE_8G; return DAL.MICROBIT_ACCELEROMETER_EVT_8G;
// Determine our posture. // Determine our posture.
if (this.getX() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getX() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_LEFT; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_LEFT;
if (this.getX() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getX() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_RIGHT; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT;
if (this.getY() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getY() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_DOWN; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_DOWN;
if (this.getY() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getY() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_UP; return DAL.MICROBIT_ACCELEROMETER_EVT_TILT_UP;
if (this.getZ() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getZ() < (-1000 + DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_FACE_UP; return DAL.MICROBIT_ACCELEROMETER_EVT_FACE_UP;
if (this.getZ() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE)) if (this.getZ() > (1000 - DAL.MICROBIT_ACCELEROMETER_TILT_TOLERANCE))
return BasicGesture.GESTURE_FACE_DOWN; return DAL.MICROBIT_ACCELEROMETER_EVT_FACE_DOWN;
return BasicGesture.GESTURE_NONE; return 0;
} }
updateGesture() { updateGesture() {
@ -573,16 +566,16 @@ namespace pxsim {
if (!runtime || runtime.dead) return; if (!runtime || runtime.dead) return;
switch (msg.type || "") { switch (msg.type || "") {
case 'eventbus': case "eventbus":
let ev = <SimulatorEventBusMessage>msg; let ev = <SimulatorEventBusMessage>msg;
this.bus.queue(ev.id, ev.eventid, ev.value); this.bus.queue(ev.id, ev.eventid, ev.value);
break; break;
case 'serial': case "serial":
this.serialIn.push((<SimulatorSerialMessage>msg).data || ''); this.serialIn.push((<SimulatorSerialMessage>msg).data || "");
break; break;
case 'radiopacket': case "radiopacket":
let packet = <SimulatorRadioPacketMessage>msg; let packet = <SimulatorRadioPacketMessage>msg;
this.radio.datagram.queue({ data: packet.data || [], rssi: packet.rssi || 0 }) this.radio.datagram.queue({ data: packet.data, rssi: packet.rssi || 0 })
break; break;
} }
} }
@ -647,7 +640,7 @@ namespace pxsim {
} }
public clear(): void { public clear(): void {
for (var i = 0; i < this.data.length; ++i) for (let i = 0; i < this.data.length; ++i)
this.data[i] = 0; this.data[i] = 0;
} }
} }
@ -683,11 +676,11 @@ namespace pxsim {
} }
export function createFont(): Image { export function createFont(): Image {
var data = [0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x8, 0x0, 0x8, 0xa, 0x4a, 0x40, 0x0, 0x0, 0xa, 0x5f, 0xea, 0x5f, 0xea, 0xe, 0xd9, 0x2e, 0xd3, 0x6e, 0x19, 0x32, 0x44, 0x89, 0x33, 0xc, 0x92, 0x4c, 0x92, 0x4d, 0x8, 0x8, 0x0, 0x0, 0x0, 0x4, 0x88, 0x8, 0x8, 0x4, 0x8, 0x4, 0x84, 0x84, 0x88, 0x0, 0xa, 0x44, 0x8a, 0x40, 0x0, 0x4, 0x8e, 0xc4, 0x80, 0x0, 0x0, 0x0, 0x4, 0x88, 0x0, 0x0, 0xe, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x22, 0x44, 0x88, 0x10, 0xc, 0x92, 0x52, 0x52, 0x4c, 0x4, 0x8c, 0x84, 0x84, 0x8e, 0x1c, 0x82, 0x4c, 0x90, 0x1e, 0x1e, 0xc2, 0x44, 0x92, 0x4c, 0x6, 0xca, 0x52, 0x5f, 0xe2, 0x1f, 0xf0, 0x1e, 0xc1, 0x3e, 0x2, 0x44, 0x8e, 0xd1, 0x2e, 0x1f, 0xe2, 0x44, 0x88, 0x10, 0xe, 0xd1, 0x2e, 0xd1, 0x2e, 0xe, 0xd1, 0x2e, 0xc4, 0x88, 0x0, 0x8, 0x0, 0x8, 0x0, 0x0, 0x4, 0x80, 0x4, 0x88, 0x2, 0x44, 0x88, 0x4, 0x82, 0x0, 0xe, 0xc0, 0xe, 0xc0, 0x8, 0x4, 0x82, 0x44, 0x88, 0xe, 0xd1, 0x26, 0xc0, 0x4, 0xe, 0xd1, 0x35, 0xb3, 0x6c, 0xc, 0x92, 0x5e, 0xd2, 0x52, 0x1c, 0x92, 0x5c, 0x92, 0x5c, 0xe, 0xd0, 0x10, 0x10, 0xe, 0x1c, 0x92, 0x52, 0x52, 0x5c, 0x1e, 0xd0, 0x1c, 0x90, 0x1e, 0x1e, 0xd0, 0x1c, 0x90, 0x10, 0xe, 0xd0, 0x13, 0x71, 0x2e, 0x12, 0x52, 0x5e, 0xd2, 0x52, 0x1c, 0x88, 0x8, 0x8, 0x1c, 0x1f, 0xe2, 0x42, 0x52, 0x4c, 0x12, 0x54, 0x98, 0x14, 0x92, 0x10, 0x10, 0x10, 0x10, 0x1e, 0x11, 0x3b, 0x75, 0xb1, 0x31, 0x11, 0x39, 0x35, 0xb3, 0x71, 0xc, 0x92, 0x52, 0x52, 0x4c, 0x1c, 0x92, 0x5c, 0x90, 0x10, 0xc, 0x92, 0x52, 0x4c, 0x86, 0x1c, 0x92, 0x5c, 0x92, 0x51, 0xe, 0xd0, 0xc, 0x82, 0x5c, 0x1f, 0xe4, 0x84, 0x84, 0x84, 0x12, 0x52, 0x52, 0x52, 0x4c, 0x11, 0x31, 0x31, 0x2a, 0x44, 0x11, 0x31, 0x35, 0xbb, 0x71, 0x12, 0x52, 0x4c, 0x92, 0x52, 0x11, 0x2a, 0x44, 0x84, 0x84, 0x1e, 0xc4, 0x88, 0x10, 0x1e, 0xe, 0xc8, 0x8, 0x8, 0xe, 0x10, 0x8, 0x4, 0x82, 0x41, 0xe, 0xc2, 0x42, 0x42, 0x4e, 0x4, 0x8a, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x8, 0x4, 0x80, 0x0, 0x0, 0x0, 0xe, 0xd2, 0x52, 0x4f, 0x10, 0x10, 0x1c, 0x92, 0x5c, 0x0, 0xe, 0xd0, 0x10, 0xe, 0x2, 0x42, 0x4e, 0xd2, 0x4e, 0xc, 0x92, 0x5c, 0x90, 0xe, 0x6, 0xc8, 0x1c, 0x88, 0x8, 0xe, 0xd2, 0x4e, 0xc2, 0x4c, 0x10, 0x10, 0x1c, 0x92, 0x52, 0x8, 0x0, 0x8, 0x8, 0x8, 0x2, 0x40, 0x2, 0x42, 0x4c, 0x10, 0x14, 0x98, 0x14, 0x92, 0x8, 0x8, 0x8, 0x8, 0x6, 0x0, 0x1b, 0x75, 0xb1, 0x31, 0x0, 0x1c, 0x92, 0x52, 0x52, 0x0, 0xc, 0x92, 0x52, 0x4c, 0x0, 0x1c, 0x92, 0x5c, 0x90, 0x0, 0xe, 0xd2, 0x4e, 0xc2, 0x0, 0xe, 0xd0, 0x10, 0x10, 0x0, 0x6, 0xc8, 0x4, 0x98, 0x8, 0x8, 0xe, 0xc8, 0x7, 0x0, 0x12, 0x52, 0x52, 0x4f, 0x0, 0x11, 0x31, 0x2a, 0x44, 0x0, 0x11, 0x31, 0x35, 0xbb, 0x0, 0x12, 0x4c, 0x8c, 0x92, 0x0, 0x11, 0x2a, 0x44, 0x98, 0x0, 0x1e, 0xc4, 0x88, 0x1e, 0x6, 0xc4, 0x8c, 0x84, 0x86, 0x8, 0x8, 0x8, 0x8, 0x8, 0x18, 0x8, 0xc, 0x88, 0x18, 0x0, 0x0, 0xc, 0x83, 0x60]; const data = [0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x8, 0x0, 0x8, 0xa, 0x4a, 0x40, 0x0, 0x0, 0xa, 0x5f, 0xea, 0x5f, 0xea, 0xe, 0xd9, 0x2e, 0xd3, 0x6e, 0x19, 0x32, 0x44, 0x89, 0x33, 0xc, 0x92, 0x4c, 0x92, 0x4d, 0x8, 0x8, 0x0, 0x0, 0x0, 0x4, 0x88, 0x8, 0x8, 0x4, 0x8, 0x4, 0x84, 0x84, 0x88, 0x0, 0xa, 0x44, 0x8a, 0x40, 0x0, 0x4, 0x8e, 0xc4, 0x80, 0x0, 0x0, 0x0, 0x4, 0x88, 0x0, 0x0, 0xe, 0xc0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x22, 0x44, 0x88, 0x10, 0xc, 0x92, 0x52, 0x52, 0x4c, 0x4, 0x8c, 0x84, 0x84, 0x8e, 0x1c, 0x82, 0x4c, 0x90, 0x1e, 0x1e, 0xc2, 0x44, 0x92, 0x4c, 0x6, 0xca, 0x52, 0x5f, 0xe2, 0x1f, 0xf0, 0x1e, 0xc1, 0x3e, 0x2, 0x44, 0x8e, 0xd1, 0x2e, 0x1f, 0xe2, 0x44, 0x88, 0x10, 0xe, 0xd1, 0x2e, 0xd1, 0x2e, 0xe, 0xd1, 0x2e, 0xc4, 0x88, 0x0, 0x8, 0x0, 0x8, 0x0, 0x0, 0x4, 0x80, 0x4, 0x88, 0x2, 0x44, 0x88, 0x4, 0x82, 0x0, 0xe, 0xc0, 0xe, 0xc0, 0x8, 0x4, 0x82, 0x44, 0x88, 0xe, 0xd1, 0x26, 0xc0, 0x4, 0xe, 0xd1, 0x35, 0xb3, 0x6c, 0xc, 0x92, 0x5e, 0xd2, 0x52, 0x1c, 0x92, 0x5c, 0x92, 0x5c, 0xe, 0xd0, 0x10, 0x10, 0xe, 0x1c, 0x92, 0x52, 0x52, 0x5c, 0x1e, 0xd0, 0x1c, 0x90, 0x1e, 0x1e, 0xd0, 0x1c, 0x90, 0x10, 0xe, 0xd0, 0x13, 0x71, 0x2e, 0x12, 0x52, 0x5e, 0xd2, 0x52, 0x1c, 0x88, 0x8, 0x8, 0x1c, 0x1f, 0xe2, 0x42, 0x52, 0x4c, 0x12, 0x54, 0x98, 0x14, 0x92, 0x10, 0x10, 0x10, 0x10, 0x1e, 0x11, 0x3b, 0x75, 0xb1, 0x31, 0x11, 0x39, 0x35, 0xb3, 0x71, 0xc, 0x92, 0x52, 0x52, 0x4c, 0x1c, 0x92, 0x5c, 0x90, 0x10, 0xc, 0x92, 0x52, 0x4c, 0x86, 0x1c, 0x92, 0x5c, 0x92, 0x51, 0xe, 0xd0, 0xc, 0x82, 0x5c, 0x1f, 0xe4, 0x84, 0x84, 0x84, 0x12, 0x52, 0x52, 0x52, 0x4c, 0x11, 0x31, 0x31, 0x2a, 0x44, 0x11, 0x31, 0x35, 0xbb, 0x71, 0x12, 0x52, 0x4c, 0x92, 0x52, 0x11, 0x2a, 0x44, 0x84, 0x84, 0x1e, 0xc4, 0x88, 0x10, 0x1e, 0xe, 0xc8, 0x8, 0x8, 0xe, 0x10, 0x8, 0x4, 0x82, 0x41, 0xe, 0xc2, 0x42, 0x42, 0x4e, 0x4, 0x8a, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1f, 0x8, 0x4, 0x80, 0x0, 0x0, 0x0, 0xe, 0xd2, 0x52, 0x4f, 0x10, 0x10, 0x1c, 0x92, 0x5c, 0x0, 0xe, 0xd0, 0x10, 0xe, 0x2, 0x42, 0x4e, 0xd2, 0x4e, 0xc, 0x92, 0x5c, 0x90, 0xe, 0x6, 0xc8, 0x1c, 0x88, 0x8, 0xe, 0xd2, 0x4e, 0xc2, 0x4c, 0x10, 0x10, 0x1c, 0x92, 0x52, 0x8, 0x0, 0x8, 0x8, 0x8, 0x2, 0x40, 0x2, 0x42, 0x4c, 0x10, 0x14, 0x98, 0x14, 0x92, 0x8, 0x8, 0x8, 0x8, 0x6, 0x0, 0x1b, 0x75, 0xb1, 0x31, 0x0, 0x1c, 0x92, 0x52, 0x52, 0x0, 0xc, 0x92, 0x52, 0x4c, 0x0, 0x1c, 0x92, 0x5c, 0x90, 0x0, 0xe, 0xd2, 0x4e, 0xc2, 0x0, 0xe, 0xd0, 0x10, 0x10, 0x0, 0x6, 0xc8, 0x4, 0x98, 0x8, 0x8, 0xe, 0xc8, 0x7, 0x0, 0x12, 0x52, 0x52, 0x4f, 0x0, 0x11, 0x31, 0x2a, 0x44, 0x0, 0x11, 0x31, 0x35, 0xbb, 0x0, 0x12, 0x4c, 0x8c, 0x92, 0x0, 0x11, 0x2a, 0x44, 0x98, 0x0, 0x1e, 0xc4, 0x88, 0x1e, 0x6, 0xc4, 0x8c, 0x84, 0x86, 0x8, 0x8, 0x8, 0x8, 0x8, 0x18, 0x8, 0xc, 0x88, 0x18, 0x0, 0x0, 0xc, 0x83, 0x60];
let nb = data.length; let nb = data.length;
let n = nb / 5; let n = nb / 5;
var font = createImage(nb); let font = createImage(nb);
for (let c = 0; c < n; c++) { for (let c = 0; c < n; c++) {
for (let row = 0; row < 5; row++) { for (let row = 0; row < 5; row++) {
let char = data[c * 5 + row]; let char = data[c * 5 + row];

View File

@ -444,13 +444,11 @@
"pvjilh", "pvjilh",
"pvqrgm", "pvqrgm",
"pvzmhz", "pvzmhz",
"pwlxyy",
"pxebwk", "pxebwk",
"pxizap", "pxizap",
"pxyovu", "pxyovu",
"pymfqh", "pymfqh",
"pzmjbx", "pzmjbx",
"pzptoo",
"pzucty", "pzucty",
"rannhh", "rannhh",
"rbnvdq", "rbnvdq",

View File

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.25123.0 VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "codemicrobit", "app\codemicrobit.jsproj", "{39122940-AB16-4CD4-A0CE-79A3EB863ECF}" Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "m.pxt.io", "app\m.pxt.io.jsproj", "{39122940-AB16-4CD4-A0CE-79A3EB863ECF}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -1 +1 @@
MainPackage=C:\gh\pxt-microbit\win10\app\bin\Debug\codemicrobit_0.1.3.0_AnyCPU_Debug.appx MainPackage=C:\gh\pxt-microbit\win10\app\bin\Debug\m.pxt.io_0.1.4.0_AnyCPU_Debug.appx

Binary file not shown.

Before

Width:  |  Height:  |  Size: 807 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

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