my first Lua

This commit is contained in:
rusefillc 2021-09-01 07:47:25 -04:00
parent 2b302f1b0c
commit 22a0b88872
6 changed files with 7 additions and 7 deletions

View File

@ -229,7 +229,7 @@ FsioResult LECalculator::processElement(const LEElement *element DECLARE_ENGINE_
return unexpected;
case LE_METHOD_FSIO_ANALOG_INPUT:
{
int index = clampF(0, pop(LE_METHOD_FSIO_ANALOG_INPUT), FSIO_ANALOG_INPUT_COUNT - 1);
int index = clampF(0, pop(LE_METHOD_FSIO_ANALOG_INPUT), AUX_ANALOG_INPUT_COUNT - 1);
int sensorIdx = static_cast<int>(SensorType::Aux1) + index;
return Sensor::get(static_cast<SensorType>(sensorIdx));
}

View File

@ -169,7 +169,7 @@ FsioResult getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
static void setFsioAnalogInputPin(const char *indexStr, const char *pinName) {
// todo: reduce code duplication between all "set pin methods"
int index = atoi(indexStr) - 1;
if (index < 0 || index >= FSIO_ANALOG_INPUT_COUNT) {
if (index < 0 || index >= AUX_ANALOG_INPUT_COUNT) {
efiPrintf("invalid FSIO index: %d", index);
return;
}

View File

@ -323,7 +323,7 @@ static void printAnalogInfo(void) {
printAnalogChannelInfo("AuxT1", engineConfiguration->auxTempSensor1.adcChannel);
printAnalogChannelInfo("AuxT2", engineConfiguration->auxTempSensor2.adcChannel);
printAnalogChannelInfo("MAF", engineConfiguration->mafAdcChannel);
for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) {
for (int i = 0; i < AUX_ANALOG_INPUT_COUNT ; i++) {
adc_channel_e ch = engineConfiguration->fsioAdc[i];
printAnalogChannelInfo("FSIO analog", ch);
}

View File

@ -34,7 +34,7 @@ static int lua_readpin(lua_State* l) {
return 1;
}
static int lua_getAnalog(lua_State* l) {
static int lua_getAuxAnalog(lua_State* l) {
auto sensorIndex = luaL_checkinteger(l, 1);
lua_pushnumber(l, sensorIndex);
@ -304,7 +304,7 @@ static int lua_stopEngine(lua_State*) {
void configureRusefiLuaHooks(lua_State* l) {
lua_register(l, "print", lua_efi_print);
lua_register(l, "readPin", lua_readpin);
lua_register(l, "getAnalog", lua_getAnalog);
lua_register(l, "getAuxAnalog", lua_getAuxAnalog);
lua_register(l, "getSensor", lua_getSensor);
lua_register(l, "getSensorRaw", lua_getSensorRaw);
lua_register(l, "hasSensor", lua_hasSensor);

View File

@ -20,7 +20,7 @@ static FunctionalSensor auxSensors[] = {
{ SensorType::Aux4, MS2NT(50) },
};
static_assert(efi::size(auxSensors) == FSIO_ANALOG_INPUT_COUNT);
static_assert(efi::size(auxSensors) == AUX_ANALOG_INPUT_COUNT);
void initAuxSensors(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
for (size_t i = 0; i < efi::size(CONFIG(fsioAdc)); i++) {

View File

@ -1352,7 +1352,7 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\
float[MAP_ACCEL_TAPER] mapAccelTaperBins;;"counter", 1, 0, 0, 300, 0
float[MAP_ACCEL_TAPER] mapAccelTaperMult;;"mult", 1, 0, 0, 300, 2
adc_channel_e[FSIO_ANALOG_INPUT_COUNT iterate] fsioAdc;todo: rename to fsioAnalogInputs
adc_channel_e[AUX_ANALOG_INPUT_COUNT iterate] fsioAdc;todo: rename to fsioAnalogInputs
float fixedTiming;Fixed timing, useful for TDC testing;"deg", 1, 0, -720, 720, 2
float mapLowValueVoltage;MAP voltage for low point;"v", 1, 0, 0, 10, 2
float mapHighValueVoltage;MAP voltage for low point;"v", 1, 0, 0, 10, 2