I’ve been looking into the Micro:Bit and Microsoft’s PXT (Programmer eXperience Toolkit). PXT and all the required build tools can be installed on macOS, but the official instructions are a little weak. Here are the required steps:
Installation / Running
All these commands need to be run in a terminal:
- Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install Node.js (using homebrew)
brew install node
- Install Yotta
brew tap ARMmbed/homebrew-formulae
brew install python cmake ninja arm-none-eabi-gcc
pip install yotta
- Install srecord
brew install srecord
- Clone the pxt repo. (Replace the repo URL with the URL of a fork if desired)
git clone https://github.com/Microsoft/pxt-microbit
- Change your directory to be within the cloned repo. For the above:
- Install pxt
npm install -g pxt
- Run the local pxt server.
This will download the needed components, do compilation, and eventually launch the PXT environment in your default browser. Watch the terminal window though. Downloads may exceed github limits and it may require you to paste a URL to login in and complete downloads (something like https://yotta.mbed.com/?provider=github#login/...).
Adding a Library
- Stop the pxt server (if running)
- Create the sub directory in ROOT/libs. Ex:
git clone https://github.com/Microsoft/pxt-bluetooth-temperature-sensor
mv pxt-bluetooth-temperature-sensor bluetooth-temperature-sensor
- Add the new directory to bluetooth-temperature-sensor in pxt-microbit/pxtarget.json
- If needed, update the pxt.json of the new library. For example, for the above update the path of the dependencies:
- Restart the server to build it.