2020-09-30 11:44:05 +08:00
|
|
|
#ifndef _PARAM_MGR_H_
|
|
|
|
|
#define _PARAM_MGR_H_
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2020-12-20 15:19:07 +08:00
|
|
|
#include <stdbool.h>
|
2020-09-30 11:44:05 +08:00
|
|
|
|
|
|
|
|
typedef enum PARAM_TYPE
|
|
|
|
|
{
|
|
|
|
|
PARAM_TYPE_UINT8 = 1, /* 8-bit unsigned integer | */
|
|
|
|
|
PARAM_TYPE_INT8 = 2, /* 8-bit signed integer | */
|
|
|
|
|
PARAM_TYPE_UINT16 = 3, /* 16-bit unsigned integer | */
|
|
|
|
|
PARAM_TYPE_INT16 = 4, /* 16-bit signed integer | */
|
|
|
|
|
PARAM_TYPE_UINT32 = 5, /* 32-bit unsigned integer | */
|
|
|
|
|
PARAM_TYPE_INT32 = 6, /* 32-bit signed integer | */
|
|
|
|
|
PARAM_TYPE_UINT64 = 7, /* 64-bit unsigned integer | */
|
|
|
|
|
PARAM_TYPE_INT64 = 8, /* 64-bit signed integer | */
|
|
|
|
|
PARAM_TYPE_REAL32 = 9, /* 32-bit floating-point | */
|
|
|
|
|
PARAM_TYPE_REAL64 = 10, /* 64-bit floating-point | */
|
|
|
|
|
PARAM_TYPE_ENUM_END = 11, /* | */
|
|
|
|
|
} PARAM_TYPE;
|
|
|
|
|
|
|
|
|
|
typedef union param_value_ptr {
|
|
|
|
|
double *d;
|
|
|
|
|
float *s;
|
|
|
|
|
uint32_t *I;
|
|
|
|
|
int32_t *i;
|
|
|
|
|
uint16_t *H;
|
|
|
|
|
int16_t *h;
|
|
|
|
|
uint8_t *B;
|
|
|
|
|
int8_t *b;
|
|
|
|
|
} param_value_ptr_t;
|
|
|
|
|
|
|
|
|
|
typedef void (*param_getter)(param_value_ptr_t);
|
|
|
|
|
typedef void (*param_setter)(param_value_ptr_t);
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
char name[16];
|
|
|
|
|
param_value_ptr_t val_ptr;
|
|
|
|
|
param_getter getter_ptr;
|
|
|
|
|
param_setter setter_ptr;
|
|
|
|
|
PARAM_TYPE typ;
|
|
|
|
|
} param_prop;
|
|
|
|
|
|
|
|
|
|
int param_mgr_regist(param_prop *prop);
|
|
|
|
|
|
|
|
|
|
param_prop *param_get_by_idx(uint16_t idx);
|
|
|
|
|
uint16_t param_get_count(void);
|
|
|
|
|
|
|
|
|
|
int16_t param_get_idx_by_name(const char name[16]);
|
|
|
|
|
param_prop *param_get_by_name(const char name[16]);
|
|
|
|
|
|
|
|
|
|
void param_get_value(param_prop *prop, uint8_t value[4]);
|
|
|
|
|
void param_set_value(param_prop *prop, const uint8_t value[4]);
|
|
|
|
|
|
2020-12-20 15:19:07 +08:00
|
|
|
bool restore_param(void);
|
|
|
|
|
bool save_param(void);
|
|
|
|
|
bool param_save(int16_t i, param_prop *p);
|
|
|
|
|
|
2020-09-30 11:44:05 +08:00
|
|
|
#endif /* _PARAM_MGR_H_ */
|