2019-09-21 11:33:38 -07:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-24 18:11:41 -07:00
|
|
|
#include "sensor_converter_func.h"
|
2019-09-21 11:33:38 -07:00
|
|
|
|
2019-09-24 18:11:41 -07:00
|
|
|
class LinearFunc final : public SensorConverter {
|
2019-09-21 11:33:38 -07:00
|
|
|
public:
|
2020-03-22 14:09:46 -07:00
|
|
|
LinearFunc(float divideInput = 1.0f) : m_divideInput(divideInput) {}
|
2019-09-21 11:33:38 -07:00
|
|
|
|
|
|
|
void configure(float in1, float out1, float in2, float out2, float minOutput, float maxOutput);
|
|
|
|
|
2019-09-24 18:11:41 -07:00
|
|
|
SensorResult convert(float inputValue) const override;
|
2019-09-21 11:33:38 -07:00
|
|
|
|
2020-03-30 22:07:08 -07:00
|
|
|
void showInfo(Logging* logger, float testRawValue) const override;
|
|
|
|
|
2020-12-05 21:41:49 -08:00
|
|
|
float getDivideInput() const {
|
|
|
|
return m_divideInput;
|
|
|
|
}
|
|
|
|
|
2019-09-21 11:33:38 -07:00
|
|
|
private:
|
|
|
|
// Linear equation parameters for equation of form
|
|
|
|
// y = ax + b
|
|
|
|
float m_a = 1;
|
|
|
|
float m_b = 0;
|
|
|
|
|
|
|
|
float m_minOutput = 0;
|
|
|
|
float m_maxOutput = 0;
|
2020-03-22 14:09:46 -07:00
|
|
|
|
|
|
|
// Divisor for the input values - some configurations use a ratio'd value for compat
|
|
|
|
const float m_divideInput;
|
2019-09-21 11:33:38 -07:00
|
|
|
};
|