Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Martin Woolley 2016-06-23 08:06:34 +01:00
commit 7bf00ff139
38 changed files with 532 additions and 146 deletions

View File

@ -3,7 +3,7 @@
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)).
* [Try it live](https://m.pxt.io)
* [Try it live](https://codethemicrobit.com)
[![Build Status](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-microbit)
@ -47,12 +47,12 @@ More instructions at https://github.com/Microsoft/pxt#running-a-target-from-loca
## 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.
that wraps ``codethemicrobit.com`` and provides additional features.
### 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 ``m.pxt.io`` project.
* open the ``win10/app.sln`` solution and launch the ``codethemicrobit`` project.
## Code of Conduct

26
clients/chrome/README.md Normal file
View File

@ -0,0 +1,26 @@
# microbit-chrome
Prototype chrome addon that exposes the micro:bit's serial output to webpages.
* watch the [demo video](https://vimeo.com/146207766)
# Installation
See [developer.chrome.com](https://developer.chrome.com/extensions/getstarted#unpacked)
for instructions on how to install the local version into your chrome browser.
# Requirements
* Chrome 48 or later.
# Sample page
The `demo.html` webpage goes along with the
https://github.com/Microsoft/microbit-touchdevelop/blob/master/examples/tcs34725.cpp
program. Run `http-server` from this directory, then visit
http://localhost:8080/demo.html
(keep in mind that pages served from `file://` cannot open ports).
# Building
Open a command prompt and run the following commands.
````
npm install
typings update
````

View File

@ -0,0 +1,68 @@
///<reference path='typings/browser.d.ts'/>
var connections = [];
// A list of "ports", i.e. connected clients (such as web pages). Multiple web
// pages can connect to our service: they all receive the same data.
var ports = [];
function byPath(path) {
return connections.filter(function (x) { return x.path == path; });
}
function byId(id) {
return connections.filter(function (x) { return x.id == id; });
}
function onReceive(data, id) {
if (ports.length == 0)
return;
var view = new DataView(data);
var decoder = new TextDecoder("utf-8");
var decodedString = decoder.decode(view);
ports.forEach(function (port) { return port.postMessage({
type: "serial",
data: decodedString,
id: id
}); });
}
function findNewDevices() {
chrome.serial.getDevices(function (serialPorts) {
serialPorts.forEach(function (serialPort) {
if (byPath(serialPort.path).length == 0 &&
serialPort.displayName == "mbed Serial Port") {
chrome.serial.connect(serialPort.path, { bitrate: 115200 }, function (info) {
// In case the [connect] operation takes more than five seconds...
if (info && byPath(serialPort.path).length == 0)
connections.push({
id: info.connectionId,
path: serialPort.path
});
});
}
});
});
}
function main() {
// Register new clients in the [ports] global variable.
chrome.runtime.onConnectExternal.addListener(function (port) {
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit)$/.test(port.name)) {
ports.push(port);
port.onDisconnect.addListener(function () {
ports = ports.filter(function (x) { return x != port; });
});
}
});
// When receiving data for one of the connections that we're tracking, forward
// it to all connected clients.
chrome.serial.onReceive.addListener(function (info) {
if (byId(info.connectionId).length > 0)
onReceive(info.data, info.connectionId);
});
// When it looks like we've been disconnected, drop the corresponding
// connection object from the [connections] global variable.
chrome.serial.onReceiveError.addListener(function (info) {
if (info.error == "system_error" || info.error == "disconnected" || info.error == "device_lost")
connections = connections.filter(function (x) { return x.id != info.connectionId; });
});
// Probe serial connections at regular intervals. In case we find an mbed port
// we haven't yet connected to, connect to it.
setInterval(findNewDevices, 5000);
findNewDevices();
}
document.addEventListener("DOMContentLoaded", main);

View File

@ -0,0 +1,92 @@
// A list of: {
// id: number;
// path: string;
// } where [id] is the [connectionId] (internal to Chrome) and [path] is the
// OS' name for the device (e.g. "COM4").
interface Connection {
id: string;
path: string;
}
let connections: Connection[] = [];
// A list of "ports", i.e. connected clients (such as web pages). Multiple web
// pages can connect to our service: they all receive the same data.
let ports = [];
interface Message {
type: string;
data: string;
id: string;
}
function byPath(path: string): Connection[] {
return connections.filter((x) => x.path == path);
}
function byId(id: string): Connection[] {
return connections.filter((x) => x.id == id);
}
function onReceive(data, id: string) {
if (ports.length == 0) return;
let view = new DataView(data);
let decoder = new TextDecoder("utf-8");
let decodedString = decoder.decode(view);
ports.forEach(port => port.postMessage(<Message>{
type: "serial",
data: decodedString,
id: id,
}));
}
function findNewDevices() {
chrome.serial.getDevices(function (serialPorts) {
serialPorts.forEach(function (serialPort) {
if (byPath(serialPort.path).length == 0 &&
serialPort.displayName == "mbed Serial Port") {
chrome.serial.connect(serialPort.path, { bitrate: 115200 }, function (info) {
// In case the [connect] operation takes more than five seconds...
if (info && byPath(serialPort.path).length == 0)
connections.push({
id: info.connectionId,
path: serialPort.path
});
});
}
});
});
}
function main() {
// Register new clients in the [ports] global variable.
chrome.runtime.onConnectExternal.addListener(function (port) {
if (/^(micro:bit|touchdevelop|yelm|pxt|codemicrobit|codethemicrobit)$/.test(port.name)) {
ports.push(port);
port.onDisconnect.addListener(function () {
ports = ports.filter(function (x) { return x != port });
});
}
});
// When receiving data for one of the connections that we're tracking, forward
// it to all connected clients.
chrome.serial.onReceive.addListener(function (info) {
if (byId(info.connectionId).length > 0)
onReceive(info.data, info.connectionId);
});
// When it looks like we've been disconnected, drop the corresponding
// connection object from the [connections] global variable.
chrome.serial.onReceiveError.addListener(function (info) {
if (info.error == "system_error" || info.error == "disconnected" || info.error == "device_lost")
connections = connections.filter((x) => x.id != info.connectionId);
});
// Probe serial connections at regular intervals. In case we find an mbed port
// we haven't yet connected to, connect to it.
setInterval(findNewDevices, 5000);
findNewDevices();
}
document.addEventListener("DOMContentLoaded", main);

BIN
clients/chrome/logo128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
clients/chrome/logo48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,30 @@
{
"app": {
"background": {
"scripts": [ "background.js" ]
}
},
"manifest_version": 2,
"name": "code the micro:bit",
"version": "0.6.0",
"author": "Microsoft Corporation",
"short_name": "code the micro:bit",
"description": "Extension for https://codethemicrobit.com.",
"homepage_url": "https://codethemicrobit.com",
"offline_enabled": "true",
"icons": {
"48": "logo48.png",
"128": "logo128.png"
},
"permissions": [
"serial",
"usb"
],
"externally_connectable": {
"matches": [ "*://localhost/*", "https://codethemicrobit.com/*", "https://*.codethemicrobit.com/*" ]
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -0,0 +1,7 @@
{
"compiler-options": {
"target": "ES5",
"module": "amd",
"sourceMap": false
}
}

View File

@ -14,13 +14,13 @@
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" StartPage="https://m.pxt.io/">
<Application Id="App" StartPage="https://codethemicrobit.com">
<uap:ApplicationContentUriRules>
<uap:Rule Match="https://m.pxt.io/" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://codemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
<uap:Rule Match="https://codethemicrobit.com/" Type="include" WindowsRuntimeAccess="all" />
</uap:ApplicationContentUriRules>
<uap:VisualElements DisplayName="codethemicrobit" Description="Code editors for the BBC micro:bit" BackgroundColor="white" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
<uap:VisualElements DisplayName="code the micro:bit" Description="A code editor for the BBC micro:bit which drag&amp;drop or javascript." BackgroundColor="white" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" ShortName="code the micro:bit">
</uap:DefaultTile>
<uap:SplashScreen Image="images\splashscreen.png" />

View File

@ -1,22 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeTheMicrobit.Uploader", "Microbit.Uploader\CodeTheMicrobit.Uploader.csproj", "{7DC6CA45-FD75-44BC-805E-708C812CD4BF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,66 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeTheMicrobit", "Microbit.Uploader\CodeTheMicrobit.csproj", "{7DC6CA45-FD75-44BC-805E-708C812CD4BF}"
EndProject
Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "codethemicrobitapp", "..\win10\app\codethemicrobitapp.jsproj", "{39122940-AB16-4CD4-A0CE-79A3EB863ECF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|ARM.Build.0 = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|x64.ActiveCfg = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|x64.Build.0 = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|x86.ActiveCfg = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Debug|x86.Build.0 = Debug|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|Any CPU.Build.0 = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|ARM.ActiveCfg = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|ARM.Build.0 = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|x64.ActiveCfg = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|x64.Build.0 = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|x86.ActiveCfg = Release|Any CPU
{7DC6CA45-FD75-44BC-805E-708C812CD4BF}.Release|x86.Build.0 = Release|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.ActiveCfg = Debug|ARM
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.Build.0 = Debug|ARM
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|ARM.Deploy.0 = Debug|ARM
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.ActiveCfg = Debug|x64
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.Build.0 = Debug|x64
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x64.Deploy.0 = Debug|x64
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.ActiveCfg = Debug|x86
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.Build.0 = Debug|x86
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Debug|x86.Deploy.0 = Debug|x86
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.Build.0 = Release|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|Any CPU.Deploy.0 = Release|Any CPU
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.ActiveCfg = Release|ARM
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.Build.0 = Release|ARM
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|ARM.Deploy.0 = Release|ARM
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.ActiveCfg = Release|x64
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.Build.0 = Release|x64
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x64.Deploy.0 = Release|x64
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.ActiveCfg = Release|x86
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.Build.0 = Release|x86
{39122940-AB16-4CD4-A0CE-79A3EB863ECF}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.MicroBit</RootNamespace>
<AssemblyName>Microbit.Uploader</AssemblyName>
<AssemblyName>CodeTheMicrobit</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

View File

@ -79,7 +79,7 @@
this.MinimizeBox = false;
this.Name = "LicenseDialog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "code the micro:bit uploader Terms Of Use";
this.Text = "code the micro:bit terms of use";
this.ResumeLayout(false);
}

View File

@ -116,6 +116,7 @@
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// linkLabel1
//
@ -148,7 +149,7 @@
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "code the micro:bit uploader";
this.Text = "code the micro:bit";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.backgroundPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

View File

@ -243,11 +243,7 @@ namespace Microsoft.MicroBit
private void backgroundPictureBox_Click(object sender, EventArgs e)
{
try
{
Process.Start("https://codethemicrobit.com");
}
catch (IOException) { }
this.openEditor();
}
private void SettingsLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@ -262,5 +258,10 @@ namespace Microsoft.MicroBit
{
this.openEditor();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.openEditor();
}
}
}

View File

@ -26,11 +26,11 @@ control.inBackground(() => {
## Advanced
```namespaces
bluetooth.onBluetoothConnected(() => {
});
devices.tellCameraTo(MesCameraEvent.TakePhoto);
bluetooth.onBluetoothConnected(() => {});
```
```package
microbit-devices
microbit-bluetooth
```

View File

@ -1,33 +1,37 @@
# On Bluetooth Disconnected
### ~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 connect to the micro:bit. This block starts an [event handler](/reference/event-handler) which in this case will run when a device which is connected to your micro:bit over Bluetooth disconnects.
For another device like a smartphone to use any of the Bluetooth "services" which the micro:bit has, it must first connect to the micro:bit.
### ~
This block starts an [event handler](/reference/event-handler) which in this case will run when a device which is connected to your micro:bit over Bluetooth disconnects.
You could use this event handler to display a letter "D" on the micro:bit LED grid so you know that the Bluetooth connection has been closed.
~~~~sig
```sig
bluetooth.onBluetoothDisconnected(() => {
});
~~~~
```
### Example: Displaying "D" when a Bluetooth connection to the micro:bit is closed
~~~~blocks
```blocks
bluetooth.onBluetoothDisconnected(() => {
basic.showString("D");
});
~~~~
```
### Video - on Bluetooth disconnected
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_on_disconnected.png)](
http://www.youtube.com/watch?v=HyBcsD9Eh6I "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=HyBcsD9Eh6I
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth SIG](https://www.bluetooth.com), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

View File

@ -1,30 +1,33 @@
# Bluetooth Accelerometer Service
### ~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 connect to the micro:bit.
### ~
The Bluetooth accelerometer service allows another device such as a smartphone to wirelessly receive data from the micro:bit's accelerometer. An accelerometer detects motion. More precisely, it measures acceleration in one or more of three directions which we call X, Y and Z.
Using the Bluetooth accelerometer service you could, for example, create a smartphone application which makes a loud noise whenever your micro:bit (or the important thing you've attached it to) is moved. Or you could use your micro:bit to control the movement of a cartoon character in a game on your smartphone just by tilting the micro:bit in the direction you want the character to move in.
No additional code is needed on the micro:bit to use the Bluetooth accelerometer service from another device.
~~~~sig
```sig
bluetooth.startAccelerometerService();
~~~~
```
### Example: Starting the Bluetooth accelerometer service
The following code shows the Bluetooth accelerometer service being started:
~~~~blocks
```blocks
bluetooth.startAccelerometerService();
~~~~
```
### Video - Accelerometer service demo - Starts at 0:18
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_accelerometer.png)](
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=aep_GVowKfs
### Advanced
@ -32,7 +35,8 @@ For more advanced information on the micro:bit Bluetooth accelerometer service i
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth SIG](https://www.bluetooth.com), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

View File

@ -1,7 +1,12 @@
# Bluetooth Button Service
### ~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 connect to the micro:bit.
### ~
The Bluetooth button service makes it possible for another device such as a smartphone to be notified wirelessly whenever a button on the front of a micro:bit is pressed. Each of the two micro:bit buttons can be in one of three possible states:
* Not pressed
@ -12,23 +17,21 @@ The button service allows you to make other things which are connected to your m
No additional code is needed on the micro:bit to use the Bluetooth button service from another device.
~~~~sig
```sig
bluetooth.startButtonService();
~~~~
```
### Example: Starting the Bluetooth button service
The following code shows the Bluetooth button service being started:
~~~~blocks
```blocks
bluetooth.startButtonService();
~~~~
```
### Video - Button service demo - Starts at 0:59
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_button.png)](
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=aep_GVowKfs
### Advanced
@ -36,7 +39,8 @@ For more advanced information on the micro:bit Bluetooth button service includin
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth SIG](https://www.bluetooth.com),[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

View File

@ -1,28 +1,31 @@
# Bluetooth IO Pin Service
### ~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 connect to the micro:bit.
### ~
The Bluetooth IO pin service makes it possible for another device such as a smartphone to communicate with other electronic 'things' connected to a micro:bit's edge connector. You could for example, use your smartphone to switch on or off a light which is connected to the micro:bit or your smartphone could receive data collected from a sensor connected to the micro:bit. In fact you could do both of these things at the same time since the Bluetooth IO pin service lets you interact with multiple 'pins' on the edge conector in different ways all at the same time.
No additional code is needed on the micro:bit to use the Bluetooth IO pin service from another device.
~~~~sig
```sig
bluetooth.startIOPinService();
~~~~
```
### Example: Starting the Bluetooth IO pin service
The following code shows the Bluetooth IO pin service being started:
~~~~blocks
```blocks
bluetooth.startIOPinService();
~~~~
```
### Video - IO pin service demo starts at 3:49
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_pin_io.png)](
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=aep_GVowKfs
### Advanced
@ -30,7 +33,8 @@ For more advanced information on the micro:bit Bluetooth IO pin service includin
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth SIG](https://www.bluetooth.com), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

View File

@ -1,30 +1,33 @@
# Bluetooth LED Service
### ~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 connect to the micro:bit.
### ~
The Bluetooth LED service allows another device such as a smartphone to send short text strings or patterns over a Bluetooth connection to a micro:bit for display on its LED matrix. Text will scroll across the micro:bit and the speed at which it scrolls can also be controlled using the Bluetooth LED service. Devices using the LED service may also read the current state of the micro:bit's LED matrix.
So you could, for example, draw a smiley face in a smartphone app and at the press of a button, have it magically appear on your micro:bit on the other side of the room. Or you could program your smartphone to send a message to your micro:bit whenever your phone receives an email, SMS or social media message so you could wear your micro:bit like a smart watch and leave your phone in your bag.
No additional code is needed on the micro:bit to use the Bluetooth LED service from another device.
~~~~sig
```sig
bluetooth.startLEDService();
~~~~
```
### Example: Starting the Bluetooth LED service
The following code shows the Bluetooth LED service being started:
~~~~blocks
```blocks
bluetooth.startLEDService();
~~~~
```
### Video - LED service demo starts at 2:00
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_led.png)](
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=aep_GVowKfs
### Advanced
@ -32,7 +35,8 @@ For more advanced information on the micro:bit Bluetooth LED service including i
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth SIG](https://www.bluetooth.com), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

View File

@ -1,30 +1,33 @@
# Bluetooth Magnetometer Service
### ~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 connect to the micro:bit.
### ~
The Bluetooth magnetometer service allows another device such as a smartphone to wirelessly receive data from the micro:bit's magnetometer. The magnetometer measures the strength and direction of magnetic fields including the earth's and so it can be used as a digital compass and indicate the way the micro:bit is pointing relative to magnetic north.
Using the Bluetooth magnetometer service you could, for example, create a smartphone application which displays your direction of travel, updating it in real time.
No additional code is needed on the micro:bit to use the Bluetooth magnetometer service from another device.
~~~~sig
```sig
bluetooth.startMagnetometerService();
~~~~
```
### Example: Starting the Bluetooth magnetometer service
The following code shows the Bluetooth magnetometer service being started:
~~~~blocks
```blocks
bluetooth.startMagnetometerService();
~~~~
```
### Video - Magnetometer service demo
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_magnetometer.png)](
http://www.youtube.com/watch?v=C_0VL4Gp4_U "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=C_0VL4Gp4_U
### Advanced
@ -32,7 +35,9 @@ For more advanced information on the micro:bit Bluetooth magnetometer service in
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth SIG](https://www.bluetooth.com), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

View File

@ -1,30 +1,33 @@
# Bluetooth Temperature Service
### ~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 connect to the micro:bit.
### ~
A micro:bit is able to provide a rough measure of the current environmental temperature. It's an approximation only as in fact the temperature value is inferred from the temperature of its main processor. The Bluetooth temperature service allows another device such as a smartphone to wirelessly find out the micro:bit's current temperature reading or to receive a constant stream of temperature data values. Temperature values are expressed in degrees celsius.
Using the Bluetooth temperature service you could turn your smartphone or tablet into a graphical thermometer using your micro:bit as the sensor.
No additional code is needed on the micro:bit to use the Bluetooth temperature service from another device.
~~~~sig
```sig
bluetooth.startTemperatureService();
~~~~
```
### Example: Starting the Bluetooth temperature service
The following code shows the Bluetooth temperature service being started:
~~~~blocks
```blocks
bluetooth.startTemperatureService();
~~~~
```
### Video - Temperature service demo - Starts at 3:05
[![micro:bit Bluetooth demo video](/static/bluetooth/microbit_temperature.png)](
http://www.youtube.com/watch?v=aep_GVowKfs "Click to launch YouTube video"
)
http://www.youtube.com/watch?v=aep_GVowKfs
### Advanced
@ -32,7 +35,10 @@ For more advanced information on the micro:bit Bluetooth temperature service inc
### See also
[Bluetooth SIG](https://www.bluetooth.com)
[Bluetooth SIG](https://www.bluetooth.com), [Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
[Bluetooth on micro:bit resources](http://bluetooth-mdw.blogspot.co.uk/p/bbc-microbit.html)
```package
microbit-bluetooth
```

19
docs/reference/devices.md Normal file
View File

@ -0,0 +1,19 @@
# Devices
Control a phone with the BBC micro:bit via Bluetooth.
```cards
devices.tellCameraTo(MesCameraEvent.TakePhoto);
devices.tellRemoteControlTo(MesRemoteControlEvent.play);
devices.raiseAlertTo(MesAlertEvent.DisplayToast);
devices.onNotified(MesDeviceInfo.IncomingCall, () => {
});
devices.onGamepadButton(MesDpadButtonInfo.ADown, () => {
});
devices.signalStrength();
devices.onSignalStrengthChanged(() => {
});
```

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://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 "/".
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://codethemicrobit.com/](https://codethemicrobit.com/), 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

@ -1,6 +1,7 @@
# Analog Read Pin
Read the specified [pin](/device/pins) (P0, P1, P2) as analog.
Read an **analog** signal (`0` through `1023`) from the
[pin](/device/pins) you say.
```sig
pins.analogReadPin(AnalogPin.P0)
@ -8,13 +9,14 @@ pins.analogReadPin(AnalogPin.P0)
### Parameters
* name - the pin name (`P0`, `P1`, or `P2`)
* a [string](/reference/types/string) that stores the pin you say (`P0` through `P4`, or `P10`)
### Returns
* [Number](/reference/types/number) - a number between 0 and 1023 (included)
* a [number](/reference/types/number) from `0` through `1024`
The following code reads `P1` and charts it on the screen:
This program reads pin `P1` and shows the number as a
[bar graph](/reference/led/plot-bar-graph).
```blocks
basic.forever(() => {
@ -25,5 +27,9 @@ basic.forever(() => {
### See also
[micro:bit pins](/device/pins), [on pin pressed](/reference/input/on-pin-pressed), [analog write pin](/reference/pins/analog-write-pin), [digital read pin](/reference/pins/digital-read-pin), [digital write pin](/reference/pins/digital-write-pin)
[micro:bit pins](/device/pins),
[on pin pressed](/reference/input/on-pin-pressed),
[analog write pin](/reference/pins/analog-write-pin),
[digital read pin](/reference/pins/digital-read-pin),
[digital write pin](/reference/pins/digital-write-pin)

View File

@ -1,24 +1,32 @@
# Digital Read Pin
The digital read pin function.
Digitally read the specified [pin](/device/pins) (``P0``, ``P1``, ``P2``, ...) as digital. **Some pins are also used by the display, read the [pin documentation ](/device/pins) carefully.**
Read a **digital** (`0` or `1`) signal from a [pin](/device/pins) on
the micro:bit board.
```sig
pins.digitalReadPin(DigitalPin.P3)
```
### ~avatar
Some pins are also used by the [LED screen](/device/screen).
Please read the [page about pins](/device/pins) carefully.
### ~
### Parameters
* name - the pin name ``P0``, ``P1``, ``P2``, ...
* a [string](/reference/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
### Returns
* [Number](/reference/types/number) - 0 or 1
* a [number](/reference/types/number) that can be `0` or `1`
### Example: football score keeper
The following example reads `P0` to determine when a goal is scored. When `P0 = 1`, the code uses `digital write pin` to play a buzzer sound:
This program reads pin `P0` to find when a goal is scored. When `P0`
is `1`, the program makes the score bigger and plays a buzzer sound
through `P2` with ``digital write pin``.
```blocks
let score = 0
@ -34,7 +42,29 @@ basic.forever(() => {
})
```
This program is a remote control for the score keeper program. If you
connect `P1` on the remote control micro:bit to `P0` on the score
keeper micro:bit, you can press button `B` on the remote to buzz and
make the score bigger on the other micro:bit.
```blocks
input.onButtonPressed(Button.B, () => {
pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0);
});
```
#### ~hint
Remember to connect `GND` on both micro:bits together!
#### ~
### See also
[micro:bit pins](/device/pins), [digital write pin](/reference/pins/digital-write-pin), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [on pin pressed](/reference/input/on-pin-pressed), [pin is pressed](/reference/input/pin-is-pressed)
[micro:bit pins](/device/pins),
[digital write pin](/reference/pins/digital-write-pin),
[analog read pin](/reference/pins/analog-read-pin),
[analog write pin](/reference/pins/analog-write-pin),
[on pin pressed](/reference/input/on-pin-pressed),
[pin is pressed](/reference/input/pin-is-pressed)

View File

@ -1,19 +1,29 @@
# Digital Write Pin
Write the value ``0`` or ``1`` to the specified (digital) [pin](/device/pins). **Some pins are also used by the display, read the [pin documentation ](/device/pins) carefully.**
Write a **digital** (`0` or `1`) signal to a [pin](/device/pins) on
the micro:bit board.
```sig
pins.digitalWritePin(DigitalPin.P1, 1)
```
### ~avatar
Some pins are also used by the [LED screen](/device/screen).
Please read the [page about pins](/device/pins) carefully.
### ~
### Parameters
* name - the pin name (``P0``, ``P1``, ``P2``, ...)
* value - [Number](/reference/types/number); 0 or 1
* a [string](/reference/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
* a [number](/reference/types/number) that can be either `0` or `1`
### Example: football score keeper
The following example reads `P0` to determine when a goal is scored. When `P0 = 1`, the code uses `digital write pin` to play a buzzer sound:
This program reads pin `P0` to find when a goal is scored. When `P0`
is `1`, the program makes the score bigger and plays a buzzer sound
through `P2` with ``digital write pin``.
```blocks
let score = 0
@ -29,7 +39,25 @@ basic.forever(() => {
})
```
This program is a remote control for the score keeper program. If you
connect `P1` on the remote control micro:bit to `P0` on the score
keeper micro:bit, you can press button `B` on the remote. This program
will use ``digital write pin`` to make the other micro:bit buzz and
make the score bigger.
```blocks
input.onButtonPressed(Button.B, () => {
pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0);
});
```
### See also
[micro:bit pins](/device/pins), [digital read pin](/reference/pins/digital-read-pin), [analog read pin](/reference/pins/analog-read-pin), [analog write pin](/reference/pins/analog-write-pin), [on pin pressed](/reference/input/on-pin-pressed)
[micro:bit pins](/device/pins),
[digital read pin](/reference/pins/digital-read-pin),
[analog read pin](/reference/pins/analog-read-pin),
[analog write pin](/reference/pins/analog-write-pin),
[on pin pressed](/reference/input/on-pin-pressed)

View File

@ -2,17 +2,11 @@
## Features
The Windows 10 App provides all the existing features of [m.pxt.io](https://m.pxt.io) plus the following ones:
The Windows 10 App provides all the existing features of [codethemicrobit](https://codethemicrobit.com) 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.
## Installing the pre-release app
## Installing the app
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://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).
Coming to the store soon!

View File

@ -4,6 +4,10 @@
MicroBitUARTService *uart;
using namespace pxt;
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
namespace bluetooth {
/**

View File

@ -1,7 +1,9 @@
// Auto-generated. Do not edit.
/**
* Support for additional Bluetooth services.
*/
//% color=#0082FB weight=20
declare namespace bluetooth {

View File

@ -120,7 +120,9 @@ enum class MesDpadButtonInfo {
_4Up = MES_DPAD_BUTTON_4_UP,
};
/**
* Control a phone with the BBC micro:bit via Bluetooth.
*/
//% color=156 weight=80
namespace devices {
static void genEvent(int id, int event) {

View File

@ -1,7 +1,9 @@
// Auto-generated. Do not edit.
/**
* Control a phone with the BBC micro:bit via Bluetooth.
*/
//% color=156 weight=80
declare namespace devices {

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.2.174",
"version": "0.2.176",
"description": "BBC micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.2.185"
"pxt-core": "0.2.187"
}
}

View File

@ -1,7 +1,7 @@
{
"id": "microbit",
"name": "m.pxt.io",
"title": "m.pxt.io",
"name": "code the micro:bit",
"title": "code the micro:bit",
"corepkg": "microbit",
"bundleddirs": [
"libs/microbit",
@ -81,14 +81,14 @@
},
"appTheme": {
"accentColor": "#5C005C",
"logoUrl": "https://m.pxt.io/about",
"logoUrl": "https://codethemicrobit.com/about",
"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/",
"homeUrl": "https://codethemicrobit.com/",
"embedUrl": "https://codethemicrobit.com/",
"privacyUrl": "https://go.microsoft.com/fwlink/?LinkId=521839",
"termsOfUseUrl": "https://go.microsoft.com/fwlink/?LinkID=206977",
"boardName": "BBC micro:bit",

View File

@ -142,7 +142,6 @@
"fbpnng",
"fbyrog",
"fcfoox",
"fcgdzt",
"fcicvk",
"fcjlto",
"fcvwvj",