From b6ad6fbc50f3d79ec5177ee6da135d0d40cc1629 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 22 Dec 2021 21:03:21 +1000 Subject: [PATCH 1/4] Change `LUA=YES` to `LUA_MIXER=Y/N` --- radio/src/CMakeLists.txt | 10 +++++++--- radio/src/gui/128x64/CMakeLists.txt | 2 +- radio/src/gui/212x64/CMakeLists.txt | 2 +- radio/src/gui/colorlcd/CMakeLists.txt | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index 5a741df79..15230113d 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -199,7 +199,7 @@ if(RTC_BACKUP_RAM) set(GTEST_SRC ${GTEST_SRC} ${RADIO_SRC_DIR}/storage/rtc_backup.cpp) endif() -if(NOT LUA STREQUAL NO) +if(LUA) add_definitions(-DLUA) if(LUA_COMPILER) add_definitions(-DLUA_COMPILER) @@ -212,7 +212,7 @@ if(NOT LUA STREQUAL NO) endif() include_directories(${LUA_DIR}) set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${LUA_EXPORT}) - if(LUA STREQUAL YES) + if(LUA_MIXER) add_definitions(-DLUA_MODEL_SCRIPTS) endif() @@ -273,6 +273,10 @@ if(NOT LUA STREQUAL NO) endif() endif() +if (LUA_MIXER AND NOT LUA) + message(FATAL_ERROR "LUA_MIXER requires LUA!!") +endif() + if(HELI) add_definitions(-DHELI) endif() @@ -589,7 +593,7 @@ if(NOT MSVC) # Use newlib nano, which saves a few kilobytes. if(NOT NANO STREQUAL NO) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --specs=nano.specs") - if(NOT LUA STREQUAL NO) + if(LUA) # Lua needs %g and %f set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -u _printf_float -u _scanf_float") endif() diff --git a/radio/src/gui/128x64/CMakeLists.txt b/radio/src/gui/128x64/CMakeLists.txt index 9cbd14165..d9a9a2971 100644 --- a/radio/src/gui/128x64/CMakeLists.txt +++ b/radio/src/gui/128x64/CMakeLists.txt @@ -28,7 +28,7 @@ if(FLIGHT_MODES) ) endif() -if(LUA STREQUAL YES) +if(LUA_MIXER) set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp diff --git a/radio/src/gui/212x64/CMakeLists.txt b/radio/src/gui/212x64/CMakeLists.txt index eabf0fd51..3d0e23889 100644 --- a/radio/src/gui/212x64/CMakeLists.txt +++ b/radio/src/gui/212x64/CMakeLists.txt @@ -28,7 +28,7 @@ if(FLIGHT_MODES) ) endif() -if(LUA STREQUAL YES) +if(LUA_MIXER) set(GUI_SRC ${GUI_SRC} model_custom_scripts.cpp diff --git a/radio/src/gui/colorlcd/CMakeLists.txt b/radio/src/gui/colorlcd/CMakeLists.txt index 96fd3ed5e..d0db6bb6b 100644 --- a/radio/src/gui/colorlcd/CMakeLists.txt +++ b/radio/src/gui/colorlcd/CMakeLists.txt @@ -89,7 +89,7 @@ if(LUA) set(SRC ${SRC} lua/widgets.cpp) endif() -if(LUA STREQUAL YES) +if(LUA_MIXER) add_gui_src(model_mixer_scripts.cpp) endif() From 0814cbca880c363319c16aa3ff88651757008853 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 22 Dec 2021 21:03:55 +1000 Subject: [PATCH 2/4] Fix `LUA=N` compilation failure --- radio/src/gui/colorlcd/radio_tools.cpp | 5 +++-- radio/src/gui/colorlcd/standalone_lua.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_tools.cpp b/radio/src/gui/colorlcd/radio_tools.cpp index 5b0092303..98ca2340e 100644 --- a/radio/src/gui/colorlcd/radio_tools.cpp +++ b/radio/src/gui/colorlcd/radio_tools.cpp @@ -119,6 +119,7 @@ class FormGridLayoutEx : public FormGridLayout uint8_t _lineHeight = PAGE_LINE_HEIGHT; }; +#if defined(LUA) void buildLuaUi(std::vector luaScripts, FormWindow *window, FormGridLayoutEx &grid) { for (auto luaScript : luaScripts) { @@ -136,7 +137,7 @@ void buildLuaUi(std::vector luaScripts, FormWindow *window, FormGridL luaExec(luaScript.path.c_str()); StandaloneLuaWindow::instance()->attach(window); - + return 0; }, OPAQUE); @@ -156,7 +157,7 @@ void buildLuaUi(std::vector luaScripts, FormWindow *window, FormGridL grid.nextLine(); } } - +#endif void RadioToolsPage::rebuild(FormWindow * window) { diff --git a/radio/src/gui/colorlcd/standalone_lua.h b/radio/src/gui/colorlcd/standalone_lua.h index f2fe4b899..b70ac407d 100644 --- a/radio/src/gui/colorlcd/standalone_lua.h +++ b/radio/src/gui/colorlcd/standalone_lua.h @@ -21,6 +21,7 @@ #pragma once +#if defined(LUA) #include "libopenui.h" #include "lua/lua_api.h" @@ -77,3 +78,4 @@ protected: LuaTouchData touch; #endif }; +#endif \ No newline at end of file From d9b725a4b1d50f3212b711a8a12051bef6a75263 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Wed, 22 Dec 2021 21:09:45 +1000 Subject: [PATCH 3/4] Newline --- radio/src/gui/colorlcd/standalone_lua.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/gui/colorlcd/standalone_lua.h b/radio/src/gui/colorlcd/standalone_lua.h index b70ac407d..de815f723 100644 --- a/radio/src/gui/colorlcd/standalone_lua.h +++ b/radio/src/gui/colorlcd/standalone_lua.h @@ -78,4 +78,4 @@ protected: LuaTouchData touch; #endif }; -#endif \ No newline at end of file +#endif From c26dcd552198f28f81cccfa9f9242f6d44968533 Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Fri, 24 Dec 2021 13:25:15 +1000 Subject: [PATCH 4/4] Add option and help text for CMake --- radio/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/radio/src/CMakeLists.txt b/radio/src/CMakeLists.txt index 15230113d..53166a85c 100644 --- a/radio/src/CMakeLists.txt +++ b/radio/src/CMakeLists.txt @@ -36,6 +36,7 @@ if(SDL_FOUND) option(SIMU_AUDIO "Enable simulator audio." ON) endif() option(LUA "Enable LUA support" ON) +option(LUA_MIXER "Enable LUA mixer/model scripts support" OFF) option(SIMU_DISKIO "Enable disk IO simulation in simulator. Simulator will use FatFs module and simulated IO layer that uses \"./sdcard.image\" file as image of SD card. This file must contain whole SD card from first to last sector" OFF) option(SIMU_LUA_COMPILER "Pre-compile and save Lua scripts in simulator." ON) option(FAS_PROTOTYPE "Support of old FAS prototypes (different resistors)" OFF)