-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Header for lookup tables (LUTs) Defines structures and whatnot for LUT code.
- Loading branch information
1 parent
a1eb13a
commit 8198942
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* lookup_tables.h | ||
* | ||
* Created on: Nov. 17, 2023 | ||
* Author: Kenneth | ||
*/ | ||
|
||
#pragma once | ||
|
||
|
||
typedef enum { | ||
SCALE_TYPE_INT8 = 0, | ||
SCALE_TYPE_INT16 | ||
} scaleType_e; | ||
|
||
|
||
//Handle circular reference. Reason explained below | ||
typedef struct scale_t scale_t; | ||
typedef struct scale_result_t scale_result_t; | ||
|
||
typedef struct scale_functions { | ||
int (*Compare)(const void *, const void *); | ||
void (*SetValue)(const void *, const void *); | ||
void * (*GetArrayValue)(void * data, uint8_t index); | ||
void (*MapValue)(void * result, void * source, void * sourceLow, void * sourceHigh, void * mapLow, void * mapHigh); | ||
} scale_functions_t; | ||
|
||
//contains snapshot of scaling action given specified source value | ||
//Thus actual scaling can be asyncronous to source value updates | ||
// if *scale->SourceValue == result.ScaledValue, no need to re-scale. | ||
// | ||
// | ||
struct scale_result_t { | ||
scale_t * Scale; | ||
uint8_t IndexHigh; | ||
uint8_t IndexLow; | ||
void * ScaledValue; | ||
}; | ||
|
||
// Defnies the | ||
struct scale_t { | ||
scaleType_e Type; | ||
scale_result_t * Result; | ||
void * SourceValue; | ||
uint8_t Length; | ||
void * Data; | ||
}; | ||
|
||
typedef struct { | ||
uint8_t Dimensions; | ||
void * Adder; | ||
scale_result_t * ScaledValue; | ||
void * Data; | ||
} map_t; | ||
|
||
void Scale(scale_t * scale, scale_functions_t * functions); | ||
void MapLookup(map_t * map, void * result, scale_functions_t * functions); | ||
void __scale_t_SetResult(scale_t * scale, scale_result_t * result); | ||
void SetScaleFunctions_int(scale_functions_t * functions); |