* lua getAuxDigital() #4861 * fix * fix simulator
This commit is contained in:
parent
a5c0fbb9d0
commit
8b9955dc67
|
@ -316,6 +316,28 @@ static int lua_getDigital(lua_State* l) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int lua_getAuxDigital(lua_State* l) {
|
||||
auto idx = luaL_checkinteger(l, 1);
|
||||
if (idx < 0 || idx >= LUA_DIGITAL_INPUT_COUNT) {
|
||||
// Return nil to indicate invalid parameter
|
||||
lua_pushnil(l);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!isBrainPinValid(engineConfiguration->luaDigitalInputPins[idx])) {
|
||||
// Return nil to indicate invalid pin
|
||||
lua_pushnil(l);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !EFI_SIMULATOR
|
||||
bool state = efiReadPin(engineConfiguration->luaDigitalInputPins[idx]);
|
||||
lua_pushboolean(l, state);
|
||||
#endif // !EFI_SIMULATOR
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lua_setDebug(lua_State* l) {
|
||||
// wrong debug mode, ignore
|
||||
if (engineConfiguration->debugMode != DBG_LUA) {
|
||||
|
@ -892,6 +914,7 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
|
||||
lua_register(l, "getFan", lua_fan);
|
||||
lua_register(l, "getDigital", lua_getDigital);
|
||||
lua_register(l, "getAuxDigital", lua_getAuxDigital);
|
||||
lua_register(l, "setDebug", lua_setDebug);
|
||||
lua_register(l, "getAirmass", lua_getAirmass);
|
||||
lua_register(l, "setAirmass", lua_setAirmass);
|
||||
|
|
|
@ -56,7 +56,7 @@ static void deInitOldAnalogInputs() {
|
|||
static void initAuxDigital() {
|
||||
#if EFI_PROD_CODE
|
||||
for (size_t i = 0;i<efi::size(engineConfiguration->luaDigitalInputPins);i++) {
|
||||
efiSetPadMode("Lua Digital", engineConfiguration->luaDigitalInputPins[i], getInputMode(PI_DEFAULT));
|
||||
efiSetPadMode("Lua Digital", engineConfiguration->luaDigitalInputPins[i], engineConfiguration->luaDigitalInputPinModes[i]);
|
||||
}
|
||||
#endif // EFI_PROD_CODE
|
||||
}
|
||||
|
|
|
@ -1889,7 +1889,7 @@ menuDialog = main
|
|||
|
||||
subMenu = std_separator
|
||||
subMenu = auxInputsDialog, "Lua Analog Inputs"
|
||||
# TODO finish https://github.com/rusefi/rusefi/issues/4861 subMenu = luaDigitalInputsDialog, "Lua Digital Inputs"
|
||||
subMenu = luaDigitalInputsDialog, "Lua Digital Inputs"
|
||||
subMenu = luaOutputs, "Lua Script PWM Outputs"
|
||||
|
||||
groupMenu = "Lua Calibrations"
|
||||
|
@ -3949,7 +3949,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
field = "Mode #7", luaDigitalInputPinModes7
|
||||
field = "Mode #8", luaDigitalInputPinModes8
|
||||
|
||||
dialog = luaDigitalInputsDialog, "Lua Digital Inputs", border
|
||||
dialog = luaDigitalInputsDialog, "Lua Digital Aux Inputs", border
|
||||
panel = luaDigitalInputsLeftDialog, West
|
||||
panel = luaDigitalInputsRightDialog, East
|
||||
|
||||
|
|
Loading…
Reference in New Issue