mirror of https://github.com/rusefi/rusefi.git
luaDigitalState into TS
This commit is contained in:
parent
5c649cd33c
commit
9dbf3896d8
|
@ -43,6 +43,10 @@ struct_no_prefix engine_state_s
|
|||
bit acrEngineMovedRecently
|
||||
! same field is used for narrow band heater enable and wide band enable via CAN
|
||||
bit heaterControlEnabled
|
||||
bit luaDigitalState0
|
||||
bit luaDigitalState1
|
||||
bit luaDigitalState2
|
||||
bit luaDigitalState3
|
||||
uint32_t startStopStateToggleCounter
|
||||
|
||||
float egtValue1
|
||||
|
|
|
@ -335,6 +335,11 @@ static bool runOneLua(lua_Alloc alloc, const char* script) {
|
|||
chThdSleep(TIME_US2I(luaTickPeriodUs));
|
||||
engine->outputChannels.luaLastCycleDuration = (getTimeNowNt() - beforeNt);
|
||||
engine->outputChannels.luaInvocationCounter++;
|
||||
|
||||
engine->engineState.luaDigitalState0 = getAuxDigital(0);
|
||||
engine->engineState.luaDigitalState1 = getAuxDigital(1);
|
||||
engine->engineState.luaDigitalState2 = getAuxDigital(2);
|
||||
engine->engineState.luaDigitalState3 = getAuxDigital(3);
|
||||
}
|
||||
|
||||
resetLua();
|
||||
|
|
|
@ -326,6 +326,14 @@ static int lua_getDigital(lua_State* l) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool getAuxDigital(int index) {
|
||||
#if EFI_PROD_CODE
|
||||
return efiReadPin(engineConfiguration->luaDigitalInputPins[index]);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int lua_getAuxDigital(lua_State* l) {
|
||||
auto idx = luaL_checkinteger(l, 1);
|
||||
if (idx < 0 || idx >= LUA_DIGITAL_INPUT_COUNT) {
|
||||
|
@ -341,7 +349,7 @@ static int lua_getAuxDigital(lua_State* l) {
|
|||
}
|
||||
|
||||
#if !EFI_SIMULATOR
|
||||
bool state = efiReadPin(engineConfiguration->luaDigitalInputPins[idx]);
|
||||
bool state = getAuxDigital(idx);
|
||||
lua_pushboolean(l, state);
|
||||
#endif // !EFI_SIMULATOR
|
||||
|
||||
|
@ -637,7 +645,7 @@ static int lua_vincpy(lua_State* l) {
|
|||
size_t sourceIndex = luaL_checknumber(l, 2);
|
||||
size_t destinationIndex = luaL_checknumber(l, 3);
|
||||
size_t size = luaL_checknumber(l, 4);
|
||||
for (int i = 0;i<size;i++) {
|
||||
for (size_t i = 0;i<size;i++) {
|
||||
lua_pushnumber(l, engineConfiguration->vinNumber[sourceIndex + i]);
|
||||
lua_rawseti(l, 1, destinationIndex + i);
|
||||
}
|
||||
|
|
|
@ -6,3 +6,4 @@ void luaDeInitPins();
|
|||
|
||||
struct AirmassModelBase;
|
||||
AirmassModelBase& getLuaAirmassModel();
|
||||
bool getAuxDigital(int index);
|
||||
|
|
Loading…
Reference in New Issue