micro:bit 実験1 CLI環境の構築
■yottaとsrecordをインストール
Offline Development - micro:bit runtime
yotta : インストーラ形式。git-scm、mbed serial driverにチェックを入れる。
srecord : ZIP形式。3つのexeファイルをc:\yotta に入れる。
■おまじないを唱える
※デスクトップに作られたRun Yottaショートカットをクリック git clone https://github.com/lancaster-university/microbit-samples cd microbit-samples yt target bbc-microbit-classic-gcc ※mbedサイトにログインする必要がある為、ブラウザが開きます。 yt build ※micro:bitのライブラリが落ちてきて、hexファイルを作ります。 copy build\bbc-microbit-classic-gcc\source\microbit-samples-combined.hex E: ※僕の環境の場合、Eドライブがmicro:bitでした。ハローワールドのhexファイルができます。
■デフォルトのプロジェクトを作る
http://www.forward.com.au/pfod/microbit/compileSetup.html
mkdir emptyproject cd emptyproject yt init ※Is this an executable の答えは yes。それ以外はデフォルト。 yotta target bbc-microbit-classic-gcc yotta install lancaster-university/microbit yt build ※ビルドの結果から、使わないtestフォルダを消す ※git リポジトリがないと警告できるけど無視する(そもそもgit使ってないし)
sourceフォルダに main.cppを作る
#include "MicroBit.h" MicroBit uBit; int main() { uBit.init(); uBit.display.scroll("HELLO WORLD!"); release_fiber(); }
最後に、yt buildすればbuild\bbc-microbit-classic-gcc\source\emptyproject-combined.hexができる。
■build.batを作る
@echo off set PATH=%YOTTA_PATH%;%YOTTA_INSTALL_LOCATION%\workspace\Scripts;%PATH% SET COM="build\bbc-microbit-classic-gcc\source\microbit-samples-combined.hex" SET SAM="build\bbc-microbit-classic-gcc\source\microbit-samples.*" cd .. :loop del %SAM% del %COM% yt build if exist %COM% goto usb :miss pause cls goto loop :usb copy %COM% d: pause cls goto loop