anyuianyui
anyui-LIVE
anyui
Feedback
  • English
  • 中文
anyui-LIVE
anyui
Feedback
  • English
  • 中文
  • Introduction

    • Introduction
  • Get Started

    • Get Started
  • Workspace

    • Workspace
  • Editor

    • Overview
    • Toolbar
    • Navigator
    • Inspector
    • Event Flow Overview
    • Statusbar
    • Settings
    • Keyboard shortcuts
    • Canvas
    • Preview
    • Resource management
    • Code Viewer
    • History
  • Agent
  • Desktop
  • Subjects

    • Image
    • Font Library
    • Layout
    • Symbol
    • Global style
    • Dynamic LVGL version
    • Dynamic Display Size Change
    • Override screen size
    • Codegen
    • User custom code
    • Transplant
    • Simulator
    • Translation
  • FAQ

Most of an exported project is generated from the design, so editing that output is a mistake you correct by changing the design and generating again. Three places are the exception: they exist for code you write yourself, and each has its own rule for what the next export keeps. The generated output as a whole is described in the codegen guide.

The rules below are the desktop app's, where the folder already holds your copies; the web app hands you a fresh ZIP every time, so folding your own code back into it is a manual merge.

Where your code lives

PlaceWhat you write thereWhat the next export does
custom/custom_event.h, custom/custom_event.cThe functions a Call Function event action calls.Adds declarations and stubs for functions the design has newly started to call, and touches nothing else.
lv_conf.hFirmware features the project settings do not cover - drivers, decoders, fonts, logging, memory.Corrects the few macros that carry settings the editor owns, and turns on what the design's assets ask for.
main.cStart-up code, at whatever position in the sequence it belongs.Corrects the display size handed to hal_init(...), and on LVGL 8 not even that.

Call Function

Call Function is an event action. Choose it on an event row in the Event tab of the inspector and name the C function to call. The name has to be a legal C identifier, because the generated code uses it as written, and the generated handler passes it the event it received:

handle_custom_click(event);

You write the function yourself, in custom/custom_event.c. An export declares it in custom/custom_event.h and writes an empty body under the declaration, wrapped in a pair of marker comments, so the project compiles before you have typed a line:

/* anyui:preserve begin handle_custom_click */
void handle_custom_click(lv_event_t * event) {
    (void)event;
}
/* anyui:preserve end handle_custom_click */

Fill that body in and it stays filled in. The merge only ever adds what the design has gained - it does not rewrite, reorder or delete what the file already holds - and those anyui:preserve markers are how it tells your code from the skeleton it wrote for you, so keep them where they are. Anything else you add to the two files, such as helper functions or extra includes, is kept the same way. The custom/ folder sits beside generated/ rather than inside it, so the pass that clears stale generated sources cannot reach what you write here.

lv_conf.h

This header at the project root is what the firmware builds against: display and input drivers, image decoders, fonts, log levels, memory sizes. Anything you switch on there is yours, and an export does not replace the file - it corrects the few lines that carry values the editor owns:

Value the export ownsApplies to
Color depthEvery target version.
Display width and heightLVGL 8 only; LVGL 9 takes its size from main.c.
Native color format9.6.0, which pairs the format with the depth.
File drive and image decoderOnly when the design uses them - see File-path sources.

Every other byte stays as your copy has it, comments included, which is also why a header saved in a non-UTF-8 encoding comes through unchanged. Change the resolution or the color depth in the project settings and the next export moves those values and nothing else.

main.c

The entry point starts LVGL, brings up the simulator display and loads the first screen. Start-up code the design cannot express goes here, at the position where it has to run: before lv_init() when a board needs its clock first, after it when something has to be registered with LVGL before the UI is built, around the hal_init(...) call that sets up the display, or before setup_ui() for state the screens read at start-up. The file is laid out in the simulator's usual sections - INCLUDES, DEFINES, TYPEDEFS, STATIC PROTOTYPES, GLOBAL FUNCTIONS - and those are where your own declarations and helpers belong.

All of it is preserved, because an export claims one value in this file:

  • LVGL 9 - the two numbers in the hal_init(...) call are corrected to the project's resolution. The correction finds that call wherever it is made and whatever arguments it carries, so moving it elsewhere in main() or giving it your own arguments does not hide it. A file with no such call, and no lv_init() after which to place one, is reported rather than guessed at.
  • LVGL 8 - nothing. That version reads its size from lv_conf.h, so its entry point calls hal_init() with no arguments and stays exactly as you left it.

An export also steps back from a copy that clearly belongs to another LVGL version - a folder whose target version you switched, for instance. It leaves your file untouched and says so, rather than correcting bytes this target cannot compile.

Getting the generated files back

Because lv_conf.h and main.c are corrected rather than replaced, a project can still drift: a header edited by another tool, an entry point whose includes no longer match the simulator. In the desktop app, Settings → Project → Code has a Build Files row: Regenerate writes the generated files again at the project's current settings, after comparing the folder against what it would write.

  • Copies that already match are left untouched.
  • A copy that holds your changes is kept beside the original as a timestamped .bak file before the generated version replaces it, so you can diff the two and move your edits across.
  • The Makefile is rewritten as well and gets no backup; your own build additions belong in custom/custom.mk, which every generated Makefile includes.
  • The next build recompiles everything, because the objects already in the folder were built against the header that has just been replaced.

That row is the only place a backup happens. If you delete one of these files yourself, the next export simply writes a fresh generated copy, and what you had in it is gone.

Related guides

  • Codegen - what the generator writes, and where it writes it.
  • Transplant - moving the generated code into a target project.
  • Image - the file-path sources that ask lv_conf.h for a file drive.
  • Simulator - building and running the project these files describe.
  • Event flow overview - reviewing the handlers that call your functions.
  • Settings - the export folder behind the Build Files row.
Prev
Codegen
Next
Transplant