2013-02-04 13:05:35 -08:00
/*
This file is used for everything related to maps / tables including their definition , functions etc
*/
2015-02-14 05:11:43 -08:00
# ifndef TABLE_H
# define TABLE_H
2014-01-07 00:01:14 -08:00
2016-10-26 14:48:44 -07:00
# define TABLE_RPM_MULTIPLIER 100
2017-01-16 15:51:53 -08:00
# define TABLE_LOAD_MULTIPLIER 2
2016-10-26 14:48:44 -07:00
2014-05-12 04:27:22 -07:00
/*
The 2 D table can contain either 8 - bit ( byte ) or 16 - bit ( int ) values
The valueSize variable should be set to either 8 or 16 to indicate this BEFORE the table is used
*/
2014-02-26 18:26:04 -08:00
struct table2D {
2017-03-29 06:01:52 -07:00
byte valueSize ;
2014-02-26 20:17:14 -08:00
byte xSize ;
2017-03-29 06:01:52 -07:00
2014-02-26 18:26:04 -08:00
byte * values ;
2014-02-26 20:17:14 -08:00
byte * axisX ;
2017-03-29 06:01:52 -07:00
2018-01-27 03:14:11 -08:00
int16_t * values16 ;
int16_t * axisX16 ;
2017-03-29 06:01:52 -07:00
2015-06-05 01:02:47 -07:00
//Store the last X and Y coordinates in the table. This is used to make the next check faster
2018-01-27 03:14:11 -08:00
int16_t lastXMax ;
int16_t lastXMin ;
2018-01-23 17:05:50 -08:00
//Store the last input and output for caching
2018-01-27 03:14:11 -08:00
int16_t lastInput ;
int16_t lastOutput ;
2018-02-04 23:05:36 -08:00
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.
2014-01-07 00:01:14 -08:00
} ;
2019-01-22 15:05:14 -08:00
//void table2D_setSize(struct table2D targetTable, byte newSize);
void table2D_setSize ( struct table2D , byte ) ;
2014-02-26 18:26:04 -08:00
2014-01-07 00:01:14 -08:00
struct table3D {
2017-03-29 06:01:52 -07:00
2013-02-04 13:05:35 -08:00
//All tables must be the same size for simplicity
2017-03-29 06:01:52 -07:00
2015-09-17 22:06:21 -07:00
byte xSize ;
byte ySize ;
2017-03-29 06:01:52 -07:00
2015-09-17 22:06:21 -07:00
byte * * values ;
2018-01-27 03:14:11 -08:00
int16_t * axisX ;
int16_t * axisY ;
2017-03-29 06:01:52 -07:00
2015-06-04 04:54:11 -07:00
//Store the last X and Y coordinates in the table. This is used to make the next check faster
byte lastXMax , lastXMin ;
byte lastYMax , lastYMin ;
2013-02-04 13:05:35 -08:00
} ;
2019-01-22 15:05:14 -08:00
//void table3D_setSize(struct table3D *targetTable, byte);
2019-01-25 23:33:25 -08:00
void table3D_setSize ( struct table3D * targetTable , byte ) ;
2015-09-17 22:06:21 -07:00
2013-02-05 00:27:06 -08:00
/*
2014-01-07 00:01:14 -08:00
3 D Tables have an origin ( 0 , 0 ) in the top left hand corner . Vertical axis is expressed first .
2013-02-05 00:27:06 -08:00
Eg : 2 x2 table
- - - - -
| 2 7 |
| 1 4 |
- - - - -
( 0 , 1 ) = 7
( 0 , 0 ) = 2
( 1 , 0 ) = 1
*/
2015-06-04 04:54:11 -07:00
int get3DTableValue ( struct table3D * fromTable , int , int ) ;
2015-06-05 01:02:47 -07:00
int table2D_getValue ( struct table2D * fromTable , int ) ;
2015-02-14 05:11:43 -08:00
# endif // TABLE_H