micro:bit 软件生态系统介绍

microbit 软件分成在microbit (Target Computer 如下图右边)上执行的及主计算机(Host Computer 如下图左边)上两类 :

一般程序写好后透过USB 转到micro:bit , 整个流程由两个芯片完成,一是 KL26Z负责程序刷新(code flashing) ,另一nRF51822则执行完成用户完成的程序。

高阶程序语言

Microbit 的高阶程序语言分成编译及直译两类(但译者若以实际的程序执行环境目前都是"编译”── 将用户程序编译后结合底层已有bytebode ,成为完整执行程序),原文便保留

The ‘highlevel’ programming languages for the micro:bit breakdown into two broad categories

·       Compiled languages: your program is compiled to ARM assembler or some otherkind of bytecode before being copied onto the micro:bit.

·       Interpreted Languages: both your script and an interpreter for it are copiedonto the micro:bit. Because the interpreter is on the micro:bit itself, theselangauges typically also allow you to program the micro:bit ‘live’ over USB by typing commands.

 

编译语言

C/C++, while certainly compiled, is not considered a high-levellanguage in this context

 

为了可以确定在线的编译环境可支持一百万片microbit 的板子,微软用TypeScript 写了浏览器版编译程序(https://makecode.com),在这编译程序上微软使用了以下的技术 : 

·       Blocks (at microbit.co.uk)

·       TouchDevelop

·       CodeKingdoms Javascript (at microbit.co.uk)

·       Blocks and Javascript as part of pxt (at pxt.microbit.org)

 

浏览编译程序不会编译整个程序,只有用户编写的部分,其他底层执行的部分已经预先用mbed 编译好,并整合进在线编译程序。当用户编写完他的程序,编译程序便会编译并结合底层软件,让用户下载!

 

PS: MakeCode的底层编程语言是TypeScript(github.com/Microsoft/TypeScript-Node-Starter)的一个子集,省略了JavaScript动态特征。

 

MakeCode的主要功能有:

 

一个基于Google Blockly的代码编辑器以及转换器到JavaScript

 

一个基于摩纳哥的文本编辑器,具有增强的强大的自动完成和自动更正功能,由TypeScript提供支持。

 

通过TypeScript或C ++定义块的可扩展性支持

 

基于markdown的文文件系统,具有内置宏以呈现块片段

 

一个ARM Thumb机器码发射器

 

一个命令行包管理器

 

MakeCode目前在微软Redmond开发。

 

直译语言

 

在microbit.co.uk 正式的编译程序中,只有 Python 是直译的。这是用MicroPython 直译器项目所完成,细部数据可以 MicroPython的链接中找到。

 

另外还有Javascript 直译器项目 port of the Javascript interpreter Espruino 支持 microbit!

 

 

程序环境及整合接口

 

这里有许多程序环境可让用户对microbit做不同层面的程序设计.

 

较普遍的编译环境都列在https://microbit.org/code,脱机的编译环境有Mu offline Python editor

 

这里已经尽可能将micro bit 相关的编译环境列出来,若你有知道,但不在这上面的,请让我们知道(Here’s a non-exhaustive list of possiblecode editors for use with the micro:bit. please add any you know about that arenot here,原文中并未指出如何通知,所以在这将原文列出)

 

·        microbit.co.uk editors based onTouchDevelop backend:

 

  • Code Kingdoms Javascript

 

  • Microsoft Blocks

 

  • Microsoft TouchDevelop

 

  • Python

 

·        mbed Online Compiler

 

·        Mu offline Python editor

 

·       PXT for micro:bit (successor to theTouchDevelop-based editors above)

 

从程序环境到 micro:bit 

 

每一个编译环境都会产生一个.hex 的档案,这是microbit 可以认得的格式。由于主计算机会将Microbit认为是USB随身碟(是由DAPLink 模拟出来),当编译出来Hex 檔拖拉至microbit。当闪灯结束,程序便开始执行。

 

另一"刷程序"(flash’ code) 是用手机AP透过蓝芽传输至micro:bit ,更多的信息请参考 here,有关蓝芽手机程序更多信息请参考 here。

micro:bit底层软件架构

 

当你为microbit 写完你的应用程序,刷你的程序进microbit 。这hex 档除了包含你写的部分也包含了许多底成软件模块,这些软件模块在底下一、一做介绍:

 

·        the micro:bit Runtime (有时称这部分为装置抽象层),是由Lancaster University 用C++ 写成。装置抽象层形成不同语言共同使用的部分,但在不同语言下使用的频繁度及包装的紧密度不同。(有兴趣的读者可以用以下列处的链接下载语言编译程序的程序代码研究,或初步去看各语言的reference 作了解)

 

·        ARM mbed 这部分提供了mbed对不同ARM based MCU 的周边有标准的SDK ,这也包含了BLE 的抽象层及API ,这也代表的microbit的软件可以执行在其他的mbed 支持的硬件上

 

·        Nordic nRF51-SDK mbed 是建构在Nordic nRF51-SDK的上层, 由 Nordic 发展的组件可以帮助程序人员使用它们的硬件。

 

·        MicroPythoninterpreter 若你是使用python的程序人员 ,它是用micro python 及mbed 开发出来的,所以microPython 是可以使用在许多不同硬件平台

 

*原文参考

https://mp.weixin.qq.com/s?__biz=MzU0MTg0ODIzNA==&mid=2247483654&idx=1&sn=d12be17453212cb5852ee1104c461ce3&chksm=fb22e6c3cc556fd59d3e102d198ebda9126a5622100c4d851623ef66763b10586bbcb1aee304#rd

 

posted @ 2018-09-28 14:30  易心Astar  阅读(1476)  评论(0编辑  收藏  举报