{"id":17918879,"url":"https://github.com/xuneo/luavgl","last_synced_at":"2025-04-06T12:08:13.052Z","repository":{"id":64605837,"uuid":"576558738","full_name":"XuNeo/luavgl","owner":"XuNeo","description":"lua + lvgl = luavgl An optimized lvgl Lua binding","archived":false,"fork":false,"pushed_at":"2024-10-22T02:36:22.000Z","size":456,"stargazers_count":81,"open_issues_count":8,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-30T11:08:38.295Z","etag":null,"topics":["binding","embbeded","gui","littlevgl","lua","luavgl","lvgl","nuttx"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XuNeo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-10T08:13:48.000Z","updated_at":"2025-02-21T05:34:42.000Z","dependencies_parsed_at":"2024-03-06T12:26:21.990Z","dependency_job_id":"d7139cd6-3307-485a-9eaa-5ff0e5357542","html_url":"https://github.com/XuNeo/luavgl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XuNeo%2Fluavgl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XuNeo%2Fluavgl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XuNeo%2Fluavgl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XuNeo%2Fluavgl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XuNeo","download_url":"https://codeload.github.com/XuNeo/luavgl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478321,"owners_count":20945266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binding","embbeded","gui","littlevgl","lua","luavgl","lvgl","nuttx"],"created_at":"2024-10-28T20:13:17.631Z","updated_at":"2025-04-06T12:08:13.019Z","avatar_url":"https://github.com/XuNeo.png","language":"C","readme":"# lvgl-lua-binding\nlua + lvgl = luavgl\n\n**luavgl is currently under development.**\n\nA flappy bird game is ready for showoff. \n\nThe simulator is built with cmake and has been tested on ubuntu and mac, but not on windows. If you need to build under windows please xmake, which has also been tested under ubuntu.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.ibb.co/nbgYvZW/flappybird.gif\" /\u003e\n\u003c/p\u003e\n\n## Introduction\n\n`luavgl` is a wrapper around lvgl **core** functions and **widgets** with class inherence in mind, which is lvgl trying to do in `C`. Lua makes widgets inherence happens smoothly.\n\n`luavgl` does not support APIs for low level hardware initialization, lvgl setup etc. Those initialization must be done before executing lua scripts.\n\n`luavgl` mainly targets for embedded device, a simulator has been provided for preview and tested on Ubuntu/macOS.\n\n```lua\nlocal root = lvgl.Object()\nroot:set { w = lvgl.HOR_RES(), h = lvgl.VER_RES() }\n\n-- flex layout and align\nroot:set {\n    flex = {\n        flex_direction = \"row\",\n        flex_wrap = \"wrap\",\n        justify_content = \"center\",\n        align_items = \"center\",\n        align_content = \"center\",\n    },\n    w = 300,\n    h = 75,\n    align = lvgl.ALIGN.CENTER\n}\n\n-- create obj on root\nlocal obj = root:Object()\n\n-- create image on root and set position/img src/etc. properties.\nlocal img = root:Image {\n    src = \"res/image.png\",\n    x = 0,\n    y = 0,\n    bg_color = \"#112233\" -- #RRGGBB, 0xRRGGBB or \"#RGB\"\n    pad_all = 0\n}\n\n-- change image properties.\n\nimg:set {\n    src = \"/assets/lvgl-logo.png\",\n    align = lvgl.ALIGN.CENTER,\n}\n\n-- create animation on object\nimg:Anim {\n    run = true,\n    start_value = 0,\n    end_value = 3600,\n    duration = 2000,\n    repeat_count = 2,\n    path = \"bounce\",\n    exec_cb = function(obj, value)\n        obj:set {\n            angle = value\n        }\n    end\n}\n\n-- create Label on root and set its font\nlocal label = root:Label {\n    text = string.format(\"Hello %03d\", 123),\n    text_font = lvgl.Font(\"montserrat\", 24, \"normal\"),\n    -- or builtin font:\n    -- text_font = lvgl.BUILTIN_FONT.MONTSERRAT_22,\n    align = {\n        type = lvgl.ALIGN.CENTER,\n        x_ofs = 0,\n        y_ofs = 100,\n    }\n}\n\n```\n\n### Embedded device\n\nFor embedded device, lvgl environment must setup before using `luavgl`. Once `lvgl` and `lua interpreter` are up and running, add the `luavgl.c` to sources for compiling. And make sure `luaopen_lvgl` is added to global lib. Below is example from `simulator/main.c` shows this exact method.\n\n```c\n  /* add `lvgl` module to global package table */\n  luaL_requiref(L, \"lvgl\", luaopen_luavgl, 1);\n  lua_pop(L, 1);\n```\n\n### LuaJIT support\n\nSupporting `LuaJIT` is done by adding `deps/lua-compat-5.3`.\n\n### Developing\n\nI personally using `vscode` plus extension [`Lua`](https://marketplace.visualstudio.com/items?itemName=sumneko.lua).\n\nFile `src/lvgl.lua` is used for linting.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.ibb.co/NpRWXZ1/luavgl-linting.png\" /\u003e\n\u003c/p\u003e\n\n### Run on RTOS nuttx\n\nCheck the ready-to-go examples [luavgl-nuttx-example](https://github.com/XuNeo/luavgl-nuttx-example)\n\n### PC simulator\n\n**Currently compile luavgl to `so` or `dll` is NOT available.**\n\n`luavgl` depends on lvgl and various configurations(`lv_conf.h`), thus cannot run without a working lvgl environment.\nThe simulator provided in this repo can be used as example if `luavgl` is required on PC.\n\nMake sure clone the submodules, luavgl simulator comes directly from lvgl simulator with lua added.\n\n```bash\ngit clone --recursive https://github.com/XuNeo/luavgl.git\n\n# or\ngit submodule update --init\n```\n\n#### Dependencies\n\n### cmake\nTo run simulator on PC, make sure `lua` header is available, you may need to install below packages.\n\n```\nsudo apt install libsdl2-dev lua5.3 liblua5.3-dev\n```\n\nBoth lua5.3 and lua5.4 are supported. Versions below 5.2 has not been verified but should work through `deps/lua-compat-5.3`.\n\n### xmake\nCompiling with xmake does not require you to install libsdl2 and lua yourself. xmake calls the package manager xrepo, which downloads libsdl2 and lua from github and applies them to the simulator's project.\n\n#### Build and run\n\n##### cmake\n\n```bash\ncmake -Bbuild -DBUILD_SIMULATOR=ON\ncd build\nmake\nmake run # run simulator\n```\n\n##### xmake\n```powershell\nxmake b simulator\nxmake r # run simulator\n```\n## Custom Widget\n\n`luavgl` support custom widget, and use them in `lua` just like lvgl core widgets.\nAn example is provided in [`simulator/extension.c`](https://github.com/XuNeo/luavgl/blob/master/simulator/extension.c#L62)\n\nFor custom widget, it should be registered to Lua after luavgl lib loaded.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuneo%2Fluavgl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuneo%2Fluavgl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuneo%2Fluavgl/lists"}