Graphical Code generator has been a trend nowadays. There is Arduino code generator with Blockly. This project tries to build a mbed C code generator to help students prototyping their ideas more quickly.
Currently, the following blocks are considered:
- GPIO
- Servo
- Serial
- SPI
The project is started from BlocklyDuino and Ardublockly.
The index.html favor and index_utility.js wrapper are based on BlocklyDuino while the blocks and the generator is based on Ardublockly.
Notice that because Ardublockly changes some functions of google blockly core, blocks and msg, the project has to use in source build.
Still, for developing and debugging, google closure-library(v20171203) is needed but "blockly-master" branch is no longer needed.
First, download a specified version closure-library and unzip it to the same directory with blockly-mbed
.
That is:
- root
- blockly-mbed
- closure-library
Then open index_debug.html
and you are done.
We can compress the files in blocks/, generators/ and use blockly_compressed.js.
Therefore, no depedency on closure-library is needed and the browser can read only a few javascript files to make everything work.
Currently, I use nodejs "google-closure-compiler-js" modules to compress these files.
use node_compress_utility.js to build "node_compressed_utility.js" from msg/*
use node_compress_block.js to build "node_compressed_block.js" from blocks/*
use node_compress_generator.js to build "node_compressed_generator.js" from generator/*
index.html is the release version of mbed-blockly.
The current implementation supports mbed OS 2 only. Mbed OS 5 will be considered in the future release.
To make Blockly support code generation of C code, we add a few js files under the folder "c_core" without changing the original code of blockly.
instances.js field_variable.js field_instance.js block.js blockly.js
To make the development up-to-date, I should manually download the latest version of google-closure-compiler and google-blockly. The former is easier to handle since all I should do is downloading the compressed library and extract it. For the latter (blockly), I only need parts of it. Therefore, I should manually download the following parts:
core/*
blocks/*
msg/message.js
-
https://os.mbed.com/platforms/ST-Nucleo-F103RB/ hardware information
-
https://developer-sjc-indigo-border.mbed.org/cookbook/Homepage SDK API reference
-
https://developers.google.com/blockly/guides/overview Google Blockly reference