Metadata-Version: 2.4
Name: figma2lvgl
Version: 0.1.0
Summary: Generate LVGL C source files from Figma XML exports
License: MIT License
        
        Copyright (c) 2026 khiyamiftikhar
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Keywords: lvgl,figma,codegen,embedded,ui
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: platformdirs>=3.0
Dynamic: license-file

# 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
```bash
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
```bash
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:
```bash
# 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
