Compare commits

...

64 Commits

Author SHA1 Message Date
8de6605112 0.2.128 2016-05-24 14:32:27 -07:00
daea493dcb Bump pxt-core to 0.2.138 2016-05-24 14:32:11 -07:00
b290692334 using pxt constant to find binary .hex 2016-05-24 14:06:25 -07:00
f25f295d0c 0.2.127 2016-05-24 13:03:06 -07:00
5fd691ef92 Bump pxt-core to 0.2.137 2016-05-24 13:03:04 -07:00
67c8753315 Updating loop docs 2016-05-24 12:30:31 -07:00
9d405afde0 0.2.126 2016-05-24 11:41:37 -07:00
b05c8ebd56 Bump pxt-core to 0.2.136 2016-05-24 11:41:35 -07:00
b69156a12e adding target compile service configuration 2016-05-24 09:46:33 -07:00
961e2cb6e9 Simple language rewrite. Needs new code example; legacy one broken. 2016-05-23 18:02:40 -07:00
924d31a211 Simple language for short topic. 2016-05-23 17:21:36 -07:00
8721b54679 Pretty thoroughly rewritten in simple language. 2016-05-23 16:21:08 -07:00
e99292d008 Minor clarification 2016-05-23 14:46:11 -07:00
cc1ed10efb pics for the 10 activities 2016-05-23 17:39:44 -04:00
b48c11d380 Simpler language; added another (simpler) example. 2016-05-23 13:41:01 -07:00
3f1602f2c0 Simpler language, more interesting example (running time was always 0). 2016-05-23 12:45:14 -07:00
324fd45fb6 Rewriting play-tone for correctness & clarity. 2016-05-23 11:50:08 -07:00
d1a3892eab Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-21 08:25:16 -07:00
28d28eb67f Rewrite text, code sample. 2016-05-20 18:33:31 -07:00
a67164d5e6 Making another topic easier to understand. 2016-05-20 16:05:45 -07:00
86b35ae88d Absolutely necessary tiny tweak. 2016-05-20 15:36:37 -07:00
919c8fdfca Rewrite in simple English, debug the examples. 2016-05-20 15:33:15 -07:00
4abdb28a59 More simple English docs. 2016-05-20 13:24:27 -07:00
21361708ec Rest of Basic in simple English. Reconsider some code samples? 2016-05-20 13:09:18 -07:00
4e56342e52 updated docs 2016-05-20 05:40:54 -07:00
7273354944 support for 3g/6g gestures 2016-05-20 05:39:44 -07:00
9c96591edd 0.2.125 2016-05-19 23:21:16 -07:00
4f38658d74 Bump pxt-core to 0.2.131 2016-05-19 23:21:14 -07:00
6329a79ce1 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-19 23:19:17 -07:00
befbdd32cc Four rewrites of basic.* API pages in simple English. 2016-05-19 16:50:02 -07:00
44688ee5d5 missing simulator function for serial 2016-05-19 14:50:02 -07:00
cc36bae97d Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-19 13:56:28 -07:00
c65bdb34af various docs updates 2016-05-19 13:56:24 -07:00
21f7ef9b55 Simplified (but not oversimplified) show-string docs. Proposed new reference format. 2016-05-19 13:49:26 -07:00
d7250d54f8 Simplified (but not oversimplified) show-string docs. Proposed new reference format. 2016-05-19 13:46:02 -07:00
9a36a2fc05 removing serial event (not supported in DAL) 2016-05-19 13:39:28 -07:00
539357237f 0.2.124 2016-05-19 12:37:54 -07:00
35d59da17e Bump pxt-core to 0.2.130 2016-05-19 12:37:52 -07:00
0b226bc9aa updated category colors theme 2016-05-19 11:59:57 -07:00
f2bab5d122 missing async annotation on serial 2016-05-19 10:53:48 -07:00
6e6a98559c updated setup instructions 2016-05-19 10:34:24 -07:00
217fce953d Table of contents proof of concept 2016-05-18 15:57:43 -07:00
bfac2910da tentative serial fix for #66 2016-05-18 11:57:10 -07:00
5962c28b0e Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-18 11:30:38 -07:00
d3509a6254 Test docs tweak 2016-05-18 11:28:15 -07:00
df91bf234c adding side menu 2016-05-18 11:15:00 -07:00
2a46935f62 better startup instructions 2016-05-18 09:18:14 -07:00
5e024c6f23 added test package 2016-05-17 10:42:44 -07:00
28b3d823b2 0.2.123 2016-05-17 10:28:46 -07:00
b7c9bc7978 fixing test suite 2016-05-17 10:28:26 -07:00
52b2ee3f4c 0.2.122 2016-05-17 09:59:06 -07:00
263cc25633 updated docs 2016-05-17 09:58:51 -07:00
2e3d875b7d added serial events 2016-05-17 09:36:01 -07:00
7704ad9f8d doc updates 2016-05-17 09:35:55 -07:00
845d7a004c updated docs 2016-05-16 22:18:58 -07:00
1cf070d649 changed starting template 2016-05-16 22:04:41 -07:00
24420a2cc4 0.2.121 2016-05-16 21:52:35 -07:00
2f8b61998b bringing back triangles / logo on simulator 2016-05-16 21:48:54 -07:00
af38071c6a 0.2.120 2016-05-16 16:25:04 -07:00
89f09c7f35 added pins->on pulsed 2016-05-16 16:24:44 -07:00
a667467bbd 0.2.119 2016-05-13 06:25:57 -07:00
ada2583e17 removing browserconfig.xml / favicon.ico until cloud supports it 2016-05-13 06:18:15 -07:00
c04538313d 0.2.118 2016-05-13 05:44:48 -07:00
1039dc560e Bump pxt-core to 0.2.129 2016-05-13 05:44:46 -07:00
75 changed files with 876 additions and 349 deletions

View File

