Lua aux gauge #4672
This commit is contained in:
parent
1cc46a1b83
commit
367d2ec324
|
@ -512,6 +512,8 @@ static void updateRawSensors() {
|
|||
engine->outputChannels.rawWastegatePosition = Sensor::getRaw(SensorType::WastegatePosition);
|
||||
engine->outputChannels.rawIdlePositionSensor = Sensor::getRaw(SensorType::IdlePosition);
|
||||
|
||||
engine->outputChannels.luaGauges[0] = Sensor::getRaw(SensorType::LuaGauge1);
|
||||
|
||||
for (int i = 0;i<AUX_ANALOG_INPUT_COUNT;i++) {
|
||||
adc_channel_e ch = engineConfiguration->auxAnalogInputs[i];
|
||||
if (ch != EFI_ADC_NONE) {
|
||||
|
|
|
@ -677,6 +677,19 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
});
|
||||
#endif // EFI_LAUNCH_CONTROL
|
||||
|
||||
/**
|
||||
* same exact could be accomplished via LuaSensor just with more API
|
||||
*/
|
||||
lua_register(l, "setLuaGauge", [](lua_State* l) {
|
||||
auto index = luaL_checkinteger(l, 1) - 1;
|
||||
auto value = luaL_checknumber(l, 2);
|
||||
if (index < 0 || index >= LUA_GAUGE_COUNT)
|
||||
return 0;
|
||||
extern StoredValueSensor luaGauges[LUA_GAUGE_COUNT];
|
||||
luaGauges[index].setValidValue(value, getTimeNowNt());
|
||||
return 0;
|
||||
});
|
||||
|
||||
lua_register(l, "enableCanTx", [](lua_State* l) {
|
||||
engine->allowCanTx = lua_toboolean(l, 1);
|
||||
return 0;
|
||||
|
|
|
@ -18,7 +18,14 @@ static FunctionalSensor auxSensors[] = {
|
|||
{ SensorType::AuxAnalog8, MS2NT(50) },
|
||||
};
|
||||
|
||||
StoredValueSensor luaGauges[] = {
|
||||
{ SensorType::LuaGauge1, MS2NT(5000) },
|
||||
{ SensorType::LuaGauge2, MS2NT(5000) },
|
||||
};
|
||||
|
||||
|
||||
static_assert(efi::size(auxSensors) == AUX_ANALOG_INPUT_COUNT);
|
||||
static_assert(efi::size(luaGauges) == LUA_GAUGE_COUNT);
|
||||
|
||||
void initAuxSensors() {
|
||||
for (size_t i = 0; i < efi::size(engineConfiguration->auxAnalogInputs); i++) {
|
||||
|
@ -35,4 +42,9 @@ void initAuxSensors() {
|
|||
|
||||
AdcSubscription::SubscribeSensor(sensor, channel, 10);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < efi::size(luaGauges); i++) {
|
||||
auto& sensor = luaGauges[i];
|
||||
sensor.Register();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1163,6 +1163,8 @@ gaugeCategory = Sensors - Extra 2
|
|||
idlePosSensGauge = idlePositionSensor, @@GAUGE_NAME_IDLE_POSITION@@, "%", 0, 100, 0, 0, 100, 100, 1, 1
|
||||
currentEnginePhaseGauge = currentEngineDecodedPhase, "Engine Phase", "deg", 0, 720, 0, 0, 720, 720, 0, 0
|
||||
auxSpeed1Gauge = auxSpeed1, "Aux Freq Input1", "hz", 0, 30000, 0, 0, 30000, 30000, 0, 0
|
||||
luaGauges1gauge = luaGauges1, "Lua Gauge 1", "lua", 0, 30000, 0, 0, 30000, 30000, 0, 3
|
||||
luaGauges2gauge = luaGauges2, "Lua Gauge 2", "lua", 0, 30000, 0, 0, 30000, 30000, 0, 3
|
||||
|
||||
gaugeCategory = ECU Status
|
||||
warningCounterGauge = warningCounter, @@GAUGE_NAME_WARNING_COUNT@@, "", 0, 100, 0, 0, 100, 100, 0, 0
|
||||
|
|
Loading…
Reference in New Issue