File syn_lut.h¶
FileList > src > syntropic > util > syn_lut.h
Go to the source code of this file
Lookup table with linear interpolation. More...
#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_LUT_Entry Lookup table entry (x, y pair). |
Public Static Functions¶
| Type | Name |
|---|---|
| int32_t | syn_lut_forward (const SYN_LUT_Entry * table, size_t count, int32_t x) Look up y for a given x, with linear interpolation. |
| int32_t | syn_lut_reverse (const SYN_LUT_Entry * table, size_t count, int32_t y) Look up x for a given y, with linear interpolation. |
Detailed Description¶
For calibration curves, thermistor tables, transfer functions, etc. The table is a const array of (x, y) pairs, sorted by ascending x. Lookups interpolate linearly between the two nearest entries.
Header-only — integer math, no floating point.
** **
static const SYN_LUT_Entry thermistor_table[] = {
{ 0, 3300 }, // 0°C → 3300 ADC counts
{ 25, 2048 },
{ 50, 1200 },
{ 100, 400 },
};
int32_t temp = syn_lut_lookup(thermistor_table, 4, adc_value);
// Returns interpolated x for a given y
int32_t adc = syn_lut_forward(thermistor_table, 4, 37);
// Returns interpolated y for a given x (37°C)
Public Static Functions Documentation¶
function syn_lut_forward¶
Look up y for a given x, with linear interpolation.
Table must be sorted by ascending x. Values outside the table range are clamped to the nearest endpoint.
Parameters:
tableArray of (x, y) entries.countNumber of entries.xInput value.
Returns:
Interpolated y.
function syn_lut_reverse¶
Look up x for a given y, with linear interpolation.
The y column can be monotonically increasing OR decreasing. Values outside the table range are clamped.
Parameters:
tableArray of (x, y) entries, sorted by ascending x.countNumber of entries.yInput value (in the y domain).
Returns:
Interpolated x.
The documentation for this class was generated from the following file src/syntropic/util/syn_lut.h