Speeduino
Loading...
Searching...
No Matches
table2d.h
Go to the documentation of this file.
1/*
2This file is used for everything related to maps/tables including their definition, functions etc
3*/
4#ifndef TABLE_H
5#define TABLE_H
6
7#include "globals.h"
8
9#define SIZE_SIGNED_BYTE 4
10#define SIZE_BYTE 8
11#define SIZE_INT 16
12
13/*
14The 2D table can contain either 8-bit (byte) or 16-bit (int) values
15The valueSize variable should be set to either 8 or 16 to indicate this BEFORE the table is used
16*/
17struct table2D {
18 //Used 5414 RAM with original version
21 byte xSize;
22
23 void *values;
24 void *axisX;
25
26 //int16_t *values16;
27 //int16_t *axisX16;
28
29 //Store the last X and Y coordinates in the table. This is used to make the next check faster
32
33 //Store the last input and output for caching
36 byte cacheTime; //Tracks when the last cache value was set so it can expire after x seconds. A timeout is required to pickup when a tuning value is changed, otherwise the old cached value will continue to be returned as the X value isn't changing.
37};
38
45
48
49int table2D_getValue(struct table2D *fromTable, int X_in);
50
51#endif // TABLE_H
static uint32_t rshift(uint32_t a)
Bitwise right shift - generic, unoptimized, case.
Definition bit_shifts.h:349
Definition table2d.h:17
int16_t lastXMax
Definition table2d.h:30
byte xSize
Definition table2d.h:21
void * axisX
Definition table2d.h:24
int16_t lastXMin
Definition table2d.h:31
byte cacheTime
Definition table2d.h:36
byte valueSize
Definition table2d.h:19
int16_t lastOutput
Definition table2d.h:35
void * values
Definition table2d.h:23
int16_t lastInput
Definition table2d.h:34
byte axisSize
Definition table2d.h:20
void construct2dTable(table2D &table, uint8_t length, uint8_t *values, uint8_t *bins)
Definition table2d.cpp:27
int16_t table2D_getRawValue(struct table2D *fromTable, byte X_index)
Returns an value from the 2D table given an index value. No interpolation is performed.
Definition table2d.cpp:181
int16_t table2D_getAxisValue(struct table2D *fromTable, byte X_in)
Returns an axis (bin) value from the 2D table. This works regardless of whether that axis is bytes or...
Definition table2d.cpp:162
int table2D_getValue(struct table2D *fromTable, int X_in)
Definition table2d.cpp:61