r/arduino 7d ago

Block-based programming in Arduino App Lab

Post image

Hi Arduiners!

I wanted to explore the possibility of adding block-style programming to App Lab.

My aim is to understand whether allowing to write Python scripts and C++ sketches using blocks can be useful for beginners to learn how to get the most out of their Q (and maybe the upcoming Ventuno Q).

I know that many of such IDEs already exist (mBlock, CodeKit, ArduBlock, Scratch running as an app etc.) but none of them currently support the dual-brain programming model of the Q - and I also wanted to give users the possibility to author and distribute their own blocks to the community.

Long story short:

How the proposed patch to App Lab works:

  • A new "Blocks" button allows to switch the workspace to the blocks view (based on Blockly  |  Google for Developers ) - both for .py and .ino files
  • Code gets automatically generated - allowing to scaffold a program. I’ve implemented more than 70 built-in blocks, but I need help in testing & validating the generated code, simulating different use case scenarios
  • Blocks are then serialized and stored in a sidecar (.blocks) file, that sits alongside its companion sketch or script in the Q’s filesystem. Removing/renaming the sidecar gives you back the possibility of manually editing the generated code
  • External block catalogs (e.g. from a local folder - in future fetched from a git repo) can be added to the toolbox, allowing to implement custom blocks. The catalog itself is made of declarative YAML files, that App Lab reads at startup and uses to dynamically make blocks available in the toolbox
  • Each block definition YAML file in the catalog describes 1+ blocks: shape, behavior, connections, inputs & outputs, parameters, template code to be generated etc.
  • (automatic update of app.yaml, sketch.yaml and brick config files is not supported, for now...)

Happy to hear your thoughts!

  • Would it be a good idea to add block programming to App Lab?
  • Do you think that people will be interested in contributing blocks, "packaging" their programming experience on the Q into reusable blocks?
  • Would block programming allow beginners to exploit the capabilities of the dual-brain nature of the Q, tackling more complex problems requiring bricks (e.g. encapsulating a brick's functionalities into blocks)?

To test it: clone the repo, follow the standard README to setup a development environment and launch App Lab like this:

BLOCK_CATALOG_PATH=<my-local-blocks-catalog-path> yarn start-app-lab-desktop

Note: BLOCK_CATALOG_PATH is entirely optional - App Lab already ships with many built-in blocks.

Thanks a lot for your help and support!

7 Upvotes

Duplicates