2016-04-07 13:34:52 -07:00
# micro:bit target for PXT
2016-03-10 14:21:48 -08:00
2016-04-07 13:33:55 -07:00
This target allow to program a [BBC micro:bit ](https://www.microbit.co.uk/ ) using
2016-05-26 21:38:11 -07:00
PXT ([Microsoft Programming Experience Toolkit ](https://github.com/Microsoft/pxt )).
2016-03-10 14:21:48 -08:00
2016-06-22 09:43:41 -07:00
* [Try it live ](https://codethemicrobit.com )
2016-05-10 21:43:12 -07:00
2016-04-07 13:33:55 -07:00
[![Build Status ](https://travis-ci.org/Microsoft/pxt-microbit.svg?branch=master )](https://travis-ci.org/Microsoft/pxt-microbit)
2016-03-10 21:11:16 -08:00
2016-05-19 10:34:24 -07:00
## Local server
2016-07-27 13:15:30 -07:00
The local server allows to run the editor and the documentation from your computer.
2016-05-19 10:34:24 -07:00
### Setup
2016-03-10 14:26:59 -08:00
2016-05-18 09:18:14 -07:00
The following commands are a 1-time setup after synching the repo on your machine.
2016-07-27 13:28:57 -07:00
* if not yet installed, install [Node.js 4.4.5 or higher ](https://nodejs.org/en/download/ )
2016-07-27 13:48:57 -07:00
* [clone this repo ](https://help.github.com/articles/cloning-a-repository/ ) to your computer and go in the project folder
```
git clone https://github.com/microsoft/pxt-microbit
cd pxt-microbit
```
2016-07-27 13:28:57 -07:00
* install the PXT command line (add ``sudo` ` for Mac/Linux shells).
2016-05-18 09:18:14 -07:00
```
npm install -g pxt
```
* install the dependencies
```
npm install
```
2016-05-19 10:34:24 -07:00
### Running
2016-06-06 10:14:56 -07:00
Run this command to open a local web server (add ``sudo` ` for Mac/Linux shells)
2016-05-18 09:18:14 -07:00
```
pxt serve
```
2016-05-26 21:38:11 -07:00
If the local server opens in the wrong browser, make sure to copy the URL containing the local token.
Otherwise, the editor will not be able to load the projects.
2016-06-06 10:14:56 -07:00
If you need modify the `.cpp` files, turn on yotta compilation with the ``-yt`` flag (add ``sudo` ` for Mac/Linux shells):
2016-05-26 21:38:11 -07:00
```
pxt serve -yt
```
2016-07-27 13:28:57 -07:00
## Updates
To update your PXT version and make sure you're running the latest tools, run (add ``sudo` ` for Mac/Linux shells)
2016-05-19 10:34:24 -07:00
```
2016-06-06 10:14:56 -07:00
pxt update
2016-05-19 10:34:24 -07:00
```
2016-05-18 09:18:14 -07:00
More instructions at https://github.com/Microsoft/pxt#running -a-target-from-localhost
2016-04-07 20:48:00 -07:00
## Universal Windows App
2016-04-08 13:49:53 -07:00
The Windows 10 app is a [Universal Windows Hosted Web App ](https://microsoftedge.github.io/WebAppsDocs/en-US/win10/CreateHWA.htm )
2016-06-22 09:43:41 -07:00
that wraps ``codethemicrobit.com` ` and provides additional features.
2016-04-08 13:49:53 -07:00
### Building
* Install Visual Studio 2015 Update 2 or higher. Make sure the Windows 10 templates are installed.
2016-06-22 09:43:41 -07:00
* open the ``win10/app.sln`` solution and launch the ``codethemicrobit` ` project.
2016-06-21 13:17:42 -07:00
2016-07-28 11:47:45 +01:00
## Testing
The build automatically runs the following:
* make sure the built-in packages compile
* `pxt run` in `libs/lang-test*` - this will run the test in command line runner;
there is a number of asserts in both of these
* `pxt testdir` in `tests` - this makes sure all the files compile and generates .hex files
* run the TD->TS converter on a number of test scripts from `microbit.co.uk` and make sure the results compile
To test something on the device:
* do a `pxt deploy` in `libs/lang-test*` - they should show `1` or `2` on the screen (and not unhappy face)
* run `pxt testdir` in `tests` and deploy some of the hex files from `tests/built`
The `lang-test0` source comes from the `pxt-core` package. It's also tested with `pxt run` there.
2016-06-21 13:17:42 -07:00
## Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct ](https://opensource.microsoft.com/codeofconduct/ ). For more information see the [Code of Conduct FAQ ](https://opensource.microsoft.com/codeofconduct/faq/ ) or contact [opencode@microsoft.com ](mailto:opencode@microsoft.com ) with any additional questions or comments.