Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example of include lua file to C to compile and run #66

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Add example of include lua file to C to compile and run #66

merged 2 commits into from
Aug 20, 2024

Conversation

XuNeo
Copy link
Owner

@XuNeo XuNeo commented Aug 19, 2024

In C

static const char lua_code_string[] = {
#include "ui.lua"
};

In lua

STRINGIZE((function()
    local root = lvgl.get_child_by_id("luaUIroot")
    root.w = lvgl.VER_RES()
    root.h = lvgl.HOR_RES()

    Button(root, {
        id = "Button in Lua",
        Label {
            text = "Hello, lua, C and lvgl!",
            align = lvgl.ALIGN_CENTER
        }
    }):center()
end)())

The additional (function() end))() is just to make lua happy with the gramma. Treat STRINGIZE is a global function in lua.

@XuNeo XuNeo merged commit d7f52e5 into master Aug 20, 2024
1 check passed
@XuNeo XuNeo deleted the t8 branch August 20, 2024 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant