diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-12-30 11:04:33 +1100 |
|---|---|---|
| committer | ailurux <ailuruxx@gmail.com> | 2024-12-30 11:04:33 +1100 |
| commit | f2198867538bec387bd54db8dc0ddca8b4a20e60 (patch) | |
| tree | a2ad6645d6866b281c93c09531423a6107d93297 /src/tangara/lua/lua_nvs.cpp | |
| parent | dac29bf98632bb4450932b06e12328af48f1bb9e (diff) | |
| parent | ff87c9217577783b60ee4cf466a3c59777a2fc40 (diff) | |
| download | tangara-fw-f2198867538bec387bd54db8dc0ddca8b4a20e60.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src/tangara/lua/lua_nvs.cpp')
| -rw-r--r-- | src/tangara/lua/lua_nvs.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/tangara/lua/lua_nvs.cpp b/src/tangara/lua/lua_nvs.cpp new file mode 100644 index 00000000..e38e58d9 --- /dev/null +++ b/src/tangara/lua/lua_nvs.cpp @@ -0,0 +1,39 @@ +/* + * Copyright 2024 Clayton Craft <clayton@craftyguy.net> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + +#include "lua/lua_version.hpp" + +#include "lua.hpp" +#include "lua/bridge.hpp" + +#include "lua.h" +#include "lua/lua_thread.hpp" + +namespace lua { + +[[maybe_unused]] static constexpr char kTag[] = "lua_nvs"; + +static auto write(lua_State* L) -> int { + Bridge* instance = Bridge::Get(L); + instance->services().nvs().Write(); + + return 1; +} + +static const struct luaL_Reg kNvsFuncs[] = {{"write", write}, + {NULL, NULL}}; + +static auto lua_nvs(lua_State* L) -> int { + luaL_newlib(L, kNvsFuncs); + return 1; +} + +auto RegisterNvsModule(lua_State* L) -> void { + luaL_requiref(L, "nvs", lua_nvs, true); + lua_pop(L, 1); +} + +} // namespace lua |
