rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
table_func.h
Go to the documentation of this file.
1/**
2 * @author Matthew Kennedy, (c) 2021
3 *
4 * A function to convert input voltage output value based on a 2d table.
5 */
6
7#pragma once
8
10#include "efi_ratio.h"
11
12#include <rusefi/interpolation.h>
13
14template <class TBin, class TValue, int TSize, typename TOutputScale = efi::ratio<1>>
15class TableFunc final : public SensorConverter {
16public:
17 TableFunc(TBin (&bins)[TSize], TValue (&values)[TSize])
18 : m_bins(bins)
19 , m_values(values)
20 {
21 }
22
23 SensorResult convert(float inputValue) const override {
24 return interpolate2d(inputValue, m_bins, m_values) * TOutputScale::asFloat();
25 }
26
27 void showInfo(float /*testInputValue*/) const override { }
28
29private:
30 TBin (&m_bins)[TSize];
31 TValue (&m_values)[TSize];
32};
SensorResult convert(float inputValue) const override
Definition table_func.h:23
TBin(& m_bins)[TSize]
Definition table_func.h:30
TValue(& m_values)[TSize]
Definition table_func.h:31
void showInfo(float) const override
Definition table_func.h:27
TableFunc(TBin(&bins)[TSize], TValue(&values)[TSize])
Definition table_func.h:17
expected< float > SensorResult
Definition sensor.h:46