Speeduino
Loading...
Searching...
No Matches
table3d.h
Go to the documentation of this file.
1
46#pragma once
47
48#include "table3d_interpolate.h"
49#include "table3d_axes.h"
50#include "table3d_values.h"
51
52#define TO_TYPE_KEY(size, xDom, yDom) table3d ## size ## xDom ## yDom ## _key
53
69enum class TableType : uint8_t {
72 #define TABLE3D_GEN_TYPEKEY(size, xDom, yDom) TO_TYPE_KEY(size, xDom, yDom),
73 TABLE3D_GENERATOR(TABLE3D_GEN_TYPEKEY)
75};
76
77// A marker type for 3d tables.
79{
80};
81
82// Generate the 3D table types
83#define TABLE3D_GEN_TYPE(size, xDom, yDom) \
84 \
85 struct TABLE3D_TYPENAME_BASE(size, xDom, yDom) : public table3d_t \
86 { \
87 typedef TABLE3D_TYPENAME_AXIS(size) xaxis_t; \
88 typedef TABLE3D_TYPENAME_AXIS(size) yaxis_t; \
89 typedef TABLE3D_TYPENAME_VALUE(size, xDom, yDom) value_t; \
90 /* This will take up zero space unless we take the address somewhere */ \
91 static constexpr TableType type_key = TableType::TO_TYPE_KEY(size, xDom, yDom); \
92 static constexpr AxisDomain XDomain = AxisDomain::xDom; \
93 static constexpr AxisDomain YDomain = AxisDomain::yDom; \
94 \
95 mutable table3DGetValueCache get_value_cache; \
96 value_t values; \
97 xaxis_t axisX; \
98 yaxis_t axisY; \
99 };
100// LCOV_EXCL_START
101TABLE3D_GENERATOR(TABLE3D_GEN_TYPE)
102// LCOV_EXCL_STOP
103
104// Generate get3DTableValue() functions
105#define TABLE3D_GEN_GET_TABLE_VALUE(size, xDom, yDom) \
106 static inline table3d_value_t get3DTableValue(const TABLE3D_TYPENAME_BASE(size, xDom, yDom) *pTable, const uint16_t y, const uint16_t x) \
107 { \
108 constexpr uint16_t xFactor = getConversionFactor(AxisDomain::xDom); \
109 constexpr uint16_t yFactor = getConversionFactor(AxisDomain::yDom); \
110 return get3DTableValue<xFactor, yFactor>( &pTable->get_value_cache, \
111 TABLE3D_TYPENAME_BASE(size, xDom, yDom)::value_t::row_size, \
112 pTable->values.values, \
113 pTable->axisX.axis, \
114 pTable->axisY.axis, \
115 { x, y }); \
116 }
117// LCOV_EXCL_START
118TABLE3D_GENERATOR(TABLE3D_GEN_GET_TABLE_VALUE)
119// LCOV_EXCL_STOP
120
121// =============================== Table function calls =========================
122
124
126
128
130
132
Iterate over table axis elements.
Definition table3d_axes.h:31
Iterate through a tables values, row by row.
Definition table3d_values.h:87
static TIntegral readSerialIntegralTimeout(void)
Reads an integral type, timing out if necessary.
Definition comms.cpp:175
table_axis_iterator y_rbegin(table3d_t *pTable, TableType key)
Definition table3d.cpp:76
table_axis_iterator x_rbegin(table3d_t *pTable, TableType key)
Definition table3d.cpp:45
TableType
Table type identifiers. Limited compile time RTTI.
Definition table3d.h:69
table_axis_iterator x_begin(table3d_t *pTable, TableType key)
Definition table3d.cpp:29
table_value_iterator rows_begin(table3d_t *pTable, TableType key)
Definition table3d.cpp:14
table_axis_iterator y_begin(table3d_t *pTable, TableType key)
Definition table3d.cpp:60
Definition table3d.h:79
3D table axis types and iterators
Functions for interpolating values from 3D tables.
3D table value structs and iterators