diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-02-28 00:18:16 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-02-28 00:18:16 +0000 |
| commit | 9fca08f8434a05e1fe93a1c4f8133f0e7fc118bf (patch) | |
| tree | d9d656ebcd2be18935f5a23550752cc9245eb34c /src/ui/ui_fsm.cpp | |
| parent | 26fc53b18b4c2c55c1fb5f0ed46152860e8f5cc2 (diff) | |
| parent | 5141c9f0bd62e575fff9e132c0ad6de089a18ece (diff) | |
| download | tangara-fw-9fca08f8434a05e1fe93a1c4f8133f0e7fc118bf.tar.gz | |
Merge pull request 'Add time.ticks to lua bridge' (#48) from lua-ticks into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/48
Diffstat (limited to 'src/ui/ui_fsm.cpp')
| -rw-r--r-- | src/ui/ui_fsm.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 9668b0f3..f5288882 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -24,6 +24,7 @@ #include "core/lv_obj_tree.h" #include "database.hpp" #include "esp_heap_caps.h" +#include "esp_timer.h" #include "haptics.hpp" #include "lauxlib.h" #include "lua_thread.hpp" @@ -503,6 +504,11 @@ void Lua::entry() { {"show", [&](lua_State* s) { return ShowAlert(s); }}, {"hide", [&](lua_State* s) { return HideAlert(s); }}, }); + + registry.AddPropertyModule( + "time", { + {"ticks", [&](lua_State* s) { return Ticks(s); }}, + }); registry.AddPropertyModule("database", { {"updating", &sDatabaseUpdating}, }); @@ -564,6 +570,11 @@ auto Lua::PopLuaScreen(lua_State* s) -> int { return 0; } +auto Lua::Ticks(lua_State* s) -> int { + lua_pushinteger(s, esp_timer_get_time()/1000); + return 1; +} + auto Lua::ShowAlert(lua_State* s) -> int { if (!sCurrentScreen) { return 0; |
