rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
controllers
sensors
converters
linear_func.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
3
#include "
linear_func.h
"
4
5
void
LinearFunc::configure
(
float
in1,
float
out1,
float
in2,
float
out2,
float
minOutput,
float
maxOutput) {
6
m_minOutput
= minOutput;
7
m_maxOutput
= maxOutput;
8
9
in1 = in1 /
m_divideInput
;
10
in2 = in2 /
m_divideInput
;
11
12
m_a
= INTERPOLATION_A(in1, out1, in2, out2);
13
m_b
= out1 -
m_a
* in1;
14
}
15
16
SensorResult
LinearFunc::convert
(
float
inputValue)
const
{
17
float
result =
m_a
* inputValue +
m_b
;
18
19
// Bounds checks
20
// Flipped error codes in case of m_a < 0 so that they indicate whether the input
21
// voltage is high/low, instead of the output high/low
22
if
(result >
m_maxOutput
) {
23
return
m_a
> 0 ? UnexpectedCode::High : UnexpectedCode::Low;
24
}
25
26
if
(result <
m_minOutput
) {
27
return
m_a
> 0 ? UnexpectedCode::Low : UnexpectedCode::High;
28
}
29
30
return
result;
31
}
LinearFunc::convert
SensorResult convert(float inputValue) const override
Definition
linear_func.cpp:16
LinearFunc::m_minOutput
float m_minOutput
Definition
linear_func.h:25
LinearFunc::m_b
float m_b
Definition
linear_func.h:23
LinearFunc::m_divideInput
const float m_divideInput
Definition
linear_func.h:29
LinearFunc::configure
void configure(float in1, float out1, float in2, float out2, float minOutput, float maxOutput)
Definition
linear_func.cpp:5
LinearFunc::m_maxOutput
float m_maxOutput
Definition
linear_func.h:26
LinearFunc::m_a
float m_a
Definition
linear_func.h:22
linear_func.h
pch.h
SensorResult
expected< float > SensorResult
Definition
sensor.h:46
Generated on Sat Sep 27 2025 00:10:06 for rusEFI by
1.9.8