Create a Visual Embedded Rust program in a web browser and automatically generate Rust + Mynewt OS code for PineTime Smart Watch
Try it here: https://lupyuen.github.io/blockly-mynewt-rust/demos/code/
Sample XML (Copy into the XML Tab): https://github.com/lupyuen/blockly-mynewt-rust/blob/master/sample.xml
Which generates this Rust code (in the Rust Tab): https://twitter.com/MisterTechBlog/status/1228289867815112705?s=20
Which compiles into this PineTime Smart Watch Firmware: https://youtu.be/6NBqJMNibCw
Watch an older demo: https://youtu.be/5hWq5TDEpIg
Read the articles:
blockly-mynewt-rust
create PineTime Watch Apps based on the druid UI framework...
Porting [druid] Rust Widgets to PineTime Smart Watch
The generated Rust source file will be placed here for building...
https://github.com/lupyuen/pinetime-rust-mynewt/blob/dispatch/rust/app/src/visual.rs
#[infer_type]
is a Rust Procedural Macro that infers the missing types denoted by underscore (_
) like this...
#[infer_type] // Infer the missing types
struct State {
count: _,
}
...
state.count = 0; // `count` is inferred as integer type (i32)
The macro has being updated to support druid UI framework...
https://github.com/lupyuen/pinetime-rust-mynewt/blob/dispatch/rust/macros/src/infer_type.rs
#[derive(Data)]
is a Rust Procedural Macro that generates custom data types (for Application State) in the druid UI framework...
https://github.com/lupyuen/druid-embedded/blob/master/druid-derive/src/data.rs
The macro has been extended to support Static Widgets on PineTime, which does not have heap storage...
https://github.com/lupyuen/druid-embedded/blob/master/druid-derive/src/widget.rs
The following have been added into the existing generators
folder to generate Rust code and to add blocks specific to Mynewt...
generators/rust.js
: Main interface for Rust Code Generator
generators/rust
: Rust Code Generator for various blocks
The Blockly demo at demos/code
has been customised to include the Rust Code Generator...
demos/code/code.js
: Customised to load the Rust Code Generator
For easier code editing, this entire repository as been wrapped into the visual-embedded-rust
Visual Studio Code Extension.
This repository is installed in the media/blockly-mynewt-rust
folder of the extension.
Google's Blockly is a web-based, visual programming editor. Users can drag blocks together to build programs. All code is free and open source.
The project page is https://developers.google.com/blockly/
Blockly has an active developer forum. Please drop by and say hello. Show us your prototypes early; collectively we have a lot of experience and can offer hints which will save you time.
Help us focus our development efforts by telling us what you are doing with Blockly. The questionnaire only takes a few minutes and will help us better support the Blockly community.
Want to contribute? Great! First, read our guidelines for contributors.