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
This commit is contained in:
cooljqln
2024-02-28 00:18:16 +00:00
2 changed files with 13 additions and 0 deletions
+2
View File
@@ -163,6 +163,8 @@ class Lua : public UiState {
auto ShowAlert(lua_State*) -> int;
auto HideAlert(lua_State*) -> int;
auto Ticks(lua_State*) -> int;
auto SetPlaying(const lua::LuaValue&) -> bool;
auto SetRandom(const lua::LuaValue&) -> bool;
auto SetRepeat(const lua::LuaValue&) -> bool;
+11
View File
@@ -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;