Lua timer (#3218)
* Lua: Timer class #3159 * Lua: Timer class #3159 * Lua: Timer class #3159 * Lua: Timer class #3159 * lua timer is happy (#3216) * hooks are happy * don't need that any more * format * update lib * module Co-authored-by: rusefillc <sdfsdfqsf2334234234> Co-authored-by: Matthew Kennedy <matthewkennedy@outlook.com>
This commit is contained in:
parent
9eef709eb1
commit
427cce7596
|
@ -29,3 +29,7 @@
|
|||
path = firmware/ext/lua
|
||||
url = https://github.com/rusefi/lua
|
||||
branch = rusefi-5.4.3
|
||||
[submodule "firmware/controllers/lua/luaaa"]
|
||||
path = firmware/controllers/lua/luaaa
|
||||
url = https://github.com/rusefi/luaaa
|
||||
branch = rusefi_prod
|
||||
|
|
|
@ -4,7 +4,7 @@ LUA_EXT=$(PROJECT_DIR)/ext/lua
|
|||
ALLCPPSRC += $(LUA_DIR)/lua.cpp \
|
||||
$(LUA_DIR)/lua_hooks.cpp \
|
||||
|
||||
ALLINC += $(LUA_DIR) $(LUA_EXT)
|
||||
ALLINC += $(LUA_DIR) $(LUA_DIR)/luaaa $(LUA_EXT)
|
||||
ALLCSRC += \
|
||||
$(LUA_EXT)/lapi.c \
|
||||
$(LUA_EXT)/lcode.c \
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#include "lua_airmass.h"
|
||||
#include "can_msg_tx.h"
|
||||
#include "settings.h"
|
||||
#include <new>
|
||||
#include "luaaa.hpp"
|
||||
using namespace luaaa;
|
||||
|
||||
// Some functions lean on existing FSIO implementation
|
||||
#include "fsio_impl.h"
|
||||
|
@ -307,6 +310,13 @@ static int lua_stopEngine(lua_State*) {
|
|||
#endif // EFI_UNIT_TEST
|
||||
|
||||
void configureRusefiLuaHooks(lua_State* l) {
|
||||
|
||||
LuaClass<Timer> luaTimer(l, "Timer");
|
||||
luaTimer
|
||||
.ctor()
|
||||
.fun("reset", static_cast<void (Timer::*)() >(&Timer::reset ))
|
||||
.fun("getElapsedSeconds", static_cast<float(Timer::*)()const>(&Timer::getElapsedSeconds));
|
||||
|
||||
lua_register(l, "print", lua_efi_print);
|
||||
lua_register(l, "readPin", lua_readpin);
|
||||
lua_register(l, "getAuxAnalog", lua_getAuxAnalog);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 97ee01219e52271f9c5bfb57522a9be919798b01
|
|
@ -73,3 +73,15 @@ TEST(LuaHooks, CanTxDataLength) {
|
|||
// invalid: not a table
|
||||
EXPECT_ANY_THROW(testLuaExecString("txCan(1, 0, 0, 26)"));
|
||||
}
|
||||
|
||||
static const char* timerTest = R"(
|
||||
function testFunc()
|
||||
local a = Timer.new()
|
||||
a:reset()
|
||||
return a:getElapsedSeconds()
|
||||
end
|
||||
)";
|
||||
|
||||
TEST(LuaHooks, TestLuaTimer) {
|
||||
EXPECT_EQ(testLuaReturnsNumber(timerTest), 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue