add setIgnDisabled (#340)

* fix md hierarchy and typos

* add setIgnDisabled
This commit is contained in:
mi-hol 2023-01-03 13:08:39 +01:00 committed by GitHub
parent 331d5a60a6
commit c7810b5513
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 73 deletions

View File

@ -20,12 +20,15 @@
"GSXR", "GSXR",
"Haltech", "Haltech",
"Hayabusa", "Hayabusa",
"hexstr",
"HOWTO", "HOWTO",
"Impreza", "Impreza",
"Integra", "Integra",
"Jetta", "Jetta",
"Jimny", "Jimny",
"Lada", "Lada",
"luamemory",
"luareset",
"MGTE", "MGTE",
"Molex", "Molex",
"MOSI", "MOSI",
@ -40,6 +43,7 @@
"SEPHIA", "SEPHIA",
"SOHC", "SOHC",
"Sorento", "Sorento",
"sparkcut",
"Speeduino", "Speeduino",
"Steinhart", "Steinhart",
"superseal", "superseal",

View File

@ -1,6 +1,6 @@
# Lua Scripting # Lua Scripting
# Basics ## Basics
A proper ECU has to offer users as much flexibility as possible, meaning a completely user-defined control strategy for both primary and auxiliary actuators. For many years rusEFI had FSIO to do just that. A proper ECU has to offer users as much flexibility as possible, meaning a completely user-defined control strategy for both primary and auxiliary actuators. For many years rusEFI had FSIO to do just that.
@ -18,7 +18,7 @@ The entire Lua script is read at startup, then a function called `onTick` is cal
Here is a simple script you can run to illustrate this behavior: Here is a simple script you can run to illustrate this behavior:
``` ```LUA
print('Hello Lua startup!') print('Hello Lua startup!')
function onTick() function onTick()
@ -30,7 +30,7 @@ end
The function `setTickRate(hz)` can be used to configure how often rusEFI calls the `onTick` function. If your script does a lot of work in the `onTick()` function it may run slower than the desired rate. Since the Lua virtual machine runs at low priority compared to other functions of the ECU, it is impossible to swamp the ECU with too much Lua work, so set the tick rate to whatever is necessary. `onCanRx` runs at the same rate as `onTick` The function `setTickRate(hz)` can be used to configure how often rusEFI calls the `onTick` function. If your script does a lot of work in the `onTick()` function it may run slower than the desired rate. Since the Lua virtual machine runs at low priority compared to other functions of the ECU, it is impossible to swamp the ECU with too much Lua work, so set the tick rate to whatever is necessary. `onCanRx` runs at the same rate as `onTick`
``` ```LUA
n = 0 n = 0
setTickRate(5) --set tick rate to 5hz setTickRate(5) --set tick rate to 5hz
function onTick() function onTick()
@ -39,125 +39,129 @@ function onTick()
end end
``` ```
# Function Reference ## Function Reference
## User Settings ### User Settings
### `getOutput(name)` #### `getOutput(name)`
For example ``getOutput("clutchUpState")`` ``getOutput("brakePedalState")`` For example ``getOutput("clutchUpState")`` ``getOutput("brakePedalState")``
See [https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/output_lookup_generated.cpp](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/output_lookup_generated.cpp) for output names. See [https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/output_lookup_generated.cpp](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/output_lookup_generated.cpp) for output names.
### `setClutchUpState(value)` #### `setClutchUpState(value)`
### `setBrakePedalState(value)` #### `setBrakePedalState(value)`
Use setBrakePedalState to tell rusEFI about CAN-based brake pedal. Use setBrakePedalState to tell rusEFI about CAN-based brake pedal.
### `setAcRequestState(value)` #### `setAcRequestState(value)`
Use setAcRequestState to tell rusEFI about CAN-based A/C request. Use setAcRequestState to tell rusEFI about CAN-based A/C request.
### `setEtbDisabled(value)` #### `setEtbDisabled(value)`
### `setIgnDisabled(value)` #### `setIgnDisabled(value)`
### ``setAcDisabled(value)`` #### ``setAcDisabled(value)``
Disable/supress A/C functionality regardless of what and how enables it, an override kind of deal. Disable/suppress A/C functionality regardless of what and how enables it, an override kind of deal.
### ``getTimeSinceAcToggleMs`` #### ``getTimeSinceAcToggleMs``
### `getCalibration(name)` #### `getCalibration(name)`
Gets current calibration value for specified scalar setting. For example ``getCalibration("cranking.rpm")`` Gets current calibration value for specified scalar setting. For example ``getCalibration("cranking.rpm")``
See [https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/value_lookup_generated.md](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/value_lookup_generated.md) for field names. See [https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/value_lookup_generated.md](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/generated/value_lookup_generated.md) for field names.
### `setCalibration(name, value, needEvent)` #### `setCalibration(name, value, needEvent)`
Sets specified calibration setting to specified value. Fires calibration change event depending on needEvent parameter. Sets specified calibration setting to specified value. Fires calibration change event depending on needEvent parameter.
For example ``setCalibration("cranking.rpm", 900, false)`` For example ``setCalibration("cranking.rpm", 900, false)``
### `findSetting(name, defaultValue)` #### `findSetting(name, defaultValue)`
Find User Setting with specified name and returns numeric value. Useful when script developer and script consumer are Find User Setting with specified name and returns numeric value. Useful when script developer and script consumer are
different people, also useful while Lua script editing is available only in TS. different people, also useful while Lua script editing is available only in TS.
- Parameters - Parameters
- `name`: Variable name, as in corresponding 'name' field in configuration - `name`: Variable name, as in corresponding 'name' field in configuration
- `dataultValue`: value to use if specified setting not located by name - `defaultValue`: value to use if specified setting not located by name
## Engine Control ### Engine Control
### `stopEngine` #### `stopEngine`
### `setSparkSkipRatio` #### `setIgnDisabled`
'setIgnDisabled' function for all kinds of cranking safety systems
#### `setSparkSkipRatio`
setSparkSkipRatio(0) to skip 0% of the ignition events, i.e. no skipping setSparkSkipRatio(0) to skip 0% of the ignition events, i.e. no skipping
setSparkSkipRatio(0.5) would skip half of ignition events. We never skip two consecutive ignitions. setSparkSkipRatio(0.5) would skip half of ignition events. We never skip two consecutive ignitions.
### `setIdleAdd` #### `setIdleAdd`
### `setFuelAdd` #### `setFuelAdd`
Sorry not finished :( Sorry not finished :(
### `setFuelMult` #### `setFuelMult`
Sorry not finished :( Sorry not finished :(
### `setBoostAdd` #### `setBoostAdd`
Additive for closed loop target boost pressure. Additive for closed loop target boost pressure.
### `setBoostMult` #### `setBoostMult`
Multiplier for closed loop target boost pressure. Multiplier for closed loop target boost pressure.
### `setTimingAdd(angle)` #### `setTimingAdd(angle)`
todo add details but ready to test! todo add details but ready to test!
### `setTimingMult(coeff)` #### `setTimingMult(coeff)`
todo add details but ready to test! todo add details but ready to test!
### `setEtbAdd(extraEtb)` #### `setEtbAdd(extraEtb)`
extraEtb `10` for 10% extraEtb `10` for 10%
## CAN bus ### CAN bus
### `enableCanTx(isEnabled)` #### `enableCanTx(isEnabled)`
enabled by default enabled by default
use enableCanTx(false) to suppress CAN TX use enableCanTx(false) to suppress CAN TX
### `txCan(bus, ID, isExt, payload)` #### `txCan(bus, ID, isExt, payload)`
- Parameters - Parameters
- bus: hardware CAN bus index, only '1' on most rusEFI boards, '1' or '2' on Proteus - bus: hardware CAN bus index, only '1' on most rusEFI boards, '1' or '2' on Proteus
- isExt: 0 for 11 bit mode - isExt: 0 for 11 bit mode
### `canRxAdd(id)` #### `canRxAdd(id)`
### `canRxAdd(bus, id)` #### `canRxAdd(bus, id)`
### `canRxAdd(id, callback)` #### `canRxAdd(id, callback)`
### `canRxAdd(bus, id, callback)` #### `canRxAdd(bus, id, callback)`
### `canRxAddMask(id, mask)` #### `canRxAddMask(id, mask)`
### `canRxAddMask(bus, id, mask)` #### `canRxAddMask(bus, id, mask)`
### `canRxAddMask(id, mask, callback)` #### `canRxAddMask(id, mask, callback)`
### `canRxAddMask(bus, id, mask, callback)` #### `canRxAddMask(bus, id, mask, callback)`
- Parameters - Parameters
- id: CAN ID to listen to. - id: CAN ID to listen to.
@ -173,9 +177,9 @@ function onCanRx(bus, id, dlc, data)
end end
``` ```
## Utility ### Utility
### `print(msg)` #### `print(msg)`
Print a line of text to the ECU's log. Print a line of text to the ECU's log.
@ -184,7 +188,7 @@ Print a line of text to the ECU's log.
- Returns - Returns
- none - none
### `vin(index)` #### `vin(index)`
Return VIN setting character at specified index Return VIN setting character at specified index
@ -203,7 +207,7 @@ print('Hello Lua, number is: ' ..n)
Output: Output:
`Hello Lua, number is 5.5` `Hello Lua, number is 5.5`
### `setTickRate(hz)` #### `setTickRate(hz)`
Sets the rate at which rusEFI calls your `onTick` and `onCanRx` functions, in hz. On reset default is 10hz. Sets the rate at which rusEFI calls your `onTick` and `onCanRx` functions, in hz. On reset default is 10hz.
@ -212,19 +216,19 @@ Sets the rate at which rusEFI calls your `onTick` and `onCanRx` functions, in hz
- Returns - Returns
- none - none
### `mcu_standby()` #### `mcu_standby()`
Stops MCU. Stops MCU.
### `interpolate(x1, y1, x2, y2, x)` #### `interpolate(x1, y1, x2, y2, x)`
Interpolates `x` placing it on the line defined by (x1, y1) and (x2, y2) Interpolates `x` placing it on the line defined by (x1, y1) and (x2, y2)
### `findTableIndex(name)` #### `findTableIndex(name)`
Find table index by specified human-readable name. Find table index by specified human-readable name.
### `table3d(tableIdx, x, y)` #### `table3d(tableIdx, x, y)`
Looks up a value from the specified Script Table. Looks up a value from the specified Script Table.
@ -235,11 +239,11 @@ Looks up a value from the specified Script Table.
- Returns - Returns
- A number representing the value looked up from the table. - A number representing the value looked up from the table.
### `findCurveIndex(name)` #### `findCurveIndex(name)`
Finds curve index by specific curve name Finds curve index by specific curve name
### `curve(curveIdx, x)` #### `curve(curveIdx, x)`
Looks up a value from the specified Script Curve. Looks up a value from the specified Script Curve.
@ -247,7 +251,7 @@ Looks up a value from the specified Script Curve.
- `tableIdx`: Index of the script to use, starting from 1. - `tableIdx`: Index of the script to use, starting from 1.
- `x`: Axis value to look up in the table - `x`: Axis value to look up in the table
### `setDebug(index, value)` #### `setDebug(index, value)`
Sets a debug channel to the specified value. Note: this only works when the ECU debug mode is set to `Lua`. Sets a debug channel to the specified value. Note: this only works when the ECU debug mode is set to `Lua`.
@ -257,13 +261,13 @@ Sets a debug channel to the specified value. Note: this only works when the ECU
- Returns - Returns
- none - none
### `mcu_standby` #### `mcu_standby`
Puts MCU into standby low current consumption mode. Puts MCU into standby low current consumption mode.
## Input ### Input
### `getSensor(name)` #### `getSensor(name)`
Reads the specified sensor. Reads the specified sensor.
@ -272,7 +276,7 @@ Reads the specified sensor.
- Returns - Returns
- A reading from the sensor, or `nil` if the sensor has a problem or isn't configured. - A reading from the sensor, or `nil` if the sensor has a problem or isn't configured.
### `getSensorByIndex(index)` #### `getSensorByIndex(index)`
Reads the specified sensor. Reads the specified sensor.
@ -281,7 +285,7 @@ Reads the specified sensor.
- Returns - Returns
- A reading from the sensor, or `nil` if the sensor has a problem or isn't configured. - A reading from the sensor, or `nil` if the sensor has a problem or isn't configured.
### `getSensorRaw(index)` #### `getSensorRaw(index)`
Reads the raw value from the specified sensor. For most sensors, this means the analog voltage on the relevant input pin. Reads the raw value from the specified sensor. For most sensors, this means the analog voltage on the relevant input pin.
@ -290,7 +294,7 @@ Reads the raw value from the specified sensor. For most sensors, this means the
- Returns - Returns
- The raw value that yielded the sensor reading, or 0 if the sensor doesn't support raw readings, isn't configured, or has failed. - The raw value that yielded the sensor reading, or 0 if the sensor doesn't support raw readings, isn't configured, or has failed.
### `getAuxAnalog(index)` #### `getAuxAnalog(index)`
More or less like getSensorRaw but always voltage of aux analog input. More or less like getSensorRaw but always voltage of aux analog input.
@ -299,7 +303,7 @@ More or less like getSensorRaw but always voltage of aux analog input.
- Returns - Returns
- Voltage of sensor reading, or nil if sensor isn't configured. - Voltage of sensor reading, or nil if sensor isn't configured.
### `hasSensor(index)` #### `hasSensor(index)`
Checks whether a particular sensor is configured (whether it is currently valid or not). Checks whether a particular sensor is configured (whether it is currently valid or not).
@ -308,7 +312,7 @@ Checks whether a particular sensor is configured (whether it is currently valid
- Returns - Returns
- A boolean value, `true` if the sensor is configured, and `false` if not. - A boolean value, `true` if the sensor is configured, and `false` if not.
### `getDigital(index)` #### `getDigital(index)`
Reads a digital input from the specified channel. Reads a digital input from the specified channel.
@ -326,20 +330,20 @@ Valid `index` parameter values:
| 2 | Brake switch | | 2 | Brake switch |
| 3 | AC switch | | 3 | AC switch |
### `readPin(pinName)` #### `readPin(pinName)`
Reads physical value of arbitrary MCU pin Reads physical value of arbitrary MCU pin
- Parameters - Parameters
- `pinName`: string name of MCU pin, for examples "PD15" - `pinName`: string name of MCU pin, for examples "PD15"
## Output ### Output
### `selfStimulateRPM(rpm)` #### `selfStimulateRPM(rpm)`
Positive value would start clicking injectors at specified RPM, zero value would stop self-stimulation. Positive value would start clicking injectors at specified RPM, zero value would stop self-stimulation.
### `startPwm(index, frequency, duty)` #### `startPwm(index, frequency, duty)`
Initializes PWM on the specified index, starting at the specified frequency and duty cycle. The index selects which config field pin to use, see "Lua PWM Outputs" page in TunerStudio. Initializes PWM on the specified index, starting at the specified frequency and duty cycle. The index selects which config field pin to use, see "Lua PWM Outputs" page in TunerStudio.
@ -350,7 +354,7 @@ Initializes PWM on the specified index, starting at the specified frequency and
- Returns - Returns
- none - none
### `setPwmDuty(index, duty)` #### `setPwmDuty(index, duty)`
Set the duty cycle of the specified PWM channel. Set the duty cycle of the specified PWM channel.
@ -360,7 +364,7 @@ Set the duty cycle of the specified PWM channel.
- Returns - Returns
- none - none
### `setPwmFreq(index, frequency)` #### `setPwmFreq(index, frequency)`
- Parameters - Parameters
- `index`: The index of the PWM channel to set. - `index`: The index of the PWM channel to set.
@ -376,7 +380,7 @@ Set the duty cycle of the specified PWM channel.
## Examples ## Examples
# timer ### timer
```lua ```lua
t = Timer.new(); t = Timer.new();
@ -404,10 +408,10 @@ function onTick()
end end
``` ```
# PWM ### PWM
```lua ```lua
-- index 0, 100Hz, zero duty inititally -- index 0, 100Hz, zero duty initially
startPwm(0, 100, 0) startPwm(0, 100, 0)
function onTick() function onTick()
@ -419,7 +423,7 @@ function onTick()
end end
``` ```
# CAN transmit ### CAN transmit
```lua ```lua
function onTick() function onTick()
@ -438,7 +442,7 @@ function onTick()
end end
``` ```
# set sensor value ### set sensor value
[A list of sensor names can be found here.](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/sensors/sensor_type.h) [A list of sensor names can be found here.](https://github.com/rusefi/rusefi/blob/master/firmware/controllers/sensors/sensor_type.h)
@ -458,7 +462,7 @@ end
``` ```
# CAN receive ### CAN receive
```lua ```lua
canRxAdd(0x500) canRxAdd(0x500)
@ -504,7 +508,7 @@ function print_array(arr)
end end
``` ```
# table ### table
```lua ```lua
tableIndex = findTableIndex("duty") tableIndex = findTableIndex("duty")
@ -521,7 +525,7 @@ sparkCutByTorque = curve(sparkCutCurve, torque)
## See also ## See also
# BMW iDrive ### BMW iDrive
See <https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/bmw-idrive.txt> See <https://github.com/rusefi/rusefi/blob/master/firmware/controllers/lua/examples/bmw-idrive.txt>