forked from landru29/HomeEasyByNoopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomeEasyByNoopy.h
69 lines (56 loc) · 2.06 KB
/
HomeEasyByNoopy.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
#ifndef HomeEasyByNoopy_h
#define HomeEasyByNoopy_h
#define HE_ON 1
#define HE_OFF 0
#define HE_OPEN 1
#define HE_CLOSE 0
#define HE_GLOBAL 1
#define HE_NOT_GLOBAL 0
#define HE_DEVICE_1 0x00
#define HE_DEVICE_2 0x01
#define HE_DEVICE_3 0x02
#define HE_DEVICE_4 0x03
#define HE_DEVICE_A 0x00
#define HE_DEVICE_B 0x04
#define HE_DEVICE_C 0x08
#define HE_DEVICE_D 0x0c
#define HE_DEVICE_G 0x10
#include "Arduino.h"
typedef void (* HomeEasyByNoopyReceiver)(unsigned long controller, unsigned int device, unsigned char onOff);
class HomeEasyByNoopy
{
public:
HomeEasyByNoopy (int pinOut, int pinIn, HomeEasyByNoopyReceiver receiverHandler);
void emit (unsigned long controller, unsigned char device, bool onOff);
void setEmitFrameCount(int count);
void EnableRead(unsigned char onOffState);
unsigned char getReceiveCommand(unsigned long* controller, unsigned int* device, unsigned char* onOff);
void setReceiver(HomeEasyByNoopyReceiver receiverHandler);
static unsigned long getRaw();
private :
int _pinOut;
int _count;
void startEndFrame();
void startEmit();
static unsigned int getTimer();
static void decodereceive_command(unsigned long _receive_command);
static void process();
void setListenPin(int pin);
static void setBit(int* framePart, bool state);
void buildFrame(int* frame, unsigned long controller, unsigned char device, bool onOff);
void sendFrame(int* frame, int count);
static int receive_pin;
static unsigned char receive_isSignal;
static unsigned char receive_flags[2];
static unsigned long receive_command[2];
static unsigned char receive_commandCursor;
static unsigned long receive_controller;
static unsigned int receive_device;
static unsigned char receive_onOff;
static unsigned char receive_global;
static unsigned long receive_commandFrame;
static unsigned char receive_sreg;
static HomeEasyByNoopyReceiver receive_handler;
static unsigned char receive_disabled;
};
#endif /* HomeEasyByNoopy_h */