-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtm_switch_matrix.hpp
89 lines (77 loc) · 3.38 KB
/
Atm_switch_matrix.hpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
// EVT_START toevoegen om in stijl te blijven met Atm_timer e.d.???
#include <Automaton.h>
#include "Atm_device.hpp"
#include "Atm_led_matrix.hpp"
#include "Symbolic_Machine.hpp"
#define MAX_SWITCHES 320
#define DYNAMIC_ELEMENTS
#define STARTUP_DELAY_MS 500
#define ATMSM_TRACE_PRESS 1
#define ATMSM_TRACE_RELEASE 2
class Atm_device;
struct switch_record {
int8_t device_index;
#ifdef DYNAMIC_ELEMENTS
Atm_device *device;
#else
Atm_device device;
#endif
};
class Atm_switch_matrix: public Symbolic_Machine {
public:
enum { IDLE, WAIT, SCAN, DISABLED, READY, INIT };
enum { EVT_DISABLE, EVT_ENABLE, EVT_TIMER, EVT_READY, EVT_INIT, ELSE }; // EVENTS
Atm_switch_matrix( void ) : Symbolic_Machine() {};
Atm_switch_matrix& begin( IO& io, Atm_led_matrix& leds );
Atm_switch_matrix& trace( Stream & stream );
Atm_switch_matrix& trace( void );
Atm_switch_matrix& traceSwitches( Stream & stream, uint8_t bitmap = 1 );
Atm_switch_matrix& traceSwitches( Stream* stream, uint8_t bitmap = 1 );
Atm_switch_matrix& trigger( int event );
int16_t index( int16_t swno, int16_t n );
int16_t count( int16_t swno );
int16_t exists( int16_t n );
int state( void );
bool isPressed( int16_t n );
Atm_switch_matrix& disable();
Atm_switch_matrix& enable();
bool enabled();
bool ready();
Atm_device& device( int16_t n, int16_t led_group = -1, int16_t* device_script = NULL,
int16_t r0 = 0, int16_t r1 = 0, int16_t r2 = 0, int16_t r3 = 0, int16_t r4 = 0, int16_t r5 = 0, int16_t r6 = 0, int16_t r7 = 0 );
Atm_device& device( const char dev_str[], int16_t led_group = -1, int16_t* device_script = NULL,
int16_t r0 = 0, int16_t r1 = 0, int16_t r2 = 0, int16_t r3 = 0, int16_t r4 = 0, int16_t r5 = 0, int16_t r6 = 0, int16_t r7 = 0 );
Atm_device& device( const char dev_str[], const char led_group_str[], int64_t code_pack,
int16_t r0 = 0, int16_t r1 = 0, int16_t r2 = 0, int16_t r3 = 0, int16_t r4 = 0, int16_t r5 = 0, int16_t r6 = 0, int16_t r7 = 0 );
Atm_switch_matrix& profile( int16_t n, int16_t press_ticks, int16_t release_ticks, int16_t throttle_ticks, int16_t separate_ticks );
Atm_switch_matrix& profile( const char* switch_group_str, int16_t press_ticks, int16_t release_ticks, int16_t throttle_ticks, int16_t separate_ticks );
Atm_switch_matrix& readProfiles( char label, const int16_t* profile_def );
Atm_device& link( const char src_str[], const char out_str[], const char dest_str[], const char in_str[] );
Atm_device& link( const char src_str[], const char out_str[], Symbolic_Machine& dest, const char in_str[] );
Atm_led_matrix* leds( void );
int16_t numberOfGroups( void );
Atm_switch_matrix& loadSymbols( const char switches[] );
Atm_switch_matrix& loadGroups( const char groups[] );
int64_t* codePack( int16_t idx );
switch_record prof[MAX_SWITCHES + 1 ];
protected:
enum { ENT_SCAN, ENT_DISABLED, ENT_READY, ENT_INIT }; // ACTIONS
char event_symbols[48] = "PF_DISABLE,PF_ENABLE,PF_TIMER,PF_READY,PF_INIT\n";
int event( int id );
void action( int id );
void scan_matrix( void );
int16_t* parseGroups( int16_t* group_def );
uint16_t numOfSwitches, numOfGroups;
int16_t* group_def;
bool active;
int8_t scan_col = 0;
Atm_led_matrix *pleds;
uint16_t global_last_kick;
atm_timer_millis timer;
bool pf_enabled = false;
IO *io;
uint8_t trace_switches = 0;
Stream* ts_stream;
uint8_t initialized = 0;
};