Skip to main content

moth v0.1.0 — Flutter's programming model on a $6 microcontroller

First public release. Write real Dart — widgets, setState, build() — and run it on an ESP32 through a 1.7k-line bytecode VM and moth's own renderer. No RTOS knowledge, no C, no second language.

What works, all of it measured and tested

  • The language: a practical Dart subset — functions, classes with inheritance, closures (capturing this), strings, lists, GC. Everything outside the subset is a compile error with a hint, never a miscompile. Goldens are generated by the real Dart SDK, so moth matches Dart, not its own past behavior.
  • The widget layer: Flutter-named widgets — Container to GestureDetector to Image — reconciled against a native scene graph with row-band damage tracking — 38 fps at 466×466 on an ESP32-S3, measured by make fps, budget-tested in CI.
  • The flutter-run loop: moth run auto-selects your board, pushes, and stays attached — r restarts your edited program on hardware in ~173ms. Under it, hot push over USB or HMAC-paired WiFi: verified before swap, persists across reboots, three crashes fall back to the built-in program.
  • Images: Image('logo.png') decodes at compile time and blits from flash — no filesystem, no RAM cost.
  • Editor support: every built-in is declared with real signatures, so moth programs get autocomplete and type checking in any Dart editor. mothc create scaffolds a project that resolves out of the box; mothc check runs the subset rules on every save.
  • Hardware API: pins and buses as objects (OutputPin, AnalogPin, I2c with bulk reads, Uart, Prefs, Servo) over Arduino-named built-ins — identical on the screen firmware and the headless one, and simulated on the desktop so programs test in CI without a board. On the verified board, sensors share the panel's I2C bus and just work.

Honest limits

No async/networking from Dart yet (and so no attachInterrupt — the polling idiom is documented), no SPI, no local-variable capture in closures, fixed-size bitmap fonts, one verified board (ESP32-S3 + Waveshare 1.75" round AMOLED; the renderer alone runs a demo scene on an ESP32-P4 dev board, but no second board is verified end to end). Push pairing accepts replay of previously-pushed programs (ADR-010 records why, and what v0.2 does about it). The API is unstable until 1.0.

Install

dart pub global activate mothc
moth create hello && cd hello && moth run

Full guide: docs/getting-started.md