-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpotiMapper.h
54 lines (48 loc) · 1.32 KB
/
potiMapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef POTIMAPPER_H
#define POTIMAPPER_H
class potiMapper {
public:
~potiMapper();
void init( int in_min,
int in_max,
float out_min,
float out_max,
unsigned int in_th,
float out_offset,
void (*read_cb)(int *),
void (*write_cb)(float *, int *),
bool enableFilter = true
);
void setWrite_cb(void (*cb)(float *, int *));
void setRead_cb(void (*cb)(int *));
void setInRange(int min, int max);
void setOutRange(float min, float max);
void setInThreshold(unsigned int th);
void setOutOffset(float offset);
void setFilterAlpha(float alpha);
void setFilterEnable(bool enable);
float getOutVal(void);
int getInVal(void);
float getSlope(void);
int getInThreshold(void);
float getOutOffset(void);
float getFilterAlpha(void);
bool getFilterEnable(void);
void update(void);
float maptofloat(int x);
protected:
void (*_write_cb)(float *, int *);
void (*_read_cb)(int *);
float _val_f = 0.0f;
int _val_i = 0;
float _in_min;
float _in_max;
float _out_min;
float _out_max;
int _in_th;
float _out_offset;
float _slope;
bool _enableFilter = false;
float _alpha = 0.7f;
};
#endif