statically add paper c library to lua interpreter
This commit is contained in:
parent
ad99018809
commit
11bbd60872
2 changed files with 18 additions and 17 deletions
6
assets/epaper.lua
Normal file
6
assets/epaper.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
local paper = require('paper')
|
||||
paper.init()
|
||||
print(
|
||||
'width: ' .. paper.get_width(),
|
||||
'height: ' .. paper.get_height()
|
||||
)
|
||||
|
|
@ -72,6 +72,11 @@ void run_lua_file(const char *file_name, const char *test_name) {
|
|||
|
||||
log_memory_usage("After luaL_openlibs");
|
||||
|
||||
// load `paper` library and expose it globally
|
||||
luaL_requiref(L, "paper", luaopen_paper, 1);
|
||||
lua_pop(L, 1);
|
||||
log_memory_usage("After adding paper");
|
||||
|
||||
// Construct the full file path
|
||||
char full_path[128];
|
||||
snprintf(full_path, sizeof(full_path), LUA_FILE_PATH"/%s", file_name);
|
||||
|
|
@ -106,8 +111,10 @@ void run_embedded_lua_test(const char *lua_script, const char *test_name) {
|
|||
luaL_openlibs(L);
|
||||
log_memory_usage("After luaL_openlibs");
|
||||
|
||||
luaopen_paper(L);
|
||||
log_memory_usage("After luaopen_paper");
|
||||
// load `paper` library and expose it globally
|
||||
luaL_requiref(L, "paper", luaopen_paper, 1);
|
||||
lua_pop(L, 1);
|
||||
log_memory_usage("After adding paper");
|
||||
|
||||
if (luaL_dostring(L, lua_script) == LUA_OK) {
|
||||
lua_pop(L, lua_gettop(L));
|
||||
|
|
@ -224,24 +231,12 @@ void app_main(void) {
|
|||
epd_hl_update_screen(&hl, MODE_GC16, temperature);
|
||||
epd_poweroff();
|
||||
*/
|
||||
|
||||
// Initialize and mount the filesystem
|
||||
init_filesystem();
|
||||
|
||||
// Test 1: Simple embedded Lua script
|
||||
const char *simple_script = "answer = 42; print('The answer is: '..answer)";
|
||||
run_embedded_lua_test(simple_script, "Simple Embedded Script");
|
||||
|
||||
//const char *paper_script = "local paper = require('paper'); paper.init(); print('width: '..paper.get_width(), 'height: '..paper.get_height())";
|
||||
//run_embedded_lua_test(paper_script, "Paper Script");
|
||||
|
||||
// Test 2: Run Lua script from a file (e.g., fibonacci.lua)
|
||||
run_lua_file("fibonacci.lua", "Fibonacci Script from File");
|
||||
|
||||
// Test 3: Run Lua script to generate QR code (e.g., qr_code.lua)
|
||||
run_lua_file("qr_code.lua", "QR Code Script from File");
|
||||
|
||||
// Perform Wi-Fi scan
|
||||
// scan_wifi_networks();
|
||||
// Run script in assets/epaper.lua
|
||||
run_lua_file("epaper.lua", "E-Paper Script");
|
||||
|
||||
ESP_LOGI(TAG, "End of testing application.");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue