Skip to content

lupyuen/blockly-mynewt-rust

 
 

Repository files navigation

blockly-mynewt-rust

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:

  1. Visual Embedded Rust Programming with Visual Studio Code

  2. Advanced Topics for Visual Embedded Rust Programming

  3. Visual Programming with Embedded Rust? Yes we can with Apache Mynewt and Google Blockly!

PineTime Watch Apps

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

Type Inference

#[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

Static Widgets

#[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

Rust Code Generator

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

Demo for Rust Code Generator

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

Visual Studio Code Extension

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.

Blockly Build Status

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.

About

Web-based visual programming editor for Apache Mynewt Embedded OS and Embedded Rust

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages

  • JavaScript 92.8%
  • Python 2.2%
  • HTML 1.5%
  • PHP 1.3%
  • Dart 1.0%
  • Lua 1.0%
  • Other 0.2%