rusEFI
The most advanced open source ECU
Functions
lua_hooks_util.h File Reference

Functions

void configureRusefiLuaUtilHooks (lua_State *l)
 

Function Documentation

◆ configureRusefiLuaUtilHooks()

void configureRusefiLuaUtilHooks ( lua_State *  l)

Definition at line 39 of file lua_hooks_util.cpp.

39  {
40  lua_register(lState, "print", lua_efi_print);
41  lua_register(lState, "interpolate", lua_interpolate);
42 
43  lua_register(lState, "findCurveIndex", [](lua_State* l) {
44  auto name = luaL_checklstring(l, 1, nullptr);
45  auto result = getCurveIndexByName(name);
46  if (!result) {
47  lua_pushnil(l);
48  } else {
49  // TS counts curve from 1 so convert indexing here
50  lua_pushnumber(l, result.Value + HUMAN_OFFSET);
51  }
52  return 1;
53  });
54 
55  lua_register(lState, "findTableIndex",
56  [](lua_State* l) {
57  auto name = luaL_checklstring(l, 1, nullptr);
58  auto index = getTableIndexByName(name);
59  if (!index) {
60  lua_pushnil(l);
61  } else {
62  // TS counts curve from 1 so convert indexing here
63  lua_pushnumber(l, index.Value + HUMAN_OFFSET);
64  }
65  return 1;
66  });
67 
68  lua_register(lState, "findSetting",
69  [](lua_State* l) {
70  auto name = luaL_checklstring(l, 1, nullptr);
71  auto defaultValue = luaL_checknumber(l, 2);
72 
73  auto index = getSettingIndexByName(name);
74  if (!index) {
75  lua_pushnumber(l, defaultValue);
76  } else {
77  // TS counts curve from 1 so convert indexing here
78  lua_pushnumber(l, engineConfiguration->scriptSetting[index.Value]);
79  }
80  return 1;
81  });
82 
83 #if defined(STM32F4) || defined(STM32F7)
84  lua_register(lState, "mcu_standby", [](lua_State*) {
86  stm32_standby();
87  return 0;
88  });
89 #endif
90 
91 /*
92  * todo: shall we? same for milliseconds?
93  lua_register(l, "getNowSeconds", [](lua_State* l) -> int {
94  int result = getTimeNowS();
95  lua_pushnumber(l, result);
96  return 1;
97  });
98 */
99 }
void stm32_standby()
Definition: mpu_util.cpp:17
void onBoardStandBy()
static int lua_efi_print(lua_State *l)
static int lua_interpolate(lua_State *l)
engine_configuration_s * engineConfiguration
expected< int > getSettingIndexByName(const char *name)
Definition: script_impl.cpp:57
expected< int > getTableIndexByName(const char *name)
Definition: script_impl.cpp:47
expected< int > getCurveIndexByName(const char *name)
Definition: script_impl.cpp:37
script_setting_t scriptSetting[SCRIPT_SETTING_COUNT]

Referenced by configureRusefiLuaHooks().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.