summaryrefslogtreecommitdiff
path: root/src/lua/lua_thread.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-02-29 12:10:44 +1100
committerjacqueline <me@jacqueline.id.au>2024-02-29 12:10:44 +1100
commit7d3ddac0eaea207aee187729e3beec95d8d201dc (patch)
tree4b4545e725697663a4768630c48f49e8bbb8cf59 /src/lua/lua_thread.cpp
parentd41f9f703375171d5766840c9edec32ff47bb25d (diff)
parent9fca08f8434a05e1fe93a1c4f8133f0e7fc118bf (diff)
downloadtangara-fw-7d3ddac0eaea207aee187729e3beec95d8d201dc.tar.gz
Merge branch 'main' into seek-support
Diffstat (limited to 'src/lua/lua_thread.cpp')
-rw-r--r--src/lua/lua_thread.cpp51
1 files changed, 8 insertions, 43 deletions
diff --git a/src/lua/lua_thread.cpp b/src/lua/lua_thread.cpp
index b94b70ab..dd72e41d 100644
--- a/src/lua/lua_thread.cpp
+++ b/src/lua/lua_thread.cpp
@@ -9,22 +9,16 @@
#include <iostream>
#include <memory>
-#include "lauxlib.h"
-#include "lua.h"
-#include "lua.hpp"
-
-#include "font/lv_font_loader.h"
-#include "luavgl.h"
-
#include "esp_heap_caps.h"
#include "esp_log.h"
+#include "lua.hpp"
+
+#include "bridge.hpp"
#include "event_queue.hpp"
+#include "memory_resource.hpp"
#include "service_locator.hpp"
#include "ui_events.hpp"
-LV_FONT_DECLARE(font_fusion_12);
-LV_FONT_DECLARE(font_fusion_10);
-
namespace lua {
[[maybe_unused]] static constexpr char kTag[] = "lua";
@@ -59,23 +53,7 @@ static int lua_panic(lua_State* L) {
return 0;
}
-static auto make_font_cb(const char* name, int size, int weight)
- -> const lv_font_t* {
- if (std::string{"fusion"} == name) {
- if (size == 12) {
- return &font_fusion_12;
- }
- if (size == 10) {
- return &font_fusion_10;
- }
- }
- return NULL;
-}
-
-static auto delete_font_cb(lv_font_t* font) -> void {}
-
-auto LuaThread::Start(system_fsm::ServiceLocator& services, lv_obj_t* lvgl_root)
- -> LuaThread* {
+auto LuaThread::Start(system_fsm::ServiceLocator& services) -> LuaThread* {
auto alloc = std::make_unique<Allocator>();
lua_State* state = lua_newstate(lua_alloc, alloc.get());
if (!state) {
@@ -85,24 +63,11 @@ auto LuaThread::Start(system_fsm::ServiceLocator& services, lv_obj_t* lvgl_root)
luaL_openlibs(state);
lua_atpanic(state, lua_panic);
- auto bridge = std::make_unique<Bridge>(services, *state);
-
- // FIXME: luavgl init should probably be a part of the bridge.
- if (lvgl_root) {
- luavgl_set_pcall(state, CallProtected);
- luavgl_set_font_extension(state, make_font_cb, delete_font_cb);
- luavgl_set_root(state, lvgl_root);
- luaL_requiref(state, "lvgl", luaopen_lvgl, true);
- lua_pop(state, 1);
- }
-
- return new LuaThread(alloc, bridge, state);
+ return new LuaThread(alloc, state);
}
-LuaThread::LuaThread(std::unique_ptr<Allocator>& alloc,
- std::unique_ptr<Bridge>& bridge,
- lua_State* state)
- : alloc_(std::move(alloc)), bridge_(std::move(bridge)), state_(state) {}
+LuaThread::LuaThread(std::unique_ptr<Allocator>& alloc, lua_State* state)
+ : alloc_(std::move(alloc)), state_(state) {}
LuaThread::~LuaThread() {
lua_close(state_);