From 4148ba15672a44ac4ceec2337aafc4b42cb5507c Mon Sep 17 00:00:00 2001 From: rusefillc <48498823+rusefillc@users.noreply.github.com> Date: Sun, 5 Feb 2023 15:39:21 -0500 Subject: [PATCH] heater: do index to channels mapping in all cases (#189) Co-authored-by: Andrey Gusakov --- firmware/heater_control.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index 321d83c..2d3a1af 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -230,7 +230,7 @@ static float GetVoltageForState(struct heater_state &s, float heaterEsr) static THD_WORKING_AREA(waHeaterThread, 256); static void HeaterThread(void*) { - int ch; + int i; chRegSetThreadName("Heater"); @@ -245,16 +245,16 @@ static void HeaterThread(void*) { auto heaterAllowState = GetHeaterAllowed(); - for (ch = 0; ch < AFR_CHANNELS; ch++) { - heater_state &s = state[ch]; + for (i = 0; i < AFR_CHANNELS; i++) { + heater_state &s = state[i]; // Read sensor state - float heaterEsr = GetSensorInternalResistance(ch); + float heaterEsr = GetSensorInternalResistance(s.ch); // If we haven't heard from rusEFI, use the internally sensed // battery voltage instead of voltage over CAN. float batteryVoltage = heaterAllowState == HeaterAllow::Unknown - ? GetInternalBatteryVoltage(ch) + ? GetInternalBatteryVoltage(s.ch) : GetRemoteBatteryVoltage(); // Run the state machine