forked from trilu2000/NewAskSin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfButton.h
70 lines (52 loc) · 2.84 KB
/
ConfButton.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin driver implementation
// 2013-08-03 <[email protected]> Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
//- -----------------------------------------------------------------------------------------------------------------------
//- AskSin config key function --------------------------------------------------------------------------------------------
//- with a lot of support from martin876 at FHEM forum
//- -----------------------------------------------------------------------------------------------------------------------
#ifndef _CB_H
#define _CB_H
#include "HAL.h"
// - scenario 00 ----------------------------
// no config button used
//
// - scenario 01 ----------------------------
// short press = pair
// long press = nothing
// double long = nothing
// double long release = reset
//
// - scenario 02 ----------------------------
// short press = toggle channel one
// long press = pair
// double long = nothing
// double long release = reset
//
// if 0x18 localResDis available, take care of it and enable or disable double long
class CB {
friend class AS;
public: //---------------------------------------------------------------------------------------------------------
protected: //---------------------------------------------------------------------------------------------------------
private: //---------------------------------------------------------------------------------------------------------
class AS *pHM; // pointer to main class for function calls
public: //---------------------------------------------------------------------------------------------------------
uint8_t scn :3; // scenario indicator
uint8_t btn :3; // result of chkPCINT
uint8_t armFlg :1; // armed flag, will be set on first touch
uint8_t lstLng :1; // remember a long press
uint8_t lngRpt :1; // remember last key press to detect double or long
uint8_t dblLng :1; // check for a double long
uint8_t lstSht :1; // remember that last key was a short
uint8_t pciByte; // PCI byte, indicate interrupt channel
uint8_t pciBit; // PCI bit indicate bit number in PCI channel byte
public: //---------------------------------------------------------------------------------------------------------
void config(uint8_t mode, uint8_t pcIntByte, uint8_t pcIntBit);
protected: //---------------------------------------------------------------------------------------------------------
private: //---------------------------------------------------------------------------------------------------------
CB();
void init(AS *ptrMain);
void poll(void);
void outSignal(uint8_t mode);
};
#endif