@ -7,21 +7,39 @@ This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) usin
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit) [![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
# Getting started ## Local server
Please follow instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost ### Setup
The following commands are a 1-time setup after synching the repo on your machine.
* install the PXT command line
```
npm install -g pxt
```
* install the dependencies
```
npm install
```
### Running
Run this command to open a local web server:
```
pxt serve
```
To make sure you're running the latest tools, run
```
npm update
```
More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
## 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 m.pxt.io and provides additional features. that wraps m.pxt.io and provides additional features.
### Sideloading
* Open Windows **settings** and search for **Developer options**
* Enable the developer mode.
* Find the latest build under ``win10/app/AppPackages/latest`` and run the ``Add-AppDevPackage.ps1`` PowerShell script (mouse right-click, then `run with PowerShell`)
### Building ### Building
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed. * Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.

View File

@ -1,8 +1,8 @@
/// <reference path="../node_modules/pxt-core/built/pxt.d.ts"/> /// <reference path="../node_modules/pxt-core/built/pxt.d.ts"/>
import * as fs from 'fs'; import * as fs from "fs";
import * as path from 'path'; import * as path from "path";
import * as child_process from 'child_process'; import * as child_process from "child_process";
let writeFileAsync: any = Promise.promisify(fs.writeFile) let writeFileAsync: any = Promise.promisify(fs.writeFile)
let execAsync: (cmd: string, options?: { cwd?: string }) => Promise<Buffer> = Promise.promisify(child_process.exec) let execAsync: (cmd: string, options?: { cwd?: string }) => Promise<Buffer> = Promise.promisify(child_process.exec)
@ -13,10 +13,10 @@ export function deployCoreAsync(res: ts.pxt.CompileResult) {
if (drives.length == 0) { if (drives.length == 0) {
console.log("cannot find any drives to deploy to") console.log("cannot find any drives to deploy to")
} else { } else {
console.log("copy microbit.hex to " + drives.join(", ")) console.log(`copy ${ts.pxt.BINARY_HEX} to ` + drives.join(", "))
} }
return Promise.map(drives, d => return Promise.map(drives, d =>
writeFileAsync(d + "microbit.hex", res.outfiles["microbit.hex"]) writeFileAsync(d + ts.pxt.BINARY_HEX, res.outfiles[ts.pxt.BINARY_HEX])
.then(() => { .then(() => {
console.log("wrote hex file to " + d) console.log("wrote hex file to " + d)
})) }))

View File

@ -26,7 +26,7 @@ input.onButtonPressed(Button.B, () => {
The [BBC micro:bit](https://www.microbit.co.uk) is a [pocket-size computer](/device) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone. The [BBC micro:bit](https://www.microbit.co.uk) is a [pocket-size computer](/device) with a 5x5 display of 25 LEDs, Bluetooth and sensors that can be programmed by anyone.
The BBC micro:bit was made possible by many [partners](https://www.microbit.co.uk/partners). The BBC micro:bit was made possible by many [partners](https://www.microbit.co.uk/partners).
The micro:bit provides a fun introduction to programming and making switch on, program it to do something fun wear it, customize it. The micro:bit provides an easy and fun introduction to programming and making switch on, program it to do something fun wear it, customize it.
Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices. Just like Arduino, the micro:bit can be connected to and interact with sensors, displays, and other devices.
## Blocks or JavaScript ## Blocks or JavaScript

View File

@ -1,8 +1,35 @@
# Documentation # Documentation
Welcome to the documentation. ```sim
basic.forever(() => {
basic.showString("DOCS ");
})
input.onButtonPressed(Button.A, () => {
led.stopAnimation();
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .`);
});
input.onButtonPressed(Button.B, () => {
led.stopAnimation();
basic.showLeds(`
. # . # .
# . # . #
# . . . #
. # . # .
. . # . .`);
});
```
* **[getting started](/getting-started)**
* Browse the [API 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++) * Follow up with the [release notes](/release-notes)
### Developers
* Learn about [packages](/packages) (possibly using C++ or ARM thumb)

View File

@ -2,7 +2,7 @@
Are you ready to build cool BBC micro:bit programs? For each challenge, reorder the blocks to recreate the program. Are you ready to build cool BBC micro:bit programs? For each challenge, reorder the blocks to recreate the program.
* If you haven't done so, open [https://m.pxt.io](/) and create a new **Blocks Editor** project ## Open [https://m.pxt.io](/) and create a new **Blocks Editor** project
## Basic ## Basic
@ -28,10 +28,9 @@ To transfer your code to the BBC micro:bit,
### Show animation Forever ### Show animation Forever
Show one image after the other to create an animation., Show one image after the other to create an animation by snapping them together.
Reorder the blocks to make the micro:bit show a happy, then unhappy face. ```blocks
```shuffle
basic.showLeds(` basic.showLeds(`
. . . . . . . . . .
. # . # . . # . # .
@ -48,6 +47,7 @@ Reorder the blocks to make the micro:bit show a happy, then unhappy face.
`) `)
``` ```
### Repeat forever ### Repeat forever
Use the ``forever`` block to repeat your code and have a continuous animation. Use the ``forever`` block to repeat your code and have a continuous animation.

View File

@ -1,23 +0,0 @@
# 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(() => {
});
```

9
docs/open-source.md Normal file
View File

@ -0,0 +1,9 @@
# Open Source
The editor is open source on GitHub under the MIT license. Contributions are welcome, please check our GitHub repos.
### Repos
* [microbit/pxt](https://github.com/Microsoft/pxt), programming experience toolkit (PXT)
* [microsoft/pxt-microbit](https://github.com/Microsoft/pxt-microbit), PXT target for BBC micro:bit
* [microsoft/pxt-microbit-core](https://github.com/Microsoft/pxt-microbit-core), Yotta module used to build the BBC micro:bit runtime

View File

@ -9,8 +9,9 @@ basic.showNumber(0);
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
}); });
led.plot(0, 0);
music.playTone(0, 0); music.playTone(0, 0);
led.plot(0, 0);
radio.sendNumber(0);
game.addScore(1); game.addScore(1);
images.createImage(` images.createImage(`
. . . . . . . . . .

View File

@ -8,7 +8,7 @@ basic.clearScreen()
### Example: vanishing heart ### Example: vanishing heart
The following code displays a heart on the screen and then turns off all the LED lights using `clear screen`: The following code shows a heart on the screen and then turns off all the LED lights using `clear screen`:
```blocks ```blocks
basic.showLeds(` basic.showLeds(`

View File

@ -1,6 +1,7 @@
# Forever # Forever
Repeat code [in the background](/reference/control/in-background) forever. Keep running part of a program
[in the background](/reference/control/in-background).
```sig ```sig
basic.forever(() => { basic.forever(() => {
@ -9,7 +10,9 @@ basic.forever(() => {
### Example: compass ### Example: compass
The following example constantly checks the [compass heading](/reference/input/compass-heading) and updates the screen with the direction. The following example constantly checks the
[compass heading](/reference/input/compass-heading)
and updates the screen with the direction.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
@ -30,7 +33,9 @@ basic.forever(() => {
### Example: counter ### Example: counter
The following example continually shows the current value of a global variable: The following example keeps showing the [number](/reference/types/number) stored in a global variable.
When you press button `A`, the number gets bigger.
You can use a program like this to count things with your BBC micro:bit.
```blocks ```blocks
let num = 0 let num = 0
@ -42,9 +47,12 @@ input.onButtonPressed(Button.A, () => {
}) })
``` ```
### Contention for the LED display ### Competing for the LED screen
If you have multiple processes that each show something on the LED screen, you may get unexpected results. Try, for example: If different parts of a program are each trying
to show something on the LED screen at the same time,
you may get unexpected results.
Try this on your micro:bit:
```blocks ```blocks
basic.forever(() => { basic.forever(() => {

View File

@ -1,6 +1,7 @@
# Pause # Pause
Pause program execution for the specified number of milliseconds. This function is helpful when you need to slow down your program's execution. Pause the program for the number of milliseconds you say.
You can use this function to slow your program down.
```sig ```sig
basic.pause(400) basic.pause(400)
@ -8,11 +9,13 @@ basic.pause(400)
### Parameters ### Parameters
* ``ms`` - the number of milliseconds that you want to pause (100 = 1/10 second, 1000 milliseconds = 1 second) * ``ms`` is the number of milliseconds that you want to pause (100 milliseconds = 1/10 second, and 1000 milliseconds = 1 second).
### Example: diagonal line ### Example: diagonal line
The following example code turns on LED `0, 0` thru `4, 4`, pausing 500 milliseconds after each LED. Without `pause`, the code would run so fast that you wouldn't see each individual LED turning on. This example draws a diagonal line by turning on LED `0, 0` (top left) through LED `4, 4` (bottom right).
The program pauses 500 milliseconds after turning on each LED.
Without `pause`, the program would run so fast that you would not have time to see each LED turning on.
```blocks ```blocks
for (let i = 0; i < 5; i++) { for (let i = 0; i < 5; i++) {

View File

@ -1,6 +1,6 @@
# Show Animation # Show Animation
Show a series of image frames on the [LED screen](/device/screen), pausing the specified time after each frame. Show a group of image frames (pictures) one after another on the [LED screen](/device/screen). It pauses the amount of time you tell it after each frame.
```sig ```sig
basic.showAnimation(` basic.showAnimation(`
@ -14,10 +14,14 @@ basic.showAnimation(`
### Parameters ### Parameters
* `leds` - [String](/reference/types/string); a series of LED on/off states * `leds` is a [String](/reference/types/string) that shows which LEDs are on and off, in groups one after another.
* `interval` - [Number](/reference/types/number); the number of milliseconds to pause after each image frame * `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds to pause after each image frame.
### Show a series of image frames ### Example: Animating a group of image frames
In this animation, each row is 15 spaces wide because
there are three frames in the animation, and each frame is
five spaces wide, just like the screen on the BBC micro:bit.
``` ```
basic.showAnimation(` basic.showAnimation(`
@ -31,13 +35,17 @@ basic.showAnimation(`
### ~hint ### ~hint
If the series of images appear too fast, increase the value of the *interval* parameter. If the animation is too fast, make `interval` bigger.
### ~ ### ~
### Example: animating frames ### Example: animating frames with a pause
The following example creates an image with six frames and then shows each frame o the screen, pausing 500 milliseconds after each frame: This example shows six frames on the screen, pausing 500 milliseconds after each frame.
In this animation, each row is 30 spaces wide because
there are six frames in the animation, and each frame is
five spaces wide, just like the screen.
``` ```
basic.showAnimation(` basic.showAnimation(`
@ -51,7 +59,7 @@ basic.showAnimation(`
### ~hint ### ~hint
Use [forever](/reference/basic/forever) to continually repeat an animation Use [forever](/reference/basic/forever) to show an animation over and over.
### ~ ### ~

View File

@ -15,12 +15,13 @@ basic.showLeds(`
### Parameters ### Parameters
* ``leds`` - a series of LED on/off states that form an image (see steps below) * `leds` is a [String](/reference/types/string) that shows which LEDs are on and off.
* (optional) ``ms`` - [Number](/reference/types/number) - time to wait after displaying image. In blocks, ``ms`` is 400 by default. * `ms` is an optional [Number](/reference/types/number) that shows how many milliseconds to wait after showing a picture.
If you are programming with blocks, `ms` starts out as 400 milliseconds.
### Example - Block Editor ### Example
1. Open the `basic` category and select the `show leds` blocks. Open the `basic` card in the Block Editor and select the `show leds` blocks.
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
@ -33,7 +34,7 @@ basic.showLeds(`
) )
``` ```
In JavaScript, the led off is represented by a `.` and the led on by a `#` character. If you are programming in JavaScript, `#` means an LED that is turned on and `.` means an LED that is turned off.
### Lessons ### Lessons

View File

@ -1,6 +1,6 @@
# Show Number # Show Number
Show a number on the [LED screen](/device/screen), one digit at a time (scrolling from left to right) Show a number on the [LED screen](/device/screen). It will slide left if it has more than one digit.
~~~~sig ~~~~sig
basic.showNumber(2, 150) basic.showNumber(2, 150)
@ -8,18 +8,18 @@ basic.showNumber(2, 150)
### Parameters ### Parameters
* value - a [Number](/reference/types/number) * `value` is a [Number](/reference/types/number).
* (optional) interval (ms) - [Number](/reference/types/number); the time (in milliseconds) before scrolling by one LED; the larger the number, the slower the scroll * `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
### ~ ### Examples:
To display the number 10: To show the number 10:
~~~~blocks ~~~~blocks
basic.showNumber(10) basic.showNumber(10)
~~~~ ~~~~
To display the number stored in the `x` variable: To show the number stored in a variable:
~~~~blocks ~~~~blocks
let x = 1 let x = 1
@ -28,19 +28,19 @@ basic.showNumber(x)
### Example: count to 5 ### Example: count to 5
This example uses a [for](/reference/loops/for) loop to show numbers ``1`` through ``5`` on the screen: This example uses a [for](/reference/loops/for) loop to show numbers ``0`` through ``5`` on the screen:
~~~~blocks ~~~~blocks
for (let i = 0; i < 5; i++) { for (let i = 0; i < 6; i++) {
basic.showNumber(i + 1) basic.showNumber(i)
basic.pause(200) basic.pause(200)
} }
~~~~ ~~~~
### Other show functions ### Other show functions
* use [show string](/reference/basic/show-string) to show a string on the screen * Use [show string](/reference/basic/show-string) to show a [String](/reference/types/string) with letters on the screen.
* use [show animation](/reference/basic/show-animation) to show a series of images on the screen * Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
### Lessons ### Lessons

View File

@ -1,6 +1,6 @@
# Show String # Show String
Show a string on the [LED screen](/device/screen) one character at a time (scrolling from left to right). Show a number on the [LED screen](/device/screen). It will slide left if it is bigger than the screen.
```sig ```sig
basic.showString("Hello!") basic.showString("Hello!")
@ -8,18 +8,18 @@ basic.showString("Hello!")
### Parameters ### Parameters
* `text` - a [String](/reference/types/string) * `text` is a [String](/reference/types/string). It can contain letters, numbers, and punctuation.
* (optional) `ms` - [Number](/reference/types/number); the time (in milliseconds) before scrolling left by one LED; the larger the number, the slower the scroll * `ms` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the [String](/reference/types/string) left by one LED each time. Bigger intervals make the sliding slower.
### Examples: ### Examples:
To display Hello: To show the word **Hello**:
```blocks ```blocks
basic.showString("Hello") basic.showString("Hello")
``` ```
To display the content of a string variable: To show what is stored in a [String](/reference/types/string) variable:
```blocks ```blocks
let s = "Hi" let s = "Hi"
@ -28,8 +28,8 @@ basic.showString(s)
### Other show functions ### Other show functions
* use [show number](/reference/basic/show-number) to show a number on the screen * Use [show number](/reference/basic/show-number) to show a number on the [LED screen](/device/screen).
* use [show animation](/reference/basic/show-animation) to show a series of images on the screen * Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
### Lessons ### Lessons

View File

@ -1,6 +1,6 @@
# Button Is Pressed # Button Is Pressed
Get the state of an input button. The micro:bit has two input buttons: A and B. Check whether a button is pressed right now. The micro:bit has two buttons: button `A` and button `B`.
```sig ```sig
input.buttonIsPressed(Button.A); input.buttonIsPressed(Button.A);
@ -8,24 +8,26 @@ input.buttonIsPressed(Button.A);
### Parameters ### Parameters
* name - [String](/reference/types/string); input button "A", "B", or "A+B" (both input buttons) * ``name`` is a [String](/reference/types/string). You should store `A` in it to check the left button, `B` to check the right button, or `A+B` to check both at the same time.
### Returns ### Returns
* [Boolean](/reference/types/boolean) - `true` if pressed, `false` if not pressed * [Boolean](/reference/types/boolean) that is `true` if the button you are checking is pressed, `false` if it is not pressed.
### Example ### Example
The following code uses an [if](/reference/logic/if) statement to run code, depending on whether or not the A button is pressed: This program uses an [if](/reference/logic/if) to run
one part of the program if the `A` button is pressed, and
another part if it is not pressed.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
let pressed = input.buttonIsPressed(Button.A) let pressed = input.buttonIsPressed(Button.A)
if (pressed) { if (pressed) {
// this code runs if the A button is pressed // this part runs if the A button is pressed
basic.showNumber(1, 150) basic.showNumber(1, 150)
} else { } else {
// this code runs if the A button is *not* pressed // this part runs if the A button is *not* pressed
basic.showNumber(0, 150) basic.showNumber(0, 150)
} }
}) })

View File

@ -1,8 +1,14 @@
# Light Level # Light Level
Gets the light level from ``0`` (dark) to ``255`` (bright). The light is measured by using various LEDs from the screen. Find the light level (how bright or dark it is) where you are.
The light level ``0`` means darkness and ``255`` means bright light.
The BBC micro:bit measures the light around it by using some of the
LEDs on the [LED screen](/device/screen).
This function will return ``0`` on the first call to this method, a light reading will be available after the display has activated the light sensor for the first time. The first time you use it, this function will say ``0``.
After that, it will say the real light level.
This is because the light sensor (the part that can find the light level)
has to be turned on first.
```sig ```sig
input.lightLevel(); input.lightLevel();
@ -10,11 +16,26 @@ input.lightLevel();
### Returns ### Returns
* [Number](/reference/types/number) - light level from ``0`` (dark) to ``255`` (bright). * a [Number](/reference/types/number) that means a light level from ``0`` (dark) to ``255`` (bright).
### Example: show light level
When you press button `B` on the microbit, this
program shows the light level
on the [LED screen](/device/screen).
```blocks
input.onButtonPressed(Button.B, () => {
let level = input.lightLevel()
basic.showNumber(level)
})
```
### Example: chart light level ### Example: chart light level
Use `plot bar chart` to visual the influence of various light source on the light level. This program shows the light level with a [bar chart](/reference/led/plot-bar-graph) on the micro:bit screen.
If you carry the micro:bit around to different places with different light levels,
the bar chart will change.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {

View File

@ -1,6 +1,9 @@
# On Button Pressed # On Button Pressed
Register an [event handler](/reference/event-handler) that will execute whenever an input button (A, B, or A and B together) is pressed during program execution. When [running code](/device/simulator) with this function in a web browser, click an on-screen input button - labelled A or B. Start an [event handler](/reference/event-handler) (part of the program that will run when something happens, like when a button is pressed).
This handler works when button `A` or `B` is pressed, or `A` and `B` together.
When you are using this function in a web browser, click the buttons on the screen instead of the ones
on the BBC micro:bit.
```sig ```sig
input.onButtonPressed(Button.A, () => {}) input.onButtonPressed(Button.A, () => {})
@ -8,7 +11,8 @@ input.onButtonPressed(Button.A, () => {})
### Example: count button clicks ### Example: count button clicks
This example counts how many times the left or right input button is pressed. Each time a button is pressed, the global count variable is increased by 1 and displayed on the screen. This example counts how many times you press the `A` button.
Each time you press the button, the [LED screen](/device/screen) shows the `count` variable getting bigger.
```blocks ```blocks
let count = 0 let count = 0
@ -19,22 +23,29 @@ input.onButtonPressed(Button.A, () => {
}) })
``` ```
### Example: roll a dice ### Example: roll dice
This example generates a random number when you press the B input button, and then displays a random die image: This example shows a number from 1 to 6 when you press the `B` button.
```blocks ```blocks
input.onButtonPressed(Button.B, () => { input.onButtonPressed(Button.B, () => {
let dice = Math.random(6) let dice = Math.random(6) + 1
basic.showNumber(dice) basic.showNumber(dice)
}) })
``` ```
### ~hint
This program adds a `1` to `random(6)` so the numbers on the dice will come out right.
Otherwise, sometimes they would show a `0`.
### ~
### Lessons ### Lessons
[smiley](/lessons/smiley), [answering machine](/lessons/answering-machine), [screen wipe](/lessons/screen-wipe), [rotation animation](/lessons/rotation-animation) [smiley](/lessons/smiley), [answering machine](/lessons/answering-machine), [screen wipe](/lessons/screen-wipe), [rotation animation](/lessons/rotation-animation)
### See also ### See also
[button is pressed](/reference/input/button-is-pressed), [forever](/reference/basic/forever) [button is pressed](/reference/input/button-is-pressed), [forever](/reference/basic/forever), [random](/reference/math/math)

View File

@ -1,6 +1,6 @@
# Running Time # Running Time
Get the number of milliseconds elapsed since the script began. 1,000 milliseconds = 1 second. Find how long it has been since the program started.
```sig ```sig
input.runningTime(); input.runningTime();
@ -8,15 +8,20 @@ input.runningTime();
### Returns ### Returns
* [Number](/reference/types/number) * the [Number](/reference/types/number) of milliseconds since the program started.
(One second is 1000 milliseconds.)
### Example: elapsed time ### Example: elapsed time
This code gets the elapsed time since the start of the program execution and displays it on the screen. When you press button `B` on the microbit, this
program finds the number of milliseconds since the program started
and shows it on the [LED screen](/device/screen).
```blocks ```blocks
let now = input.runningTime() input.onButtonPressed(Button.B, () => {
basic.showNumber(now) let now = input.runningTime()
basic.showNumber(now)
})
``` ```
### Lessons ### Lessons

View File

@ -1,6 +1,6 @@
# Brightness # Brightness
Set the brightness of the [LED screen](/device/screen). Find how bright the [LED screen](/device/screen) is.
```sig ```sig
led.brightness(); led.brightness();
@ -8,11 +8,11 @@ led.brightness();
### Returns ### Returns
* [Number](/reference/types/number) - returns the LCD screen brightness as a number from 0 to 255. A return value of 255 means the screen brightness is at 100% and 127 is about 50% brightness. * a [Number](/reference/types/number) that means how bright the screen is, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright.
### Example: maximum brightness ### Example: highest brightness
If the screen brightness is < 100%, the following code sets the brightness to 100% (255): This program makes the screen completely bright if it is not that way already:
```blocks ```blocks
if (led.brightness() < 255) { if (led.brightness() < 255) {

View File

@ -1,6 +1,7 @@
# Plot Bar Graph # Plot Bar Graph
Displays a vertical bar graph based on the value and high value. Displays a bar graph of the numbers you say.
A bar graph is a kind of chart that shows numbers as lines with different lengths.
```sig ```sig
led.plotBarGraph(2, 20); led.plotBarGraph(2, 20);
@ -8,10 +9,18 @@ led.plotBarGraph(2, 20);
### Parameters ### Parameters
* value: [Number](/reference/types/number) , high : [Number](/reference/types/number) displays a vertical bar graph based on the value and high value * `value` is a [Number](/reference/types/number) that means what you are measuring or trying to show. For example, if you are measuring the temperature of ice with the BBC micro:bit, `value` might be 0 because the temperature might be 0 degrees centigrade.
* `high` is a [Number](/reference/types/number) that means the highest possible number that the `value` parameter can be. This number is also the tallest that the lines in the bar chart can be.
### Example: chart acceleration ### Example: chart acceleration
This program shows a bar graph of the [acceleration](/reference/input/acceleration)
in the `x` direction of the micro:bit.
The micro:bit's `x` direction is from left to right (or right to left).
The more you speed up moving the micro:bit in this direction,
the taller the lines in the bar graph will be,
until they are as tall as the parameter `high` says they can be.
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
let a = input.acceleration(Dimension.X); let a = input.acceleration(Dimension.X);

View File

@ -1,39 +1,9 @@
# Logic # Logic
[if](/reference/logic/if) ```cards
if(true) {}
```blocks true;
if(true) {
}
```
[Boolean](/reference/types/boolean) values: *true*; *false*
```blocks
true
false
```
Boolean binary operators: *and* (conjunction); *or* (disjunction)
```blocks
true && false; true && false;
true || false; !true;
``` 1 != 0;
Boolean negation operator
```blocks
!true
```
Comparison operators (=, !=, <, >, <=, >=)
```blocks
0 == 0;
1 !- 0;
0 < 1;
1 > 0;
0 <= 1;
1 >= 0;
``` ```

View File

@ -1,23 +1,26 @@
# If # If
Run code based on a condition.
### @parent blocks/language ### @parent blocks/language
Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false. Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false.
### Block Editor ```blocks
if(true) {
![](/static/mb/hourofcode-0.png) }
```
In the Block Editor, click on the dark blue gear icon (see above) to add an *else* or *if* to the current block. In the Block Editor, click on the dark blue gear icon (see above) to add an *else* or *if* to the current block.
### Example: adjusting screen brightness ### Example: adjusting screen brightness
![](/static/mb/blocks/game-library/pic0.png) ```blocks
if(input.lightLevel()<100){
led.setBrightness(255);
}
```
If the screen [brightness](/reference/led/brightness) is `< 100`, this code sets the brightness to `255`: If the [light level](/input/light-level) is `< 100`, this code sets the brightness to `255`:
### Lessons ### Lessons

View File

@ -1,26 +1,8 @@
# Loops # Loops
Repeat code. ```cards
[for](/reference/loops/for)
```blocks
for(let i = 0;i<5;i++) {} for(let i = 0;i<5;i++) {}
``` for(let i = 1;i<5;i++) {}
[repeat](/reference/loops/repeat)
![](/static/mb/blocks/contents-0.png)
[while](/reference/loops/while)
```blocks
while(true) {} while(true) {}
```
[forever](/reference/basic/forever)
```blocks
basic.forever(() => {}) basic.forever(() => {})
``` ```

View File

@ -1,20 +1,16 @@
# For # For
Repeat code a preset number of times.
### @parent blocks/language ### @parent blocks/language
Run part of the program the number of times you say.
Repeat code a fixed number of times. ### Example: Count to 4
### Block Editor This program will show the numbers 0, 1, 2, 3, and 4 one after another on the LED screen.
![](/static/mb/events-0.png) ```blocks
for(let i = 0; i < 5; ++i) {
The Block Editor *for* loop is different than the Touch Develop *for* loop in an important way. The above for loop will iterate *five* times, with the loop variable *i* taking on values 0, 1, 2, 3, and 4. The Touch Develop for loop shown below will iterate four times: basic.showNumber(i)
```
for (let k = 0; k < 4; k++) {
} }
``` ```
@ -24,5 +20,5 @@ for (let k = 0; k < 4; k++) {
### See also ### See also
[while](/reference/loops/while), [if](/reference/logic/if) [repeat](/reference/loops/repeat), [while](/reference/loops/while), [if](/reference/logic/if), [show number](/reference/basic/show-number)

View File

@ -1,21 +1,16 @@
# Repeat # Repeat
Repeat code a preset number of times. Run part of the program the number of times you say.
Repeat code a fixed number of times.
### Block Editor ### Block Editor
![](/static/mb/blocks/contents-0.png) ![](/static/mb/blocks/contents-0.png)
### Touch Develop ### Lessons
Touch Develop has no `repeat` loop. Instead you can used a for loop [looper](/lessons/looper)
``` ### See also
for (let i = 0; i < 5; i++) {
}
```
The loop above will repeat five (5) times. [for](/reference/loops/for), [while](/reference/loops/while), [if](/reference/logic/if), [show number](/reference/basic/show-number)

View File

@ -1,23 +1,14 @@
# While # While
Repeat code in a loop while a condition is true.
### @parent blocks/language ### @parent blocks/language
Repeat code while a [Boolean](/reference/types/boolean) `condition` is true. Repeat code while a [Boolean](/reference/types/boolean) `condition` is true.
### ~hide ```blocks
while(true) {
}
``` ```
let condition = false
```
### ~
### Block Editor
![](/static/mb/string-0.png)
The while loop has a *condition* that evaluates to a [Boolean](/reference/types/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`. The while loop has a *condition* that evaluates to a [Boolean](/reference/types/boolean) value. After the `do` keyword, add the code that you want to run while the `condition` is `true`. The while loop concludes with `end while`.
@ -27,11 +18,13 @@ The condition is tested before any code runs. Which means that if the condition
The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`). The following example uses a while loop to make a diagonal line on the LED screen (points `0, 0`, `1, 1`, `2, 2`, `3, 3`, `4, 4`).
// index is set to 4 ```blocks
let index = 4;
![](/static/mb/blocks/var-10.png) while(index >= 0) {
led.plot(index, index);
// subtract 1 from `index` each time through loop index--;
}
```
### Lessons ### Lessons

View File

@ -1,10 +1,10 @@
# Play Tone # Play Tone
Plays a music tone through pin ``P0`` for the given duration. Play a musical tone through pin ``P0`` of the micro:bit for as long as you say.
## Simulator ## Simulator
Simulation of this function is available in many, but not all browsers. This function only works on the micro:bit and in some browsers.
```sig ```sig
music.playTone(440, 120) music.playTone(440, 120)
@ -12,11 +12,14 @@ music.playTone(440, 120)
### Parameters ### Parameters
* `frequency` : [Number](/reference/types/number) - the frequency of the note (in Herz) * `Hz` is the [Number](/reference/types/number) of Hertz (the frequency, how high or low the tone is).
* `ms`: [Number](/reference/types/number) - the duration of the note (milliseconds) * `ms` is the [Number](/reference/types/number) of milliseconds that the tone lasts.
## Example ## Example
This example stores the musical note C in the variable `freq`.
Next, it plays that note for 1000 milliseconds (one second).
```blocks ```blocks
let freq = music.noteFrequency(Note.C) let freq = music.noteFrequency(Note.C)
music.playTone(freq, 1000) music.playTone(freq, 1000)

View File

@ -1,16 +1,16 @@
# Tempo # Tempo
Returns the tempo in beats per minute. Finds the tempo (speed of a piece of music).
```sig ```sig
music.tempo() music.tempo()
``` ```
### Parameters ### Returns
* Returns : [Number](/reference/types/number) - returns the tempo in beats per minute * a [Number](/reference/types/number) that means the bpm (beats per minute, or number of beats in a minute of the music that the micro:bit is playing).
### See also ### See also
[play tone](/reference/music/play-tone), [ring tone](/reference/music/ring-tone) , [rest](/reference/music/rest), [set tempo](/reference/music/set-tempo), [change tempo by](/reference/music/change-tempo-by) [play tone](/reference/music/play-tone), [ring tone](/reference/music/ring-tone), [rest](/reference/music/rest), [set tempo](/reference/music/set-tempo), [change tempo by](/reference/music/change-tempo-by)

View File

@ -4,7 +4,7 @@ The micro:bit pins.
## How to work offline ## How to work offline
If you have loaded the web app at some time in the past (by clicking on "my scripts" from the home page), then if you later open the same browser (whether you are online or offline) and type in [https://codemicrobit.com/](https://codemicrobit.com/), you will be able to access all the features of the web app. Note that it is important to end the URL with "/". If you have loaded the web app at some time in the past (by clicking on "my scripts" from the home page), then if you later open the same browser (whether you are online or offline) and type in [https://m.pxt.io/](https://m.pxt.io/), you will be able to access all the features of the web app. Note that it is important to end the URL with "/".
## Save and load code using files ## Save and load code using files

View File

@ -8,8 +8,14 @@ pins.digitalWritePin(DigitalPin.P0, 0);
pins.analogReadPin(AnalogPin.P0); pins.analogReadPin(AnalogPin.P0);
pins.analogWritePin(AnalogPin.P0, 1023); pins.analogWritePin(AnalogPin.P0, 1023);
pins.analogSetPeriod(AnalogPin.P0, 20000); pins.analogSetPeriod(AnalogPin.P0, 20000);
pins.onPulsed(DigitalPin.P0, PulseValue.High, () => {
});
pins.pulseDuration();
pins.servoWritePin(AnalogPin.P0, 180); pins.servoWritePin(AnalogPin.P0, 180);
pins.servoSetPulse(AnalogPin.P0, 1500); pins.servoSetPulse(AnalogPin.P0, 1500);
pins.i2cReadNumber(0, NumberFormat.Int8LE);
pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE);
pins.map(0, 0, 1023, 0, 4); pins.map(0, 0, 1023, 0, 4);
pins.analogPitch(0, 0); pins.analogPitch(0, 0);
pins.analogSetPitchPin(AnalogPin.P0); pins.analogSetPitchPin(AnalogPin.P0);

View File

@ -4,13 +4,17 @@ Communicate data using radio packets
```cards ```cards
radio.sendNumber(0); radio.sendNumber(0);
radio.sendNumbers(0, 0, 0, 0); radio.sendValue("data", 0);
radio.sendString("");
radio.onDataReceived(() => { radio.onDataReceived(() => {
}); });
radio.receiveNumber(); radio.receiveNumber();
radio.receivedNumberAt(0); radio.receivedNumberAt(0);
radio.receiveString();
radio.receivedSignalStrength(); radio.receivedSignalStrength();
radio.setGroup(0); radio.setGroup(0);
radio.setTransmitPower(0); radio.setTransmitPower(0);
radio.writeValueToSerial();
radio.setTransmitSerialNumber(true);
``` ```

View File

@ -3,6 +3,9 @@
Reading and writing data over a serial connection. Reading and writing data over a serial connection.
```cards ```cards
serial.writeValue(x, 0);
serial.writeLine(""); serial.writeLine("");
serial.writeNumber(0);
serial.writeValue(x, 0);
serial.writeString("");
serial.readLine();
``` ```

197
docs/reference/toc.md Normal file
View File

@ -0,0 +1,197 @@
acceleration
analog-pitch
analog-read-pin
analog-set-period
analog-set-pitch-pin
analog-write-pin
assign
boolean
brightness
button-is-pressed
change
change-score-by
change-tempo
change-var
clear
clear-screen
compass-heading
create-image
digital-read-pin
digital-write-pin
fade-in
fade-out
for
forever
game-library
game-over
if
image
in-background
light-level
magnetic-force
map
math
move
number
[on button pressed](/reference/input/on-button-pressed)
on-data-received
on-gamepad-button
on-gesture
on-pin-pressed
on-signal-strength-changed
pause
pin-is-pressed
pixel
play-tone
plot
plot-all
plot-bar-graph
plot-frame
plot-image
plot-leds
point
position
raise-alert-to
receive-number
receive-number
repeat
reports
reset
rest
ring-tone
rotation
running-time
score
screenshot
scroll-image
send-number
servo-set-pulse
servo-write-pin
set-brightness
set-display-mode
set-group
set-pixel
set-tempo
show-animation
show-frame
show-image
show-leds
show-number
show-string
signal-strength
start-countdown
stop-animation
string
tell-camera-to
tell-microphone-to
tell-remote-control-to
temperature
tempo
toggle
toggle-all
touching
turn
unplot
var
while
width
write-line
write-value

11
docs/release-notes.md Normal file
View File

@ -0,0 +1,11 @@
# Release notes
```sim
basic.forever(() => { basic.showString("RELEASE NOTES"); });
```
### May 2017
We're happy to announce [m.pxt.io](https://m.pxt.io), an Blocks/JavaScript editor for the [BBC micro:bit](https://www.microbit.co.uk).
The editor is [open source](/open-source) on GitHub. Send us your PR!

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/static/icons/mstile-70x70.png"/>
<square150x150logo src="/static/icons/mstile-150x150.png"/>
<square310x310logo src="/static/icons/mstile-310x310.png"/>
<wide310x150logo src="/static/icons/mstile-310x150.png"/>
<TileColor>#9f00a7</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/static/mb/activities/a1-display.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/static/mb/activities/a10-watch.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
docs/static/mb/activities/a2-buttons.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/static/mb/activities/a3-pins.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
docs/static/mb/activities/a4-motion.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
docs/static/mb/activities/a5-compass.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
docs/static/mb/activities/a6-music.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
docs/static/mb/activities/a8-network.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
docs/static/mb/activities/a9-radio.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -2,7 +2,7 @@
## Features ## Features
The Windows 10 App provides all the existing features of codemicrobit.com plus the following ones: The Windows 10 App provides all the existing features of [m.pxt.io](https://m.pxt.io) plus the following ones:
* **auto-upload**: the compiled .hex file is automatically deployed to all connected BBC micro:bits * **auto-upload**: the compiled .hex file is automatically deployed to all connected BBC micro:bits
* **serial piping**: all serial data sent by connected BBC micro:bit is automatically imported and analyzed in the editor. * **serial piping**: all serial data sent by connected BBC micro:bit is automatically imported and analyzed in the editor.
@ -12,7 +12,7 @@ The Windows 10 App provides all the existing features of codemicrobit.com plus t
The following instructions allow to side-load the Windows 10 app. This is required until the app is in the store. The following instructions allow to side-load the Windows 10 app. This is required until the app is in the store.
* Search for “developer settings” in Windows 10 and put your computer in “Developer mode”. * Search for “developer settings” in Windows 10 and put your computer in “Developer mode”.
* Download https://pxt.io/codemicrobit.appx and unzip it. **DO NOT try to install from a zipped folder.** * Download https://m.pxt.io/codemicrobit.appx and unzip it. **DO NOT try to install from a zipped folder.**
* Open the extracted folder, right-click on `Add-AppDevPackage.ps1` and click on `Run with PowerShell`. Follow the prompts… * Open the extracted folder, right-click on `Add-AppDevPackage.ps1` and click on `Run with PowerShell`. Follow the prompts…
4) In order to communicate with the micro:bit via serial, you need to install the [ARM mbed driver](https://developer.mbed.org/handbook/Windows-serial-configuration). 4) In order to communicate with the micro:bit via serial, you need to install the [ARM mbed driver](https://developer.mbed.org/handbook/Windows-serial-configuration).

View File

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

View File

@ -1,6 +1,6 @@
/** /**
* Communicate data using radio packets * Communicate data using radio packets
*/ */
//% color=270 weight=34 //% color=#E3008C weight=34
namespace radio { namespace radio {
} }

View File

@ -72,7 +72,11 @@
"pins.analogWritePin": "Set the connector value as analog. Value must be comprised between 0 and 1023.", "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.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.digitalWritePin": "Set a pin or connector value to either 0 or 1.",
"pins.i2cReadNumber": "Read one number from 7-bit I2C address.",
"pins.i2cWriteNumber": "Write one number to a 7-bit I2C address.",
"pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.", "pins.map": "Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.",
"pins.onPulsed": "Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.",
"pins.pulseDuration": "Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.",
"pins.servoSetPulse": "Configures this IO pin as an analog/pwm output, configures the period to be 20 ms, and sets the pulse width, based on the value it is given **microseconds** or `1/1000` milliseconds.", "pins.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).", "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": "Reading and writing data over a serial connection.",

View File

@ -4,7 +4,7 @@
/** /**
* Provides access to basic micro:bit functionality. * Provides access to basic micro:bit functionality.
*/ */
//% color=190 weight=100 //% color=#0078D7 weight=100
namespace basic { namespace basic {
/** /**

View File

@ -141,7 +141,7 @@ namespace control {
* @param value Component specific code indicating the cause of the event. * @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE). * @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/ */
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1 //% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
//% mode.defl=CREATE_AND_FIRE //% mode.defl=CREATE_AND_FIRE
void raiseEvent(int src, int value, EventCreationMode mode) { void raiseEvent(int src, int value, EventCreationMode mode) {
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode); MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
@ -150,11 +150,29 @@ namespace control {
/** /**
* Raises an event in the event bus. * Raises an event in the event bus.
*/ */
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value" //% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
//% blockExternalInputs=1 //% blockExternalInputs=1
void onEvent(int src, int value, Action handler) { void onEvent(int src, int value, Action handler) {
registerWithDal(src, value, handler); registerWithDal(src, value, handler);
} }
/**
* Gets the value of the last event executed on the bus
*/
//% blockId=control_event_value" block="event value"
//% weight=18
int eventValue() {
return pxt::lastEvent.value;
}
/**
* Gets the timestamp of the last event executed on the bus
*/
//% blockId=control_event_timestamp" block="event timestamp"
//% weight=19 blockGap=8
int eventTimestamp() {
return pxt::lastEvent.timestamp;
}
/** /**
* Gets a friendly name for the device derived from the its serial number * Gets a friendly name for the device derived from the its serial number

View File

@ -7,15 +7,15 @@ namespace control {
/** /**
* Returns the value of a C++ runtime constant * Returns the value of a C++ runtime constant
*/ */
//% weight=19 weight=19 blockId="control_event_source" block="%id" //% weight=2 weight=19 blockId="control_event_source_id" block="%id" blockGap=8
export function eventSource(id: EventBusSource) : number { export function eventSourceId(id: EventBusSource): number {
return id; return id;
} }
/** /**
* Returns the value of a C++ runtime constant * Returns the value of a C++ runtime constant
*/ */
//% weight=19 weight=19 blockId="control_event_value" block="%id" //% weight=1 weight=19 blockId="control_event_value_id" block="%id"
export function eventValue(id: EventBusValue) : number { export function eventValueId(id: EventBusValue): number {
return id; return id;
} }
@ -23,8 +23,7 @@ namespace control {
* Display specified error code and stop the program. * Display specified error code and stop the program.
*/ */
//% shim=pxtrt::panic //% shim=pxtrt::panic
export function panic(code:number) export function panic(code: number) {
{
} }
/** /**

View File

@ -105,6 +105,16 @@ declare namespace basic {
*/ */
//% block="free fall" //% block="free fall"
FreeFall = 7, // MICROBIT_ACCELEROMETER_EVT_FREEFALL FreeFall = 7, // MICROBIT_ACCELEROMETER_EVT_FREEFALL
/**
* Raised when a 3G shock is detected
*/
//% block="3g"
ThreeG = 8, // MICROBIT_ACCELEROMETER_EVT_3G
/**
* Raised when a 6G shock is detected
*/
//% block="6g"
SixG = 9, // MICROBIT_ACCELEROMETER_EVT_6G
} }
declare namespace input { declare namespace input {
} }
@ -262,6 +272,12 @@ declare namespace led {
P4 = 11, // MICROBIT_ID_IO_P4 P4 = 11, // MICROBIT_ID_IO_P4
P10 = 17, // MICROBIT_ID_IO_P10 P10 = 17, // MICROBIT_ID_IO_P10
} }
declare enum PulseValue {
High = 4, // MICROBIT_PIN_EVT_PULSE_HI
Low = 5, // MICROBIT_PIN_EVT_PULSE_LO
}
declare namespace pins { declare namespace pins {
} }
declare namespace serial { declare namespace serial {

View File

@ -21,19 +21,19 @@ enum LedSpriteProperty {
/** /**
* A single-LED sprite game engine * A single-LED sprite game engine
*/ */
//% color=176 weight=32 //% color=#008272 weight=32
namespace game { namespace game {
var _score: number = 0; let _score: number = 0;
var _life: number = 3; let _life: number = 3;
var _startTime: number = 0; let _startTime: number = 0;
var _endTime: number = 0; let _endTime: number = 0;
var _isGameOver: boolean = false; let _isGameOver: boolean = false;
var _countdownPause: number = 0; let _countdownPause: number = 0;
var _level: number = 1; let _level: number = 1;
var _gameId: number = 0; let _gameId: number = 0;
var img: Image; let img: Image;
var sprites: LedSprite[]; let sprites: LedSprite[];
/** /**
* Creates a new LED sprite pointing to the right. * Creates a new LED sprite pointing to the right.
* @param x sprite horizontal coordinate, eg: 2 * @param x sprite horizontal coordinate, eg: 2
@ -47,7 +47,7 @@ namespace game {
sprites.push(p); sprites.push(p);
plot(); plot();
return p; return p;
} }
/** /**
* Gets the current score * Gets the current score
@ -394,7 +394,7 @@ namespace game {
} }
plot(); plot();
} }
/** /**
* Turn the sprite * Turn the sprite
* @param this TODO * @param this TODO
@ -403,7 +403,7 @@ namespace game {
*/ */
//% weight=49 //% weight=49
//% blockId=game_turn_sprite block="%sprite|turn %direction|by (°) %degrees" //% blockId=game_turn_sprite block="%sprite|turn %direction|by (°) %degrees"
public turn(direction : Direction, degrees: number) { public turn(direction: Direction, degrees: number) {
if (direction == Direction.Right) if (direction == Direction.Right)
this.setDirection(this._dir + degrees); this.setDirection(this._dir + degrees);
else else
@ -435,8 +435,8 @@ namespace game {
*/ */
//% weight=29 //% weight=29
//% blockId=game_sprite_set_property block="%sprite|set %property|to %value" blockGap=8 //% blockId=game_sprite_set_property block="%sprite|set %property|to %value" blockGap=8
public set(property : LedSpriteProperty, value:number) { public set(property: LedSpriteProperty, value: number) {
switch(property) { switch (property) {
case LedSpriteProperty.X: this.setX(value); break; case LedSpriteProperty.X: this.setX(value); break;
case LedSpriteProperty.Y: this.setY(value); break; case LedSpriteProperty.Y: this.setY(value); break;
case LedSpriteProperty.Direction: this.setDirection(value); break; case LedSpriteProperty.Direction: this.setDirection(value); break;
@ -452,8 +452,8 @@ namespace game {
*/ */
//% weight=30 //% weight=30
//% blockId=game_sprite_change_xy block="%sprite|change %property|by %value" blockGap=8 //% blockId=game_sprite_change_xy block="%sprite|change %property|by %value" blockGap=8
public change(property : LedSpriteProperty, value:number) { public change(property: LedSpriteProperty, value: number) {
switch(property) { switch (property) {
case LedSpriteProperty.X: this.changeXBy(value); break; case LedSpriteProperty.X: this.changeXBy(value); break;
case LedSpriteProperty.Y: this.changeYBy(value); break; case LedSpriteProperty.Y: this.changeYBy(value); break;
case LedSpriteProperty.Direction: this.changeDirectionBy(value); break; case LedSpriteProperty.Direction: this.changeDirectionBy(value); break;
@ -461,15 +461,15 @@ namespace game {
case LedSpriteProperty.Blink: this.changeBlinkBy(value); break; case LedSpriteProperty.Blink: this.changeBlinkBy(value); break;
} }
} }
/** /**
* Gets a property of the sprite * Gets a property of the sprite
* @param property the name of the property to change * @param property the name of the property to change
*/ */
//% weight=28 //% weight=28
//% blockId=game_sprite_property block="%sprite|%property" //% blockId=game_sprite_property block="%sprite|%property"
public get(property : LedSpriteProperty) { public get(property: LedSpriteProperty) {
switch(property) { switch (property) {
case LedSpriteProperty.X: return this.x(); case LedSpriteProperty.X: return this.x();
case LedSpriteProperty.Y: return this.y(); case LedSpriteProperty.Y: return this.y();
case LedSpriteProperty.Direction: return this.direction() case LedSpriteProperty.Direction: return this.direction()
@ -681,7 +681,7 @@ namespace game {
function init(): void { function init(): void {
if (img == null) { if (img == null) {
img = images.createImage( img = images.createImage(
`0 0 0 0 0 `0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0

View File

@ -3,7 +3,7 @@
/** /**
* Creation, manipulation and display of LED images. * Creation, manipulation and display of LED images.
*/ */
//% color=45 weight=31 //% color=#5C2D91 weight=31
namespace images { namespace images {
/** /**
* Creates an image that fits on the LED screen. * Creates an image that fits on the LED screen.

View File

@ -94,7 +94,17 @@ enum class Gesture {
* Raised when the board is falling! * Raised when the board is falling!
*/ */
//% block="free fall" //% block="free fall"
FreeFall = MICROBIT_ACCELEROMETER_EVT_FREEFALL FreeFall = MICROBIT_ACCELEROMETER_EVT_FREEFALL,
/**
* Raised when a 3G shock is detected
*/
//% block="3g"
ThreeG = MICROBIT_ACCELEROMETER_EVT_3G,
/**
* Raised when a 6G shock is detected
*/
//% block="6g"
SixG = MICROBIT_ACCELEROMETER_EVT_6G
}; };
//% color=300 weight=99 //% color=300 weight=99
@ -104,7 +114,7 @@ namespace input {
* @param button TODO * @param button TODO
* @param body TODO * @param body TODO
*/ */
//% help=input/on-button-pressed weight=85 //% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" //% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192"
void onButtonPressed(Button button, Action body) { void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body); registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
@ -114,9 +124,13 @@ namespace input {
* Attaches code to run when the screen is facing up. * Attaches code to run when the screen is facing up.
* @param body TODO * @param body TODO
*/ */
//% help=input/on-gesture weight=84 //% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135" //% blockId=device_gesture_event block="on |%NAME" icon="\uf135"
void onGesture(Gesture gesture, Action body) { void onGesture(Gesture gesture, Action body) {
if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_3G && uBit.accelerometer.getRange() < 3)
uBit.accelerometer.setRange(4);
else if ((int)gesture == MICROBIT_ACCELEROMETER_EVT_6G && uBit.accelerometer.getRange() < 6)
uBit.accelerometer.setRange(8);
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body); registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);
} }

View File

@ -1,7 +1,7 @@
/** /**
* Events and data from sensors * Events and data from sensors
*/ */
//% color=300 weight=99 //% color=#B4009E weight=99
namespace input { namespace input {
/** /**
* Attaches code to run when the screen is facing up. * Attaches code to run when the screen is facing up.

View File

@ -1,14 +1,14 @@
/** /**
* Control of the LED screen. * Control of the LED screen.
*/ */
//% color=3 weight=35 //% color=#5C2D91 weight=35
namespace led { namespace led {
// what's the current high value // what's the current high value
let barGraphHigh = 0; let barGraphHigh = 0;
// when was the current high value recorded // when was the current high value recorded
let barGraphHighLast = 0; let barGraphHighLast = 0;
/** /**
* Displays a vertical bar graph based on the `value` and `high` value. * Displays a vertical bar graph based on the `value` and `high` value.
* If `high` is 0, the chart gets adjusted automatically. * If `high` is 0, the chart gets adjusted automatically.
@ -17,35 +17,35 @@ namespace led {
*/ */
//% help=/led/plot-bar-graph weight=20 //% help=/led/plot-bar-graph weight=20
//% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true //% blockId=device_plot_bar_graph block="plot bar graph of %value |up to %high" icon="\uf080" blockExternalInputs=true
export function plotBarGraph(value: number, high: number): void { export function plotBarGraph(value: number, high: number): void {
let now = input.runningTime(); let now = input.runningTime();
serial.writeString(value.toString() + "\r\n"); serial.writeString(value.toString() + "\r\n");
value = Math.abs(value); value = Math.abs(value);
if (high != 0) barGraphHigh = high; if (high != 0) barGraphHigh = high;
else if (value > barGraphHigh || now - barGraphHighLast > 5000) { else if (value > barGraphHigh || now - barGraphHighLast > 5000) {
barGraphHigh = value; barGraphHigh = value;
barGraphHighLast = now; barGraphHighLast = now;
} }
barGraphHigh = Math.max(barGraphHigh, 16); barGraphHigh = Math.max(barGraphHigh, 16);
let v = (value * 15) / barGraphHigh; let v = (value * 15) / barGraphHigh;
let k = 0; let k = 0;
for(let y = 4; y >= 0; --y) { for (let y = 4; y >= 0; --y) {
for (let x = 0; x < 3; ++x) { for (let x = 0; x < 3; ++x) {
if (k > v) { if (k > v) {
unplot(2-x,y); unplot(2 - x, y);
unplot(2+x,y); unplot(2 + x, y);
} else { } else {
plot(2-x, y); plot(2 - x, y);
plot(2+x, y); plot(2 + x, y);
} }
++k; ++k;
} }
} }
} }
/** /**
* Toggles a particular pixel * Toggles a particular pixel
* @param x TODO * @param x TODO

View File

@ -77,17 +77,17 @@ enum BeatFraction {
/** /**
* Generation of music tones through pin ``P0``. * Generation of music tones through pin ``P0``.
*/ */
//% color=52 weight=33 //% color=#D83B01 weight=98
namespace music { namespace music {
var beatsPerMinute: number = 120; let beatsPerMinute: number = 120;
/** /**
* Plays a tone through pin ``P0`` for the given duration. * Plays a tone through pin ``P0`` for the given duration.
* @param frequency TODO * @param frequency pitch of the tone to play in Hertz (Hz)
* @param ms TODO * @param ms tone duration in milliseconds (ms)
*/ */
//% help=music/play-tone weight=90 //% help=music/play-tone weight=90
//% blockId=device_play_note block="play|tone (Hz) %note=device_note|for (ms) %duration=device_beat" icon="\uf025" blockGap=8 //% blockId=device_play_note block="play|tone %note=device_note|for %duration=device_beat" icon="\uf025" blockGap=8
export function playTone(frequency: number, ms: number): void { export function playTone(frequency: number, ms: number): void {
pins.analogSetPitchPin(AnalogPin.P0); pins.analogSetPitchPin(AnalogPin.P0);
pins.analogPitch(frequency, ms); pins.analogPitch(frequency, ms);
@ -95,7 +95,7 @@ namespace music {
/** /**
* Plays a tone through pin ``P0``. * Plays a tone through pin ``P0``.
* @param frequency TODO * @param frequency pitch of the tone to play in Hertz (Hz)
*/ */
//% help=music/ring-tone weight=80 //% help=music/ring-tone weight=80
//% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8 //% blockId=device_ring block="ring tone (Hz)|%note=device_note" icon="\uf025" blockGap=8
@ -106,7 +106,7 @@ namespace music {
/** /**
* Rests (plays nothing) for a specified time through pin ``P0``. * Rests (plays nothing) for a specified time through pin ``P0``.
* @param ms TODO * @param ms rest duration in milliseconds (ms)
*/ */
//% help=music/rest weight=79 //% help=music/rest weight=79
//% blockId=device_rest block="rest(ms)|%duration=device_beat" //% blockId=device_rest block="rest(ms)|%duration=device_beat"
@ -117,16 +117,16 @@ namespace music {
/** /**
* Gets the frequency of a note. * Gets the frequency of a note.
* @param name TODO * @param name the note name
*/ */
//% weight=50 help=music/note-frequency //% weight=50 help=music/note-frequency
//% blockId=device_note block="%note" //% blockId=device_note block="%note"
export function noteFrequency(name: Note): number { export function noteFrequency(name: Note): number {
return name; return name;
} }
function init() { function init() {
if (beatsPerMinute <= 0) beatsPerMinute = 120; if (beatsPerMinute <= 0) beatsPerMinute = 120;
} }
/** /**

View File

@ -31,6 +31,11 @@ enum class AnalogPin {
P10 = MICROBIT_ID_IO_P10, P10 = MICROBIT_ID_IO_P10,
}; };
enum class PulseValue {
High = MICROBIT_PIN_EVT_PULSE_HI,
Low = MICROBIT_PIN_EVT_PULSE_LO
};
MicroBitPin *getPin(int id) { MicroBitPin *getPin(int id) {
switch (id) { switch (id) {
case MICROBIT_ID_IO_P0: return &uBit.io.P0; case MICROBIT_ID_IO_P0: return &uBit.io.P0;
@ -75,7 +80,6 @@ namespace pins {
return getPin(id); return getPin(id);
} }
/** /**
* Read the specified pin or connector as either 0 or 1 * Read the specified pin or connector as either 0 or 1
* @param name pin to read from * @param name pin to read from
@ -129,6 +133,29 @@ namespace pins {
void analogSetPeriod(AnalogPin name, int micros) { void analogSetPeriod(AnalogPin name, int micros) {
PINOP(setAnalogPeriodUs(micros)); PINOP(setAnalogPeriodUs(micros));
} }
/**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
*/
//% help=pins/on-pulsed weight=22 blockGap=8
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
void onPulsed(DigitalPin name, PulseValue pulse, Action body) {
MicroBitPin* pin = getPin((int)name);
if (!pin) return;
pin->eventOn(MICROBIT_PIN_EVENT_ON_PULSE);
registerWithDal((int)name, (int)pulse, body);
}
/**
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.
*/
//% help=pins/pulse-micros
//% blockId=pins_pulse_duration block="pulse duration (us)"
//% weight=21
int pulseDuration() {
return pxt::lastEvent.timestamp;
}
/** /**
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement). * Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).

View File

@ -1,7 +1,7 @@
/** /**
* Control currents in Pins for analog/digital signals, servos, i2c, ... * Control currents in Pins for analog/digital signals, servos, i2c, ...
*/ */
//% color=351 weight=30 //% color=#A80000 weight=30
namespace pins { namespace pins {
/** /**
* Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc. * Re-maps a number from one range to another. That is, a value of ``from low`` would get mapped to ``to low``, a value of ``from high`` to ``to high``, values in-between to values in-between, etc.
@ -20,7 +20,7 @@ namespace pins {
/** /**
* Read one number from 7-bit I2C address. * Read one number from 7-bit I2C address.
*/ */
//% help=pins/i2c-read-number //% help=pins/i2c-read-number blockGap=8
//% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7 //% blockId=pins_i2c_readnumber block="i2c read number|at address %address|of format %format=i2c_sizeof" weight=7
export function i2cReadNumber(address: number, format: NumberFormat): number { export function i2cReadNumber(address: number, format: NumberFormat): number {
let buf = pins.i2cReadBuffer(address, pins.sizeOf(format)) let buf = pins.i2cReadBuffer(address, pins.sizeOf(format))

View File

@ -7,16 +7,31 @@ namespace serial {
/** /**
* Reads a line of text from the serial port. * Reads a line of text from the serial port.
*/ */
//% //% help=serial/read-line
StringData* readString() { //% blockId=serial_read_line block="serial read line"
return uBit.serial.readUntil(ManagedString("\r\n")).leakData(); //% weight=20
StringData* readLine() {
return uBit.serial.readUntil(ManagedString("\n")).leakData();
} }
/** /**
* Sends a piece of text through Serial connection. * Sends a piece of text through Serial connection.
*/ */
//% blockId=serial_writestring block="serial write %text" //% help=serial/write-string
//% weight=87
//% blockId=serial_writestring block="serial write string %text"
void writeString(StringData *text) { void writeString(StringData *text) {
uBit.serial.send(ManagedString(text)); uBit.serial.send(ManagedString(text));
} }
/**
* Registers an event to be fired when one of the delimiter is matched
* @param delimiters the characters to match received characters against. eg:"\n"
*/
// help=serial/on-data-received
// weight=19
void onDataReceived(StringData* delimiters, Action body) {
uBit.serial.eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
}
} }

View File

@ -1,22 +1,24 @@
/** /**
* Reading and writing data over a serial connection. * Reading and writing data over a serial connection.
*/ */
//% weight=2 color=30 //% weight=2 color=#002050
namespace serial { namespace serial {
/** /**
* Prints a line of text to the serial * Prints a line of text to the serial
* @param value to send over serial * @param value to send over serial
*/ */
//% help=serial/write-line //% weight=90
//% help=serial/write-line blockGap=8
//% blockId=serial_writeline block="serial|write line %text" //% blockId=serial_writeline block="serial|write line %text"
export function writeLine(text: string): void { export function writeLine(text: string): void {
writeString(text); writeString(text + "\r\n");
writeString("\r\n");
} }
/** /**
* Prints a numeric value to the serial * Prints a numeric value to the serial
*/ */
//% help=serial/write-number
//% weight=89 blockGap=8
//% blockId=serial_writenumber block="serial|write number %value" //% blockId=serial_writenumber block="serial|write number %value"
export function writeNumber(value: number): void { export function writeNumber(value: number): void {
writeString(value.toString()); writeString(value.toString());
@ -27,13 +29,20 @@ namespace serial {
* @param name name of the value stream, eg: x * @param name name of the value stream, eg: x
* @param value to write * @param value to write
*/ */
//% weight=80 //% weight=88 blockGap=8
//% help=serial/write-value //% help=serial/write-value
//% blockId=serial_writevalue block="serial|write line %name|= %value" //% blockId=serial_writevalue block="serial|write value %name|= %value"
export function writeValue(name: string, value: number): void { export function writeValue(name: string, value: number): void {
writeString(name); writeString(name + ":" + value + "\r\n");
writeString(": "); }
writeNumber(value);
writeLine(""); /**
* Registers an event to be fired when a line has been received
*/
// help=serial/on-line-received
// blockId=serial_on_line_received block="serial on line received"
// weight=21 blockGap=8
export function onLineReceived(body: Action): void {
// serial.onDataReceived("\n", body);
} }
} }

View File

@ -4,7 +4,7 @@
/** /**
* Creation, manipulation and display of LED images. * Creation, manipulation and display of LED images.
*/ */
//% color=45 weight=31 //% color=#5C2D91 weight=31
declare namespace images { declare namespace images {
/** /**
@ -113,7 +113,7 @@ declare interface Image {
/** /**
* Provides access to basic micro:bit functionality. * Provides access to basic micro:bit functionality.
*/ */
//% color=190 weight=100 //% color=#0078D7 weight=100
declare namespace basic { declare namespace basic {
/** /**
@ -200,7 +200,7 @@ declare namespace input {
* @param button TODO * @param button TODO
* @param body TODO * @param body TODO
*/ */
//% help=input/on-button-pressed weight=85 //% help=input/on-button-pressed weight=85 blockGap=8
//% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" shim=input::onButtonPressed //% blockId=device_button_event block="on button|%NAME|pressed" icon="\uf192" shim=input::onButtonPressed
function onButtonPressed(button: Button, body: () => void): void; function onButtonPressed(button: Button, body: () => void): void;
@ -208,7 +208,7 @@ declare namespace input {
* Attaches code to run when the screen is facing up. * Attaches code to run when the screen is facing up.
* @param body TODO * @param body TODO
*/ */
//% help=input/on-gesture weight=84 //% help=input/on-gesture weight=84 blockGap=8
//% blockId=device_gesture_event block="on |%NAME" icon="\uf135" shim=input::onGesture //% blockId=device_gesture_event block="on |%NAME" icon="\uf135" shim=input::onGesture
function onGesture(gesture: Gesture, body: () => void): void; function onGesture(gesture: Gesture, body: () => void): void;
@ -332,17 +332,31 @@ declare namespace control {
* @param value Component specific code indicating the cause of the event. * @param value Component specific code indicating the cause of the event.
* @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE). * @param mode optional definition of how the event should be processed after construction (default is CREATE_AND_FIRE).
*/ */
//% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source|with value %value=control_event_value" blockExternalInputs=1 //% weight=21 blockGap=12 blockId="control_raise_event" block="raise event|from source %src=control_event_source_id|with value %value=control_event_value_id" blockExternalInputs=1
//% mode.defl=1 shim=control::raiseEvent //% mode.defl=1 shim=control::raiseEvent
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void; function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
/** /**
* Raises an event in the event bus. * Raises an event in the event bus.
*/ */
//% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source|with value %value=control_event_value" //% weight=20 blockGap=8 blockId="control_on_event" block="on event|from %src=control_event_source_id|with value %value=control_event_value_id"
//% blockExternalInputs=1 shim=control::onEvent //% blockExternalInputs=1 shim=control::onEvent
function onEvent(src: number, value: number, handler: () => void): void; function onEvent(src: number, value: number, handler: () => void): void;
/**
* Gets the value of the last event executed on the bus
*/
//% blockId=control_event_value" block="event value"
//% weight=18 shim=control::eventValue
function eventValue(): number;
/**
* Gets the timestamp of the last event executed on the bus
*/
//% blockId=control_event_timestamp" block="event timestamp"
//% weight=19 blockGap=8 shim=control::eventTimestamp
function eventTimestamp(): number;
/** /**
* Gets a friendly name for the device derived from the its serial number * Gets a friendly name for the device derived from the its serial number
*/ */
@ -473,6 +487,21 @@ declare namespace pins {
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod //% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
function analogSetPeriod(name: AnalogPin, micros: number): void; function analogSetPeriod(name: AnalogPin, micros: number): void;
/**
* Configures this pin to a digital input, and generates events where the timestamp is the duration that this pin was either ``high`` or ``low``.
*/
//% help=pins/on-pulsed weight=22 blockGap=8
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse" shim=pins::onPulsed
function onPulsed(name: DigitalPin, pulse: PulseValue, body: () => void): void;
/**
* Gets the duration of the last pulse in micro-seconds. This function should be called from a ``onPulse`` handler.
*/
//% help=pins/pulse-micros
//% blockId=pins_pulse_duration block="pulse duration (us)"
//% weight=21 shim=pins::pulseDuration
function pulseDuration(): number;
/** /**
* Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement). * Writes a value to the servo, controlling the shaft accordingly. On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation. On a continuous rotation servo, this will set the speed of the servo (with ``0`` being full-speed in one direction, ``180`` being full speed in the other, and a value near ``90`` being no movement).
* @param name pin to write to * @param name pin to write to
@ -534,13 +563,17 @@ declare namespace serial {
/** /**
* Reads a line of text from the serial port. * Reads a line of text from the serial port.
*/ */
//% shim=serial::readString //% help=serial/read-line
function readString(): string; //% blockId=serial_read_line block="serial read line"
//% weight=20 shim=serial::readLine
function readLine(): string;
/** /**
* Sends a piece of text through Serial connection. * Sends a piece of text through Serial connection.
*/ */
//% blockId=serial_writestring block="serial write %text" shim=serial::writeString //% help=serial/write-string
//% weight=87
//% blockId=serial_writestring block="serial write string %text" shim=serial::writeString
function writeString(text: string): void; function writeString(text: string): void;
} }

View File

@ -0,0 +1 @@
run ``pxt testdir ../../buit/docs/blocks`` from this folder

View File

View File

@ -0,0 +1,13 @@
{
"name": "test-snippets",
"description": "A test project for doc snippets",
"installedVersion": "file:.",
"files": [
"main.ts"
],
"public": true,
"dependencies": {
"microbit": "file:../microbit",
"microbit-radio": "file:../microbit-radio"
}
}

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.2.117", "version": "0.2.128",
"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.127" "pxt-core": "0.2.138"
} }
} }

View File

@ -26,7 +26,7 @@
] ]
}, },
"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_show_leds\"><field name=\"LED00\">FALSE</field><field name=\"LED10\">FALSE</field><field name=\"LED20\">FALSE</field><field name=\"LED30\">FALSE</field><field name=\"LED40\">FALSE</field><field name=\"LED01\">FALSE</field><field name=\"LED11\">TRUE</field><field name=\"LED21\">FALSE</field><field name=\"LED31\">TRUE</field><field name=\"LED41\">FALSE</field><field name=\"LED02\">FALSE</field><field name=\"LED12\">FALSE</field><field name=\"LED12\">FALSE</field><field name=\"LED22\">FALSE</field><field name=\"LED32\">FALSE</field><field name=\"LED42\">FALSE</field><field name=\"LED03\">TRUE</field><field name=\"LED13\">FALSE</field><field name=\"LED23\">FALSE</field><field name=\"LED33\">FALSE</field><field name=\"LED43\">TRUE</field><field name=\"LED04\">FALSE</field><field name=\"LED14\">TRUE</field><field name=\"LED24\">TRUE</field><field name=\"LED34\">TRUE</field><field name=\"LED44\">FALSE</field></block></xml>",
"main.ts": "\n" "main.ts": "\n"
} }
}, },
@ -44,7 +44,7 @@
] ]
}, },
"files": { "files": {
"main.ts": "basic.showString('Hello!')\n" "main.ts": "basic.showLeds(`\r\n . . . . .\r\n . # . # .\r\n . . . . .\r\n # . . . #\r\n . # # # .\r\n `);"
} }
}, },
"compile": { "compile": {
@ -63,7 +63,10 @@
"aspectRatio": 1.22 "aspectRatio": 1.22
}, },
"compileService": { "compileService": {
"gittag": "v0.1.9", "yottaTarget": "bbc-microbit-classic-gcc",
"yottaCorePackage": "pxt-microbit-core",
"githubCorePackage": "microsoft/pxt-microbit-core",
"gittag": "v0.1.10",
"serviceId": "ws" "serviceId": "ws"
}, },
"serial": { "serial": {
@ -72,7 +75,7 @@
"log": true "log": true
}, },
"appTheme": { "appTheme": {
"accentColor": "#5C2D91", "accentColor": "#5C005C",
"logoUrl": "https://m.pxt.io/about", "logoUrl": "https://m.pxt.io/about",
"logo": "./static/microbit.simplified.svg", "logo": "./static/microbit.simplified.svg",
"docsLogo": "./static/microbit.simplified.svg", "docsLogo": "./static/microbit.simplified.svg",
@ -102,6 +105,7 @@
"name": "Device", "name": "Device",
"path": "/device" "path": "/device"
} }
] ],
"sideDoc": "getting-started"
} }
} }

View File

@ -429,6 +429,15 @@ namespace pxsim.serial {
export function readString(): string { export function readString(): string {
return board().readSerial(); return board().readSerial();
} }
export function readLine(): string {
return board().readSerial();
}
export function onDataReceived(delimiters: string, handler: RefAction) {
let b = board();
b.bus.listen(DAL.MICROBIT_ID_SERIAL, DAL.MICROBIT_SERIAL_EVT_DELIM_MATCH, handler);
}
} }
@ -501,6 +510,13 @@ namespace pxsim.radio {
} }
namespace pxsim.pins { namespace pxsim.pins {
export function onPulse(name: number, pulse: number, body: RefAction) {
}
export function pulseDuration(): number {
return 0;
}
export function digitalReadPin(pinId: number): number { export function digitalReadPin(pinId: number): number {
let pin = getPin(pinId); let pin = getPin(pinId);
if (!pin) return; if (!pin) return;

View File

@ -234,8 +234,8 @@ 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";
} }
private updateHeading() { private updateHeading() {
@ -244,8 +244,8 @@ namespace pxsim.micro_bit {
let state = this.board; let state = this.board;
if (!state || !state.usesHeading) return; if (!state || !state.usesHeading) return;
if (!this.headInitialized) { if (!this.headInitialized) {
let p = svg.path(this.head, "sim-theme", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z"); let p = this.head.firstChild.nextSibling as SVGPathElement;
this.logos.push(p); p.setAttribute("d", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
this.updateTheme(); this.updateTheme();
let pt = this.element.createSVGPoint(); let pt = this.element.createSVGPoint();
svg.buttonEvents( svg.buttonEvents(
@ -437,6 +437,18 @@ svg.sim.grayscale {
} }
/* animations */ /* animations */
.sim-theme-glow {
animation-name: sim-theme-glow-animation;
animation-timing-function: ease-in-out;
animation-direction: alternate;
animation-iteration-count: infinite;
animation-duration: 1.25s;
}
@keyframes sim-theme-glow-animation {
from { opacity: 1; }
to { opacity: 0.8; }
}
.sim-flash { .sim-flash {
animation-name: sim-flash-animation; animation-name: sim-flash-animation;
animation-duration: 0.1s; animation-duration: 0.1s;
@ -452,9 +464,6 @@ svg.sim.grayscale {
animation-duration: 0.4s; animation-duration: 0.4s;
animation-timing-function: ease-in; animation-timing-function: ease-in;
} }
.sim-button-label {
fill:#fff;
}
@keyframes sim-flash-stroke-animation { @keyframes sim-flash-stroke-animation {
from { stroke: yellow; } from { stroke: yellow; }
@ -481,11 +490,11 @@ svg.sim.grayscale {
this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z"); this.display = svg.path(this.g, "sim-display", "M333.8,310.3H165.9c-8.3,0-15-6.7-15-15V127.5c0-8.3,6.7-15,15-15h167.8c8.3,0,15,6.7,15,15v167.8C348.8,303.6,342.1,310.3,333.8,310.3z");
this.logos = []; this.logos = [];
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" })); this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "115,56.7 173.1,0 115,0" }));
//this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z")); this.logos.push(svg.path(this.g, "sim-theme", "M114.2,0H25.9C12.1,2.1,0,13.3,0,27.7v83.9L114.2,0z"));
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" })); this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "173,27.9 202.5,0 173,0" }));
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" })); this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "54.1,242.4 54.1,274.1 22.4,274.1" }));
//this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" })); this.logos.push(svg.child(this.g, "polygon", { class: "sim-theme", points: "446.2,164.6 446.2,132.8 477.9,132.8" }));
// leds // leds
this.leds = []; this.leds = [];
@ -504,9 +513,9 @@ svg.sim.grayscale {
// head // head
this.head = <SVGGElement>svg.child(this.g, "g", {}); this.head = <SVGGElement>svg.child(this.g, "g", {});
svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" }) svg.child(this.head, "circle", { cx: 258, cy: 75, r: 100, fill: "transparent" })
//this.logos.push(svg.path(this.head, "sim-theme", "M269.9,50.2L269.9,50.2l-39.5,0v0c-14.1,0.1-24.6,10.7-24.6,24.8c0,13.9,10.4,24.4,24.3,24.7v0h39.6c14.2,0,24.8-10.6,24.8-24.7C294.5,61,284,50.3,269.9,50.2 M269.7,89.2L269.7,89.2l-39.3,0c-7.7-0.1-14-6.4-14-14.2c0-7.8,6.4-14.2,14.2-14.2h39.1c7.8,0,14.2,6.4,14.2,14.2C283.9,82.9,277.5,89.2,269.7,89.2")); this.logos.push(svg.path(this.head, "sim-theme sim-theme-glow", "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 sim-theme-glow", "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 sim-theme-glow", "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

View File

@ -527,7 +527,6 @@
"tnvnko", "tnvnko",
"toqcgf", "toqcgf",
"tpdiyw", "tpdiyw",
"tpxxzl",
"tqeddl", "tqeddl",
"tqhpqp", "tqhpqp",
"tqwach", "tqwach",
@ -550,12 +549,10 @@
"vbcdot", "vbcdot",
"vbtmwf", "vbtmwf",
"vcijrw", "vcijrw",
"vcmhms",
"vcoevo", "vcoevo",
"vcrvjm", "vcrvjm",
"vcudrv", "vcudrv",
"vczceh", "vczceh",
"vezrot",
"vfcwwr", "vfcwwr",
"vftxlg", "vftxlg",
"vfusfw", "vfusfw",