Skip to main content

Generate LVGL C source files from Figma XML exports

Project description

figma2lvgl — Figma to LVGL C Code Generator

A code-generation tool that converts Figma UI layouts into LVGL C source files ready to drop into any embedded project.

  • Works with any LVGL v9 project (ESP-IDF, Zephyr, bare-metal, etc.)
  • Installable via pip — no manual script setup
  • Fully cross-platform — Windows, Linux, macOS

✨ Key Features

  • 📐 Figma XML → Deterministic C code
  • 🧵 Thread-safe UI updates via worker queue
  • 🧱 Static metadata-driven UI (ui_screen_t, ui_child_t)
  • 📦 Generates self-contained ui_src/ folder
  • 🔁 Versioned runtime (safe upgrades)
  • 🧩 Extensible via template system
  • 🎯 Zero dynamic layout parsing at runtime

🚀 Installation

pip install figma2lvgl

Prerequisite — LVGLImage.py

Image conversion requires LVGLImage.py from the official LVGL repository. On first run, figma2lvgl will ask to download and cache it automatically. You can also place it manually next to your XML file.


📖 Usage

figma2lvgl -x diagram.xml

All arguments:

Argument Description Default
-x Path to Figma XML file Required
-i Folder containing PNG images Same directory as XML
-d Destination for generated output Same directory as XML

Examples:

# Minimal — everything next to the XML
figma2lvgl -x /home/user/project/layout.xml

# Full control
figma2lvgl -x layout.xml -i assets/images -d build/output

# Windows
figma2lvgl -x E:\project\layout.xml -i E:\project\images -d E:\project\output

📁 Output Layout

Running the tool produces a ui_src/ folder at the destination:

ui_src/
  src/              ← Generated screen .c files
  include/          ← Generated screen .h files
  priv_src/         ← Converted image .c files
  priv_include/     ← Image headers + assets.h + ui_defs.h
  CMakeLists.txt    ← Ready to include in your build system

Drop ui_src/ into your project as a component or library.


🧠 Architecture Overview

Figma XML
    ↓
Parser
    ↓
Model (Screen + Children)
    ↓
Templates
    ↓
Generated Code (ui_src/)
    ├── src/
    ├── include/
    ├── priv_src/
    └── priv_include/

🧩 Extending with New GUI Elements

To add a new UI element:

  1. Create a new template inside core/templates/
  2. Register it in child_registry.py
  3. Use naming tokens in Figma (e.g. _button)

No changes to the generator core required.


💡 Examples

See the examples/ folder for complete project setups:

examples/
  espidf/
    ili9486/        ← ESP-IDF project with ILI9486 display

🏁 Design Philosophy

  • Figma = layout only
  • Naming conventions = semantics
  • Generator = metadata builder
  • Output = portable C, no runtime dependencies beyond LVGL
  • All UI updates = thread-safe

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

figma2lvgl-0.1.0.tar.gz (51.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

figma2lvgl-0.1.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file figma2lvgl-0.1.0.tar.gz.

File metadata

  • Download URL: figma2lvgl-0.1.0.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for figma2lvgl-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f3b798993fb7cc629fcc352ee380ac4ab782ec67ed7c13b1e2c06bb66b1989cc
MD5 fbc38344e901cda5ce4a8d1f60416a55
BLAKE2b-256 4c25ac8055d195412179575984fd007e85b51a062a58ad50ef71c2e91a75467f

See more details on using hashes here.

Provenance

The following attestation bundles were made for figma2lvgl-0.1.0.tar.gz:

Publisher: publish.yml on khiyamiftikhar/figma2lvgl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file figma2lvgl-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: figma2lvgl-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for figma2lvgl-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b3eedbff491eec7cff9fa85db5ccaba9caad1eb068fc28fcf3dcab8c6c8f173
MD5 b2a11b65f5032a742fc1c005c5478ea1
BLAKE2b-256 e5fbbf3cad37670067ef75e378f0c31606209cbeac957fd87584d0ce37b52007

See more details on using hashes here.

Provenance

The following attestation bundles were made for figma2lvgl-0.1.0-py3-none-any.whl:

Publisher: publish.yml on khiyamiftikhar/figma2lvgl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page