forked from tinkerspy/Automaton
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtm_comparator.h
More file actions
executable file
·43 lines (32 loc) · 1.2 KB
/
Atm_comparator.h
File metadata and controls
executable file
·43 lines (32 loc) · 1.2 KB
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
#ifndef Atm_comparator_h
#define Atm_comparator_h
#include <Automaton.h>
typedef void (*triggercb_t)( int v, int up, int idx_threshold, int v_threshold );
class Atm_comparator: public Machine {
public:
Atm_comparator( void ) : Machine() { class_label = "CMP"; };
short pin;
atm_timer_millis timer;
int v_sample, v_threshold, v_previous;
uint64_t bitmap_sample, bitmap_previous, bitmap_diff;
uint16_t * p_threshold; // Max 64 values
uint16_t p_threshold_size;
uint16_t * avg_buf;
uint16_t avg_buf_size;
uint16_t avg_buf_head;
uint32_t avg_buf_total;
void (*callback)( int v, int up, int idx_threshold, int v_threshold ) = 0;
enum { IDLE, SAMPLE, SEND } STATES;
enum { EVT_TRIGGER, EVT_TIMER, ELSE } EVENTS;
enum { ACT_SAMPLE, ACT_SEND } ACTIONS;
Atm_comparator & begin( int attached_pin, int blinkrate, triggercb_t callback );
Atm_comparator & threshold( uint16_t * v, uint16_t size, bool catchUp=false );
Atm_comparator & average( uint16_t * v, uint16_t size );
int _avg();
Atm_comparator & bitmap( int v );
int sample();
virtual int read_sample();
int event( int id );
void action( int id );
};
#endif