Compare commits

..

73 Commits

Author SHA1 Message Date
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
957c7ad848 0.2.117 2016-05-13 05:08:07 -07:00
5e7351a481 Bump pxt-core to 0.2.127 2016-05-13 05:08:05 -07:00
f0c089373b updated mobile icons 2016-05-13 04:55:28 -07:00
879a85bdbb exposing i2c blocks in pins 2016-05-13 03:38:52 -07:00
7a9c2e0fe4 0.2.116 2016-05-12 22:23:46 -07:00
9656c1159a Bump pxt-core to 0.2.125 2016-05-12 22:23:45 -07:00
801117d6b0 remove head from simulator 2016-05-12 22:23:23 -07:00
c084bff334 remove logo in simulator 2016-05-12 21:56:22 -07:00
18bf35f179 updated camp 2016-05-12 13:56:03 -07:00
7e7dc91947 updated camp 2016-05-12 13:50:27 -07:00
da79f643dc 0.2.115 2016-05-12 13:41:34 -07:00
ea10cde3eb added camp 2016-05-12 13:41:15 -07:00
0a60b0ee37 0.2.114 2016-05-12 12:37:57 -07:00
b4bc985068 upgraded to lancaster 2.0.0.rc3 (core 0.1.9)
added radio.send/receive string
2016-05-12 12:35:40 -07:00
78f9af5bc2 0.2.113 2016-05-11 12:05:13 -07:00
e9410d17a6 0.2.112 2016-05-11 11:42:51 -07:00
ca8ef260d5 Bump pxt-core to 0.2.124 2016-05-11 11:42:49 -07:00
5ea5e9bb5b added accent color 2016-05-11 11:39:45 -07:00
19c689a8c4 added microsoft logo 2016-05-11 09:18:29 -07:00
72226cd4e5 0.2.111 2016-05-11 08:49:33 -07:00
0d3af60892 Merge branch 'master' of https://github.com/Microsoft/pxt-microbit 2016-05-11 06:46:05 -07:00
f88cda8244 added privacy/tou urls 2016-05-11 06:45:45 -07:00
f71925fdd2 Simplify logo some more 2016-05-11 15:39:20 +02:00
bfeda371a9 Add simplified logo (more suitable for small size) 2016-05-11 15:33:55 +02:00
eb09530391 Fix typo 2016-05-11 14:12:09 +02:00
346d1e77da 0.2.110 2016-05-10 21:49:16 -07:00
bf384355c4 Bump pxt-core to 0.2.122 2016-05-10 21:49:15 -07:00
3801e52370 fixed build instructions 2016-05-10 21:43:41 -07:00
99574f1ec8 added link to live editor 2016-05-10 21:43:12 -07:00
12705eed06 removed some ids 2016-05-10 21:40:39 -07:00
a62f2b00b4 updated radio apis to support key/value pair 2016-05-10 21:13:16 -07:00
7d0101af25 marking various radio functions as debug until API is stable 2016-05-10 16:42:18 -07:00
60c3f1f427 0.2.109 2016-05-10 12:41:37 -07:00
8552a2de52 fixing docs icon size 2016-05-10 12:41:20 -07:00
b0d4fdb009 0.2.108 2016-05-10 11:42:14 -07:00
88 changed files with 1209 additions and 514 deletions

View File

@ -3,24 +3,44 @@
This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using
[Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt).
* [Try it live](https://m.pxt.io)
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
# 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
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.
### 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
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
* open the ``win10/app.sln`` solution and launch the ``codemicrobit`` project.
* open the ``win10/app.sln`` solution and launch the ``m.pxt.io`` project.

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 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.
## Blocks or JavaScript

View File

@ -1,8 +1,35 @@
# 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)
* Learn more about the [device](/device)
* 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)

171
docs/getting-started.md Normal file
View File

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

View File

