Structures and functions related to 3D tables, such as VE, Spark Advance, AFR etc.
More...
|
| #define | TO_TYPE_KEY(size, xDom, yDom) table3d ## size ## xDom ## yDom ## _key |
| |
| #define | TABLE3D_GEN_TYPE_INNER(size, xDom, yDom, typeName) |
| |
| #define | TABLE3D_GEN_TYPE(size, xDom, yDom) TABLE3D_GEN_TYPE_INNER(size, xDom, yDom, TABLE3D_TYPENAME_BASE(size, xDom, yDom)) |
| |
| #define | TABLE3D_GENERATOR(GENERATOR, ...) |
| | Core 3d table generation macro.
|
| |
| #define | TABLE3D_TYPENAME_BASE(size, xDom, yDom) table3d ## size ## xDom ## yDom |
| |
|
| | TABLE3D_GEN_TYPE_INNER (6, Rpm, Load, TABLE3D_TYPENAME_BASE(6, Rpm, Load))) TABLE3D_GEN_TYPE_INNER(4 |
| |
| | TABLE3D_TYPENAME_BASE (4, Rpm, Load))) TABLE3D_GEN_TYPE_INNER(8 |
| |
| | TABLE3D_TYPENAME_BASE (8, Rpm, Load))) TABLE3D_GEN_TYPE_INNER(16 |
| |
| | TABLE3D_TYPENAME_BASE (16, Rpm, Load))) template< typename TTable > static inline table3d_value_t get3DTableValue(const TTable *pTable |
| |
| return | get3DTableValue< xFactor, yFactor > (&pTable->get_value_cache, pTable->values, pTable->axisX, pTable->axisY, { x, y }) |
| |
| static constexpr uint16_t | getConversionFactor (AxisDomain domain) |
| |
Structures and functions related to 3D tables, such as VE, Spark Advance, AFR etc.
Logical:
- each 3D table is a continuous height map spread over a cartesian (x, y) plane
- Continuous: we expect to interpolate between any 4 points
- The axes are
- Bounded. I.e. non-infinite
- Non-linear. I.e. x[n]-x[n-1] != x[n+1]-x[n]
- Increasing. I.e. x[n] >= x[n-1]
- Do not have to start at [0,0]
E.g. for a 3x3 table, this is what the TS table editor would show:
Y-Max V6 V7 V8
Y-Int V3 V4 V5
Y-Min V0 V1 V2
X-Min X-Int X-Max
In memory, we store rows in reverse:
- Both axes are inverted:
x[0] stores X-Max
x[2] stores X-Min
y[0] stores Y-Max
y[2] stores Y-Min
- The value locations match the axes.
value[0][0] stores V6.
value[2][0] stores V0.
I.e.
Y-Min V0 V1 V2
Y-Int V3 V4 V5
Y-Max V6 V7 V8
X-Min X-Int X-Max
◆ TABLE3D_GEN_TYPE
◆ TABLE3D_GEN_TYPE_INNER
| #define TABLE3D_GEN_TYPE_INNER |
( |
|
size, |
|
|
|
xDom, |
|
|
|
yDom, |
|
|
|
typeName |
|
) |
| |
Value: \
{ \
\
static constexpr TableType type_key = TableType::TO_TYPE_KEY(size, xDom, yDom); \
static constexpr AxisDomain XDomain = AxisDomain::xDom; \
static constexpr AxisDomain YDomain = AxisDomain::yDom; \
\
};
AxisDomain
Encodes the real world measurement that a table axis captures.
Definition table3d_axes.h:17
uint8_t table3d_axis_t
The type of each axis value.
Definition table3d_typedefs.h:28
TableType
Table type identifiers. Limited compile time RTTI.
Definition table3d.h:69
Cache structure for 3D table value lookups.
Definition table3d_interpolate.h:36
◆ TABLE3D_GENERATOR
| #define TABLE3D_GENERATOR |
( |
|
GENERATOR, |
|
|
|
... |
|
) |
| |
Value: GENERATOR(6,
Rpm,
Load, ##__VA_ARGS__) \
GENERATOR(4,
Rpm,
Load, ##__VA_ARGS__) \
GENERATOR(8,
Rpm,
Load, ##__VA_ARGS__) \
GENERATOR(16,
Rpm,
Load, ##__VA_ARGS__)
Rpm
Definition table3d.h:100
Load
Definition table3d.h:100
Core 3d table generation macro.
We have a fixed number of table types: they are defined by this macro. GENERATOR is expected to be another macros that takes at least 3 arguments: axis length, x-axis domain, y-axis domain
◆ TABLE3D_TYPENAME_BASE
| #define TABLE3D_TYPENAME_BASE |
( |
|
size, |
|
|
|
xDom, |
|
|
|
yDom |
|
) |
| table3d ## size ## xDom ## yDom |
◆ TO_TYPE_KEY
| #define TO_TYPE_KEY |
( |
|
size, |
|
|
|
xDom, |
|
|
|
yDom |
|
) |
| table3d ## size ## xDom ## yDom ## _key |
◆ table3d_axis_t
The type of each axis value.
◆ table3d_dim_t
Encodes the length of the axes.
◆ table3d_value_t
The type of each table value.
◆ AxisDomain
Encodes the real world measurement that a table axis captures.
| Enumerator |
|---|
| Rpm | RPM (engine speed)
|
| Load | Load
|
◆ TableType
Table type identifiers. Limited compile time RTTI.
With no virtual functions (they have quite a bit of overhead in both space & time), we have to pass void* around in certain cases. In order to cast that back to a concrete table type, we need to somehow identify the type.
Once approach is to register each type - but that requires a central registry which will use RAM.
Since we have a compile time fixed set of table types, we can map a unique identifier to the type via a cast - this enum is that unique identifier.
Typically used in conjunction with visitTable3d()
| Enumerator |
|---|
| table_type_None | |
◆ get3DTableValue< xFactor, yFactor >()
| return get3DTableValue< xFactor, yFactor > |
( |
&pTable-> |
get_value_cache, |
|
|
pTable-> |
values, |
|
|
pTable-> |
axisX, |
|
|
pTable-> |
axisY, |
|
|
{ x, y } |
|
|
) |
| |
◆ getConversionFactor()
| static constexpr uint16_t getConversionFactor |
( |
AxisDomain |
domain | ) |
|
|
staticconstexpr |
◆ TABLE3D_GEN_TYPE_INNER()
◆ TABLE3D_TYPENAME_BASE() [1/3]
| TABLE3D_TYPENAME_BASE |
( |
16 |
, |
|
|
Rpm |
, |
|
|
Load |
|
|
) |
| const |
◆ TABLE3D_TYPENAME_BASE() [2/3]
| TABLE3D_TYPENAME_BASE |
( |
4 |
, |
|
|
Rpm |
, |
|
|
Load |
|
|
) |
| |
◆ TABLE3D_TYPENAME_BASE() [3/3]
| TABLE3D_TYPENAME_BASE |
( |
8 |
, |
|
|
Rpm |
, |
|
|
Load |
|
|
) |
| |
◆ Load
◆ noexcept
| const uint16_t const uint16_t x noexcept |
Initial value:{
static constexpr uint16_t getConversionFactor(AxisDomain domain)
Definition table3d_axes.h:24
◆ Rpm
◆ yFactor