summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2024-02-28 00:18:16 +0000
committercooljqln <cooljqln@noreply.codeberg.org>2024-02-28 00:18:16 +0000
commit9fca08f8434a05e1fe93a1c4f8133f0e7fc118bf (patch)
treed9d656ebcd2be18935f5a23550752cc9245eb34c /src/ui
parent26fc53b18b4c2c55c1fb5f0ed46152860e8f5cc2 (diff)
parent5141c9f0bd62e575fff9e132c0ad6de089a18ece (diff)
downloadtangara-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')
-rw-r--r--src/ui/include/ui_fsm.hpp2
-rw-r--r--src/ui/ui_fsm.cpp11
2 files changed, 13 insertions, 0 deletions
diff --git a/src/ui/include/ui_fsm.hpp b/src/ui/include/ui_fsm.hpp
index ffaff0bb..6cf2ba4c 100644
--- a/src/ui/include/ui_fsm.hpp
+++ b/src/ui/include/ui_fsm.hpp
@@ -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;
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;