@ -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, () => {
});
led.plot(0, 0);
music.playTone(0, 0);
led.plot(0, 0);
radio.sendNumber(0);
game.addScore(1);
images.createImage(`
. . . . .
@ -24,4 +25,4 @@ serial.writeValue(x, 0);
control.inBackground(() => {
});
```

View File

@ -1,6 +1,6 @@
# 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
basic.showAnimation(`
@ -14,10 +14,14 @@ basic.showAnimation(`
### Parameters
* `leds` - [String](/reference/types/string); a series of LED on/off states
* `interval` - [Number](/reference/types/number); the number of milliseconds to pause after each image frame
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off, in groups one after another.
* `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(`
@ -31,13 +35,17 @@ basic.showAnimation(`
### ~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(`
@ -51,7 +59,7 @@ basic.showAnimation(`
### ~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
* ``leds`` - a series of LED on/off states that form an image (see steps below)
* (optional) ``ms`` - [Number](/reference/types/number) - time to wait after displaying image. In blocks, ``ms`` is 400 by default.
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off.
* `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
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

View File

@ -1,6 +1,6 @@
# 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
basic.showNumber(2, 150)
@ -8,18 +8,18 @@ basic.showNumber(2, 150)
### Parameters
* value - 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
* `value` is a [Number](/reference/types/number).
* `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
basic.showNumber(10)
~~~~
To display the number stored in the `x` variable:
To show the number stored in a variable:
~~~~blocks
let x = 1
@ -28,19 +28,19 @@ basic.showNumber(x)
### 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
for (let i = 0; i < 5; i++) {
basic.showNumber(i + 1)
for (let i = 0; i < 6; i++) {
basic.showNumber(i)
basic.pause(200)
}
~~~~
### Other show functions
* use [show string](/reference/basic/show-string) to show a string on the screen
* use [show animation](/reference/basic/show-animation) to show a series of images 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 group of pictures on the screen, one after another.
### Lessons

View File

@ -1,6 +1,6 @@
# 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
basic.showString("Hello!")
@ -8,18 +8,18 @@ basic.showString("Hello!")
### Parameters
* `text` - a [String](/reference/types/string)
* (optional) `ms` - [Number](/reference/types/number); the time (in milliseconds) before scrolling left by one LED; the larger the number, the slower the scroll
* `text` is a [String](/reference/types/string). It can contain letters, numbers, and punctuation.
* `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:
To display Hello:
To show the word **Hello**:
```blocks
basic.showString("Hello")
```
To display the content of a string variable:
To show what is stored in a [String](/reference/types/string) variable:
```blocks
let s = "Hi"
@ -28,8 +28,8 @@ basic.showString(s)
### Other show functions
* use [show number](/reference/basic/show-number) to show a number on the screen
* use [show animation](/reference/basic/show-animation) to show a series of images 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 group of pictures on the screen, one after another.
### Lessons

View File

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

View File

@ -1,23 +1,26 @@
# If
Run code based on a condition.
### @parent blocks/language
Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false.
### Block Editor
![](/static/mb/hourofcode-0.png)
```blocks
if(true) {
}
```
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
![](/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

View File

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

View File

@ -1,15 +1,13 @@
# For
Repeat code a preset number of times.
### @parent blocks/language
Repeat code a fixed number of times.
### Block Editor
![](/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:

View File

@ -2,8 +2,6 @@
Repeat code a preset number of times.
Repeat code a fixed number of times.
### Block Editor
![](/static/mb/blocks/contents-0.png)

View File

@ -1,23 +1,14 @@
# While
Repeat code in a loop while a condition is true.
### @parent blocks/language
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`.
@ -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`).
// index is set to 4
![](/static/mb/blocks/var-10.png)
// subtract 1 from `index` each time through loop
```blocks
let index = 4;
while(index >= 0) {
led.plot(index, index);
index--;
}
```
### Lessons

View File

@ -4,7 +4,7 @@ The micro:bit pins.
## 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

View File

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

View File

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

View File

@ -3,6 +3,9 @@
Reading and writing data over a serial connection.
```cards
serial.writeValue(x, 0);
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!

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
docs/static/favicon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 382 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

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

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

After

Width:  |  Height:  |  Size: 3.6 KiB

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

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

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

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -2,7 +2,7 @@
## 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
* **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.
* 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…
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

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

View File

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

View File

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

View File

@ -72,7 +72,11 @@
"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).",
"serial": "Reading and writing data over a serial connection.",

View File

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

View File

@ -141,7 +141,7 @@ namespace control {
* @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).
*/
//% 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
void raiseEvent(int src, int value, EventCreationMode mode) {
MicroBitEvent evt(src, value, (MicroBitEventLaunchMode)mode);
@ -150,11 +150,29 @@ namespace control {
/**
* 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
void onEvent(int src, int value, Action 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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -59,42 +59,42 @@ enum class Gesture {
* Raised when shaken
*/
//% block=shake
Shake = GESTURE_SHAKE,
Shake = MICROBIT_ACCELEROMETER_EVT_SHAKE,
/**
* Raised when the logo is upward and the screen is vertical
*/
//% block="logo up"
LogoUp = GESTURE_UP,
LogoUp = MICROBIT_ACCELEROMETER_EVT_TILT_UP,
/**
* Raised when the logo is downward and the screen is vertical
*/
//% block="logo down"
LogoDown = GESTURE_DOWN,
LogoDown = MICROBIT_ACCELEROMETER_EVT_TILT_DOWN,
/**
* Raised when the screen is pointing down and the board is horizontal
*/
//% block="screen up"
ScreenUp = GESTURE_FACE_UP,
ScreenUp = MICROBIT_ACCELEROMETER_EVT_FACE_UP,
/**
* Raised when the screen is pointing up and the board is horizontal
*/
//% block="screen down"
ScreenDown = GESTURE_FACE_DOWN,
ScreenDown = MICROBIT_ACCELEROMETER_EVT_FACE_DOWN,
/**
* Raised when the screen is pointing left
*/
//% block="tilt left"
TiltLeft = GESTURE_LEFT,
TiltLeft = MICROBIT_ACCELEROMETER_EVT_TILT_LEFT,
/**
* Raised when the screen is pointing right
*/
//% block="tilt right"
TiltRight = GESTURE_RIGHT,
TiltRight = MICROBIT_ACCELEROMETER_EVT_TILT_RIGHT,
/**
* Raised when the board is falling!
*/
//% block="free fall"
FreeFall = GESTURE_FREEFALL
FreeFall = MICROBIT_ACCELEROMETER_EVT_FREEFALL
};
//% color=300 weight=99
@ -104,7 +104,7 @@ namespace input {
* @param button 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"
void onButtonPressed(Button button, Action body) {
registerWithDal((int)button, MICROBIT_BUTTON_EVT_CLICK, body);
@ -114,7 +114,7 @@ namespace input {
* Attaches code to run when the screen is facing up.
* @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"
void onGesture(Gesture gesture, Action body) {
registerWithDal(MICROBIT_ID_GESTURE, (int)gesture, body);

View File

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

View File

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

View File

@ -77,9 +77,9 @@ enum BeatFraction {
/**
* Generation of music tones through pin ``P0``.
*/
//% color=52 weight=33
//% color=#D83B01 weight=98
namespace music {
var beatsPerMinute: number = 120;
let beatsPerMinute: number = 120;
/**
* Plays a tone through pin ``P0`` for the given duration.

View File

@ -31,6 +31,11 @@ enum class AnalogPin {
P10 = MICROBIT_ID_IO_P10,
};
enum class PulseValue {
High = MICROBIT_PIN_EVT_PULSE_HI,
Low = MICROBIT_PIN_EVT_PULSE_LO
};
MicroBitPin *getPin(int id) {
switch (id) {
case MICROBIT_ID_IO_P0: return &uBit.io.P0;
@ -75,7 +80,6 @@ namespace pins {
return getPin(id);
}
/**
* Read the specified pin or connector as either 0 or 1
* @param name pin to read from
@ -129,6 +133,29 @@ namespace pins {
void analogSetPeriod(AnalogPin name, int 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).

View File

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

View File

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

View File

@ -7,16 +7,31 @@ namespace serial {
/**
* Reads a line of text from the serial port.
*/
//%
StringData* readString() {
return uBit.serial.readUntil(ManagedString("\r\n")).leakData();
//% help=serial/read-line
//% blockId=serial_read_line block="serial read line"
//% weight=20
StringData* readLine() {
return uBit.serial.readUntil(ManagedString("\n")).leakData();
}
/**
* 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) {
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.
*/
//% weight=2 color=30
//% weight=2 color=#002050
namespace serial {
/**
* Prints a line of text to the 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"
export function writeLine(text: string): void {
writeString(text);
writeString("\r\n");
writeString(text + "\r\n");
}
/**
* Prints a numeric value to the serial
*/
//% help=serial/write-number
//% weight=89 blockGap=8
//% blockId=serial_writenumber block="serial|write number %value"
export function writeNumber(value: number): void {
writeString(value.toString());
@ -27,13 +29,20 @@ namespace serial {
* @param name name of the value stream, eg: x
* @param value to write
*/
//% weight=80
//% weight=88 blockGap=8
//% 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 {
writeString(name);
writeString(": ");
writeNumber(value);
writeLine("");
writeString(name + ":" + value + "\r\n");
}
/**
* 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.
*/
//% color=45 weight=31
//% color=#5C2D91 weight=31
declare namespace images {
/**
@ -113,7 +113,7 @@ declare interface Image {
/**
* Provides access to basic micro:bit functionality.
*/
//% color=190 weight=100
//% color=#0078D7 weight=100
declare namespace basic {
/**
@ -200,7 +200,7 @@ declare namespace input {
* @param button 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
function onButtonPressed(button: Button, body: () => void): void;
@ -208,7 +208,7 @@ declare namespace input {
* Attaches code to run when the screen is facing up.
* @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
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 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
function raiseEvent(src: number, value: number, mode?: EventCreationMode): void;
/**
* 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
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
*/
@ -473,6 +487,21 @@ declare namespace pins {
//% blockId=device_set_analog_period block="analog set period|pin %pin|to (µs)%micros" shim=pins::analogSetPeriod
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).
* @param name pin to write to
@ -534,13 +563,17 @@ declare namespace serial {
/**
* Reads a line of text from the serial port.
*/
//% shim=serial::readString
function readString(): string;
//% help=serial/read-line
//% blockId=serial_read_line block="serial read line"
//% weight=20 shim=serial::readLine
function readLine(): string;
/**
* 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;
}
@ -597,37 +630,4 @@ declare interface Buffer {
write(dstOffset: number, src: Buffer): void;
}
/**
* This allows reading and writing of small blocks of data to FLASH memory.
*/
//% weight=10 color=#cc6600
declare namespace storage {
/**
* Writes the key and buffer pair into FLASH. This operation is rather costly as all the key/value pairs
* have to be rewritten as well.
*/
//% shim=storage::putBuffer
function putBuffer(key: string, buffer: Buffer): void;
/**
* Gets the buffer at the given key if any. If no key is available, empty buffer is returned.
*/
//% shim=storage::getBuffer
function getBuffer(key: string): Buffer;
/**
* Removes an entry identified by the key.
*/
//% shim=storage::remove
function remove(key: string): void;
/**
* The number of entries in the key value store
*/
//% shim=storage::size
function size(): number;
}
// Auto-generated. Do not edit. Really.

View File

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

View File

@ -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",
"version": "0.2.107",
"version": "0.2.125",
"description": "BBC micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.2.121"
"pxt-core": "0.2.131"
}
}

View File

@ -26,7 +26,7 @@
]
},
"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"
}
},
@ -44,7 +44,7 @@
]
},
"files": {
"main.ts": "basic.showString('Hello!')\n"
"main.ts": "basic.showLeds(`\r\n . . . . .\r\n . # . # .\r\n . . . . .\r\n # . . . #\r\n . # # # .\r\n `);"
}
},
"compile": {
@ -53,17 +53,17 @@
"deployDrives": "^MICROBIT"
},
"runtime": {
"mathBlocks": true,
"loopsBlocks": true,
"logicBlocks": true,
"variablesBlocks": true
"mathBlocks": true,
"loopsBlocks": true,
"logicBlocks": true,
"variablesBlocks": true
},
"simulator": {
"autoRun": true,
"aspectRatio": 1.22
},
"compileService": {
"gittag": "v0.1.8",
"gittag": "v0.1.10",
"serviceId": "ws"
},
"serial": {
@ -72,14 +72,18 @@
"log": true
},
"appTheme": {
"accentColor": "#5C005C",
"logoUrl": "https://m.pxt.io/about",
"logo": "./static/microbit.red.svg",
"docsLogo": "./static/microbit.red.svg",
"portraitLogo":"./static/microbit.red.svg",
"footerLogo": "./static/microbit.red.svg",
"logo": "./static/microbit.simplified.svg",
"docsLogo": "./static/microbit.simplified.svg",
"portraitLogo": "./static/microbit.simplified.svg",
"footerLogo": "./static/microbit.simplified.svg",
"organizationLogo": "./static/Microsoft-logo_rgb_c-gray.png",
"homeUrl": "https://m.pxt.io/",
"embedUrl": "https://m.pxt.io/",
"koduUrl": "https://www.kodugamelab.com/bbc-microbit/",
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
"visualStudioCode": true,
"docMenu": [
{
@ -98,6 +102,7 @@
"name": "Device",
"path": "/device"
}
]
],
"sideDoc": "getting-started"
}
}
}

View File

@ -429,6 +429,15 @@ namespace pxsim.serial {
export function readString(): string {
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);
}
}
@ -449,20 +458,46 @@ namespace pxsim.radio {
board().radio.setTransmitPower(power);
}
export function sendNumbers(value0: number, value1: number, value2: number, value3: number): void {
board().radio.datagram.send([value0, value1, value2, value3]);
export function setTransmitSerialNumber(transmit: boolean): void {
board().radio.setTransmitSerialNumber(transmit);
}
export function streamValue(name: string, value: number) {
export function sendNumber(value: number): void {
board().radio.datagram.send([value]);
}
export function sendString(msg: string): void {
board().radio.datagram.send(msg);
}
export function writeValueToSerial(): void {
let b = board();
let v = b.radio.datagram.recv().data[0];
b.writeSerial(`{v:${v}}`);
}
export function sendValue(name: string, value: number) {
board().radio.datagram.send([value]);
}
export function receiveNumber(): number {
return board().radio.datagram.recv().data[0];
let buffer = board().radio.datagram.recv().data;
if (buffer instanceof Array) return buffer[0];
return 0;
}
export function receiveString(): string {
let buffer = board().radio.datagram.recv().data;
if (typeof buffer === "string") return <string>buffer;
return "";
}
export function receivedNumberAt(index: number): number {
return board().radio.datagram.lastReceived.data[index] || 0;
let buffer = board().radio.datagram.recv().data;
if (buffer instanceof Array) return buffer[index] || 0;
return 0;
}
export function receivedSignalStrength(): number {
@ -475,6 +510,13 @@ namespace pxsim.radio {
}
namespace pxsim.pins {
export function onPulse(name: number, pulse: number, body: RefAction) {
}
export function pulseDuration(): number {
return 0;
}
export function digitalReadPin(pinId: number): number {
let pin = getPin(pinId);
if (!pin) return;

View File

@ -234,8 +234,8 @@ namespace pxsim.micro_bit {
let t = Math.max(tmin, Math.min(tmax, state.temperature))
let per = Math.floor((state.temperature - tmin) / (tmax - tmin) * 100)
svg.setGradientValue(this.thermometerGradient, 100 - per + '%');
this.thermometerText.textContent = t + '°C';
svg.setGradientValue(this.thermometerGradient, 100 - per + "%");
this.thermometerText.textContent = t + "°C";
}
private updateHeading() {
@ -246,6 +246,7 @@ namespace pxsim.micro_bit {
if (!this.headInitialized) {
let p = this.head.firstChild.nextSibling as SVGPathElement;
p.setAttribute("d", "m269.9,50.134647l0,0l-39.5,0l0,0c-14.1,0.1 -24.6,10.7 -24.6,24.8c0,13.9 10.4,24.4 24.3,24.7l0,0l39.6,0c14.2,0 40.36034,-22.97069 40.36034,-24.85394c0,-1.88326 -26.06034,-24.54606 -40.16034,-24.64606m-0.2,39l0,0l-39.3,0c-7.7,-0.1 -14,-6.4 -14,-14.2c0,-7.8 6.4,-14.2 14.2,-14.2l39.1,0c7.8,0 14.2,6.4 14.2,14.2c0,7.9 -6.4,14.2 -14.2,14.2l0,0l0,0z");
this.updateTheme();
let pt = this.element.createSVGPoint();
svg.buttonEvents(
this.head,
@ -253,13 +254,12 @@ namespace pxsim.micro_bit {
let cur = svg.cursorPoint(pt, this.element, ev);
state.heading = Math.floor(Math.atan2(cur.y - yc, cur.x - xc) * 180 / Math.PI + 90);
if (state.heading < 0) state.heading += 360;
console.log('heading: ' + state.heading)
this.updateHeading();
});
this.headInitialized = true;
}
let txt = state.heading.toString() + '°';
let txt = state.heading.toString() + "°";
if (txt != this.headText.textContent) {
svg.rotateElement(this.head, xc, yc, state.heading + 180);
this.headText.textContent = txt;
@ -273,7 +273,7 @@ namespace pxsim.micro_bit {
let now = Date.now();
if (now - this.lastFlashTime > 150) {
this.lastFlashTime = now;
svg.animate(this.systemLed, 'sim-flash')
svg.animate(this.systemLed, "sim-flash")
}
}
@ -437,6 +437,18 @@ svg.sim.grayscale {
}
/* 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 {
animation-name: sim-flash-animation;
animation-duration: 0.1s;
@ -501,9 +513,9 @@ svg.sim.grayscale {
// head
this.head = <SVGGElement>svg.child(this.g, "g", {});
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", "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.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", "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", "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" })
// https://www.microbit.co.uk/device/pins
@ -567,9 +579,10 @@ svg.sim.grayscale {
svg.path(this.g, "sim-label", "M35.7,376.4c0-2.8,2.1-5.1,5.5-5.1c3.3,0,5.5,2.4,5.5,5.1v4.7c0,2.8-2.2,5.1-5.5,5.1c-3.3,0-5.5-2.4-5.5-5.1V376.4zM43.3,376.4c0-1.3-0.8-2.3-2.2-2.3c-1.3,0-2.1,1.1-2.1,2.3v4.7c0,1.2,0.8,2.3,2.1,2.3c1.3,0,2.2-1.1,2.2-2.3V376.4z");
svg.path(this.g, "sim-label", "M136.2,374.1c2.8,0,3.4-0.8,3.4-2.5h2.9v14.3h-3.4v-9.5h-3V374.1z");
svg.path(this.g, "sim-label", "M248.6,378.5c1.7-1,3-1.7,3-3.1c0-1.1-0.7-1.6-1.6-1.6c-1,0-1.8,0.6-1.8,2.1h-3.3c0-2.6,1.8-4.6,5.1-4.6c2.6,0,4.9,1.3,4.9,4.3c0,2.4-2.3,3.9-3.8,4.7c-2,1.3-2.5,1.8-2.5,2.9h6.1v2.7h-10C244.8,381.2,246.4,379.9,248.6,378.5z");
svg.path(this.g, "sim-label", "M48.1,270.9l-0.6-1.7h-5.1l-0.6,1.7h-3.5l5.1-14.3h3.1l5.2,14.3H48.1z M45,260.7l-1.8,5.9h3.5L45,260.7z");
svg.path(this.g, "sim-label", "M449.1,135.8h5.9c3.9,0,4.7,2.4,4.7,3.9c0,1.8-1.4,2.9-2.5,3.2c0.9,0,2.6,1.1,2.6,3.3c0,1.5-0.8,4-4.7,4h-6V135.8zM454.4,141.7c1.6,0,2-1,2-1.7c0-0.6-0.3-1.7-2-1.7h-2v3.4H454.4z M452.4,144.1v3.5h2.1c1.6,0,2-1,2-1.8c0-0.7-0.4-1.8-2-1.8H452.4z")
svg.path(this.g, "sim-button-label", "M48.1,270.9l-0.6-1.7h-5.1l-0.6,1.7h-3.5l5.1-14.3h3.1l5.2,14.3H48.1z M45,260.7l-1.8,5.9h3.5L45,260.7z");
svg.path(this.g, "sim-button-label", "M449.1,135.8h5.9c3.9,0,4.7,2.4,4.7,3.9c0,1.8-1.4,2.9-2.5,3.2c0.9,0,2.6,1.1,2.6,3.3c0,1.5-0.8,4-4.7,4h-6V135.8zM454.4,141.7c1.6,0,2-1,2-1.7c0-0.6-0.3-1.7-2-1.7h-2v3.4H454.4z M452.4,144.1v3.5h2.1c1.6,0,2-1,2-1.8c0-0.7-0.4-1.8-2-1.8H452.4z")
svg.path(this.g, "sim-label", "M352.1,381.1c0,1.6,0.9,2.5,2.2,2.5c1.2,0,1.9-0.9,1.9-1.9c0-1.2-0.6-2-2.1-2h-1.3v-2.6h1.3c1.5,0,1.9-0.7,1.9-1.8c0-1.1-0.7-1.6-1.6-1.6c-1.4,0-1.8,0.8-1.8,2.1h-3.3c0-2.4,1.5-4.6,5.1-4.6c2.6,0,5,1.3,5,4c0,1.6-1,2.8-2.1,3.2c1.3,0.5,2.3,1.6,2.3,3.5c0,2.7-2.4,4.3-5.2,4.3c-3.5,0-5.5-2.1-5.5-5.1H352.1z")
svg.path(this.g, "sim-label", "M368.5,385.9h-3.1l-5.1-14.3h3.5l3.1,10.1l3.1-10.1h3.6L368.5,385.9z")
svg.path(this.g, "sim-label", "M444.4,378.3h7.4v2.5h-1.5c-0.6,3.3-3,5.5-7.1,5.5c-4.8,0-7.5-3.5-7.5-7.5c0-3.9,2.8-7.5,7.5-7.5c3.8,0,6.4,2.3,6.6,5h-3.5c-0.2-1.1-1.4-2.2-3.1-2.2c-2.7,0-4.1,2.3-4.1,4.7c0,2.5,1.4,4.7,4.4,4.7c2,0,3.2-1.2,3.4-2.7h-2.5V378.3z")

View File

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

View File

@ -444,13 +444,11 @@
"pvjilh",
"pvqrgm",
"pvzmhz",
"pwlxyy",
"pxebwk",
"pxizap",
"pxyovu",
"pymfqh",
"pzmjbx",
"pzptoo",
"pzucty",
"rannhh",
"rbnvdq",
@ -529,7 +527,6 @@
"tnvnko",
"toqcgf",
"tpdiyw",
"tpxxzl",
"tqeddl",
"tqhpqp",
"tqwach",
@ -552,12 +549,10 @@
"vbcdot",
"vbtmwf",
"vcijrw",
"vcmhms",
"vcoevo",
"vcrvjm",
"vcudrv",
"vczceh",
"vezrot",
"vfcwwr",
"vftxlg",
"vfusfw",