2013-02-04 13:05:35 -08:00
|
|
|
/*
|
|
|
|
This file is used for everything related to maps/tables including their definition, functions etc
|
|
|
|
*/
|
2013-07-09 05:12:35 -07:00
|
|
|
#include <Arduino.h>
|
2014-01-07 00:01:14 -08:00
|
|
|
|
2014-05-12 04:27:22 -07:00
|
|
|
/*
|
|
|
|
The 2D 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 {
|
2014-05-12 04:27:22 -07:00
|
|
|
byte valueSize;
|
2014-02-26 20:17:14 -08:00
|
|
|
byte xSize;
|
2014-01-07 00:01:14 -08:00
|
|
|
|
2014-02-26 18:26:04 -08:00
|
|
|
byte *values;
|
2014-02-26 20:17:14 -08:00
|
|
|
byte *axisX;
|
2014-05-12 04:27:22 -07:00
|
|
|
|
|
|
|
int *values16;
|
|
|
|
int *axisX16;
|
2014-01-07 00:01:14 -08:00
|
|
|
};
|
|
|
|
|
2014-02-26 18:26:04 -08:00
|
|
|
void table2D_setSize(struct table2D targetTable, byte newSize);
|
|
|
|
|
2014-01-07 00:01:14 -08:00
|
|
|
struct table3D {
|
2013-02-04 13:05:35 -08:00
|
|
|
//All tables must be the same size for simplicity
|
2013-07-16 05:29:17 -07:00
|
|
|
const static byte xSize = 8;
|
|
|
|
const static byte ySize = 8;
|
2013-02-04 13:05:35 -08:00
|
|
|
|
2013-07-09 05:12:35 -07:00
|
|
|
byte values[ySize][xSize];
|
2013-02-10 16:34:30 -08:00
|
|
|
int axisX[xSize];
|
|
|
|
int axisY[ySize];
|
2013-02-04 13:05:35 -08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-02-05 00:27:06 -08:00
|
|
|
/*
|
2014-01-07 00:01:14 -08:00
|
|
|
3D 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: 2x2 table
|
|
|
|
-----
|
|
|
|
|2 7|
|
|
|
|
|1 4|
|
|
|
|
-----
|
|
|
|
|
|
|
|
(0,1) = 7
|
|
|
|
(0,0) = 2
|
|
|
|
(1,0) = 1
|
|
|
|
|
|
|
|
*/
|
2014-01-07 00:01:14 -08:00
|
|
|
int get3DTableValue(struct table3D, int, int);
|
2014-02-26 18:26:04 -08:00
|
|
|
int table2D_getValue(struct table2D, int);
|