turn off display before updating rows
[Arduino] / libraries / RCSwitch / RCSwitch.h
1 /*\r
2   RCSwitch - Arduino libary for remote control outlet switches\r
3   Copyright (c) 2011 Suat Özgür.  All right reserved.\r
4 \r
5   Contributors:\r
6   - Andre Koehler / info(at)tomate-online(dot)de\r
7   - Gordeev Andrey Vladimirovich / gordeev(at)openpyro(dot)com\r
8   - Dominik Fischer / dom_fischer(at)web(dot)de\r
9   \r
10   Project home: http://code.google.com/p/rc-switch/\r
11 \r
12   This library is free software; you can redistribute it and/or\r
13   modify it under the terms of the GNU Lesser General Public\r
14   License as published by the Free Software Foundation; either\r
15   version 2.1 of the License, or (at your option) any later version.\r
16 \r
17   This library is distributed in the hope that it will be useful,\r
18   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
19   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
20   Lesser General Public License for more details.\r
21 \r
22   You should have received a copy of the GNU Lesser General Public\r
23   License along with this library; if not, write to the Free Software\r
24   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
25 */\r
26 #ifndef _RCSwitch_h\r
27 #define _RCSwitch_h\r
28 \r
29 #if defined(ARDUINO) && ARDUINO >= 100\r
30     #include "Arduino.h"\r
31 #else\r
32     #include "WProgram.h"\r
33 #endif\r
34 \r
35 // Number of maximum High/Low changes per packet.\r
36 // We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync\r
37 #define RCSWITCH_MAX_CHANGES 67\r
38 \r
39 \r
40 class RCSwitch {\r
41 \r
42   public:\r
43     RCSwitch();\r
44     \r
45     void switchOn(int nGroupNumber, int nSwitchNumber);\r
46     void switchOff(int nGroupNumber, int nSwitchNumber);\r
47     void switchOn(char* sGroup, int nSwitchNumber);\r
48     void switchOff(char* sGroup, int nSwitchNumber);\r
49     void switchOn(char sFamily, int nGroup, int nDevice);\r
50     void switchOff(char sFamily, int nGroup, int nDevice);\r
51         void switchOn(char* sGroup, char* sDevice);\r
52         void switchOff(char* sGroup, char* sDevice);\r
53 \r
54     void sendTriState(char* Code);\r
55     void send(unsigned long Code, unsigned int length);\r
56     void send(char* Code);\r
57     \r
58     void enableReceive(int interrupt);\r
59     void enableReceive();\r
60     void disableReceive();\r
61     bool available();\r
62         void resetAvailable();\r
63         \r
64     unsigned long getReceivedValue();\r
65     unsigned int getReceivedBitlength();\r
66     unsigned int getReceivedDelay();\r
67         unsigned int getReceivedProtocol();\r
68     unsigned int* getReceivedRawdata();\r
69   \r
70     void enableTransmit(int nTransmitterPin);\r
71     void disableTransmit();\r
72     void setPulseLength(int nPulseLength);\r
73     void setRepeatTransmit(int nRepeatTransmit);\r
74     void setReceiveTolerance(int nPercent);\r
75         void setProtocol(int nProtocol);\r
76         void setProtocol(int nProtocol, int nPulseLength);\r
77   \r
78   private:\r
79     char* getCodeWordB(int nGroupNumber, int nSwitchNumber, boolean bStatus);\r
80     char* getCodeWordA(char* sGroup, int nSwitchNumber, boolean bStatus);\r
81     char* getCodeWordA(char* sGroup, char* sDevice, boolean bStatus);\r
82     char* getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bStatus);\r
83     void sendT0();\r
84     void sendT1();\r
85     void sendTF();\r
86     void send0();\r
87     void send1();\r
88     void sendSync();\r
89     void transmit(int nHighPulses, int nLowPulses);\r
90 \r
91     static char* dec2binWzerofill(unsigned long dec, unsigned int length);\r
92     \r
93     static void handleInterrupt();\r
94         static bool receiveProtocol1(unsigned int changeCount);\r
95         static bool receiveProtocol2(unsigned int changeCount);\r
96     int nReceiverInterrupt;\r
97     int nTransmitterPin;\r
98     int nPulseLength;\r
99     int nRepeatTransmit;\r
100         char nProtocol;\r
101 \r
102         static int nReceiveTolerance;\r
103     static unsigned long nReceivedValue;\r
104     static unsigned int nReceivedBitlength;\r
105         static unsigned int nReceivedDelay;\r
106         static unsigned int nReceivedProtocol;\r
107     static unsigned int timings[RCSWITCH_MAX_CHANGES];\r
108 \r
109     \r
110 };\r
111 \r
112 #endif\r