LUA/SENT: hook to get RAW sig0 and sig1 (WIP)
TODO: how to return two (N) values from LUA hook?
This commit is contained in:
parent
4dad071eba
commit
355f0c51fb
|
@ -655,6 +655,17 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
lua_pushnumber(l, value);
|
||||
return 1;
|
||||
});
|
||||
|
||||
lua_register(l, "getSentValues",
|
||||
[](lua_State* l) {
|
||||
uint16_t sig0;
|
||||
uint16_t sig1;
|
||||
auto humanIndex = luaL_checkinteger(l, 1);
|
||||
auto ret = getSentValues(humanIndex - 1, &sig0, &sig1);
|
||||
lua_pushnumber(l, sig0);
|
||||
lua_pushnumber(l, sig1);
|
||||
return 2;
|
||||
});
|
||||
#endif // EFI_SENT_SUPPORT
|
||||
|
||||
#if EFI_LAUNCH_CONTROL
|
||||
|
|
|
@ -603,6 +603,7 @@ static void printSentInfo()
|
|||
}
|
||||
|
||||
/* Don't be confused: this actually returns throttle body position */
|
||||
/* TODO: remove, replace with getSentValues() */
|
||||
float getSentValue(size_t index) {
|
||||
if (index < SENT_CHANNELS_NUM) {
|
||||
uint16_t sig0, sig1;
|
||||
|
@ -623,6 +624,17 @@ float getSentValue(size_t index) {
|
|||
return NAN;
|
||||
}
|
||||
|
||||
int getSentValues(size_t index, uint16_t *sig0, uint16_t *sig1) {
|
||||
if (index < SENT_CHANNELS_NUM) {
|
||||
sent_channel &ch = channels[index];
|
||||
|
||||
return ch.GetSignals(NULL, sig0, sig1);
|
||||
}
|
||||
|
||||
/* invalid channel */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Should be called once */
|
||||
void initSent(void)
|
||||
{
|
||||
|
|
|
@ -20,3 +20,4 @@ void startSent(void);
|
|||
void stopSent(void);
|
||||
|
||||
float getSentValue(size_t index);
|
||||
int getSentValues(size_t index, uint16_t *sig0, uint16_t *sig1);
|
||||
|
|
Loading…
Reference in New Issue