Merge remote-tracking branch 'refs/remotes/origin/master' into docs
|
@ -13,4 +13,5 @@ notifications:
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
|
- built/cache
|
||||||
|
|
||||||
|
|
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
// Place your settings in this file to overwrite default and user settings.
|
||||||
|
{
|
||||||
|
"tslint.enable": true,
|
||||||
|
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib"
|
||||||
|
}
|
|
@ -12,7 +12,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
|
||||||
|
|
||||||
|
|
22
docs/_locales/pl/_theme.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "koduj z micro:bit",
|
||||||
|
"title": "koduj z micro:bit",
|
||||||
|
"docMenu": [
|
||||||
|
{
|
||||||
|
"name": "O nas",
|
||||||
|
"path": "/about"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Lekcje",
|
||||||
|
"path": "/lessons"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Instrukcja obsługi",
|
||||||
|
"path": "/reference"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Urządzenie",
|
||||||
|
"path": "/device"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
7
docs/_locales/pl/docs.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Dokumentacja
|
||||||
|
|
||||||
|
Witamy na stronach dokumentacji!
|
||||||
|
|
||||||
|
* Przeglądnij [instrukcje obsługi](/reference)
|
||||||
|
* Dowiedz się więcej o [urządzeniu](/device)
|
||||||
|
* Wystartuj z [lekcjami](/lessons)
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Welcome to the documentation.
|
Welcome to the documentation.
|
||||||
|
|
||||||
* Browse the [reference](/reference)
|
* Browse the [API reference](/reference)
|
||||||
* Learn more about the [device](/device)
|
* Learn more about the [device](/device)
|
||||||
* Get started with [lessons](/lessons)
|
* Get started with [lessons](/lessons)
|
||||||
|
* Learn about [libraries](/libraries) (possibly using C++)
|
||||||
|
|
|
@ -57,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
|
||||||
|
@ -68,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)
|
||||||
|
|
||||||
|
|
|
@ -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`.
|
||||||
|
|
||||||
|
|
|
@ -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")
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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?
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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:
|
||||||
|
|
29
docs/lessons/catch-the-egg-game/tutorial.md
Normal 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)
|
||||||
|
})
|
||||||
|
```
|
|
@ -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.
|
||||||
|
|
||||||
|
|
|
@ -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`.
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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?
|
||||||
|
|
||||||
|
|
29
docs/lessons/glowing-pendulum/tutorial.md
Normal 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)
|
||||||
|
});
|
||||||
|
```
|
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
25
docs/lessons/guess-the-number/tutorial.md
Normal 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)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
|
@ -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...
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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!".
|
||||||
|
|
||||||
|
|
27
docs/lessons/magic-8/tutorial.md
Normal 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")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
|
@ -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!
|
||||||
|
|
|
@ -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`.
|
||||||
|
|
||||||
|
|
|
@ -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`.
|
||||||
|
|
||||||
|
|
|
@ -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()`.
|
||||||
|
|
||||||
|
|
|
@ -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".
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
63
docs/lessons/truth-or-dare/tutorial.md
Normal 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, () => {});
|
||||||
|
```
|
||||||
|
|
14
docs/libraries.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Extensions
|
||||||
|
|
||||||
|
You can publish libraries (also known as packages or extensions)
|
||||||
|
that users can then add to their scripts. These typically
|
||||||
|
provide a driver for a particular hardware device you can connect
|
||||||
|
to a microbit.
|
||||||
|
|
||||||
|
* [Sample C++ extension](https://github.com/Microsoft/pxt-microbit-cppsample)
|
||||||
|
* [Sample TypeScript extension](https://github.com/Microsoft/pxt-microbit/tree/master/libs/i2c-fram)
|
||||||
|
|
||||||
|
## Finding libraries
|
||||||
|
|
||||||
|
## Publishing libraries
|
||||||
|
|
23
docs/microbit-reference.md
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# microbit Reference
|
||||||
|
|
||||||
|
```namespaces
|
||||||
|
basic.showNumber(0);
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
|
||||||
|
});
|
||||||
|
led.plot(0, 0);
|
||||||
|
music.playTone(0, 0);
|
||||||
|
game.addScore(1);
|
||||||
|
images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`);
|
||||||
|
pins.digitalReadPin(DigitalPin.P0);
|
||||||
|
serial.writeValue(x, 0);
|
||||||
|
control.inBackground(() => {
|
||||||
|
|
||||||
|
});
|
||||||
|
```
|
|
@ -1,17 +1,27 @@
|
||||||
# Reference
|
# Reference
|
||||||
|
|
||||||
```namespaces
|
```namespaces
|
||||||
basic.showString("Hello!");
|
|
||||||
input.onButtonPressed(Button.A, () => {});
|
|
||||||
for (let i = 0;i<5;++i) {}
|
for (let i = 0;i<5;++i) {}
|
||||||
if (true){}
|
if (true){}
|
||||||
let x = 0;
|
let x = 0;
|
||||||
Math.random(5);
|
Math.random(5);
|
||||||
|
basic.showNumber(0);
|
||||||
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
|
||||||
|
});
|
||||||
led.plot(0, 0);
|
led.plot(0, 0);
|
||||||
radio.sendNumber(0);
|
music.playTone(0, 0);
|
||||||
music.playTone(music.noteFrequency(Note.C), music.beat(BeatFraction.Whole));
|
game.addScore(1);
|
||||||
game.createSprite(2,2);
|
images.createImage(`
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
. . # . .
|
||||||
|
. . . . .
|
||||||
|
. . . . .
|
||||||
|
`);
|
||||||
pins.digitalReadPin(DigitalPin.P0);
|
pins.digitalReadPin(DigitalPin.P0);
|
||||||
serial.writeLine("Hello!");
|
serial.writeValue(x, 0);
|
||||||
control.inBackground(() => {});
|
control.inBackground(() => {
|
||||||
```
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
Provides access to basic micro:bit functionality.
|
Provides access to basic micro:bit functionality.
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
basic.showNumber(0);
|
basic.showNumber(0);
|
||||||
basic.showLeds(`
|
basic.showLeds(`
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Control
|
# Control
|
||||||
|
|
||||||
|
Runtime and event utilities.
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
control.inBackground(() => {
|
control.inBackground(() => {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Game
|
# Game
|
||||||
|
|
||||||
|
A single-LED sprite game engine
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
game.addScore(1);
|
game.addScore(1);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Images
|
# Images
|
||||||
|
|
||||||
|
Creation, manipulation and display of LED images.
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
images.createImage(`
|
images.createImage(`
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Input
|
# Input
|
||||||
|
|
||||||
|
Events and data from sensors
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
input.onButtonPressed(Button.A, () => {
|
input.onButtonPressed(Button.A, () => {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Led
|
# Led
|
||||||
|
|
||||||
|
Control of the LED screen.
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
led.plot(0, 0);
|
led.plot(0, 0);
|
||||||
|
@ -10,7 +9,7 @@ led.point(0, 0);
|
||||||
led.brightness();
|
led.brightness();
|
||||||
led.setBrightness(255);
|
led.setBrightness(255);
|
||||||
led.stopAnimation();
|
led.stopAnimation();
|
||||||
led.plotBarGraph(0, 1023);
|
led.plotBarGraph(0, 0);
|
||||||
led.fadeIn();
|
led.fadeIn();
|
||||||
led.fadeOut();
|
led.fadeOut();
|
||||||
led.plotAll();
|
led.plotAll();
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
# Music
|
# Music
|
||||||
|
|
||||||
|
Generation of music tones through pin ``P0``.
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
music.playTone(0, 0);
|
music.playTone(0, 0);
|
||||||
music.ringTone(0);
|
music.ringTone(0);
|
||||||
music.rest(0);
|
music.rest(0);
|
||||||
music.noteFrequency(Note.C);
|
music.noteFrequency(Note.C);
|
||||||
music.beat();
|
music.beat(BeatFraction.Whole);
|
||||||
music.tempo();
|
music.tempo();
|
||||||
music.changeTempoBy(20);
|
music.changeTempoBy(20);
|
||||||
music.setTempo(120);
|
music.setTempo(120);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Pins
|
# Pins
|
||||||
|
|
||||||
|
Control currents in Pins for analog/digital signals, servos, i2c, ...
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
pins.digitalReadPin(DigitalPin.P0);
|
pins.digitalReadPin(DigitalPin.P0);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Radio
|
# Radio
|
||||||
|
|
||||||
|
Communicate data using radio packets
|
||||||
|
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
radio.sendNumber(0);
|
radio.sendNumber(0);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Serial
|
# Serial
|
||||||
|
|
||||||
[Serial communication](/device/serial) between the BBC micro:bit and another computer.
|
Reading and writing data over a serial connection.
|
||||||
|
|
||||||
```cards
|
```cards
|
||||||
|
serial.writeValue(x, 0);
|
||||||
serial.writeLine("");
|
serial.writeLine("");
|
||||||
serial.writeValue("x", 0);
|
|
||||||
```
|
```
|
||||||
|
|
1
docs/static/docslogo.svg
vendored
|
@ -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 |
BIN
docs/static/favicon.png
vendored
Before Width: | Height: | Size: 2.3 KiB |
1
docs/static/footerlogo.svg
vendored
|
@ -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 |
1
docs/static/logo.svg
vendored
|
@ -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 |
BIN
docs/static/logo128.png
vendored
Before Width: | Height: | Size: 18 KiB |
BIN
docs/static/logo32.png
vendored
Before Width: | Height: | Size: 2.3 KiB |
BIN
docs/static/logo512.png
vendored
Before Width: | Height: | Size: 129 KiB |
1
docs/static/microbit.docs.svg
vendored
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
docs/static/microbit.red.png
vendored
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
docs/static/microbit.red.square.png
vendored
Normal file
After Width: | Height: | Size: 2.0 KiB |
1
docs/static/microbit.red.svg
vendored
Normal file
After Width: | Height: | Size: 18 KiB |
1
docs/static/portraitlogo.svg
vendored
|
@ -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 |
64
docs/static/splashscreen.svg
vendored
|
@ -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 |
61
docs/static/squarelogo.svg
vendored
|
@ -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 |
9
docs/thank-you.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# You completed the survey!
|
||||||
|
|
||||||
|
```sim
|
||||||
|
basic.forever(() => { basic.showString("THANK YOU") })
|
||||||
|
```
|
||||||
|
|
||||||
|
Thank you for participating in this survey.
|
||||||
|
|
||||||
|
Please [contact us](mailto:microbitpilots@microsoft.com) with any information you think we might find useful.
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
using namespace pxt;
|
using namespace pxt;
|
||||||
|
|
||||||
|
#define RADIO_VALUE_PACKET_TYPE 24641622
|
||||||
|
|
||||||
//% color=270 weight=34
|
//% color=270 weight=34
|
||||||
namespace radio {
|
namespace radio {
|
||||||
|
|
||||||
|
@ -39,7 +41,7 @@ namespace radio {
|
||||||
* Broadcasts 4 numbers over radio to any connected micro:bit in the group.
|
* Broadcasts 4 numbers over radio to any connected micro:bit in the group.
|
||||||
*/
|
*/
|
||||||
//% help=radio/send-numbers
|
//% help=radio/send-numbers
|
||||||
//% weight=59
|
//% weight=59 debug=true
|
||||||
//% blockId=radio_datagram_send_numbers block="send numbers|0: %VALUE0|1: %VALUE1|2: %VALUE2|3: %VALUE3"
|
//% blockId=radio_datagram_send_numbers block="send numbers|0: %VALUE0|1: %VALUE1|2: %VALUE2|3: %VALUE3"
|
||||||
void sendNumbers(int value_0, int value_1, int value_2, int value_3) {
|
void sendNumbers(int value_0, int value_1, int value_2, int value_3) {
|
||||||
if (radioEnable() != MICROBIT_OK) return;
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
|
@ -47,6 +49,72 @@ namespace radio {
|
||||||
uBit.radio.datagram.send((uint8_t*)buf, 4*sizeof(int));
|
uBit.radio.datagram.send((uint8_t*)buf, 4*sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 the numberic value
|
||||||
|
*/
|
||||||
|
//% help=radio/send-value
|
||||||
|
//% weight=4 debug=true
|
||||||
|
//% blockId=radio_datagram_send_value block="send|value %name|= %value"
|
||||||
|
void sendValue(StringData* name, int number) {
|
||||||
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
|
|
||||||
|
ManagedString n(name);
|
||||||
|
uint8_t buf[32];
|
||||||
|
uint32_t* buf32 = (uint32_t*)buf;
|
||||||
|
memset(buf, 32, 0);
|
||||||
|
buf32[0] = number; // 4 bytes: value
|
||||||
|
buf32[1] = microbit_serial_number(); // 4 bytes: serial number
|
||||||
|
buf32[2] = system_timer_current_time(); // 4 bytes: running time
|
||||||
|
memcpy(buf + 12, n.toCharArray(), min(12, n.length())); // 12-24: field name
|
||||||
|
buf32[7] = RADIO_VALUE_PACKET_TYPE; // last 4 bytes: magic number of package type
|
||||||
|
uBit.radio.datagram.send(buf, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a value sent with `stream value` and writes it
|
||||||
|
* to the serial stream as JSON
|
||||||
|
*/
|
||||||
|
//% help=radio/read-value-to-serial
|
||||||
|
//% weight=3 debug=true
|
||||||
|
void readValueToSerial() {
|
||||||
|
if (radioEnable() != MICROBIT_OK) return;
|
||||||
|
PacketBuffer p = uBit.radio.datagram.recv();
|
||||||
|
int length = p.length();
|
||||||
|
if (length < 32) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* bytes = p.getBytes();
|
||||||
|
//uint32_t* buf32 = (uint32_t*)bytes;
|
||||||
|
//uint32_t type = buf32[7];
|
||||||
|
//if (type != RADIO_VALUE_PACKET_TYPE)
|
||||||
|
//{
|
||||||
|
// uBit.serial.send("type: ");
|
||||||
|
// uBit.serial.send(type);
|
||||||
|
// uBit.serial.send("\r\n");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
int value;
|
||||||
|
int serial;
|
||||||
|
int time;
|
||||||
|
char name[12+1]; memset(name, 0, 13 * sizeof(char));
|
||||||
|
|
||||||
|
memcpy(&value, bytes, 4);
|
||||||
|
memcpy(&serial, bytes + 4, 4);
|
||||||
|
memcpy(&time, bytes + 8, 4);
|
||||||
|
memcpy(&name, bytes + 12, 12);
|
||||||
|
|
||||||
|
uBit.serial.send("{s:"); uBit.serial.send(serial);
|
||||||
|
uBit.serial.send(",t:"); uBit.serial.send(time);
|
||||||
|
uBit.serial.send(",v:"); uBit.serial.send(value);
|
||||||
|
uBit.serial.send(",n:\""); uBit.serial.send(name);
|
||||||
|
uBit.serial.send("\"}\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers code to run when a packet is received over radio.
|
* Registers code to run when a packet is received over radio.
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +131,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;
|
||||||
|
|
23
libs/microbit-radio/shims.d.ts
vendored
|
@ -9,10 +9,29 @@ declare namespace radio {
|
||||||
* Broadcasts 4 numbers over radio to any connected micro:bit in the group.
|
* Broadcasts 4 numbers over radio to any connected micro:bit in the group.
|
||||||
*/
|
*/
|
||||||
//% help=radio/send-numbers
|
//% help=radio/send-numbers
|
||||||
//% weight=59
|
//% weight=59 debug=true
|
||||||
//% blockId=radio_datagram_send_numbers block="send numbers|0: %VALUE0|1: %VALUE1|2: %VALUE2|3: %VALUE3" shim=radio::sendNumbers
|
//% blockId=radio_datagram_send_numbers block="send numbers|0: %VALUE0|1: %VALUE1|2: %VALUE2|3: %VALUE3" shim=radio::sendNumbers
|
||||||
function sendNumbers(value_0: number, value_1: number, value_2: number, value_3: number): void;
|
function sendNumbers(value_0: number, value_1: number, value_2: number, value_3: 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 the numberic value
|
||||||
|
*/
|
||||||
|
//% help=radio/send-value
|
||||||
|
//% weight=4 debug=true
|
||||||
|
//% blockId=radio_datagram_send_value block="send|value %name|= %value" shim=radio::sendValue
|
||||||
|
function sendValue(name: string, number: number): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a value sent with `stream value` and writes it
|
||||||
|
* to the serial stream as JSON
|
||||||
|
*/
|
||||||
|
//% help=radio/read-value-to-serial
|
||||||
|
//% weight=3 debug=true shim=radio::readValueToSerial
|
||||||
|
function readValueToSerial(): 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 +45,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;
|
||||||
|
|
||||||
|
|
81
libs/microbit/_locales/microbit-strings.json
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
{
|
||||||
|
"basic": "Provides access to basic micro:bit functionality.",
|
||||||
|
"basic.clearScreen": "Turn off all LEDs",
|
||||||
|
"basic.forever": "Repeats the code forever in the background. On each iteration, allows other codes to run.",
|
||||||
|
"basic.pause": "Pause for the specified time in milliseconds",
|
||||||
|
"basic.plotLeds": "Draws an image on the LED screen.",
|
||||||
|
"basic.showAnimation": "Shows a sequence of LED screens as an animation.",
|
||||||
|
"basic.showLeds": "Draws an image on the LED screen.",
|
||||||
|
"basic.showNumber": "Scroll a number on the screen. If the number fits on the screen (i.e. is a single digit), do not scroll.",
|
||||||
|
"basic.showString": "Display text on the display, one character at a time. If the string fits on the screen (i.e. is one letter), does not scroll.",
|
||||||
|
"control": "Runtime and event utilities.",
|
||||||
|
"control.inBackground": "Schedules code that run in the background.",
|
||||||
|
"control.reset": "Resets the BBC micro:bit.",
|
||||||
|
"game": "A single-LED sprite game engine",
|
||||||
|
"game.addScore": "Adds points to the current score",
|
||||||
|
"game.gameOver": "Displays a game over animation.",
|
||||||
|
"game.score": "Gets the current score",
|
||||||
|
"game.setScore": "Sets the current score value",
|
||||||
|
"game.startCountdown": "Starts a game countdown timer",
|
||||||
|
"images": "Creation, manipulation and display of LED images.",
|
||||||
|
"images.createBigImage": "Creates an image with 2 frames.",
|
||||||
|
"images.createImage": "Creates an image that fits on the LED screen.",
|
||||||
|
"input": "Events and data from sensors",
|
||||||
|
"input.acceleration": "Get the acceleration value in milli-gravitys (when the board is laying flat with the screen up, x=0, y=0 and z=-1024)",
|
||||||
|
"input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
|
||||||
|
"input.calibrate": "Obsolete, compass calibration is automatic.",
|
||||||
|
"input.compassHeading": "Get the current compass compass heading in degrees.",
|
||||||
|
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||||
|
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||||
|
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
||||||
|
"input.onGesture": "Attaches code to run when the screen is facing up.",
|
||||||
|
"input.onLogoDown": "Attaches code to run when the logo is oriented downwards and the board is vertical.",
|
||||||
|
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||||
|
"input.onPinPressed": "Do something when a pin(``P0``, ``P1`` or both ``P2``) is pressed.",
|
||||||
|
"input.onScreenDown": "Attaches code to run when the screen is facing down.",
|
||||||
|
"input.onScreenUp": "Attaches code to run when the screen is facing up.",
|
||||||
|
"input.onShake": "Attaches code to run when the device is shaken.",
|
||||||
|
"input.pinIsPressed": "Get the pin state (pressed or not). Requires to hold the ground to close the circuit.",
|
||||||
|
"input.rotation": "The pitch of the device, rotation along the ``x-axis``, in degrees.",
|
||||||
|
"input.runningTime": "Gets the number of milliseconds elapsed since power on.",
|
||||||
|
"input.setAccelerometerRange": "Sets the accelerometer sample range in gravities.",
|
||||||
|
"input.temperature": "Gets the temperature in Celsius degrees (°C).",
|
||||||
|
"led": "Control of the LED screen.",
|
||||||
|
"led.brightness": "Get the screen brightness from 0 (off) to 255 (full bright).",
|
||||||
|
"led.fadeIn": "Fades in the screen display.",
|
||||||
|
"led.fadeOut": "Fades out the screen brightness.",
|
||||||
|
"led.plot": "Turn on the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||||
|
"led.plotAll": "Turns all LEDS on",
|
||||||
|
"led.plotBarGraph": "Displays a vertical bar graph based on the `value` and `high` value.\nIf `high` is 0, the chart gets adjusted automatically.",
|
||||||
|
"led.point": "Get the on/off state of the specified LED using x, y coordinates. (0,0) is upper left.",
|
||||||
|
"led.screenshot": "Takes a screenshot of the LED screen and returns an image.",
|
||||||
|
"led.setBrightness": "Set the screen brightness from 0 (off) to 255 (full bright).",
|
||||||
|
"led.setDisplayMode": "Sets the display mode between black and white and greyscale for rendering LEDs.",
|
||||||
|
"led.stopAnimation": "Cancels the current animation and clears other pending animations.",
|
||||||
|
"led.toggle": "Toggles a particular pixel",
|
||||||
|
"led.toggleAll": "Inverts the current LED display",
|
||||||
|
"led.unplot": "Turn off the specified LED using x, y coordinates (x is horizontal, y is vertical). (0,0) is upper left.",
|
||||||
|
"music": "Generation of music tones through pin ``P0``.",
|
||||||
|
"music.beat": "Returns the duration of a beat in milli-seconds",
|
||||||
|
"music.changeTempoBy": "Change the tempo by the specified amount",
|
||||||
|
"music.noteFrequency": "Gets the frequency of a note.",
|
||||||
|
"music.playTone": "Plays a tone through pin ``P0`` for the given duration.",
|
||||||
|
"music.rest": "Rests (plays nothing) for a specified time through pin ``P0``.",
|
||||||
|
"music.ringTone": "Plays a tone through pin ``P0``.",
|
||||||
|
"music.setTempo": "Sets the tempo to the specified amount",
|
||||||
|
"music.tempo": "Returns the tempo in beats per minute. Tempo is the speed (bpm = beats per minute) at which notes play. The larger the tempo value, the faster the notes will play.",
|
||||||
|
"pins": "Control currents in Pins for analog/digital signals, servos, i2c, ...",
|
||||||
|
"pins.analogPitch": "Emits a Pulse-width modulation (PWM) signal to the current pitch pin. Use `analog set pitch pin` to define the pitch pin.",
|
||||||
|
"pins.analogReadPin": "Read the connector value as analog, that is, as a value comprised between 0 and 1023.",
|
||||||
|
"pins.analogSetPeriod": "Configures the Pulse-width modulation (PWM) of the analog output to the given value in **microseconds** or `1/1000` milliseconds.\nIf this pin is not configured as an analog output (using `analog write pin`), the operation has no effect.",
|
||||||
|
"pins.analogSetPitchPin": "Sets the pin used when using `pins->analog pitch`.",
|
||||||
|
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.",
|
||||||
|
"pins.digitalReadPin": "Read the specified pin or connector as either 0 or 1",
|
||||||
|
"pins.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
|
||||||
|
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
|
||||||
|
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.",
|
||||||
|
"pins.servoWritePin": "Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).",
|
||||||
|
"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."
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pxt-microbit",
|
"name": "pxt-microbit",
|
||||||
"version": "0.2.95",
|
"version": "0.2.109",
|
||||||
"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.106"
|
"pxt-core": "0.2.121"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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",
|
||||||
|
@ -22,14 +22,12 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"files": [
|
"files": [
|
||||||
"main.blocks",
|
"main.blocks",
|
||||||
"main.ts",
|
"main.ts"
|
||||||
"README.md"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"main.blocks": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"device_print_message\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">Hello!</field></shadow></value></block></xml>",
|
"main.blocks": "<xml xmlns=\"http://www.w3.org/1999/xhtml\"><block type=\"device_print_message\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">Hello!</field></shadow></value></block></xml>",
|
||||||
"main.ts": "\n",
|
"main.ts": "\n"
|
||||||
"README.md": "Describe your project here!"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsprj": {
|
"tsprj": {
|
||||||
|
@ -42,13 +40,11 @@
|
||||||
},
|
},
|
||||||
"description": "",
|
"description": "",
|
||||||
"files": [
|
"files": [
|
||||||
"main.ts",
|
"main.ts"
|
||||||
"README.md"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"main.ts": "basic.showString('Hello!')\n",
|
"main.ts": "basic.showString('Hello!')\n"
|
||||||
"README.md": "Describe your project here!"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compile": {
|
"compile": {
|
||||||
|
@ -63,7 +59,8 @@
|
||||||
"variablesBlocks": true
|
"variablesBlocks": true
|
||||||
},
|
},
|
||||||
"simulator": {
|
"simulator": {
|
||||||
"autoRun": true
|
"autoRun": true,
|
||||||
|
"aspectRatio": 1.22
|
||||||
},
|
},
|
||||||
"compileService": {
|
"compileService": {
|
||||||
"gittag": "v0.1.8",
|
"gittag": "v0.1.8",
|
||||||
|
@ -75,13 +72,13 @@
|
||||||
"log": true
|
"log": true
|
||||||
},
|
},
|
||||||
"appTheme": {
|
"appTheme": {
|
||||||
"logoUrl": "https://codemicrobit.com/about",
|
"logoUrl": "https://m.pxt.io/about",
|
||||||
"logo": "./static/logo.svg",
|
"logo": "./static/microbit.red.svg",
|
||||||
"docsLogo": "./static/docslogo.svg",
|
"docsLogo": "./static/microbit.docs.svg",
|
||||||
"portraitLogo":"./static/portraitlogo.svg",
|
"portraitLogo":"./static/microbit.red.svg",
|
||||||
"footerLogo": "./static/footerlogo.svg",
|
"footerLogo": "./static/microbit.red.svg",
|
||||||
"homeUrl": "https://codemicrobit.com/",
|
"homeUrl": "https://m.pxt.io/",
|
||||||
"embedUrl": "https://codemicrobit.com/",
|
"embedUrl": "https://m.pxt.io/",
|
||||||
"koduUrl": "https://www.kodugamelab.com/bbc-microbit/",
|
"koduUrl": "https://www.kodugamelab.com/bbc-microbit/",
|
||||||
"visualStudioCode": true,
|
"visualStudioCode": true,
|
||||||
"docMenu": [
|
"docMenu": [
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
namespace pxsim {
|
namespace pxsim {
|
||||||
pxsim.initCurrentRuntime = () => {
|
pxsim.initCurrentRuntime = () => {
|
||||||
U.assert(!runtime.board)
|
U.assert(!runtime.board);
|
||||||
runtime.board = new Board()
|
runtime.board = new Board();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function board() {
|
export function board() {
|
||||||
return runtime.board as Board
|
return runtime.board as Board;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AnimationOptions {
|
export interface AnimationOptions {
|
||||||
|
@ -125,9 +125,9 @@ namespace pxsim {
|
||||||
|
|
||||||
|
|
||||||
export namespace AudioContextManager {
|
export namespace AudioContextManager {
|
||||||
var _context: any; // AudioContext
|
let _context: any; // AudioContext
|
||||||
var _vco: any; //OscillatorNode;
|
let _vco: any; // OscillatorNode;
|
||||||
var _vca: any; // GainNode;
|
let _vca: any; // GainNode;
|
||||||
|
|
||||||
function context(): any {
|
function context(): any {
|
||||||
if (!_context) _context = freshContext();
|
if (!_context) _context = freshContext();
|
||||||
|
@ -152,7 +152,7 @@ namespace pxsim {
|
||||||
|
|
||||||
export function tone(frequency: number, gain: number) {
|
export function tone(frequency: number, gain: number) {
|
||||||
if (frequency <= 0) return;
|
if (frequency <= 0) return;
|
||||||
var ctx = context();
|
let ctx = context();
|
||||||
if (!ctx) return;
|
if (!ctx) return;
|
||||||
|
|
||||||
gain = Math.max(0, Math.min(1, gain));
|
gain = Math.max(0, Math.min(1, gain));
|
||||||
|
@ -198,7 +198,7 @@ namespace pxsim.basic {
|
||||||
pause(interval * 5);
|
pause(interval * 5);
|
||||||
} else {
|
} else {
|
||||||
if (s.length == 1) showLeds(createImageFromString(s), interval * 5)
|
if (s.length == 1) showLeds(createImageFromString(s), interval * 5)
|
||||||
else ImageMethods.scrollImage(createImageFromString(s + ' '), interval, 1);
|
else ImageMethods.scrollImage(createImageFromString(s + " "), interval, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,14 +231,14 @@ namespace pxsim.control {
|
||||||
let b = board();
|
let b = board();
|
||||||
return b && b.id
|
return b && b.id
|
||||||
? b.id.slice(0, 4)
|
? b.id.slice(0, 4)
|
||||||
: 'abcd';
|
: "abcd";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deviceSerialNumber(): number {
|
export function deviceSerialNumber(): number {
|
||||||
let b = board();
|
let b = board();
|
||||||
return parseInt(b && b.id
|
return parseInt(b && b.id
|
||||||
? b.id.slice(1)
|
? b.id.slice(1)
|
||||||
: '42');
|
: "42");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onEvent(id: number, evid: number, handler: RefAction) {
|
export function onEvent(id: number, evid: number, handler: RefAction) {
|
||||||
|
@ -306,7 +306,7 @@ namespace pxsim.input {
|
||||||
|
|
||||||
|
|
||||||
export function compassHeading(): number {
|
export function compassHeading(): number {
|
||||||
var b = board();
|
let b = board();
|
||||||
if (!b.usesHeading) {
|
if (!b.usesHeading) {
|
||||||
b.usesHeading = true;
|
b.usesHeading = true;
|
||||||
runtime.queueDisplayUpdate();
|
runtime.queueDisplayUpdate();
|
||||||
|
@ -315,7 +315,7 @@ namespace pxsim.input {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function temperature(): number {
|
export function temperature(): number {
|
||||||
var b = board();
|
let b = board();
|
||||||
if (!b.usesTemperature) {
|
if (!b.usesTemperature) {
|
||||||
b.usesTemperature = true;
|
b.usesTemperature = true;
|
||||||
runtime.queueDisplayUpdate();
|
runtime.queueDisplayUpdate();
|
||||||
|
@ -453,6 +453,10 @@ namespace pxsim.radio {
|
||||||
board().radio.datagram.send([value0, value1, value2, value3]);
|
board().radio.datagram.send([value0, value1, value2, value3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function streamValue(name: string, value: number) {
|
||||||
|
board().radio.datagram.send([value]);
|
||||||
|
}
|
||||||
|
|
||||||
export function receiveNumber(): number {
|
export function receiveNumber(): number {
|
||||||
return board().radio.datagram.recv().data[0];
|
return board().radio.datagram.recv().data[0];
|
||||||
}
|
}
|
||||||
|
|
292
sim/simsvg.ts
|
@ -1,5 +1,5 @@
|
||||||
namespace pxsim.micro_bit {
|
namespace pxsim.micro_bit {
|
||||||
const Svg = pxsim.Svg;
|
const svg = pxsim.svg;
|
||||||
|
|
||||||
export interface IBoardTheme {
|
export interface IBoardTheme {
|
||||||
accent?: string;
|
accent?: string;
|
||||||
|
@ -35,7 +35,8 @@ namespace pxsim.micro_bit {
|
||||||
virtualButtonUp: "#fff",
|
virtualButtonUp: "#fff",
|
||||||
lightLevelOn: "yellow",
|
lightLevelOn: "yellow",
|
||||||
lightLevelOff: "#555"
|
lightLevelOff: "#555"
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export function randomTheme(): IBoardTheme {
|
export function randomTheme(): IBoardTheme {
|
||||||
return themes[Math.floor(Math.random() * themes.length)];
|
return themes[Math.floor(Math.random() * themes.length)];
|
||||||
|
@ -59,8 +60,7 @@ namespace pxsim.micro_bit {
|
||||||
leave: "mouseleave"
|
leave: "mouseleave"
|
||||||
};
|
};
|
||||||
|
|
||||||
export class MicrobitBoardSvg
|
export class MicrobitBoardSvg {
|
||||||
{
|
|
||||||
public element: SVGSVGElement;
|
public element: SVGSVGElement;
|
||||||
private style: SVGStyleElement;
|
private style: SVGStyleElement;
|
||||||
private defs: SVGDefsElement;
|
private defs: SVGDefsElement;
|
||||||
|
@ -102,20 +102,20 @@ namespace pxsim.micro_bit {
|
||||||
private updateTheme() {
|
private updateTheme() {
|
||||||
let theme = this.props.theme;
|
let theme = this.props.theme;
|
||||||
|
|
||||||
Svg.fill(this.display, theme.display);
|
svg.fill(this.display, theme.display);
|
||||||
Svg.fills(this.leds, theme.ledOn);
|
svg.fills(this.leds, theme.ledOn);
|
||||||
Svg.fills(this.ledsOuter, theme.ledOff);
|
svg.fills(this.ledsOuter, theme.ledOff);
|
||||||
Svg.fills(this.buttonsOuter.slice(0, 2), theme.buttonOuter);
|
svg.fills(this.buttonsOuter.slice(0, 2), theme.buttonOuter);
|
||||||
Svg.fills(this.buttons.slice(0, 2), theme.buttonUp);
|
svg.fills(this.buttons.slice(0, 2), theme.buttonUp);
|
||||||
Svg.fill(this.buttonsOuter[2], theme.virtualButtonOuter);
|
svg.fill(this.buttonsOuter[2], theme.virtualButtonOuter);
|
||||||
Svg.fill(this.buttons[2], theme.virtualButtonUp);
|
svg.fill(this.buttons[2], theme.virtualButtonUp);
|
||||||
Svg.fills(this.logos, theme.accent);
|
svg.fills(this.logos, theme.accent);
|
||||||
if (this.shakeButton) Svg.fill(this.shakeButton, theme.virtualButtonUp);
|
if (this.shakeButton) svg.fill(this.shakeButton, theme.virtualButtonUp);
|
||||||
|
|
||||||
this.pinGradients.forEach(lg => Svg.setGradientColors(lg, theme.pin, theme.pinActive));
|
this.pinGradients.forEach(lg => svg.setGradientColors(lg, theme.pin, theme.pinActive));
|
||||||
Svg.setGradientColors(this.lightLevelGradient, theme.lightLevelOn, theme.lightLevelOff);
|
svg.setGradientColors(this.lightLevelGradient, theme.lightLevelOn, theme.lightLevelOff);
|
||||||
|
|
||||||
Svg.setGradientColors(this.thermometerGradient, theme.ledOff, theme.ledOn);
|
svg.setGradientColors(this.thermometerGradient, theme.ledOff, theme.ledOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateState() {
|
public updateState() {
|
||||||
|
@ -124,13 +124,13 @@ namespace pxsim.micro_bit {
|
||||||
let theme = this.props.theme;
|
let theme = this.props.theme;
|
||||||
|
|
||||||
state.buttons.forEach((btn, index) => {
|
state.buttons.forEach((btn, index) => {
|
||||||
Svg.fill(this.buttons[index], btn.pressed ? theme.buttonDown : theme.buttonUp);
|
svg.fill(this.buttons[index], btn.pressed ? theme.buttonDown : theme.buttonUp);
|
||||||
});
|
});
|
||||||
|
|
||||||
var bw = state.displayMode == pxsim.DisplayMode.bw
|
let bw = state.displayMode == pxsim.DisplayMode.bw
|
||||||
var img = state.image;
|
let img = state.image;
|
||||||
this.leds.forEach((led, i) => {
|
this.leds.forEach((led, i) => {
|
||||||
var sel = (<SVGStylable><any>led)
|
let sel = (<SVGStylable><any>led)
|
||||||
sel.style.opacity = ((bw ? img.data[i] > 0 ? 255 : 0 : img.data[i]) / 255.0) + "";
|
sel.style.opacity = ((bw ? img.data[i] > 0 ? 255 : 0 : img.data[i]) / 255.0) + "";
|
||||||
})
|
})
|
||||||
this.updatePins();
|
this.updatePins();
|
||||||
|
@ -141,29 +141,29 @@ namespace pxsim.micro_bit {
|
||||||
this.updateButtonAB();
|
this.updateButtonAB();
|
||||||
this.updateGestures();
|
this.updateGestures();
|
||||||
|
|
||||||
if (!runtime || runtime.dead) Svg.addClass(this.element, "grayscale");
|
if (!runtime || runtime.dead) svg.addClass(this.element, "grayscale");
|
||||||
else Svg.removeClass(this.element, "grayscale");
|
else svg.removeClass(this.element, "grayscale");
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateGestures() {
|
private updateGestures() {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
if (state.useShake && !this.shakeButton) {
|
if (state.useShake && !this.shakeButton) {
|
||||||
this.shakeButton = Svg.child(this.g, "circle", {cx:380, cy:100, r:16.5}) as SVGCircleElement;
|
this.shakeButton = svg.child(this.g, "circle", { cx: 380, cy: 100, r: 16.5 }) as SVGCircleElement;
|
||||||
Svg.fill(this.shakeButton, this.props.theme.virtualButtonUp)
|
svg.fill(this.shakeButton, this.props.theme.virtualButtonUp)
|
||||||
this.shakeButton.addEventListener(pointerEvents.down, ev => {
|
this.shakeButton.addEventListener(pointerEvents.down, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
Svg.fill(this.shakeButton, this.props.theme.buttonDown);
|
svg.fill(this.shakeButton, this.props.theme.buttonDown);
|
||||||
})
|
})
|
||||||
this.shakeButton.addEventListener(pointerEvents.leave, ev => {
|
this.shakeButton.addEventListener(pointerEvents.leave, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
Svg.fill(this.shakeButton, this.props.theme.virtualButtonUp);
|
svg.fill(this.shakeButton, this.props.theme.virtualButtonUp);
|
||||||
})
|
})
|
||||||
this.shakeButton.addEventListener(pointerEvents.up, ev => {
|
this.shakeButton.addEventListener(pointerEvents.up, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
Svg.fill(this.shakeButton, this.props.theme.virtualButtonUp);
|
svg.fill(this.shakeButton, this.props.theme.virtualButtonUp);
|
||||||
this.board.bus.queue(DAL.MICROBIT_ID_GESTURE, 11); // GESTURE_SHAKE
|
this.board.bus.queue(DAL.MICROBIT_ID_GESTURE, 11); // GESTURE_SHAKE
|
||||||
})
|
})
|
||||||
this.shakeText = Svg.child(this.g, "text", {x:400, y:110, class:'sim-text'}) as SVGTextElement;
|
this.shakeText = svg.child(this.g, "text", { x: 400, y: 110, class: "sim-text" }) as SVGTextElement;
|
||||||
this.shakeText.textContent = "SHAKE"
|
this.shakeText.textContent = "SHAKE"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,9 @@ namespace pxsim.micro_bit {
|
||||||
private updateButtonAB() {
|
private updateButtonAB() {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
if (state.usesButtonAB && !this.buttonABText) {
|
if (state.usesButtonAB && !this.buttonABText) {
|
||||||
(<any>this.buttonsOuter[2]).style.visibility = 'visible';
|
(<any>this.buttonsOuter[2]).style.visibility = "visible";
|
||||||
(<any>this.buttons[2]).style.visibility = 'visible';
|
(<any>this.buttons[2]).style.visibility = "visible";
|
||||||
this.buttonABText = Svg.child(this.g, "text", {class: 'sim-text', x:370, y:272 }) as SVGTextElement;
|
this.buttonABText = svg.child(this.g, "text", { class: "sim-text", x: 370, y: 272 }) as SVGTextElement;
|
||||||
this.buttonABText.textContent = "A+B";
|
this.buttonABText.textContent = "A+B";
|
||||||
this.updateTheme();
|
this.updateTheme();
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,9 @@ namespace pxsim.micro_bit {
|
||||||
private updatePin(pin: Pin, index: number) {
|
private updatePin(pin: Pin, index: number) {
|
||||||
if (!pin) return;
|
if (!pin) return;
|
||||||
let text = this.pinTexts[index];
|
let text = this.pinTexts[index];
|
||||||
let v = '';
|
let v = "";
|
||||||
if (pin.mode & PinMode.Analog) {
|
if (pin.mode & PinMode.Analog) {
|
||||||
v = Math.floor(100 - (pin.value || 0) / 1023 * 100) + '%';
|
v = Math.floor(100 - (pin.value || 0) / 1023 * 100) + "%";
|
||||||
if (text) text.textContent = (pin.period ? "~" : "") + (pin.value || 0) + "";
|
if (text) text.textContent = (pin.period ? "~" : "") + (pin.value || 0) + "";
|
||||||
}
|
}
|
||||||
else if (pin.mode & PinMode.Digital) {
|
else if (pin.mode & PinMode.Digital) {
|
||||||
|
@ -198,7 +198,7 @@ namespace pxsim.micro_bit {
|
||||||
v = '100%';
|
v = '100%';
|
||||||
if (text) text.textContent = '';
|
if (text) text.textContent = '';
|
||||||
}
|
}
|
||||||
if (v) Svg.setGradientValue(this.pinGradients[index], v);
|
if (v) svg.setGradientValue(this.pinGradients[index], v);
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateTemperature() {
|
private updateTemperature() {
|
||||||
|
@ -209,8 +209,8 @@ namespace pxsim.micro_bit {
|
||||||
let tmax = 50;
|
let tmax = 50;
|
||||||
if (!this.thermometer) {
|
if (!this.thermometer) {
|
||||||
let gid = "gradient-thermometer";
|
let gid = "gradient-thermometer";
|
||||||
this.thermometerGradient = Svg.linearGradient(this.defs, gid);
|
this.thermometerGradient = svg.linearGradient(this.defs, gid);
|
||||||
this.thermometer = <SVGRectElement> Svg.child(this.g, "rect", {
|
this.thermometer = <SVGRectElement>svg.child(this.g, "rect", {
|
||||||
class: "sim-thermometer",
|
class: "sim-thermometer",
|
||||||
x: 120,
|
x: 120,
|
||||||
y: 110,
|
y: 110,
|
||||||
|
@ -219,13 +219,13 @@ namespace pxsim.micro_bit {
|
||||||
rx: 5, ry: 5,
|
rx: 5, ry: 5,
|
||||||
fill: `url(#${gid})`
|
fill: `url(#${gid})`
|
||||||
});
|
});
|
||||||
this.thermometerText = Svg.child(this.g, "text", { class:'sim-text', x:58, y:130}) as SVGTextElement;
|
this.thermometerText = svg.child(this.g, "text", { class: 'sim-text', x: 58, y: 130 }) as SVGTextElement;
|
||||||
this.updateTheme();
|
this.updateTheme();
|
||||||
|
|
||||||
let pt = this.element.createSVGPoint();
|
let pt = this.element.createSVGPoint();
|
||||||
Svg.buttonEvents(this.thermometer,
|
svg.buttonEvents(this.thermometer,
|
||||||
(ev) => {
|
(ev) => {
|
||||||
let cur = Svg.cursorPoint(pt, this.element, ev);
|
let cur = svg.cursorPoint(pt, this.element, ev);
|
||||||
let t = Math.max(0, Math.min(1, (260 - cur.y) / 140))
|
let t = Math.max(0, Math.min(1, (260 - cur.y) / 140))
|
||||||
state.temperature = Math.floor(tmin + t * (tmax - tmin));
|
state.temperature = Math.floor(tmin + t * (tmax - tmin));
|
||||||
this.updateTemperature();
|
this.updateTemperature();
|
||||||
|
@ -234,7 +234,7 @@ namespace pxsim.micro_bit {
|
||||||
|
|
||||||
let t = Math.max(tmin, Math.min(tmax, state.temperature))
|
let t = Math.max(tmin, Math.min(tmax, state.temperature))
|
||||||
let per = Math.floor((state.temperature - tmin) / (tmax - tmin) * 100)
|
let per = Math.floor((state.temperature - tmin) / (tmax - tmin) * 100)
|
||||||
Svg.setGradientValue(this.thermometerGradient, 100 - per + '%');
|
svg.setGradientValue(this.thermometerGradient, 100 - per + '%');
|
||||||
this.thermometerText.textContent = t + '°C';
|
this.thermometerText.textContent = t + '°C';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,10 +247,10 @@ namespace pxsim.micro_bit {
|
||||||
let p = this.head.firstChild.nextSibling as SVGPathElement;
|
let p = this.head.firstChild.nextSibling as SVGPathElement;
|
||||||
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");
|
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");
|
||||||
let pt = this.element.createSVGPoint();
|
let pt = this.element.createSVGPoint();
|
||||||
Svg.buttonEvents(
|
svg.buttonEvents(
|
||||||
this.head,
|
this.head,
|
||||||
(ev: MouseEvent) => {
|
(ev: MouseEvent) => {
|
||||||
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)
|
console.log('heading: ' + state.heading)
|
||||||
|
@ -261,7 +261,7 @@ namespace pxsim.micro_bit {
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,11 +269,11 @@ namespace pxsim.micro_bit {
|
||||||
private lastFlashTime: number = 0;
|
private lastFlashTime: number = 0;
|
||||||
public flashSystemLed() {
|
public flashSystemLed() {
|
||||||
if (!this.systemLed)
|
if (!this.systemLed)
|
||||||
this.systemLed = <SVGCircleElement>Svg.child(this.g, "circle", {class:"sim-systemled", cx:300, cy:20, r:5})
|
this.systemLed = <SVGCircleElement>svg.child(this.g, "circle", { class: "sim-systemled", cx: 300, cy: 20, r: 5 })
|
||||||
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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,12 +284,12 @@ namespace pxsim.micro_bit {
|
||||||
let dax = 18;
|
let dax = 18;
|
||||||
let ayt = 10;
|
let ayt = 10;
|
||||||
let ayb = 40;
|
let ayb = 40;
|
||||||
this.antenna = <SVGPolylineElement>Svg.child(this.g, "polyline", { class:"sim-antenna", points: `${ax},${ayb} ${ax},${ayt} ${ax+=dax},${ayt} ${ax},${ayb} ${ax+=dax},${ayb} ${ax},${ayt} ${ax+=dax},${ayt} ${ax},${ayb} ${ax+=dax},${ayb} ${ax},${ayt} ${ax+=dax},${ayt}`})
|
this.antenna = <SVGPolylineElement>svg.child(this.g, "polyline", { class: "sim-antenna", points: `${ax},${ayb} ${ax},${ayt} ${ax += dax},${ayt} ${ax},${ayb} ${ax += dax},${ayb} ${ax},${ayt} ${ax += dax},${ayt} ${ax},${ayb} ${ax += dax},${ayb} ${ax},${ayt} ${ax += dax},${ayt}` })
|
||||||
}
|
}
|
||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
if (now - this.lastAntennaFlash > 200) {
|
if (now - this.lastAntennaFlash > 200) {
|
||||||
this.lastAntennaFlash = now;
|
this.lastAntennaFlash = now;
|
||||||
Svg.animate(this.antenna, 'sim-flash-stroke')
|
svg.animate(this.antenna, 'sim-flash-stroke')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,17 +306,18 @@ namespace pxsim.micro_bit {
|
||||||
|
|
||||||
if (!this.lightLevelButton) {
|
if (!this.lightLevelButton) {
|
||||||
let gid = "gradient-light-level";
|
let gid = "gradient-light-level";
|
||||||
this.lightLevelGradient = Svg.linearGradient(this.defs, gid)
|
this.lightLevelGradient = svg.linearGradient(this.defs, gid)
|
||||||
let cy = 50;
|
let cy = 50;
|
||||||
let r = 35;
|
let r = 35;
|
||||||
this.lightLevelButton = Svg.child(this.g, "circle", {
|
this.lightLevelButton = svg.child(this.g, "circle", {
|
||||||
cx: `50px`, cy: `${cy}px`, r: `${r}px`,
|
cx: `50px`, cy: `${cy}px`, r: `${r}px`,
|
||||||
class: 'sim-light-level-button',
|
class: 'sim-light-level-button',
|
||||||
fill: `url(#${gid})` }) as SVGCircleElement;
|
fill: `url(#${gid})`
|
||||||
|
}) as SVGCircleElement;
|
||||||
let pt = this.element.createSVGPoint();
|
let pt = this.element.createSVGPoint();
|
||||||
Svg.buttonEvents(this.lightLevelButton,
|
svg.buttonEvents(this.lightLevelButton,
|
||||||
(ev) => {
|
(ev) => {
|
||||||
let pos = Svg.cursorPoint(pt, this.element, ev);
|
let pos = svg.cursorPoint(pt, this.element, ev);
|
||||||
let rs = r / 2;
|
let rs = r / 2;
|
||||||
let level = Math.max(0, Math.min(255, Math.floor((pos.y - (cy - rs)) / (2 * rs) * 255)));
|
let level = Math.max(0, Math.min(255, Math.floor((pos.y - (cy - rs)) / (2 * rs) * 255)));
|
||||||
if (level != this.board.lightLevel) {
|
if (level != this.board.lightLevel) {
|
||||||
|
@ -325,17 +326,17 @@ namespace pxsim.micro_bit {
|
||||||
}
|
}
|
||||||
}, ev => { },
|
}, ev => { },
|
||||||
ev => { })
|
ev => { })
|
||||||
this.lightLevelText = Svg.child(this.g, "text", { x:85, y:cy+r-5, text:'', class:'sim-text'}) as SVGTextElement;
|
this.lightLevelText = svg.child(this.g, "text", { x: 85, y: cy + r - 5, text: '', class: 'sim-text' }) as SVGTextElement;
|
||||||
this.updateTheme();
|
this.updateTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
Svg.setGradientValue(this.lightLevelGradient, Math.min(100, Math.max(0, Math.floor(state.lightLevel * 100 / 255))) + '%')
|
svg.setGradientValue(this.lightLevelGradient, Math.min(100, Math.max(0, Math.floor(state.lightLevel * 100 / 255))) + '%')
|
||||||
this.lightLevelText.textContent = state.lightLevel.toString();
|
this.lightLevelText.textContent = state.lightLevel.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyLightLevel() {
|
private applyLightLevel() {
|
||||||
let lv = this.board.lightLevel;
|
let lv = this.board.lightLevel;
|
||||||
Svg.setGradientValue(this.lightLevelGradient, Math.min(100, Math.max(0, Math.floor(lv * 100 / 255))) + '%')
|
svg.setGradientValue(this.lightLevelGradient, Math.min(100, Math.max(0, Math.floor(lv * 100 / 255))) + '%')
|
||||||
this.lightLevelText.textContent = lv.toString();
|
this.lightLevelText.textContent = lv.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,15 +355,16 @@ namespace pxsim.micro_bit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildDom() {
|
private buildDom() {
|
||||||
this.element = <SVGSVGElement>Svg.elt("svg")
|
this.element = <SVGSVGElement>svg.elt("svg")
|
||||||
Svg.hydrate(this.element, {
|
svg.hydrate(this.element, {
|
||||||
"version": "1.0",
|
"version": "1.0",
|
||||||
"viewBox": "0 0 498 406",
|
"viewBox": "0 0 498 406",
|
||||||
"enable-background": "new 0 0 498 406",
|
"enable-background": "new 0 0 498 406",
|
||||||
"class": "sim",
|
"class": "sim",
|
||||||
"x": "0px",
|
"x": "0px",
|
||||||
"y": "0px"});
|
"y": "0px"
|
||||||
this.style = <SVGStyleElement>Svg.child(this.element, "style", {});
|
});
|
||||||
|
this.style = <SVGStyleElement>svg.child(this.element, "style", {});
|
||||||
this.style.textContent = `
|
this.style.textContent = `
|
||||||
svg.sim {
|
svg.sim {
|
||||||
margin-bottom:1em;
|
margin-bottom:1em;
|
||||||
|
@ -459,50 +461,50 @@ svg.sim.grayscale {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
this.defs = <SVGDefsElement>Svg.child(this.element, "defs", {});
|
this.defs = <SVGDefsElement>svg.child(this.element, "defs", {});
|
||||||
this.g = Svg.elt("g");
|
this.g = svg.elt("g");
|
||||||
this.element.appendChild(this.g);
|
this.element.appendChild(this.g);
|
||||||
|
|
||||||
// filters
|
// filters
|
||||||
let glow = Svg.child(this.defs, "filter", {id:"filterglow", x:"-5%", y:"-5%", width:"120%", height:"120%"});
|
let glow = svg.child(this.defs, "filter", { id: "filterglow", x: "-5%", y: "-5%", width: "120%", height: "120%" });
|
||||||
Svg.child(glow, "feGaussianBlur", {stdDeviation:"5", result: "glow" });
|
svg.child(glow, "feGaussianBlur", { stdDeviation: "5", result: "glow" });
|
||||||
let merge = Svg.child(glow, "feMerge", {});
|
let merge = svg.child(glow, "feMerge", {});
|
||||||
for(let i=0;i<3;++i) Svg.child(merge, "feMergeNode", {in:"glow"})
|
for (let i = 0; i < 3; ++i) svg.child(merge, "feMergeNode", { in: "glow" })
|
||||||
|
|
||||||
// outline
|
// outline
|
||||||
Svg.path(this.g, "sim-board", "M498,31.9C498,14.3,483.7,0,466.1,0H31.9C14.3,0,0,14.3,0,31.9v342.2C0,391.7,14.3,406,31.9,406h434.2c17.6,0,31.9-14.3,31.9-31.9V31.9z M14.3,206.7c-2.7,0-4.8-2.2-4.8-4.8c0-2.7,2.2-4.8,4.8-4.8c2.7,0,4.8,2.2,4.8,4.8C19.2,204.6,17,206.7,14.3,206.7z M486.2,206.7c-2.7,0-4.8-2.2-4.8-4.8c0-2.72.2-4.8,4.8-4.8c2.7,0,4.8,2.2,4.8,4.8C491,204.6,488.8,206.7,486.2,206.7z");
|
svg.path(this.g, "sim-board", "M498,31.9C498,14.3,483.7,0,466.1,0H31.9C14.3,0,0,14.3,0,31.9v342.2C0,391.7,14.3,406,31.9,406h434.2c17.6,0,31.9-14.3,31.9-31.9V31.9z M14.3,206.7c-2.7,0-4.8-2.2-4.8-4.8c0-2.7,2.2-4.8,4.8-4.8c2.7,0,4.8,2.2,4.8,4.8C19.2,204.6,17,206.7,14.3,206.7z M486.2,206.7c-2.7,0-4.8-2.2-4.8-4.8c0-2.72.2-4.8,4.8-4.8c2.7,0,4.8,2.2,4.8,4.8C491,204.6,488.8,206.7,486.2,206.7z");
|
||||||
|
|
||||||
// script background
|
// script background
|
||||||
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 = [];
|
||||||
this.ledsOuter = [];
|
this.ledsOuter = [];
|
||||||
var left = 154, top = 113, ledoffw = 46, ledoffh = 44;
|
let left = 154, top = 113, ledoffw = 46, ledoffh = 44;
|
||||||
for (var i = 0; i < 5; ++i) {
|
for (let i = 0; i < 5; ++i) {
|
||||||
var ledtop = i * ledoffh + top;
|
let ledtop = i * ledoffh + top;
|
||||||
for (var j = 0; j < 5; ++j) {
|
for (let j = 0; j < 5; ++j) {
|
||||||
var ledleft = j * ledoffw + left;
|
let ledleft = j * ledoffw + left;
|
||||||
var k = i * 5 + j;
|
let k = i * 5 + j;
|
||||||
this.ledsOuter.push(Svg.child(this.g, "rect", { class:"sim-led-back", x:ledleft, y:ledtop, width:10, height:20, rx:2, ry:2 }));
|
this.ledsOuter.push(svg.child(this.g, "rect", { class: "sim-led-back", x: ledleft, y: ledtop, width: 10, height: 20, rx: 2, ry: 2 }));
|
||||||
this.leds.push(Svg.child(this.g, "rect", { class:"sim-led", x:ledleft-2, y:ledtop-2, width:14, height:24, rx:3, ry:3, title:`(${j},${i})`}));
|
this.leds.push(svg.child(this.g, "rect", { class: "sim-led", x: ledleft - 2, y: ledtop - 2, width: 14, height: 24, rx: 3, ry: 3, title: `(${j},${i})` }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
// P0, P1, P2
|
// P0, P1, P2
|
||||||
|
@ -510,69 +512,69 @@ svg.sim.grayscale {
|
||||||
"M16.5,341.2c0,0.4-0.1,0.9-0.1,1.3v60.7c4.1,1.7,8.6,2.7,12.9,2.7h34.4v-64.7h0.3c0,0,0-0.1,0-0.1c0-13-10.6-23.6-23.7-23.6C27.2,317.6,16.5,328.1,16.5,341.2z M21.2,341.6c0-10.7,8.7-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3c0,10.7-8.6,19.3-19.3,19.3C29.9,360.9,21.2,352.2,21.2,341.6z",
|
"M16.5,341.2c0,0.4-0.1,0.9-0.1,1.3v60.7c4.1,1.7,8.6,2.7,12.9,2.7h34.4v-64.7h0.3c0,0,0-0.1,0-0.1c0-13-10.6-23.6-23.7-23.6C27.2,317.6,16.5,328.1,16.5,341.2z M21.2,341.6c0-10.7,8.7-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3c0,10.7-8.6,19.3-19.3,19.3C29.9,360.9,21.2,352.2,21.2,341.6z",
|
||||||
"M139.1,317.3c-12.8,0-22.1,10.3-23.1,23.1V406h46.2v-65.6C162.2,327.7,151.9,317.3,139.1,317.3zM139.3,360.1c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C158.6,351.5,150,360.1,139.3,360.1z",
|
"M139.1,317.3c-12.8,0-22.1,10.3-23.1,23.1V406h46.2v-65.6C162.2,327.7,151.9,317.3,139.1,317.3zM139.3,360.1c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C158.6,351.5,150,360.1,139.3,360.1z",
|
||||||
"M249,317.3c-12.8,0-22.1,10.3-23.1,23.1V406h46.2v-65.6C272.1,327.7,261.8,317.3,249,317.3z M249.4,360.1c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C268.7,351.5,260.1,360.1,249.4,360.1z"
|
"M249,317.3c-12.8,0-22.1,10.3-23.1,23.1V406h46.2v-65.6C272.1,327.7,261.8,317.3,249,317.3z M249.4,360.1c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C268.7,351.5,260.1,360.1,249.4,360.1z"
|
||||||
].map((p,pi) => Svg.path(this.g, "sim-pin sim-pin-touch", p, `P${pi}, ANALOG IN`));
|
].map((p, pi) => svg.path(this.g, "sim-pin sim-pin-touch", p, `P${pi}, ANALOG IN`));
|
||||||
|
|
||||||
// P3
|
// P3
|
||||||
this.pins.push(Svg.path(this.g, "sim-pin", "M0,357.7v19.2c0,10.8,6.2,20.2,14.4,25.2v-44.4H0z", "P3, ANALOG IN, LED Col 1"));
|
this.pins.push(svg.path(this.g, "sim-pin", "M0,357.7v19.2c0,10.8,6.2,20.2,14.4,25.2v-44.4H0z", "P3, ANALOG IN, LED Col 1"));
|
||||||
|
|
||||||
[66.7, 79.1, 91.4, 103.7, 164.3, 176.6, 188.9, 201.3, 213.6, 275.2, 287.5, 299.8, 312.1, 324.5, 385.1, 397.4, 409.7, 422].forEach(x => {
|
[66.7, 79.1, 91.4, 103.7, 164.3, 176.6, 188.9, 201.3, 213.6, 275.2, 287.5, 299.8, 312.1, 324.5, 385.1, 397.4, 409.7, 422].forEach(x => {
|
||||||
this.pins.push(Svg.child(this.g, "rect", {x:x, y:356.7, width:10, height:50, class:"sim-pin"}));
|
this.pins.push(svg.child(this.g, "rect", { x: x, y: 356.7, width: 10, height: 50, class: "sim-pin" }));
|
||||||
})
|
})
|
||||||
Svg.title(this.pins[4], "P4, ANALOG IN, LED Col 2")
|
svg.title(this.pins[4], "P4, ANALOG IN, LED Col 2")
|
||||||
Svg.title(this.pins[5], "P5, BUTTON A")
|
svg.title(this.pins[5], "P5, BUTTON A")
|
||||||
Svg.title(this.pins[6], "P6, LED Col 9")
|
svg.title(this.pins[6], "P6, LED Col 9")
|
||||||
Svg.title(this.pins[7], "P7, LED Col 8")
|
svg.title(this.pins[7], "P7, LED Col 8")
|
||||||
Svg.title(this.pins[8], "P8")
|
svg.title(this.pins[8], "P8")
|
||||||
Svg.title(this.pins[9], "P9, LED Col 7")
|
svg.title(this.pins[9], "P9, LED Col 7")
|
||||||
Svg.title(this.pins[10], "P10, ANALOG IN, LED Col 3")
|
svg.title(this.pins[10], "P10, ANALOG IN, LED Col 3")
|
||||||
Svg.title(this.pins[11], "P11, BUTTON B")
|
svg.title(this.pins[11], "P11, BUTTON B")
|
||||||
Svg.title(this.pins[12], "P12, RESERVED ACCESSIBILITY")
|
svg.title(this.pins[12], "P12, RESERVED ACCESSIBILITY")
|
||||||
Svg.title(this.pins[13], "P13, SPI - SCK")
|
svg.title(this.pins[13], "P13, SPI - SCK")
|
||||||
Svg.title(this.pins[14], "P14, SPI - MISO")
|
svg.title(this.pins[14], "P14, SPI - MISO")
|
||||||
Svg.title(this.pins[15], "P15, SPI - MOSI")
|
svg.title(this.pins[15], "P15, SPI - MOSI")
|
||||||
Svg.title(this.pins[16], "P16, SPI - Chip Select")
|
svg.title(this.pins[16], "P16, SPI - Chip Select")
|
||||||
Svg.title(this.pins[17], "P17, +3v3")
|
svg.title(this.pins[17], "P17, +3v3")
|
||||||
Svg.title(this.pins[18], "P18, +3v3")
|
svg.title(this.pins[18], "P18, +3v3")
|
||||||
Svg.title(this.pins[19], "P19, I2C - SCL")
|
svg.title(this.pins[19], "P19, I2C - SCL")
|
||||||
Svg.title(this.pins[20], "P20, I2C - SDA")
|
svg.title(this.pins[20], "P20, I2C - SDA")
|
||||||
Svg.title(this.pins[21], "GND")
|
svg.title(this.pins[21], "GND")
|
||||||
|
|
||||||
this.pins.push(Svg.path(this.g, "sim-pin", "M483.6,402c8.2-5,14.4-14.4,14.4-25.1v-19.2h-14.4V402z", "GND"));
|
this.pins.push(svg.path(this.g, "sim-pin", "M483.6,402c8.2-5,14.4-14.4,14.4-25.1v-19.2h-14.4V402z", "GND"));
|
||||||
|
|
||||||
this.pins.push(Svg.path(this.g, "sim-pin", "M359.9,317.3c-12.8,0-22.1,10.3-23.1,23.1V406H383v-65.6C383,327.7,372.7,317.3,359.9,317.3z M360,360.1c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C379.3,351.5,370.7,360.1,360,360.1z", "+3v3"));
|
this.pins.push(svg.path(this.g, "sim-pin", "M359.9,317.3c-12.8,0-22.1,10.3-23.1,23.1V406H383v-65.6C383,327.7,372.7,317.3,359.9,317.3z M360,360.1c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C379.3,351.5,370.7,360.1,360,360.1z", "+3v3"));
|
||||||
this.pins.push(Svg.path(this.g, "sim-pin", "M458,317.6c-13,0-23.6,10.6-23.6,23.6c0,0,0,0.1,0,0.1h0V406H469c4.3,0,8.4-1,12.6-2.7v-60.7c0-0.4,0-0.9,0-1.3C481.6,328.1,471,317.6,458,317.6z M457.8,360.9c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C477.1,352.2,468.4,360.9,457.8,360.9z", "GND"));
|
this.pins.push(svg.path(this.g, "sim-pin", "M458,317.6c-13,0-23.6,10.6-23.6,23.6c0,0,0,0.1,0,0.1h0V406H469c4.3,0,8.4-1,12.6-2.7v-60.7c0-0.4,0-0.9,0-1.3C481.6,328.1,471,317.6,458,317.6z M457.8,360.9c-10.7,0-19.3-8.6-19.3-19.3c0-10.7,8.6-19.3,19.3-19.3c10.7,0,19.3,8.7,19.3,19.3C477.1,352.2,468.4,360.9,457.8,360.9z", "GND"));
|
||||||
|
|
||||||
|
|
||||||
this.pinGradients = this.pins.map((pin, i) => {
|
this.pinGradients = this.pins.map((pin, i) => {
|
||||||
let gid = "gradient-pin-" + i
|
let gid = "gradient-pin-" + i
|
||||||
let lg = Svg.linearGradient(this.defs, gid)
|
let lg = svg.linearGradient(this.defs, gid)
|
||||||
pin.setAttribute("fill", `url(#${gid})`);
|
pin.setAttribute("fill", `url(#${gid})`);
|
||||||
return lg;
|
return lg;
|
||||||
})
|
})
|
||||||
|
|
||||||
this.pinTexts = [67,165,275].map(x => <SVGTextElement>Svg.child(this.g, "text", { class:'sim-text-pin', x:x, y:345}));
|
this.pinTexts = [67, 165, 275].map(x => <SVGTextElement>svg.child(this.g, "text", { class: 'sim-text-pin', x: x, y: 345 }));
|
||||||
|
|
||||||
this.buttonsOuter = []; this.buttons = [];
|
this.buttonsOuter = []; this.buttons = [];
|
||||||
this.buttonsOuter.push(Svg.path(this.g, "sim-button-outer", "M82.1,232.6H25.9c-0.5,0-1-0.4-1-1v-56.2c0-0.5,0.4-1,1-1h56.2c0.5,0,1,0.4,1,1v56.2C83,232.2,82.6,232.6,82.1,232.6", "A"));
|
this.buttonsOuter.push(svg.path(this.g, "sim-button-outer", "M82.1,232.6H25.9c-0.5,0-1-0.4-1-1v-56.2c0-0.5,0.4-1,1-1h56.2c0.5,0,1,0.4,1,1v56.2C83,232.2,82.6,232.6,82.1,232.6", "A"));
|
||||||
this.buttons.push(Svg.path(this.g, "sim-button", "M69.7,203.5c0,8.7-7,15.7-15.7,15.7s-15.7-7-15.7-15.7c0-8.7,7-15.7,15.7-15.7S69.7,194.9,69.7,203.5"));
|
this.buttons.push(svg.path(this.g, "sim-button", "M69.7,203.5c0,8.7-7,15.7-15.7,15.7s-15.7-7-15.7-15.7c0-8.7,7-15.7,15.7-15.7S69.7,194.9,69.7,203.5"));
|
||||||
this.buttonsOuter.push(Svg.path(this.g, "sim-button-outer", "M474.3,232.6h-56.2c-0.5,0-1-0.4-1-1v-56.2c0-0.5,0.4-1,1-1h56.2c0.5,0,1,0.4,1,1v56.2C475.3,232.2,474.8,232.6,474.3,232.6", "B"));
|
this.buttonsOuter.push(svg.path(this.g, "sim-button-outer", "M474.3,232.6h-56.2c-0.5,0-1-0.4-1-1v-56.2c0-0.5,0.4-1,1-1h56.2c0.5,0,1,0.4,1,1v56.2C475.3,232.2,474.8,232.6,474.3,232.6", "B"));
|
||||||
this.buttons.push(Svg.path(this.g, "sim-button", "M461.9,203.5c0,8.7-7,15.7-15.7,15.7c-8.7,0-15.7-7-15.7-15.7c0-8.7,7-15.7,15.7-15.7C454.9,187.8,461.9,194.9,461.9,203.5"));
|
this.buttons.push(svg.path(this.g, "sim-button", "M461.9,203.5c0,8.7-7,15.7-15.7,15.7c-8.7,0-15.7-7-15.7-15.7c0-8.7,7-15.7,15.7-15.7C454.9,187.8,461.9,194.9,461.9,203.5"));
|
||||||
this.buttonsOuter.push(Svg.child(this.g, "rect", {class:"sim-button-outer", x:417, y:250, width:58, height:58, rx:1, ry:1, title:"A+B"}));
|
this.buttonsOuter.push(svg.child(this.g, "rect", { class: "sim-button-outer", x: 417, y: 250, width: 58, height: 58, rx: 1, ry: 1, title: "A+B" }));
|
||||||
this.buttons.push(Svg.child(this.g, "circle", {class:"sim-button", cx:446, cy:278, r:16.5}));
|
this.buttons.push(svg.child(this.g, "circle", { class: "sim-button", cx: 446, cy: 278, r: 16.5 }));
|
||||||
(<any>this.buttonsOuter[2]).style.visibility = 'hidden';
|
(<any>this.buttonsOuter[2]).style.visibility = 'hidden';
|
||||||
(<any>this.buttons[2]).style.visibility = 'hidden';
|
(<any>this.buttons[2]).style.visibility = 'hidden';
|
||||||
|
|
||||||
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", "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-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")
|
||||||
Svg.path(this.g, "sim-label", "M461.4,380.9v-9.3h3.3v14.3h-3.5l-5.2-9.2v9.2h-3.3v-14.3h3.5L461.4,380.9z")
|
svg.path(this.g, "sim-label", "M461.4,380.9v-9.3h3.3v14.3h-3.5l-5.2-9.2v9.2h-3.3v-14.3h3.5L461.4,380.9z")
|
||||||
Svg.path(this.g, "sim-label", "M472.7,371.6c4.8,0,7.5,3.5,7.5,7.2s-2.7,7.2-7.5,7.2h-5.3v-14.3H472.7z M470.8,374.4v8.6h1.8c2.7,0,4.2-2.1,4.2-4.3s-1.6-4.3-4.2-4.3H470.8z")
|
svg.path(this.g, "sim-label", "M472.7,371.6c4.8,0,7.5,3.5,7.5,7.2s-2.7,7.2-7.5,7.2h-5.3v-14.3H472.7z M470.8,374.4v8.6h1.8c2.7,0,4.2-2.1,4.2-4.3s-1.6-4.3-4.2-4.3H470.8z")
|
||||||
}
|
}
|
||||||
|
|
||||||
private attachEvents() {
|
private attachEvents() {
|
||||||
|
@ -630,14 +632,14 @@ svg.sim.grayscale {
|
||||||
this.pins.forEach((pin, index) => {
|
this.pins.forEach((pin, index) => {
|
||||||
if (!this.board.pins[index]) return;
|
if (!this.board.pins[index]) return;
|
||||||
let pt = this.element.createSVGPoint();
|
let pt = this.element.createSVGPoint();
|
||||||
Svg.buttonEvents(pin,
|
svg.buttonEvents(pin,
|
||||||
// move
|
// move
|
||||||
ev => {
|
ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
let pin = state.pins[index];
|
let pin = state.pins[index];
|
||||||
let svgpin = this.pins[index];
|
let svgpin = this.pins[index];
|
||||||
if (pin.mode & PinMode.Input) {
|
if (pin.mode & PinMode.Input) {
|
||||||
let cursor = Svg.cursorPoint(pt, this.element, ev);
|
let cursor = svg.cursorPoint(pt, this.element, ev);
|
||||||
let v = (400 - cursor.y) / 40 * 1023
|
let v = (400 - cursor.y) / 40 * 1023
|
||||||
pin.value = Math.max(0, Math.min(1023, Math.floor(v)));
|
pin.value = Math.max(0, Math.min(1023, Math.floor(v)));
|
||||||
}
|
}
|
||||||
|
@ -648,9 +650,9 @@ svg.sim.grayscale {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
let pin = state.pins[index];
|
let pin = state.pins[index];
|
||||||
let svgpin = this.pins[index];
|
let svgpin = this.pins[index];
|
||||||
Svg.addClass(svgpin, 'touched');
|
svg.addClass(svgpin, "touched");
|
||||||
if (pin.mode & PinMode.Input) {
|
if (pin.mode & PinMode.Input) {
|
||||||
let cursor = Svg.cursorPoint(pt, this.element, ev);
|
let cursor = svg.cursorPoint(pt, this.element, ev);
|
||||||
let v = (400 - cursor.y) / 40 * 1023
|
let v = (400 - cursor.y) / 40 * 1023
|
||||||
pin.value = Math.max(0, Math.min(1023, Math.floor(v)));
|
pin.value = Math.max(0, Math.min(1023, Math.floor(v)));
|
||||||
}
|
}
|
||||||
|
@ -661,7 +663,7 @@ svg.sim.grayscale {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
let pin = state.pins[index];
|
let pin = state.pins[index];
|
||||||
let svgpin = this.pins[index];
|
let svgpin = this.pins[index];
|
||||||
Svg.removeClass(svgpin, 'touched');
|
svg.removeClass(svgpin, "touched");
|
||||||
this.updatePin(pin, index);
|
this.updatePin(pin, index);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -688,17 +690,17 @@ svg.sim.grayscale {
|
||||||
btn.addEventListener(pointerEvents.down, ev => {
|
btn.addEventListener(pointerEvents.down, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
state.buttons[index].pressed = true;
|
state.buttons[index].pressed = true;
|
||||||
Svg.fill(this.buttons[index], this.props.theme.buttonDown);
|
svg.fill(this.buttons[index], this.props.theme.buttonDown);
|
||||||
})
|
})
|
||||||
btn.addEventListener(pointerEvents.leave, ev => {
|
btn.addEventListener(pointerEvents.leave, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
state.buttons[index].pressed = false;
|
state.buttons[index].pressed = false;
|
||||||
Svg.fill(this.buttons[index], this.props.theme.buttonUp);
|
svg.fill(this.buttons[index], this.props.theme.buttonUp);
|
||||||
})
|
})
|
||||||
btn.addEventListener(pointerEvents.up, ev => {
|
btn.addEventListener(pointerEvents.up, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
state.buttons[index].pressed = false;
|
state.buttons[index].pressed = false;
|
||||||
Svg.fill(this.buttons[index], this.props.theme.buttonUp);
|
svg.fill(this.buttons[index], this.props.theme.buttonUp);
|
||||||
|
|
||||||
this.board.bus.queue(state.buttons[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
this.board.bus.queue(state.buttons[index].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
||||||
})
|
})
|
||||||
|
@ -708,27 +710,27 @@ svg.sim.grayscale {
|
||||||
state.buttons[0].pressed = true;
|
state.buttons[0].pressed = true;
|
||||||
state.buttons[1].pressed = true;
|
state.buttons[1].pressed = true;
|
||||||
state.buttons[2].pressed = true;
|
state.buttons[2].pressed = true;
|
||||||
Svg.fill(this.buttons[0], this.props.theme.buttonDown);
|
svg.fill(this.buttons[0], this.props.theme.buttonDown);
|
||||||
Svg.fill(this.buttons[1], this.props.theme.buttonDown);
|
svg.fill(this.buttons[1], this.props.theme.buttonDown);
|
||||||
Svg.fill(this.buttons[2], this.props.theme.buttonDown);
|
svg.fill(this.buttons[2], this.props.theme.buttonDown);
|
||||||
})
|
})
|
||||||
this.buttonsOuter[2].addEventListener(pointerEvents.leave, ev => {
|
this.buttonsOuter[2].addEventListener(pointerEvents.leave, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
state.buttons[0].pressed = false;
|
state.buttons[0].pressed = false;
|
||||||
state.buttons[1].pressed = false;
|
state.buttons[1].pressed = false;
|
||||||
state.buttons[2].pressed = false;
|
state.buttons[2].pressed = false;
|
||||||
Svg.fill(this.buttons[0], this.props.theme.buttonUp);
|
svg.fill(this.buttons[0], this.props.theme.buttonUp);
|
||||||
Svg.fill(this.buttons[1], this.props.theme.buttonUp);
|
svg.fill(this.buttons[1], this.props.theme.buttonUp);
|
||||||
Svg.fill(this.buttons[2], this.props.theme.virtualButtonUp);
|
svg.fill(this.buttons[2], this.props.theme.virtualButtonUp);
|
||||||
})
|
})
|
||||||
this.buttonsOuter[2].addEventListener(pointerEvents.up, ev => {
|
this.buttonsOuter[2].addEventListener(pointerEvents.up, ev => {
|
||||||
let state = this.board;
|
let state = this.board;
|
||||||
state.buttons[0].pressed = false;
|
state.buttons[0].pressed = false;
|
||||||
state.buttons[1].pressed = false;
|
state.buttons[1].pressed = false;
|
||||||
state.buttons[2].pressed = false;
|
state.buttons[2].pressed = false;
|
||||||
Svg.fill(this.buttons[0], this.props.theme.buttonUp);
|
svg.fill(this.buttons[0], this.props.theme.buttonUp);
|
||||||
Svg.fill(this.buttons[1], this.props.theme.buttonUp);
|
svg.fill(this.buttons[1], this.props.theme.buttonUp);
|
||||||
Svg.fill(this.buttons[2], this.props.theme.virtualButtonUp);
|
svg.fill(this.buttons[2], this.props.theme.virtualButtonUp);
|
||||||
|
|
||||||
this.board.bus.queue(state.buttons[2].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
this.board.bus.queue(state.buttons[2].id, DAL.MICROBIT_BUTTON_EVT_CLICK);
|
||||||
})
|
})
|
||||||
|
|
56
tslint.json
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"class-name": true,
|
||||||
|
"comment-format": [
|
||||||
|
true
|
||||||
|
],
|
||||||
|
"indent": [
|
||||||
|
true,
|
||||||
|
"spaces"
|
||||||
|
],
|
||||||
|
"no-duplicate-variable": true,
|
||||||
|
"no-eval": true,
|
||||||
|
"no-internal-module": true,
|
||||||
|
"no-trailing-whitespace": true,
|
||||||
|
"no-var-keyword": true,
|
||||||
|
"one-line": [
|
||||||
|
true,
|
||||||
|
"check-open-brace",
|
||||||
|
"check-whitespace"
|
||||||
|
],
|
||||||
|
"quotemark": [
|
||||||
|
true,
|
||||||
|
"double"
|
||||||
|
],
|
||||||
|
"semicolon": [
|
||||||
|
false,
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"triple-equals": [
|
||||||
|
false,
|
||||||
|
"allow-null-check"
|
||||||
|
],
|
||||||
|
"typedef-whitespace": [
|
||||||
|
true,
|
||||||
|
{
|
||||||
|
"call-signature": "nospace",
|
||||||
|
"index-signature": "nospace",
|
||||||
|
"parameter": "nospace",
|
||||||
|
"property-declaration": "nospace",
|
||||||
|
"variable-declaration": "nospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"variable-name": [
|
||||||
|
true,
|
||||||
|
"ban-keywords"
|
||||||
|
],
|
||||||
|
"whitespace": [
|
||||||
|
true,
|
||||||
|
"check-branch",
|
||||||
|
"check-decl",
|
||||||
|
"check-operator",
|
||||||
|
"check-separator",
|
||||||
|
"check-type"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Before Width: | Height: | Size: 807 B After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 849 B After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 8.4 KiB |
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
|
||||||
<Identity Name="39122940-ab16-4cd4-a0ce-79a3eb863ecf" Version="0.1.3.0" Publisher="CN=jhalleux" />
|
<Identity Name="39122940-ab16-4cd4-a0ce-79a3eb863ecf" Version="0.1.4.0" Publisher="CN=jhalleux" />
|
||||||
<mp:PhoneIdentity PhoneProductId="39122940-ab16-4cd4-a0ce-79a3eb863ecf" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
<mp:PhoneIdentity PhoneProductId="39122940-ab16-4cd4-a0ce-79a3eb863ecf" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>codemicrobitapp</DisplayName>
|
<DisplayName>codemicrobitapp</DisplayName>
|
||||||
|
@ -14,12 +14,12 @@
|
||||||
<Resource Language="x-generate" />
|
<Resource Language="x-generate" />
|
||||||
</Resources>
|
</Resources>
|
||||||
<Applications>
|
<Applications>
|
||||||
<Application Id="App" StartPage="https://codemicrobit.com/">
|
<Application Id="App" StartPage="https://m.pxt.io/">
|
||||||
<uap:ApplicationContentUriRules>
|
<uap:ApplicationContentUriRules>
|
||||||
<uap:Rule Match="https://codemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
|
<uap:Rule Match="https://m.pxt.io/" Type="include" WindowsRuntimeAccess="all" />
|
||||||
</uap:ApplicationContentUriRules>
|
</uap:ApplicationContentUriRules>
|
||||||
<uap:VisualElements DisplayName="code micro:bit" Description="Code editors for the BBC micro:bits" BackgroundColor="white" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
|
<uap:VisualElements DisplayName="m.pxt.io" Description="Code editors for the BBC micro:bit" BackgroundColor="white" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
|
||||||
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png">
|
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" ShortName="m.pxt.io">
|
||||||
</uap:DefaultTile>
|
</uap:DefaultTile>
|
||||||
<uap:SplashScreen Image="images\splashscreen.png" />
|
<uap:SplashScreen Image="images\splashscreen.png" />
|
||||||
</uap:VisualElements>
|
</uap:VisualElements>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<uap:Extension Category="windows.fileTypeAssociation">
|
<uap:Extension Category="windows.fileTypeAssociation">
|
||||||
<uap:FileTypeAssociation Name="microbithex">
|
<uap:FileTypeAssociation Name="microbithex">
|
||||||
<uap:DisplayName>BBC micro:bit binary file</uap:DisplayName>
|
<uap:DisplayName>BBC micro:bit binary file</uap:DisplayName>
|
||||||
<uap:InfoTip>.hex file created with codemicrobit.com or microbit.co.uk</uap:InfoTip>
|
<uap:InfoTip>.hex file created with m.pxt.io or microbit.co.uk</uap:InfoTip>
|
||||||
<uap:SupportedFileTypes>
|
<uap:SupportedFileTypes>
|
||||||
<uap:FileType ContentType="application/x-microbit-hex">.hex</uap:FileType>
|
<uap:FileType ContentType="application/x-microbit-hex">.hex</uap:FileType>
|
||||||
</uap:SupportedFileTypes>
|
</uap:SupportedFileTypes>
|
||||||
|
|