summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;