Speeduino
Loading...
Searching...
No Matches
Files | Classes | Macros | Typedefs | Enumerations | Functions | Variables
3D Tables

Structures and functions related to 3D tables, such as VE, Spark Advance, AFR etc. More...

Files

file  table3d.h
 3D table data types and functions
 
file  table3d_axes.h
 3D table axis types and iterators
 
file  table3d_typedefs.h
 Typedefs for primitive 3D table elements.
 

Classes

struct  table3d_t
 

Macros

#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
 

Typedefs

using table3d_dim_t = uint8_t
 Encodes the length of the axes.
 
using table3d_value_t = uint8_t
 The type of each table value.
 
using table3d_axis_t = uint8_t
 The type of each axis value.
 

Enumerations

enum class  TableType : uint8_t { TableType::table_type_None }
 Table type identifiers. Limited compile time RTTI. More...
 
enum class  AxisDomain : uint8_t { AxisDomain::Rpm , AxisDomain::Load }
 Encodes the real world measurement that a table axis captures. More...
 

Functions

 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)
 

Variables

 Rpm
 
 Load
 
const uint16_t y
 
const uint16_t const uint16_t x noexcept
 
constexpr uint16_t yFactor = getConversionFactor(TTable::YDomain)
 

Detailed Description

Structures and functions related to 3D tables, such as VE, Spark Advance, AFR etc.

Logical:

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:

I.e.

     Y-Min    V0      V1      V2
     Y-Int    V3      V4      V5
     Y-Max    V6      V7      V8
             X-Min   X-Int   X-Max

Macro Definition Documentation

◆ TABLE3D_GEN_TYPE

#define TABLE3D_GEN_TYPE (   size,
  xDom,
  yDom 
)    TABLE3D_GEN_TYPE_INNER(size, xDom, yDom, TABLE3D_TYPENAME_BASE(size, xDom, yDom))

◆ TABLE3D_GEN_TYPE_INNER

#define TABLE3D_GEN_TYPE_INNER (   size,
  xDom,
  yDom,
  typeName 
)
Value:
\
struct typeName : public table3d_t \
{ \
/* This will take up zero space unless we take the address somewhere */ \
static constexpr TableType type_key = TableType::TO_TYPE_KEY(size, xDom, yDom); \
static constexpr AxisDomain XDomain = AxisDomain::xDom; \
static constexpr AxisDomain YDomain = AxisDomain::yDom; \
\
mutable table3DGetValueCache get_value_cache; \
std::array<table3d_axis_t, (size)*(size)> values; \
std::array<table3d_axis_t, (size)> axisX; \
std::array<table3d_axis_t, (size)> axisY; \
};
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
Definition table3d.h:79

◆ 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

Typedef Documentation

◆ table3d_axis_t

using table3d_axis_t = uint8_t

The type of each axis value.

◆ table3d_dim_t

using table3d_dim_t = uint8_t

Encodes the length of the axes.

◆ table3d_value_t

using table3d_value_t = uint8_t

The type of each table value.

Enumeration Type Documentation

◆ AxisDomain

enum class AxisDomain : uint8_t
strong

Encodes the real world measurement that a table axis captures.

Enumerator
Rpm 

RPM (engine speed)

Load 

Load

◆ TableType

enum class TableType : uint8_t
strong

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 

Function Documentation

◆ 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_GEN_TYPE_INNER ( ,
Rpm  ,
Load  ,
TABLE3D_TYPENAME_BASE(6, Rpm, Load  
)

◆ TABLE3D_TYPENAME_BASE() [1/3]

TABLE3D_TYPENAME_BASE ( 16  ,
Rpm  ,
Load   
) const

◆ TABLE3D_TYPENAME_BASE() [2/3]

TABLE3D_TYPENAME_BASE ( ,
Rpm  ,
Load   
)

◆ TABLE3D_TYPENAME_BASE() [3/3]

TABLE3D_TYPENAME_BASE ( ,
Rpm  ,
Load   
)

Variable Documentation

◆ Load

Load

◆ noexcept

const uint16_t const uint16_t x noexcept
Initial value:
{
constexpr uint16_t xFactor = getConversionFactor(TTable::XDomain)
static constexpr uint16_t getConversionFactor(AxisDomain domain)
Definition table3d_axes.h:24

◆ Rpm

Rpm

◆ y

const uint16_t y

◆ yFactor

constexpr uint16_t yFactor = getConversionFactor(TTable::YDomain)
constexpr