Skip to content
Snippets Groups Projects
Commit 0284a3c3 authored by Robert ter Vehn's avatar Robert ter Vehn
Browse files

Merged latest from sui77:master

parents b20216c2 c4ac5663
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
- Skineffect / http://forum.ardumote.com/viewtopic.php?f=2&t=46 - Skineffect / http://forum.ardumote.com/viewtopic.php?f=2&t=46
- Dominik Fischer / dom_fischer(at)web(dot)de - Dominik Fischer / dom_fischer(at)web(dot)de
- Frank Oltmanns / <first name>.<last name>(at)gmail(dot)com - Frank Oltmanns / <first name>.<last name>(at)gmail(dot)com
- Max Horn / max(at)quendi(dot)de
- Robert ter Vehn / <first name>.<last name>(at)gmail(dot)com
Project home: http://code.google.com/p/rc-switch/ Project home: https://github.com/sui77/rc-switch/
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
...@@ -48,7 +50,7 @@ typedef uint8_t byte; ...@@ -48,7 +50,7 @@ typedef uint8_t byte;
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif // Last line inside Raspberry Pi block #endif // Last line within Raspberry Pi block
#else #else
#include "WProgram.h" #include "WProgram.h"
#endif #endif
...@@ -64,12 +66,6 @@ typedef uint8_t byte; ...@@ -64,12 +66,6 @@ typedef uint8_t byte;
// We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync // We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync
#define RCSWITCH_MAX_CHANGES 67 #define RCSWITCH_MAX_CHANGES 67
#define PROTOCOL3_SYNC_FACTOR 71
#define PROTOCOL3_0_HIGH_CYCLES 4
#define PROTOCOL3_0_LOW_CYCLES 11
#define PROTOCOL3_1_HIGH_CYCLES 9
#define PROTOCOL3_1_LOW_CYCLES 6
class RCSwitch { class RCSwitch {
public: public:
...@@ -77,18 +73,18 @@ class RCSwitch { ...@@ -77,18 +73,18 @@ class RCSwitch {
void switchOn(int nGroupNumber, int nSwitchNumber); void switchOn(int nGroupNumber, int nSwitchNumber);
void switchOff(int nGroupNumber, int nSwitchNumber); void switchOff(int nGroupNumber, int nSwitchNumber);
void switchOn(char* sGroup, int nSwitchNumber); void switchOn(const char* sGroup, int nSwitchNumber);
void switchOff(char* sGroup, int nSwitchNumber); void switchOff(const char* sGroup, int nSwitchNumber);
void switchOn(char sFamily, int nGroup, int nDevice); void switchOn(char sFamily, int nGroup, int nDevice);
void switchOff(char sFamily, int nGroup, int nDevice); void switchOff(char sFamily, int nGroup, int nDevice);
void switchOn(char* sGroup, char* sDevice); void switchOn(const char* sGroup, const char* sDevice);
void switchOff(char* sGroup, char* sDevice); void switchOff(const char* sGroup, const char* sDevice);
void switchOn(char sGroup, int nDevice); void switchOn(char sGroup, int nDevice);
void switchOff(char sGroup, int nDevice); void switchOff(char sGroup, int nDevice);
void sendTriState(char* Code); void sendTriState(const char* Code);
void send(unsigned long Code, unsigned int length); void send(unsigned long Code, unsigned int length);
void send(char* Code); void send(const char* Code);
#if not defined( RCSwitchDisableReceiving ) #if not defined( RCSwitchDisableReceiving )
void enableReceive(int interrupt); void enableReceive(int interrupt);
...@@ -111,13 +107,27 @@ class RCSwitch { ...@@ -111,13 +107,27 @@ class RCSwitch {
#if not defined( RCSwitchDisableReceiving ) #if not defined( RCSwitchDisableReceiving )
void setReceiveTolerance(int nPercent); void setReceiveTolerance(int nPercent);
#endif #endif
struct HighLow {
byte high;
byte low;
};
struct Protocol {
int pulseLength;
HighLow syncFactor;
HighLow zero;
HighLow one;
};
void setProtocol(Protocol protocol);
void setProtocol(int nProtocol); void setProtocol(int nProtocol);
void setProtocol(int nProtocol, int nPulseLength); void setProtocol(int nProtocol, int nPulseLength);
private: private:
char* getCodeWordB(int nGroupNumber, int nSwitchNumber, boolean bStatus); char* getCodeWordB(int nGroupNumber, int nSwitchNumber, boolean bStatus);
char* getCodeWordA(char* sGroup, int nSwitchNumber, boolean bStatus); char* getCodeWordA(const char* sGroup, int nSwitchNumber, boolean bStatus);
char* getCodeWordA(char* sGroup, char* sDevice, boolean bStatus); char* getCodeWordA(const char* sGroup, const char* sDevice, boolean bStatus);
char* getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bStatus); char* getCodeWordC(char sFamily, int nGroup, int nDevice, boolean bStatus);
char* getCodeWordD(char group, int nDevice, boolean bStatus); char* getCodeWordD(char group, int nDevice, boolean bStatus);
void sendT0(); void sendT0();
...@@ -127,21 +137,19 @@ class RCSwitch { ...@@ -127,21 +137,19 @@ class RCSwitch {
void send1(); void send1();
void sendSync(); void sendSync();
void transmit(int nHighPulses, int nLowPulses); void transmit(int nHighPulses, int nLowPulses);
void transmit(HighLow pulses);
static char* dec2binWzerofill(unsigned long dec, unsigned int length);
static char* dec2binWcharfill(unsigned long dec, unsigned int length, char fill); static char* dec2binWcharfill(unsigned long dec, unsigned int length, char fill);
#if not defined( RCSwitchDisableReceiving ) #if not defined( RCSwitchDisableReceiving )
static void handleInterrupt(); static void handleInterrupt();
static bool receiveProtocol1(unsigned int changeCount); static bool receiveProtocol(const int p, unsigned int changeCount);
static bool receiveProtocol2(unsigned int changeCount);
static bool receiveProtocol3(unsigned int changeCount);
int nReceiverInterrupt; int nReceiverInterrupt;
#endif #endif
int nTransmitterPin; int nTransmitterPin;
int nPulseLength;
int nRepeatTransmit; int nRepeatTransmit;
char nProtocol;
Protocol protocol;
#if not defined( RCSwitchDisableReceiving ) #if not defined( RCSwitchDisableReceiving )
static int nReceiveTolerance; static int nReceiveTolerance;
...@@ -149,11 +157,12 @@ class RCSwitch { ...@@ -149,11 +157,12 @@ class RCSwitch {
static unsigned int nReceivedBitlength; static unsigned int nReceivedBitlength;
static unsigned int nReceivedDelay; static unsigned int nReceivedDelay;
static unsigned int nReceivedProtocol; static unsigned int nReceivedProtocol;
#endif const static unsigned int nSeparationLimit;
/* /*
* timings[0] contains sync timing, followed by a number of bits * timings[0] contains sync timing, followed by a number of bits
*/ */
static unsigned int timings[RCSWITCH_MAX_CHANGES]; static unsigned int timings[RCSWITCH_MAX_CHANGES];
#endif
}; };
......
...@@ -4,6 +4,9 @@ Use your Arduino or Raspberry Pi to operate remote radio controlled devices ...@@ -4,6 +4,9 @@ Use your Arduino or Raspberry Pi to operate remote radio controlled devices
##Download ##Download
https://github.com/sui77/rc-switch/releases/latest https://github.com/sui77/rc-switch/releases/latest
##Wiki
https://github.com/sui77/rc-switch/wiki
##Info ##Info
###Send RC codes ###Send RC codes
......
/* /*
Example for receiving Example for receiving
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
If you want to visualize a telegram copy the raw data and If you want to visualize a telegram copy the raw data and
paste it into http://test.sui.li/oszi/ paste it into http://test.sui.li/oszi/
...@@ -13,7 +13,7 @@ RCSwitch mySwitch = RCSwitch(); ...@@ -13,7 +13,7 @@ RCSwitch mySwitch = RCSwitch();
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
} }
void loop() { void loop() {
......
/* /*
Simple example for receiving Simple example for receiving
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
#include <RCSwitch.h> #include <RCSwitch.h>
...@@ -10,7 +10,7 @@ RCSwitch mySwitch = RCSwitch(); ...@@ -10,7 +10,7 @@ RCSwitch mySwitch = RCSwitch();
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on inerrupt 0 => that is pin #2 mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
} }
void loop() { void loop() {
......
/* /*
Example for different sending methods Example for different sending methods
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
......
/* /*
Example for outlets which are configured with a 10 pole DIP switch. Example for outlets which are configured with a 10 pole DIP switch.
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
#include <RCSwitch.h> #include <RCSwitch.h>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
the 10 pole dip switch sockets. It saves a lot of memory and thus might be the 10 pole dip switch sockets. It saves a lot of memory and thus might be
very useful to use with ATTinys :) very useful to use with ATTinys :)
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
int RCLpin = 7; int RCLpin = 7;
......
/* /*
Example for outlets which are configured with two rotary/sliding switches. Example for outlets which are configured with two rotary/sliding switches.
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
#include <RCSwitch.h> #include <RCSwitch.h>
......
/* /*
Example for Intertechno outlets Example for Intertechno outlets
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
#include <RCSwitch.h> #include <RCSwitch.h>
......
/* /*
Example for REV outlets (e.g. 8342L) Example for REV outlets (e.g. 8342L)
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
Need help? http://forum.ardumote.com Need help? http://forum.ardumote.com
*/ */
......
/* /*
A simple RCSwitch/Ethernet/Webserver demo A simple RCSwitch/Ethernet/Webserver demo
http://code.google.com/p/rc-switch/ https://github.com/sui77/rc-switch/
*/ */
#include <SPI.h> #include <SPI.h>
...@@ -79,7 +79,7 @@ void httpResponseHome(EthernetClient c) { ...@@ -79,7 +79,7 @@ void httpResponseHome(EthernetClient c) {
c.println( "<li><a href=\"./?2-off\">Switch #2 off</a></li>"); c.println( "<li><a href=\"./?2-off\">Switch #2 off</a></li>");
c.println( "</ul>"); c.println( "</ul>");
c.println( "<hr>"); c.println( "<hr>");
c.println( "<a href=\"http://code.google.com/p/rc-switch/\">http://code.google.com/p/rc-switch/</a>"); c.println( "<a href=\"https://github.com/sui77/rc-switch/\">https://github.com/sui77/rc-switch/</a>");
c.println("</body>"); c.println("</body>");
c.println("</html>"); c.println("</html>");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment