-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathIHCInput.h
92 lines (70 loc) · 2.17 KB
/
IHCInput.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
(C) 2015 dingus.dk J.Ø.N.
This file is part of ArduinoIHC.
ArduinoIHC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ArduinoIHC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ArduinoIHC. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------------
The IHCinput class simulates an IHC input module.
To make the code footprint smaller you can define the following to remove
features
#define IHCINPUT_NO_CALLBACK
This will remove function for callback on change
#define IHCINPUT_NO_MULTIPORTSUPPORT
Multiport support is only suppoted using the PinChangeInt library
#define IHC_USEPINCHANGEINT
This will use the PinChangeInt library
Also note the defines in PinChangeInt.h:
#define NO_PORT?_PINCHANGE
*/
#ifndef _ihcinput_h
#define _ihcinput_h
#define IHC_USEPINCHANGEINT
#ifdef ESP8266
#define IHCINPUT_NO_MULTIPORTSUPPORT
#endif
#ifndef IHC_USEPINCHANGEINT
#define IHCINPUT_NO_MULTIPORTSUPPORT
#endif
class IHCinput {
protected:
byte pin;
volatile unsigned long startpulse;
volatile unsigned long endpulse;
volatile short int dataline;
volatile byte input;
volatile byte newinput;
volatile byte parity;
volatile byte changemask;
#ifndef IHCINPUT_NO_MULTIPORTSUPPORT
IHCinput* pNext;
#endif
static IHCinput* pTheFirst;
#ifdef ESP8266
static void ICACHE_RAM_ATTR _PinChangeInterrupt();
#else
static void _PinChangeInterrupt();
#endif
void PinChangeInterrupt( byte pinstate);
#ifndef IHCINPUT_NO_CALLBACK
/*
Callback when output changes.
This it from the interrupt - do NOT make code running too long
*/
virtual void OnChange(byte changemask, byte data);
#endif
public:
IHCinput();
void Begin( int pin);
bool GetData(int channel);
byte GetInput();
byte GetChangeMask();
};
#endif