Compare commits

..

29 Commits

Author SHA1 Message Date
8030f27fb7 0.4.57 2016-10-19 22:47:10 -07:00
33c4b2b9b7 Bump pxt-core to 0.4.67 2016-10-19 22:47:07 -07:00
2463faf8d6 updated tracking info 2016-10-19 22:46:44 -07:00
6db78761c4 0.4.56 2016-10-19 16:53:30 -07:00
a0893cdaff Bump pxt-core to 0.4.66 2016-10-19 16:53:25 -07:00
c6fa997f02 updated docs from codethemicrobit to pxt.microbit.org 2016-10-19 16:49:05 -07:00
76d236e4d9 updated loc files 2016-10-19 10:45:39 -07:00
0f7323f2da 0.4.55 2016-10-18 21:52:38 -07:00
23d30484d4 updated docs page 2016-10-18 21:52:10 -07:00
6ad59e04a6 fixed uart issues 2016-10-18 21:47:54 -07:00
ae5d5c74a7 better support for BLE UART and alignment with serial blocks. (#276)
* aligning uart apis with serial

* reorganizing serial/bluetooth blocks

* Autoupdate configuration for UART. (#279)

* Autoupdate configuration for UART.

* removing serial autoupdates.
2016-10-18 21:36:42 -07:00
75baca4a97 0.4.54 2016-10-18 21:03:36 -07:00
58ae4945cb Bump pxt-core to 0.4.65 2016-10-18 21:03:34 -07:00
fba37d96b2 updated localization help 2016-10-18 13:19:46 -07:00
5eb8704382 0.4.53 2016-10-18 13:18:20 -07:00
81b66664ef Bump pxt-core to 0.4.63 2016-10-18 13:18:19 -07:00
135aaf4855 0.4.52 2016-10-18 09:08:25 -07:00
1fbf257619 0.4.51 2016-10-17 21:12:33 -07:00
932c01f394 Bump pxt-core to 0.4.62 2016-10-17 21:12:30 -07:00
c3b2b99d7c 0.4.50 2016-10-17 16:45:20 -07:00
ec910cb10f Bump pxt-core to 0.4.60 2016-10-17 16:45:17 -07:00
a19d1c848b renaming board name 2016-10-17 16:18:04 -07:00
790b9f557a renaming translation files 2016-10-17 13:33:27 -07:00
0b469f69b6 Fix i18n not working after 277d5a7 (#277)
* Fix i18n not working after 277d5a7

The translation strings file in "core" package should have file names
"core-strings.json" or "core-jsdoc-strings.json".

* Enable ja translation

Rename "core-strings.json" to "core-jsdoc-strings.json".
Add new "core-strings.json" as a copy of the template.
Add two lines for the files in "pxt.json".
2016-10-17 11:13:38 -07:00
1a3c31c9f3 Deploy no longer throws when no drives found (#269)
pxt deploy no longer throws when no drives found
2016-10-17 07:39:29 -07:00
5d4bd77bf4 0.4.49 2016-10-14 22:57:42 -07:00
c83d7e9f07 Bump pxt-core to 0.4.58 2016-10-14 22:57:35 -07:00
efee05c7f5 0.4.48 2016-10-14 11:30:47 -07:00
cc9ab86181 Bump pxt-core to 0.4.57 2016-10-14 11:30:41 -07:00
59 changed files with 460 additions and 262 deletions

View File

@ -3,7 +3,7 @@
This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using This target allow to program a [BBC micro:bit](https://www.microbit.co.uk/) using
PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)). PXT ([Microsoft Programming Experience Toolkit](https://github.com/Microsoft/pxt)).
* [Try it live](https://codethemicrobit.com) * [Try it live](https://pxt.microbit.org)
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit) [![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
@ -53,11 +53,6 @@ pxt update
More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost More instructions at https://github.com/Microsoft/pxt#running-a-target-from-localhost
### 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 ``codethemicrobit`` project.
## Testing ## Testing
The build automatically runs the following: The build automatically runs the following:

View File

@ -61,7 +61,7 @@ function findNewDevices() {
function main() { function main() {
// Register new clients in the [ports] global variable. // Register new clients in the [ports] global variable.
chrome.runtime.onConnectExternal.addListener(function (port) { chrome.runtime.onConnectExternal.addListener(function (port) {
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit)$/.test(port.name)) { if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit|pxt.microbit.org)$/.test(port.name)) {
ports.push(port); ports.push(port);
port.onDisconnect.addListener(function () { port.onDisconnect.addListener(function () {
ports = ports.filter(function (x) { return x != port }); ports = ports.filter(function (x) { return x != port });

View File

@ -3,10 +3,10 @@
![](Microbit Uploader/Assets.xcassets/AppIcon.appiconset/icon_256x256.png) ![](Microbit Uploader/Assets.xcassets/AppIcon.appiconset/icon_256x256.png)
This project is a clone of the [Windows This project is a clone of the [Windows
uploader](https://codethemicrobit.com/uploader), but for OS X. Once launched, uploader](https://pxt.microbit.org/uploader), but for OS X. Once launched,
the app runs in your menu bar and will automatically deploy any HEX files to the app runs in your menu bar and will automatically deploy any HEX files to
your `micro:bit`. Like the Windows version, it is compatible with any browser your `micro:bit`. Like the Windows version, it is compatible with any browser
that can run [codethemicrobit.com](http://codethemicrobit.com). that can run [pxt.microbit.org](http://pxt.microbit.org).
## Install the built version ## Install the built version

View File

@ -13,20 +13,20 @@ export function deployCoreAsync(res: ts.pxtc.CompileResult) {
return getBitDrivesAsync() return getBitDrivesAsync()
.then(drives => { .then(drives => {
if (drives.length == 0) { if (drives.length == 0) {
let msg = "cannot find any drives to deploy to"; console.log("cannot find any drives to deploy to");
console.log(msg); return Promise.resolve(0);
return Promise.reject(new Error(msg));
} }
console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", ")) console.log(`copy ${ts.pxtc.BINARY_HEX} to ` + drives.join(", "));
return Promise.map(drives, d => let writeHexFile = (filename: string) => {
writeFileAsync(d + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX]) return writeFileAsync(filename + ts.pxtc.BINARY_HEX, res.outfiles[ts.pxtc.BINARY_HEX])
.then(() => { .then(() => console.log("wrote hex file to " + filename));
console.log("wrote hex file to " + d) };
}))
}) return Promise.map(drives, d => writeHexFile(d))
.then(() => { }) .then(() => drives.length);
});
} }
function getBitDrivesAsync(): Promise<string[]> { function getBitDrivesAsync(): Promise<string[]> {

View File

@ -2,5 +2,5 @@
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]); for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true }); mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion }); if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion, targetVersion: pxtConfig.targetId + '/' + pxtConfig.targetVersion });
</script> </script>

View File

@ -2,5 +2,5 @@
(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]); for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true }); mixpanel.init("762fef19c053a0ea4cec43d2fecae76e", { disable_persistence: true });
if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion }); if (typeof pxtConfig !== "undefined") mixpanel.register({ target: pxtConfig.targetId, version: pxtConfig.targetVersion, targetVersion: pxtConfig.targetId + '/' + pxtConfig.targetVersion });
</script> </script>

View File

@ -79,7 +79,7 @@ When code is compiled to ARM machine code, the calls to JavaScript micro:bit fun
## [Command Line Tools](/cli) ## [Command Line Tools](/cli)
Looking to use codethemicrobit.com in your favorite editor? Install the [command line tools](/cli) and get rolling! Looking to use pxt.microbit.org in your favorite editor? Install the [command line tools](/cli) and get rolling!
## [Packages](/packages) ## [Packages](/packages)

View File

@ -1,3 +0,0 @@
{
"appref": "Microsoft/pxt-microbit-built#HEAD"
}

View File

@ -1,6 +1,6 @@
# Unsupported configuration # Unsupported configuration
[codethemicrobit.com](https://codethemicrobit.com) doesn't currently support [pxt.microbit.org](https://pxt.microbit.org) doesn't currently support
your browser or operating system. The following configurations are supported: your browser or operating system. The following configurations are supported:
## Windows ## Windows

View File

@ -1,12 +1,12 @@
# Technical information about browser support # Technical information about browser support
[codethemicrobit.com][] requires that you use a recent version of a modern [pxt.microbit.org][] requires that you use a recent version of a modern
browser, such as Microsoft Edge, Google Chrome, Mozilla Firefox, Safari, Opera, browser, such as Microsoft Edge, Google Chrome, Mozilla Firefox, Safari, Opera,
or IE11. This is because the editor uses modern web technologies such as [web or IE11. This is because the editor uses modern web technologies such as [web
workers][] to enable compiling [TypeScript][] in the browser, or the using the workers][] to enable compiling [TypeScript][] in the browser, or the using the
same [Monaco][] editor that powers [Visual Studio Code][]. same [Monaco][] editor that powers [Visual Studio Code][].
[codethemicrobit.com]: https://codethemicrobit.com [pxt.microbit.org]: https://pxt.microbit.org
[web workers]: http://www.w3.org/TR/workers/ [web workers]: http://www.w3.org/TR/workers/
[typescript]: http://www.typescriptlang.org [typescript]: http://www.typescriptlang.org
[monaco]: https://microsoft.github.io/monaco-editor/ [monaco]: https://microsoft.github.io/monaco-editor/

View File

@ -6,7 +6,7 @@ basic.forever(() => {
}) })
``` ```
It is possible to use the codethemicrobit tools from a command line interface (CLI). The PXT CLI allows to It is possible to use the tools from a command line interface (CLI). The PXT CLI allows to
* edit, compile or deploy JavaScript programs * edit, compile or deploy JavaScript programs
* can easily be integrated in most IDEs. It comes with built-in support for [Visual Studio Code](/code)! * can easily be integrated in most IDEs. It comes with built-in support for [Visual Studio Code](/code)!
* run a local web server for the web editor * run a local web server for the web editor

View File

@ -29,7 +29,7 @@ Unfortunately, using the serial library requires quite a bit of a setup.
If you are using the Google Chrome browser, you can use our extension to get serial data streaming in the editor. If you are using the Google Chrome browser, you can use our extension to get serial data streaming in the editor.
* Install the [Extension for BBC micro:bit](https://chrome.google.com/webstore/detail/extension-for-bbc-microbi/cihhkhnngbjlhahcfmhekmbnnjcjdbge?hl=en-US) on the Chrome Web Store. * Install the [Extension for BBC micro:bit](https://chrome.google.com/webstore/detail/extension-for-bbc-microbi/cihhkhnngbjlhahcfmhekmbnnjcjdbge?hl=en-US) on the Chrome Web Store.
* Restart Chrome and open the [web editor](https://codethemicrobit.com) * Restart Chrome and open the [web editor](https://pxt.microbit.org)
* The serial data will show below the simulator * The serial data will show below the simulator
### Windows ### Windows

View File

@ -34,7 +34,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -34,7 +34,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -34,7 +34,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -41,7 +41,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -43,7 +43,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -43,7 +43,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -41,7 +41,7 @@ it appears as a new drive under Devices.
## Step 2: Download your program ## Step 2: Download your program
1. Open your project on [codethemicrobit.com](https://codethemicrobit.com) 1. Open your project on [pxt.microbit.org](https://pxt.microbit.org)
2. Click **Download** 2. Click **Download**
3. When prompted, choose to **save** the compiled file onto your computer. The 3. When prompted, choose to **save** the compiled file onto your computer. The
prompt will be different depending on which browser you are using, or prompt will be different depending on which browser you are using, or

View File

@ -5,7 +5,8 @@
### Things to do ### Things to do
* **[Getting Started](/getting-started)** * **[Getting Started](/getting-started)**
* [Ten projects](/projects) * [Projects](/projects)
* [Lessons](/lessons)
### Micro:bit reference ### Micro:bit reference
@ -16,16 +17,15 @@
* [Blocks language](/blocks) * [Blocks language](/blocks)
* [JavaScript language](/javascript) * [JavaScript language](/javascript)
* [Streaming data](/streaming)
### More questions? ### More questions?
* [Frequently Asked Question](/faq) * [Frequently Asked Question](/faq)
* [Embedding project](/share)
* [Help Translate](/translate) * [Help Translate](/translate)
* [Release notes](/release-notes) * [Embedding project](/share)
### Developers ### Developers
* [Command Line Interface](/cli) * [Command Line Interface](/cli)
* Learn about [packages](/packages) * Learn about [packages](/packages)
* [Release notes](/release-notes)

View File

@ -1,3 +0,0 @@
{
"appref": "Microsoft/pxt-microbit-built#vtest8"
}

View File

@ -2,7 +2,7 @@
## Web application ## Web application
**https://codethemicrobit.com is an HTML5 web application** that automatically gets cached locally by your browser. **https://pxt.microbit.org is an HTML5 web application** that automatically gets cached locally by your browser.
Once the web app is loaded and you have compiled at least once, you will have all the code needed to work without an internet connection. Once the web app is loaded and you have compiled at least once, you will have all the code needed to work without an internet connection.
## Command line interface ## Command line interface

View File

@ -43,7 +43,7 @@ music.beat(BeatFraction.Quarter)
``` ```
## Step 1: Make a Smiley ## Step 1: Make a Smiley
Open [codethemicrobit.com](https://codethemicrobit.com) in your web browser Open [pxt.microbit.org](https://pxt.microbit.org) in your web browser
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .

View File

@ -5,7 +5,7 @@ with [Raspbian Jessie with Pixel](https://www.raspberrypi.org/downloads/raspbian
## Web editor ## Web editor
Starting with **Raspbian Pixel**, Raspbian comes with Chromium. Simply open [](https://codethemicrobit.com). Starting with **Raspbian Pixel**, Raspbian comes with Chromium. Simply open [](https://pxt.microbit.org).
## Command line ## Command line

View File

@ -2,6 +2,14 @@
Support for additional Bluetooth services. Support for additional Bluetooth services.
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first be [paired with the micro:bit](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the micro:bit and exchange data relating to many of the micro:bit's features.
### ~
```cards ```cards
bluetooth.startAccelerometerService(); bluetooth.startAccelerometerService();
bluetooth.startButtonService(); bluetooth.startButtonService();
@ -9,20 +17,34 @@ bluetooth.startIOPinService();
bluetooth.startLEDService(); bluetooth.startLEDService();
bluetooth.startMagnetometerService(); bluetooth.startMagnetometerService();
bluetooth.startTemperatureService(); bluetooth.startTemperatureService();
bluetooth.uartRead(""); bluetooth.onBluetoothConnected(() => {});
bluetooth.uartWrite(""); bluetooth.onBluetoothDisconnected(() => {});
bluetooth.onBluetoothConnected(() => { ```
}); ## UART
bluetooth.onBluetoothDisconnected(() => {
```cards
}); bluetooth.startUartService();
bluetooth.uartReadUntil("");
bluetooth.uartWriteString("");
bluetooth.uartWriteNumber(0);
bluetooth.uartWriteValue("", 0);
``` ```
```package ```package
microbit-bluetooth microbit-bluetooth
``` ```
### Advanced
For more advanced information on the micro:bit Bluetooth UART service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/uart-service/)
### See Also ### See Also
[startAccelerometerService](/reference/bluetooth/start-accelerometer-service), [startButtonService](/reference/bluetooth/start-button-service), [startIOPinService](/reference/bluetooth/start-io-pin-service), [startLEDService](/reference/bluetooth/start-led-service), [startMagnetometerService](/reference/bluetooth/start-magnetometer-service), [startTemperatureService](/reference/bluetooth/start-temperature-service), [uartRead](/reference/bluetooth/uart-read), [uartWrite](/reference/bluetooth/uart-write), [onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected), [onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected) [startAccelerometerService](/reference/bluetooth/start-accelerometer-service), [startButtonService](/reference/bluetooth/start-button-service), [startIOPinService](/reference/bluetooth/start-io-pin-service), [startLEDService](/reference/bluetooth/start-led-service), [startMagnetometerService](/reference/bluetooth/start-magnetometer-service), [startTemperatureService](/reference/bluetooth/start-temperature-service),
[startUartService](/reference/bluetooth/start-uart-service),
[uartReadUntil](/reference/bluetooth/uart-read-until),
[uartWriteString](/reference/bluetooth/uart-write-string),
[uartWriteNumber](/reference/bluetooth/uart-write-number),
[uartWriteValue](/reference/bluetooth/uart-write-value),
[onBluetoothConnected](/reference/bluetooth/on-bluetooth-connected), [onBluetoothDisconnected](/reference/bluetooth/on-bluetooth-disconnected)

View File

@ -12,7 +12,7 @@ The [Bluetooth UART service](start-uart-service.md) allows another device such a
With the Bluetooth UART service running, this block allows a micro:bit to read data which has been received from a Bluetooth connected device, terminating reading and returning the value obtained as soon as a specified delimiter character is encountered. This means that connected devices can send data to the micro:bit and indicate that the complete message has been sent by appending the message with the delimiter character. With the Bluetooth UART service running, this block allows a micro:bit to read data which has been received from a Bluetooth connected device, terminating reading and returning the value obtained as soon as a specified delimiter character is encountered. This means that connected devices can send data to the micro:bit and indicate that the complete message has been sent by appending the message with the delimiter character.
```sig ```sig
bluetooth.uartRead(""); bluetooth.uartReadUntil("");
``` ```
### Example: Starting the Bluetooth UART service and then reading data received from another device which is terminated by ":" character and then displaying it ### Example: Starting the Bluetooth UART service and then reading data received from another device which is terminated by ":" character and then displaying it
@ -25,7 +25,7 @@ bluetooth.onBluetoothConnected(() => {
basic.showString("C"); basic.showString("C");
connected = 1; connected = 1;
while (connected == 1) { while (connected == 1) {
uartData = bluetooth.uartRead(":"); uartData = bluetooth.uartReadUntil(":");
basic.showString(uartData); basic.showString(uartData);
} }
}); });

View File

@ -0,0 +1,28 @@
# UART Write Number
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first be [paired with the micro:bit](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the micro:bit and exchange data relating to many of the micro:bit's features.
### ~
The [Bluetooth UART service](/reference/bluetooth/start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device.
```sig
bluetooth.uartWriteNumber(42);
```
### Advanced
For more advanced information on the micro:bit Bluetooth UART service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/uart-service/)
### See also
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
```

View File

@ -1,4 +1,4 @@
# UART Write # UART Write String
### ~hint ### ~hint
![](/static/bluetooth/Bluetooth_SIG.png) ![](/static/bluetooth/Bluetooth_SIG.png)
@ -7,12 +7,12 @@ For another device like a smartphone to use any of the Bluetooth "services" whic
### ~ ### ~
The [Bluetooth UART service](start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks. The [Bluetooth UART service](/reference/bluetooth/start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device. With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device.
```sig ```sig
bluetooth.uartWrite(""); bluetooth.uartWriteString("");
``` ```
### Example: Starting the Bluetooth UART service and then sending "HELLO" whenever button A is pressed and another device has connected over Bluetooth ### Example: Starting the Bluetooth UART service and then sending "HELLO" whenever button A is pressed and another device has connected over Bluetooth
@ -29,7 +29,7 @@ bluetooth.onBluetoothDisconnected(() => {
}); });
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
if (connected == 1) { if (connected == 1) {
bluetooth.uartWrite("HELLO"); bluetooth.uartWriteString("HELLO");
} }
}); });
``` ```

View File

@ -0,0 +1,28 @@
# UART Write Value
### ~hint
![](/static/bluetooth/Bluetooth_SIG.png)
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first be [paired with the micro:bit](/reference/bluetooth/bluetooth-pairing). Once paired, the other device may connect to the micro:bit and exchange data relating to many of the micro:bit's features.
### ~
The [Bluetooth UART service](/reference/bluetooth/start-uart-service.md) allows another device such as a smartphone to exchange any data it wants to with the micro:bit, in small chunks.
With the Bluetooth UART service running, this block allows a micro:bit to send data to a Bluetooth connected device.
```sig
bluetooth.uartWriteValue("x", 42);
```
### Advanced
For more advanced information on the micro:bit Bluetooth UART service including information on using a smartphone, see the [Lancaster University micro:bit runtime technical documentation](http://lancaster-university.github.io/microbit-docs/ble/uart-service/)
### See also
[About Bluetooth](/reference/bluetooth/about-bluetooth), [micro:bit Bluetooth profile overview ](http://lancaster-university.github.io/microbit-docs/ble/profile/), [micro:bit Bluetooth profile reference](http://lancaster-university.github.io/microbit-docs/resources/bluetooth/microbit-profile-V1.9-Level-2.pdf), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html), [Bluetooth SIG](https://www.bluetooth.com)
```package
microbit-bluetooth
```

View File

@ -13,7 +13,7 @@ Once you've made your project, you can save it the cloud, share it, or embed it
## Sharing the URL ## Sharing the URL
You can share the URL for the project ([https://codethemicrobit.com/httuftrbtg](https://codethemicrobit.com/httuftrbtg) above) with other people, and they will be able to visit that page to see your project, download it, or edit it: You can share the URL for the project ([https://pxt.microbit.org/httuftrbtg](https://pxt.microbit.org/httuftrbtg) above) with other people, and they will be able to visit that page to see your project, download it, or edit it:
![Project page](/static/embed/project-page.png) ![Project page](/static/embed/project-page.png)
@ -36,12 +36,12 @@ Open the HTML editor for your blog or website and paste it with your content
### Wordpress ### Wordpress
[wordpress.com][] blogs do not support embedding content from most websites, so you will need to link to your project instead. Alternatively, if you have a Wordpress VIP account you can follow [these instructions][wordpress-vip] to embed an `iframe` into your blog. The URL that you need to add is like `https://codethemicrobit.com/?sandbox=1#pub:httuftrbtg`, but replace `httuftrbtg` with your project's unique identifier. [wordpress.com][] blogs do not support embedding content from most websites, so you will need to link to your project instead. Alternatively, if you have a Wordpress VIP account you can follow [these instructions][wordpress-vip] to embed an `iframe` into your blog. The URL that you need to add is like `https://pxt.microbit.org/?sandbox=1#pub:httuftrbtg`, but replace `httuftrbtg` with your project's unique identifier.
If you self host a Wordpress blog you can install the [iframe-plugin][] and then write the following in your blog-post (again, replacing the `httuftrbtg` with your project's identifier): If you self host a Wordpress blog you can install the [iframe-plugin][] and then write the following in your blog-post (again, replacing the `httuftrbtg` with your project's identifier):
``` ```
[iframe src="https://codethemicrobit.com/?sandbox=1#pub:httuftrbtg"] [iframe src="https://pxt.microbit.org/?sandbox=1#pub:httuftrbtg"]
``` ```
### Blogger ### Blogger

View File

@ -5,24 +5,20 @@ and you can volunteer to translate parts of the web site.
## Translating the editor interface ## Translating the editor interface
The project below contains the resources from https://www.pxt.io and the menu items of https://codethemicrobit.com. The project below contains the resources from https://www.pxt.io and the menu items of https://pxt.microbit.org.
* [https://crowdin.com/project/kindscript](https://crowdin.com/project/kindscript) * [https://crowdin.com/project/kindscript](https://crowdin.com/project/kindscript)
You will find two files in that project: You will find two files in that project:
* ``string.json``: text contained in the menu items of https://codethemicrobit.com * ``string.json``: text contained in the menu items of https://pxt.microbit.org
* ``website.json``: text contained in the pages served by https://www.pxt.io * ``website.json``: text contained in the pages served by https://www.pxt.io
## Translating the blocks and reference documentation ## Translating the blocks and reference documentation
The project below contains the resources from the blocks and functions using in the https://codethemicrobit.com. You will find package files under ``/microbit`` , one for the block definition and one for the descriptions:
* [https://crowdin.com/project/pxt-microbit](https://crowdin.com/project/pxt-microbit) * ``core-strings.json``: contains the block definitions
* ``core-jsdoc-strings.json``: contains the descriptions
You will find two files for each package available in the micro:bit, one for the block definition and one for the descriptions:
* ``microbit-strings.json``: contains the block definitions
* ``microbit-jsdoc-strings.json``: contains the descriptions
The block definition should be carefully translated using the [block definition syntax](https://www.pxt.io/defining-blocks). The block definition should be carefully translated using the [block definition syntax](https://www.pxt.io/defining-blocks).

View File

@ -1,4 +1,5 @@
{ {
"bluetooth": "Support for additional Bluetooth services.",
"bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth", "bluetooth.onBluetoothConnected": "Register code to run when the micro:bit is connected to over Bluetooth",
"bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established", "bluetooth.onBluetoothConnected|param|body": "Code to run when a Bluetooth connection is established",
"bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost", "bluetooth.onBluetoothDisconnected": "Register code to run when a bluetooth connection to the micro:bit is lost",
@ -10,6 +11,10 @@
"bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service", "bluetooth.startMagnetometerService": "Starts the Bluetooth magnetometer service",
"bluetooth.startTemperatureService": "Starts the Bluetooth temperature service", "bluetooth.startTemperatureService": "Starts the Bluetooth temperature service",
"bluetooth.startUartService": "Starts the Bluetooth UART service", "bluetooth.startUartService": "Starts the Bluetooth UART service",
"bluetooth.uartRead": "Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.", "bluetooth.uartReadUntil": "Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.",
"bluetooth.uartWrite": "Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device." "bluetooth.uartWriteNumber": "Prints a numeric value to the serial",
"bluetooth.uartWriteString": "Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.",
"bluetooth.uartWriteValue": "Writes a ``name: value`` pair line to the serial.",
"bluetooth.uartWriteValue|param|name": "name of the value stream, eg: x",
"bluetooth.uartWriteValue|param|value": "to write"
} }

View File

@ -8,7 +8,10 @@
"bluetooth.startMagnetometerService|block": "bluetooth magnetometer service", "bluetooth.startMagnetometerService|block": "bluetooth magnetometer service",
"bluetooth.startTemperatureService|block": "bluetooth temperature service", "bluetooth.startTemperatureService|block": "bluetooth temperature service",
"bluetooth.startUartService|block": "bluetooth uart service", "bluetooth.startUartService|block": "bluetooth uart service",
"bluetooth.uartRead|block": "bluetooth uart read %del=bluetooth_uart_delimiter_conv", "bluetooth.uartReadUntil|block": "bluetooth uart|read until %del=serial_delimiter_conv",
"bluetooth.uartWrite|block": "bluetooth uart write %data", "bluetooth.uartWriteNumber|block": "bluetooth uart|write number %value",
"bluetooth|block": "bluetooth" "bluetooth.uartWriteString|block": "bluetooth uart|write string %data",
"bluetooth.uartWriteValue|block": "bluetooth uart|write value %name|= %value",
"bluetooth|block": "bluetooth",
"{id:category}Bluetooth": "Bluetooth"
} }

View File

@ -4,22 +4,6 @@
using namespace pxt; using namespace pxt;
enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
};
/** /**
* Support for additional Bluetooth services. * Support for additional Bluetooth services.
*/ */
@ -27,12 +11,33 @@ enum Delimiters {
namespace bluetooth { namespace bluetooth {
MicroBitUARTService *uart = NULL; MicroBitUARTService *uart = NULL;
/**
* Starts the Bluetooth accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service"
//% parts="bluetooth" weight=90 blockGap=8
void startAccelerometerService() {
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
}
/**
* Starts the Bluetooth button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth" weight=89
void startButtonService() {
new MicroBitButtonService(*uBit.ble);
}
/** /**
* Starts the Bluetooth IO pin service. * Starts the Bluetooth IO pin service.
*/ */
//% help=bluetooth/start-io-pin-service //% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8 //% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth" //% parts="bluetooth" weight=88
void startIOPinService() { void startIOPinService() {
new MicroBitIOPinService(*uBit.ble, uBit.io); new MicroBitIOPinService(*uBit.ble, uBit.io);
} }
@ -42,7 +47,7 @@ namespace bluetooth {
*/ */
//% help=bluetooth/start-led-service //% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8 //% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth" //% parts="bluetooth" weight=87
void startLEDService() { void startLEDService() {
new MicroBitLEDService(*uBit.ble, uBit.display); new MicroBitLEDService(*uBit.ble, uBit.display);
} }
@ -52,7 +57,7 @@ namespace bluetooth {
*/ */
//% help=bluetooth/start-temperature-service //% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8 //% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth" //% parts="bluetooth" weight=86
void startTemperatureService() { void startTemperatureService() {
new MicroBitTemperatureService(*uBit.ble, uBit.thermometer); new MicroBitTemperatureService(*uBit.ble, uBit.thermometer);
} }
@ -61,38 +66,19 @@ namespace bluetooth {
* Starts the Bluetooth magnetometer service * Starts the Bluetooth magnetometer service
*/ */
//% help=bluetooth/start-magnetometer-service //% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8 //% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service"
//% parts="bluetooth" //% parts="bluetooth" weight=85
void startMagnetometerService() { void startMagnetometerService() {
new MicroBitMagnetometerService(*uBit.ble, uBit.compass); new MicroBitMagnetometerService(*uBit.ble, uBit.compass);
} }
/**
* Starts the Bluetooth accelerometer service
*/
//% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8
//% parts="bluetooth"
void startAccelerometerService() {
new MicroBitAccelerometerService(*uBit.ble, uBit.accelerometer);
}
/**
* Starts the Bluetooth button service
*/
//% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth"
void startButtonService() {
new MicroBitButtonService(*uBit.ble);
}
/** /**
* Starts the Bluetooth UART service * Starts the Bluetooth UART service
*/ */
//% help=bluetooth/start-uart-service //% help=bluetooth/start-uart-service
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8 //% blockId=bluetooth_start_uart_service block="bluetooth uart service"
//% parts="bluetooth" //% parts="bluetooth" advanced=true
void startUartService() { void startUartService() {
if (uart) return; if (uart) return;
// 61 octet buffer size is 3 x (MTU - 3) + 1 // 61 octet buffer size is 3 x (MTU - 3) + 1
@ -102,13 +88,13 @@ namespace bluetooth {
} }
//% //%
void uartWrite(StringData *data) { void uartWriteString(StringData *data) {
startUartService(); startUartService();
uart->send(ManagedString(data)); uart->send(ManagedString(data));
} }
//% //%
StringData* uartRead(StringData *del) { StringData* uartReadUntil(StringData *del) {
startUartService(); startUartService();
return uart->readUntil(ManagedString(del)).leakData(); return uart->readUntil(ManagedString(del)).leakData();
} }
@ -133,7 +119,5 @@ namespace bluetooth {
//% parts="bluetooth" //% parts="bluetooth"
void onBluetoothDisconnected(Action body) { void onBluetoothDisconnected(Action body) {
registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body); registerWithDal(MICROBIT_ID_BLE, MICROBIT_BLE_EVT_DISCONNECTED, body);
} }
} }

View File

@ -1,42 +1,48 @@
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
namespace bluetooth { namespace bluetooth {
/**
* Returns the delimiter corresponding string
*/
//% blockId="bluetooth_uart_delimiter_conv" block="%del"
//% weight=1 parts="bluetooth"
export function delimiters(del: Delimiters): string {
// even though it might not look like, this is more
// (memory) efficient than the C++ implementation, because the
// strings are statically allocated and take no RAM
switch (del) {
case Delimiters.NewLine: return "\n"
case Delimiters.Comma: return ","
case Delimiters.Dollar: return "$"
case Delimiters.Colon: return ":"
case Delimiters.Fullstop: return "."
case Delimiters.Hash: return "#"
default: return "\n"
}
}
/** /**
* Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device. * Writes to the Bluetooth UART service buffer. From there the data is transmitted over Bluetooth to a connected device.
*/ */
//% help=bluetooth/uart-write //% help=bluetooth/uart-write-string weight=80
//% blockId=bluetooth_uart_write block="bluetooth uart write %data" blockGap=8 //% blockId=bluetooth_uart_write block="bluetooth uart|write string %data" blockGap=8
//% parts="bluetooth" shim=bluetooth::uartWrite //% parts="bluetooth" shim=bluetooth::uartWriteString advanced=true
export function uartWrite(data: string): void { export function uartWriteString(data: string): void {
// dummy implementation for simulator // dummy implementation for simulator
console.log("UART Write: " + data) console.log("UART Write: " + data)
} }
/**
* Prints a numeric value to the serial
*/
//% help=bluetooth/uart-write-number weight=79
//% weight=89 blockGap=8 advanced=true
//% blockId=bluetooth_uart_writenumber block="bluetooth uart|write number %value"
export function uartWriteNumber(value: number): void {
uartWriteString(value.toString());
}
/**
* Writes a ``name: value`` pair line to the serial.
* @param name name of the value stream, eg: x
* @param value to write
*/
//% weight=88 weight=78
//% help=bluetooth/uart-write-value advanced=true
//% blockId=bluetooth_uart_writevalue block="bluetooth uart|write value %name|= %value"
export function uartWriteValue(name: string, value: number): void {
uartWriteString(name + ":" + value + "\r\n");
}
/** /**
* Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered. * Reads from the Bluetooth UART service buffer, returning its contents when the specified delimiter character is encountered.
*/ */
//% help=bluetooth/uart-read //% help=bluetooth/uart-read-until weight=75
//% blockId=bluetooth_uart_read block="bluetooth uart read %del=bluetooth_uart_delimiter_conv" blockGap=8 //% blockId=bluetooth_uart_read block="bluetooth uart|read until %del=serial_delimiter_conv"
//% parts="bluetooth" shim=bluetooth::uartRead //% parts="bluetooth" shim=bluetooth::uartReadUntil advanced=true
export function uartRead(del: string): string { export function uartReadUntil(del: string): string {
// dummy implementation for simulator // dummy implementation for simulator
return "???" return "???"
} }

View File

@ -1,20 +1,4 @@
// Auto-generated. Do not edit. // Auto-generated. Do not edit.
declare enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
}
declare namespace bluetooth { declare namespace bluetooth {
} }

View File

@ -7,44 +7,12 @@
//% color=#0082FB weight=20 //% color=#0082FB weight=20
declare namespace bluetooth { declare namespace bluetooth {
/**
* Starts the Bluetooth IO pin service.
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startIOPinService
function startIOPinService(): void;
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startLEDService
function startLEDService(): void;
/**
* Starts the Bluetooth temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startTemperatureService
function startTemperatureService(): void;
/**
* Starts the Bluetooth magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startMagnetometerService
function startMagnetometerService(): void;
/** /**
* Starts the Bluetooth accelerometer service * Starts the Bluetooth accelerometer service
*/ */
//% help=bluetooth/start-accelerometer-service //% help=bluetooth/start-accelerometer-service
//% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service" blockGap=8 //% blockId=bluetooth_start_accelerometer_service block="bluetooth accelerometer service"
//% parts="bluetooth" shim=bluetooth::startAccelerometerService //% parts="bluetooth" weight=90 blockGap=8 shim=bluetooth::startAccelerometerService
function startAccelerometerService(): void; function startAccelerometerService(): void;
/** /**
@ -52,15 +20,47 @@ declare namespace bluetooth {
*/ */
//% help=bluetooth/start-button-service //% help=bluetooth/start-button-service
//% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8 //% blockId=bluetooth_start_button_service block="bluetooth button service" blockGap=8
//% parts="bluetooth" shim=bluetooth::startButtonService //% parts="bluetooth" weight=89 shim=bluetooth::startButtonService
function startButtonService(): void; function startButtonService(): void;
/**
* Starts the Bluetooth IO pin service.
*/
//% help=bluetooth/start-io-pin-service
//% blockId=bluetooth_start_io_pin_service block="bluetooth io pin service" blockGap=8
//% parts="bluetooth" weight=88 shim=bluetooth::startIOPinService
function startIOPinService(): void;
/**
* Starts the Bluetooth LED service
*/
//% help=bluetooth/start-led-service
//% blockId=bluetooth_start_led_service block="bluetooth led service" blockGap=8
//% parts="bluetooth" weight=87 shim=bluetooth::startLEDService
function startLEDService(): void;
/**
* Starts the Bluetooth temperature service
*/
//% help=bluetooth/start-temperature-service
//% blockId=bluetooth_start_temperature_service block="bluetooth temperature service" blockGap=8
//% parts="bluetooth" weight=86 shim=bluetooth::startTemperatureService
function startTemperatureService(): void;
/**
* Starts the Bluetooth magnetometer service
*/
//% help=bluetooth/start-magnetometer-service
//% blockId=bluetooth_start_magnetometer_service block="bluetooth magnetometer service"
//% parts="bluetooth" weight=85 shim=bluetooth::startMagnetometerService
function startMagnetometerService(): void;
/** /**
* Starts the Bluetooth UART service * Starts the Bluetooth UART service
*/ */
//% help=bluetooth/start-uart-service //% help=bluetooth/start-uart-service
//% blockId=bluetooth_start_uart_service block="bluetooth uart service" blockGap=8 //% blockId=bluetooth_start_uart_service block="bluetooth uart service"
//% parts="bluetooth" shim=bluetooth::startUartService //% parts="bluetooth" advanced=true shim=bluetooth::startUartService
function startUartService(): void; function startUartService(): void;
/** /**

View File

@ -161,6 +161,8 @@
"pins.spiWrite|param|value": "Data to be sent to the SPI slave", "pins.spiWrite|param|value": "Data to be sent to the SPI slave",
"serial": "Reading and writing data over a serial connection.", "serial": "Reading and writing data over a serial connection.",
"serial.readLine": "Reads a line of text from the serial port.", "serial.readLine": "Reads a line of text from the serial port.",
"serial.readUntil": "Reads a line of text from the serial port and returns the buffer when the delimiter is met.",
"serial.readUntil|param|delimiter": "text delimiter that separates each text chunk",
"serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.", "serial.redirect": "Dynamically configuring the serial instance to use pins other than USBTX and USBRX.",
"serial.redirect|param|rx": "the new reception pin", "serial.redirect|param|rx": "the new reception pin",
"serial.redirect|param|tx": "the new transmission pins", "serial.redirect|param|tx": "the new transmission pins",

View File

@ -0,0 +1,91 @@
{
"Math.randomBoolean|block": "pick random true or false",
"Math|block": "Math",
"String.fromCharCode|block": "text from char code %code",
"String|block": "String",
"basic.clearScreen|block": "clear screen",
"basic.forever|block": "forever",
"basic.pause|block": "pause (ms) %pause",
"basic.showLeds|block": "show leds",
"basic.showNumber|block": "show|number %number",
"basic.showString|block": "show|string %text",
"basic|block": "basic",
"control.inBackground|block": "run in background",
"control.reset|block": "reset",
"control.waitMicros|block": "wait (µs)%micros",
"control|block": "control",
"game.addScore|block": "change score by|%points",
"game.gameOver|block": "game over",
"game.score|block": "score",
"game.startCountdown|block": "start countdown|(ms) %duration",
"game|block": "game",
"images.createBigImage|block": "create big image",
"images.createImage|block": "create image",
"images|block": "images",
"input.acceleration|block": "acceleration (mg)|%NAME",
"input.buttonIsPressed|block": "button|%NAME|is pressed",
"input.compassHeading|block": "compass heading (°)",
"input.lightLevel|block": "light level",
"input.magneticForce|block": "magnetic force (µT)|%NAME",
"input.onButtonPressed|block": "on button|%NAME|pressed",
"input.onGesture|block": "on |%NAME",
"input.onPinPressed|block": "on pin %NAME|pressed",
"input.onPinReleased|block": "on pin %NAME|released",
"input.pinIsPressed|block": "pin %NAME|is pressed",
"input.rotation|block": "rotation (°)|%NAME",
"input.runningTime|block": "running time (ms)",
"input.setAccelerometerRange|block": "set accelerometer|range %range",
"input.temperature|block": "temperature (°C)",
"input|block": "input",
"led.brightness|block": "brightness",
"led.plotBarGraph|block": "plot bar graph of %value |up to %high",
"led.plot|block": "plot|x %x|y %y",
"led.point|block": "point|x %x|y %y",
"led.setBrightness|block": "set brightness %value",
"led.stopAnimation|block": "stop animation",
"led.toggle|block": "toggle|x %x|y %y",
"led.unplot|block": "unplot|x %x|y %y",
"led|block": "led",
"music.beat|block": "%fraction|beat",
"music.changeTempoBy|block": "change tempo by (bpm)|%value",
"music.noteFrequency|block": "%note",
"music.playTone|block": "play|tone %note=device_note|for %duration=device_beat",
"music.rest|block": "rest(ms)|%duration=device_beat",
"music.ringTone|block": "ring tone (Hz)|%note=device_note",
"music.setTempo|block": "set tempo to (bpm)|%value",
"music.tempo|block": "tempo (bpm)",
"music|block": "music",
"pins.analogReadPin|block": "analog read|pin %name",
"pins.analogSetPeriod|block": "analog set period|pin %pin|to (µs)%micros",
"pins.analogWritePin|block": "analog write|pin %name|to %value",
"pins.digitalReadPin|block": "digital read|pin %name",
"pins.digitalWritePin|block": "digital write|pin %name|to %value",
"pins.i2cReadNumber|block": "i2c read number|at address %address|of format %format=i2c_sizeof",
"pins.i2cWriteNumber|block": "i2c write number|at address %address|with value %value|of format %format=i2c_sizeof",
"pins.map|block": "map %value|from low %fromLow|from high %fromHigh|to low %toLow|to high %toHigh",
"pins.onPulsed|block": "on|pin %pin|pulsed %pulse",
"pins.pulseDuration|block": "pulse duration (µs)",
"pins.servoSetPulse|block": "servo set pulse|pin %value|to (µs) %micros",
"pins.servoWritePin|block": "servo write|pin %name|to %value",
"pins.setPull|block": "set pull|pin %pin|to %pull",
"pins.spiWrite|block": "spi write %value",
"pins|block": "pins",
"serial.readLine|block": "serial|read line",
"serial.readUntil|block": "serial|read until %delimiter=serial_delimiter_conv",
"serial.redirect|block": "serial|redirect to|TX %tx|RX %rx|at baud rate %rate",
"serial.writeLine|block": "serial|write line %text",
"serial.writeNumber|block": "serial|write number %value",
"serial.writeString|block": "serial|write string %text",
"serial.writeValue|block": "serial|write value %name|= %value",
"serial|block": "serial",
"{id:category}Basic": "Basic",
"{id:category}Control": "Control",
"{id:category}Game": "Game",
"{id:category}Images": "Images",
"{id:category}Input": "Input",
"{id:category}Led": "Led",
"{id:category}Math": "Math",
"{id:category}Music": "Music",
"{id:category}Pins": "Pins",
"{id:category}Serial": "Serial"
}

26
libs/core/dal.d.ts vendored
View File

@ -79,7 +79,6 @@ declare const enum DAL {
MICROBIT_BLE_PAIRING_TIMEOUT = 90, MICROBIT_BLE_PAIRING_TIMEOUT = 90,
MICROBIT_BLE_POWER_LEVELS = 8, MICROBIT_BLE_POWER_LEVELS = 8,
MICROBIT_BLE_MAXIMUM_BONDS = 4, MICROBIT_BLE_MAXIMUM_BONDS = 4,
MICROBIT_BLE_EDDYSTONE_URL_ADV_INTERVAL = 400,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitButtonService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitButtonService.h
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitDFUService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitDFUService.h
MICROBIT_DFU_OPCODE_START_DFU = 1, MICROBIT_DFU_OPCODE_START_DFU = 1,
@ -89,7 +88,6 @@ declare const enum DAL {
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitIOPinService.h
MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19, MICROBIT_IO_PIN_SERVICE_PINCOUNT = 19,
MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10, MICROBIT_IO_PIN_SERVICE_DATA_SIZE = 10,
MICROBIT_PWM_PIN_SERVICE_DATA_SIZE = 2,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitLEDService.h
MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20, MICROBIT_BLE_MAXIMUM_SCROLLTEXT = 20,
// built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitMagnetometerService.h // built/yt/yotta_modules/microbit-dal/inc//bluetooth/MicroBitMagnetometerService.h
@ -307,30 +305,6 @@ declare const enum DAL {
MICROBIT_DISPLAY_ROTATION_90 = 1, MICROBIT_DISPLAY_ROTATION_90 = 1,
MICROBIT_DISPLAY_ROTATION_180 = 2, MICROBIT_DISPLAY_ROTATION_180 = 2,
MICROBIT_DISPLAY_ROTATION_270 = 3, MICROBIT_DISPLAY_ROTATION_270 = 3,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitFile.h
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitFileSystem.h
MBFS_FILENAME_LENGTH = 16,
MB_READ = 0x01,
MB_WRITE = 0x02,
MB_CREAT = 0x04,
MB_APPEND = 0x08,
MB_SEEK_SET = 0x01,
MB_SEEK_END = 0x02,
MB_SEEK_CUR = 0x04,
MBFS_STATUS_INITIALISED = 0x01,
MBFS_UNUSED = 0xFFFF,
MBFS_EOF = 0xEFFF,
MBFS_DELETED = 0x0000,
MBFS_DIRECTORY_ENTRY_FREE = 0x8000,
MBFS_DIRECTORY_ENTRY_VALID = 0x4000,
MBFS_DIRECTORY_ENTRY_DIRECTORY = 0x2000,
MBFS_DIRECTORY_ENTRY_NEW = 0xffff,
MBFS_DIRECTORY_ENTRY_DELETED = 0x0000,
MBFS_BLOCK_TYPE_FILE = 1,
MBFS_BLOCK_TYPE_DIRECTORY = 2,
MBFS_BLOCK_TYPE_FILETABLE = 3,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitFlash.h
PAGE_SIZE = 1024,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitI2C.h // built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitI2C.h
MICROBIT_I2C_MAX_RETRIES = 9, MICROBIT_I2C_MAX_RETRIES = 9,
// built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitIO.h // built/yt/yotta_modules/microbit-dal/inc//drivers/MicroBitIO.h

16
libs/core/enums.d.ts vendored
View File

@ -309,6 +309,22 @@ declare namespace led {
//% block=9600 //% block=9600
BaudRate9600 = 9600, BaudRate9600 = 9600,
} }
declare enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
}
declare namespace serial { declare namespace serial {
} }

View File

@ -30,7 +30,9 @@
"pxtparts.json", "pxtparts.json",
"parts/speaker.svg", "parts/speaker.svg",
"parts/headphone.svg", "parts/headphone.svg",
"_locales/fr/microbit-jsdoc-strings.json" "_locales/ja/core-jsdoc-strings.json",
"_locales/ja/core-strings.json",
"_locales/fr/core-jsdoc-strings.json"
], ],
"public": true, "public": true,
"dependencies": {}, "dependencies": {},

View File

@ -1,6 +1,6 @@
#include "ksbit.h" #include "ksbit.h"
enum class SerialPin { enum SerialPin {
P0 = MICROBIT_ID_IO_P0, P0 = MICROBIT_ID_IO_P0,
P1 = MICROBIT_ID_IO_P1, P1 = MICROBIT_ID_IO_P1,
P2 = MICROBIT_ID_IO_P2, P2 = MICROBIT_ID_IO_P2,
@ -12,36 +12,52 @@ enum class SerialPin {
P16 = MICROBIT_ID_IO_P16 P16 = MICROBIT_ID_IO_P16
}; };
enum class BaudRate { enum BaudRate {
//% block=115200 //% block=115200
BaudRate115200 = 115200, BaudRate115200 = 115200,
//% block=9600 //% block=9600
BaudRate9600 = 9600 BaudRate9600 = 9600
}; };
enum Delimiters {
//% block="new line"
NewLine = 1,
//% block=","
Comma = 2,
//% block="$"
Dollar = 3,
//% block=":"
Colon = 4,
//% block="."
Fullstop = 5,
//% block="#"
Hash = 6,
};
//% weight=2 color=30 //% weight=2 color=30
//% advanced=true //% advanced=true
namespace serial { namespace serial {
// note that at least one // followed by % is needed per declaration! // note that at least one // followed by % is needed per declaration!
/** /**
* Reads a line of text from the serial port. * Reads a line of text from the serial port and returns the buffer when the delimiter is met.
* @param delimiter text delimiter that separates each text chunk
*/ */
//% help=serial/read-line //% help=serial/read-until
//% blockId=serial_read_line block="serial read line" //% blockId=serial_read_until block="serial|read until %delimiter=serial_delimiter_conv"
//% weight=20 //% weight=19
StringData* readLine() { StringData* readUntil(StringData* delimiter) {
return uBit.serial.readUntil(ManagedString("\n")).leakData(); return uBit.serial.readUntil(ManagedString(delimiter)).leakData();
} }
/** /**
* Sends a piece of text through Serial connection. * Reads a line of text from the serial port.
*/ */
//% help=serial/write-string //% help=serial/read-line
//% weight=87 //% blockId=serial_read_line block="serial|read line"
//% blockId=serial_writestring block="serial write string %text" //% weight=20 blockGap=8
void writeString(StringData *text) { StringData* readLine() {
uBit.serial.send(ManagedString(text)); return readUntil(ManagedString("\n").leakData());
} }
/** /**
@ -49,12 +65,22 @@ namespace serial {
* @param delimiters the characters to match received characters against. eg:"\n" * @param delimiters the characters to match received characters against. eg:"\n"
*/ */
// help=serial/on-data-received // help=serial/on-data-received
// weight=19 // weight=18
void onDataReceived(StringData* delimiters, Action body) { void onDataReceived(StringData* delimiters, Action body) {
uBit.serial.eventOn(ManagedString(delimiters)); uBit.serial.eventOn(ManagedString(delimiters));
registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body); registerWithDal(MICROBIT_ID_SERIAL, MICROBIT_SERIAL_EVT_DELIM_MATCH, body);
} }
/**
* Sends a piece of text through Serial connection.
*/
//% help=serial/write-string
//% weight=87
//% blockId=serial_writestring block="serial|write string %text"
void writeString(StringData *text) {
uBit.serial.send(ManagedString(text));
}
/** /**
* Dynamically configuring the serial instance to use pins other than USBTX and USBRX. * Dynamically configuring the serial instance to use pins other than USBTX and USBRX.
* @param tx the new transmission pins * @param tx the new transmission pins
@ -63,7 +89,7 @@ namespace serial {
*/ */
//% weight=10 //% weight=10
//% help=serial/redirect-to //% help=serial/redirect-to
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate" //% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1 //% blockExternalInputs=1
void redirect(SerialPin tx, SerialPin rx, BaudRate rate) { void redirect(SerialPin tx, SerialPin rx, BaudRate rate) {
uBit.serial.redirect((PinName)tx, (PinName)rx); uBit.serial.redirect((PinName)tx, (PinName)rx);

View File

@ -46,4 +46,24 @@ namespace serial {
export function onLineReceived(body: Action): void { export function onLineReceived(body: Action): void {
// serial.onDataReceived("\n", body); // serial.onDataReceived("\n", body);
} }
/**
* Returns the delimiter corresponding string
*/
//% blockId="serial_delimiter_conv" block="%del"
//% weight=1
export function delimiters(del: Delimiters): string {
// even though it might not look like, this is more
// (memory) efficient than the C++ implementation, because the
// strings are statically allocated and take no RAM
switch (del) {
case Delimiters.NewLine: return "\n"
case Delimiters.Comma: return ","
case Delimiters.Dollar: return "$"
case Delimiters.Colon: return ":"
case Delimiters.Fullstop: return "."
case Delimiters.Hash: return "#"
default: return "\n"
}
}
} }

17
libs/core/shims.d.ts vendored
View File

@ -648,12 +648,21 @@ declare namespace pins {
//% advanced=true //% advanced=true
declare namespace serial { declare namespace serial {
/**
* Reads a line of text from the serial port and returns the buffer when the delimiter is met.
* @param delimiter text delimiter that separates each text chunk
*/
//% help=serial/read-until
//% blockId=serial_read_until block="serial|read until %delimiter=serial_delimiter_conv"
//% weight=19 shim=serial::readUntil
function readUntil(delimiter: string): string;
/** /**
* Reads a line of text from the serial port. * Reads a line of text from the serial port.
*/ */
//% help=serial/read-line //% help=serial/read-line
//% blockId=serial_read_line block="serial read line" //% blockId=serial_read_line block="serial|read line"
//% weight=20 shim=serial::readLine //% weight=20 blockGap=8 shim=serial::readLine
function readLine(): string; function readLine(): string;
/** /**
@ -661,7 +670,7 @@ declare namespace serial {
*/ */
//% help=serial/write-string //% help=serial/write-string
//% weight=87 //% weight=87
//% blockId=serial_writestring block="serial write string %text" shim=serial::writeString //% blockId=serial_writestring block="serial|write string %text" shim=serial::writeString
function writeString(text: string): void; function writeString(text: string): void;
/** /**
@ -672,7 +681,7 @@ declare namespace serial {
*/ */
//% weight=10 //% weight=10
//% help=serial/redirect-to //% help=serial/redirect-to
//% blockId=serial_redirect block="serial redirect to|TX %tx|RX %rx|at baud rate %rate" //% blockId=serial_redirect block="serial|redirect to|TX %tx|RX %rx|at baud rate %rate"
//% blockExternalInputs=1 shim=serial::redirect //% blockExternalInputs=1 shim=serial::redirect
function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void; function redirect(tx: SerialPin, rx: SerialPin, rate: BaudRate): void;
} }

View File

@ -6,5 +6,6 @@
"devices.signalStrength|block": "signal strength", "devices.signalStrength|block": "signal strength",
"devices.tellCameraTo|block": "tell camera to|%property", "devices.tellCameraTo|block": "tell camera to|%property",
"devices.tellRemoteControlTo|block": "tell remote control to|%property", "devices.tellRemoteControlTo|block": "tell remote control to|%property",
"devices|block": "devices" "devices|block": "devices",
"{id:category}Devices": "Devices"
} }

View File

@ -15,5 +15,6 @@
"radio.setTransmitPower": "Change the output power level of the transmitter to the given value.", "radio.setTransmitPower": "Change the output power level of the transmitter to the given value.",
"radio.setTransmitPower|param|power": "a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7", "radio.setTransmitPower|param|power": "a value in the range 0..7, where 0 is the lowest power and 7 is the highest. eg: 7",
"radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.", "radio.setTransmitSerialNumber": "Set the radio to transmit the serial number in each message.",
"radio.setTransmitSerialNumber|param|transmit": "value indicating if the serial number is transmitted, eg: true",
"radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON" "radio.writeValueToSerial": "Reads a value sent with `stream value` and writes it\nto the serial stream as JSON"
} }

View File

@ -2,7 +2,6 @@
"radio.onDataReceived|block": "radio on data received", "radio.onDataReceived|block": "radio on data received",
"radio.receiveNumber|block": "radio receive number", "radio.receiveNumber|block": "radio receive number",
"radio.receiveString|block": "radio receive string", "radio.receiveString|block": "radio receive string",
"radio.receivedNumberAt|block": "radio receive number|at %VALUE",
"radio.receivedSignalStrength|block": "radio received signal strength", "radio.receivedSignalStrength|block": "radio received signal strength",
"radio.sendNumber|block": "radio send number %value", "radio.sendNumber|block": "radio send number %value",
"radio.sendString|block": "radio send string %msg", "radio.sendString|block": "radio send string %msg",
@ -11,5 +10,6 @@
"radio.setTransmitPower|block": "radio set transmit power %power", "radio.setTransmitPower|block": "radio set transmit power %power",
"radio.setTransmitSerialNumber|block": "radio set transmit serial number %transmit", "radio.setTransmitSerialNumber|block": "radio set transmit serial number %transmit",
"radio.writeValueToSerial|block": "radio write value to serial", "radio.writeValueToSerial|block": "radio write value to serial",
"radio|block": "radio" "radio|block": "radio",
"{id:category}Radio": "Radio"
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "pxt-microbit", "name": "pxt-microbit",
"version": "0.5.0", "version": "0.4.57",
"description": "micro:bit target for PXT", "description": "micro:bit target for PXT",
"keywords": [ "keywords": [
"JavaScript", "JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7" "typescript": "^1.8.7"
}, },
"dependencies": { "dependencies": {
"pxt-core": "0.5.0-rc1" "pxt-core": "0.4.67"
} }
} }

View File

@ -84,6 +84,13 @@
"microbit-pins": "", "microbit-pins": "",
"microbit-serial": "" "microbit-serial": ""
} }
},
{
"type": "api",
"map": {
"bluetooth\\.uartRead\\((.*?)\\)" : "bluetooth.uartReadUntil($1)",
"bluetooth\\.uartWrite\\((.*?)\\)" : "bluetooth.uartWriteUntil($1)"
}
} }
] ]
}, },
@ -249,7 +256,7 @@
"path": "/browsers/windows" "path": "/browsers/windows"
} }
], ],
"boardName": "BBC micro:bit", "boardName": "micro:bit",
"docMenu": [ "docMenu": [
{ {
"name": "Getting Started", "name": "Getting Started",

View File

@ -168,7 +168,7 @@ namespace pxsim.bluetooth {
export function uartWrite(s : string): void { export function uartWrite(s : string): void {
// TODO // TODO
} }
export function uartRead(): string { export function uartReadUntil(del: string): string {
// TODO // TODO
return "" return ""
} }

View File

@ -43,6 +43,10 @@ namespace pxsim.serial {
return board().serialState.readSerial(); return board().serialState.readSerial();
} }
export function readUntil(del: string): string {
return readLine();
}
export function onDataReceived(delimiters: string, handler: RefAction) { export function onDataReceived(delimiters: string, handler: RefAction) {
let b = board(); let b = board();
b.bus.listen(DAL.MICROBIT_ID_SERIAL, DAL.MICROBIT_SERIAL_EVT_DELIM_MATCH, handler); b.bus.listen(DAL.MICROBIT_ID_SERIAL, DAL.MICROBIT_SERIAL_EVT_DELIM_MATCH, handler);