diff --git a/.gitignore b/.gitignore index b6e4761..4d7446d 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,13 @@ dmypy.json # Pyre type checker .pyre/ + +# mbed CLI - micro:bit +/.temp +/__pycache__ +/BUILD +/mbed +/mbed-src +/microbit +/.mbed +/mbed.bld diff --git a/README.md b/README.md index 83429b1..b6c33f2 100644 --- a/README.md +++ b/README.md @@ -1 +1,103 @@ -# mbed-microbit-template \ No newline at end of file +# mbed-microbit-template + +mbed-microbit-templateは、GitHubテンプレートであり、C/C++言語を使ってランチェスター大学によって作成されたmicro:bitランタイムへの参照をあらかじめ含んでいます。 +The mbed-microbit-template is a GitHub template that comes pre-populated with references to it, the micro:bit runtime provides an easy to use environment for programming the BBC micro:bit in the C/C++ language, written by Lancaster University.   + +## 概要 Overview + +micro:bitランタイムには、micro:bitが備えているLEDマトリクスディスプレイ機能といった各種ハードウェア機能だけでなく、ピアツーピアの無線通信やセキュアなBluetooth Low Energyサービスなど、micro:bitのプログラミングをより簡単かつ柔軟にするためのデバイスドライバやメカニズムが含まれています。micro:bitランタイムは、ARM MbedとNordic nrf51プラットフォーム上に構築されています。 +The micro:bit runtime contains device drivers for all the hardware capabilities of the micro:bit, and also a suite of runtime mechanisms to make programming the micro:bit easier and more flexible. These range from control of the LED matrix display to peer-to-peer radio communication and secure Bluetooth Low Energy services. The micro:bit runtime is proudly built on the ARM Mbed and Nordic nrf51 platforms, BBC micro:bit v1.5. + +ところが、Windows10とPython3環境で、ARM Mbedを使って、プログラミングを行う場合、いくつかの問題点があります。ここでは、Windows10でも容易にプログラミング環境を整える手順を説明します。 +However, there are a few problems when programming with ARM Mbed in Windows10 and Python3 environment. This section explains the steps to easily set up a programming environment on Windows 10. + +> 補足:BBC micro:bit v1.5をターゲットとしています。 +> Note: BBC micro:bit v1.5 is the target. + +# はじめに Get Started + +## インストール Install + +1. [Git](https://git-scm.com/) +2. [Mercurial](https://www.mercurial-scm.org/) +3. [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) - [**6-2017-q2-update**](https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32-sha2.exe) +※ GNU Arm Embedded Toolchain + → [gcc-arm-none-eabi-6-2017-q2-update-win32-sha2.exe](https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32-sha2.exe) +4. [Python3](https://www.python.org/downloads/) + +## 環境構築 Environment + +コマンドプロンプトを開き、次のコマンドを実行します。 +Open the command prompt and run below commands. + +```CommandPrompt.cmd +py -3 -m pip install --upgrade virtualenv +mkdir c:\workubit +cd c:\workubit +py -3 -m virtualenv venv +C:\workubit\venv\Scripts\activate.bat +pip install mbed-cli git+https://github.com/jp-rad/mbed-microbit-win10-setup.git +mbed config --global GCC_ARM_PATH "C:\Program Files (x86)\GNU Tools Arm Embedded\6 2017-q2-update\bin" + +``` + +# 使い方 How to use + +## Using this template + +1. GitHubのリポジトリを開きます。 + Open the repository on github. + https://github.com/jp-rad/mbed-microbit-template + +1. `Use this template`をクリックします。 + Click `Use this template`. + [Here - https://github.com/jp-rad/mbed-microbit-template/generate] (https://github.com/jp-rad/mbed-microbit-template/generate) + + +## git clone + +コマンドプロンプトを開き、次のコマンドを実行します。 +Open the command prompt and run below commands. + +```CommandPrompt.cmd +C:\workubit\venv\Scripts\activate.bat +cd c:\workubit +git clone +``` + +## コンパイル compile + +パソコンにBBC micro:bitを接続し、例えば、Dドライブとして認識させます。 +引き続き、コマンドプロンプトで次のコマンドを実行します。 +Connect the BBC micro:bit to the PC. For example, it will be recognized as drive D. +Continue to run below commands at the command prompt. + +```CommandPrompt.cmd +cd +mbedubitwin10 +mbed compile +copy .\BUILD\NRF51_MICROBIT\GCC_ARM\microbit-mbed.hex d:\ +``` + +## Hello World! + +```cpp +#include "MicroBit.h" +MicroBit uBit; +int main() +{ + uBit.init(); + uBit.display.scroll("HELLO WORLD! :)"); + release_fiber(); +} +``` + +# リンク Links + +## micro:bit runtime + +[micro:bit runtime docs](https://lancaster-university.github.io/microbit-docs/) + +## BBC Community Guidelines + +[Microbit Community Guidelines](http://microbit.org/community/) diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..6509ec1 --- /dev/null +++ b/main.cpp @@ -0,0 +1,43 @@ +/* +The MIT License (MIT) + +Copyright (c) 2016 British Broadcasting Corporation. +This software is provided by Lancaster University by arrangement with the BBC. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + +#include "MicroBit.h" + +MicroBit uBit; + +int main() +{ + // Initialise the micro:bit runtime. + uBit.init(); + + // Insert your code here! + uBit.display.scroll("HELLO WORLD! :)"); + + // If main exits, there may still be other fibers running or registered event handlers etc. + // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then + // sit in the idle task forever, in a power efficient sleep. + release_fiber(); +} + diff --git a/microbit.lib b/microbit.lib new file mode 100644 index 0000000..12f706b --- /dev/null +++ b/microbit.lib @@ -0,0 +1 @@ +https://developer.mbed.org/teams/Lancaster-University/code/microbit/#4b89e7e3494f