zhaofeng-shu33 / blockly-mbed

USE Blockly to build a simple mbed C code generator
8 stars 3 forks source link

USE Blockly to build a simple mbed C code generator

Background

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.

Ambition

Currently, the following blocks are considered:

Developer Build

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:

Then open index_debug.html and you are done.

Release Build

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.

Version

The current implementation supports mbed OS 2 only. Mbed OS 5 will be considered in the future release.

Enhanced feature to core library of blockly

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

Keep up-to-date with upstream library

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:

Reference