Browse Source

Imported external libraries not included in PlatformIO as submodules and linked from lib folder

fastled
Xose Pérez 8 years ago
parent
commit
9f02d95ed9
23 changed files with 22 additions and 936 deletions
  1. +12
    -0
      .gitmodules
  2. +0
    -1
      code/arduino/code/code.ino
  3. +0
    -1
      code/arduino/code/data
  4. +1
    -0
      code/lib/Embedis
  5. +1
    -0
      code/lib/EmonLiteESP
  6. +1
    -0
      code/lib/NoFUSSClient
  7. +1
    -0
      code/lib/RemoteSwitch
  8. +0
    -158
      code/lib/RemoteSwitch/RemoteReceiver.cpp
  9. +0
    -75
      code/lib/RemoteSwitch/RemoteReceiver.h
  10. +0
    -263
      code/lib/RemoteSwitch/RemoteSwitch.cpp
  11. +0
    -197
      code/lib/RemoteSwitch/RemoteSwitch.h
  12. +0
    -53
      code/lib/RemoteSwitch/examples/Light_show/Light_show.pde
  13. +0
    -58
      code/lib/RemoteSwitch/examples/Remote_translator/Remote_translator.pde
  14. +0
    -52
      code/lib/RemoteSwitch/examples/Retransmitter/Retransmitter.pde
  15. +0
    -39
      code/lib/RemoteSwitch/examples/Show_received_code/Show_received_code.pde
  16. +0
    -12
      code/lib/RemoteSwitch/keywords.txt
  17. +0
    -25
      code/lib/RemoteSwitch/license.txt
  18. +1
    -0
      code/lib/WProgram/WProgram.h
  19. +1
    -2
      code/src/rf.ino
  20. +1
    -0
      code/vendor/RemoteSwitch-arduino-library
  21. +1
    -0
      code/vendor/embedis
  22. +1
    -0
      code/vendor/emonliteesp
  23. +1
    -0
      code/vendor/nofuss

+ 12
- 0
.gitmodules View File

@ -0,0 +1,12 @@
[submodule "code/vendor/embedis"]
path = code/vendor/embedis
url = https://github.com/thingSoC/embedis.git
[submodule "code/vendor/nofuss"]
path = code/vendor/nofuss
url = git@bitbucket.org:xoseperez/nofuss.git
[submodule "code/vendor/emonliteesp"]
path = code/vendor/emonliteesp
url = git@bitbucket.org:xoseperez/emonliteesp.git
[submodule "code/vendor/RemoteSwitch-arduino-library"]
path = code/vendor/RemoteSwitch-arduino-library
url = https://github.com/jccprj/RemoteSwitch-arduino-library

+ 0
- 1
code/arduino/code/code.ino View File

@ -1 +0,0 @@
../../src/code.ino

+ 0
- 1
code/arduino/code/data View File

@ -1 +0,0 @@
../../data

+ 1
- 0
code/lib/Embedis View File

@ -0,0 +1 @@
../vendor/embedis/src

+ 1
- 0
code/lib/EmonLiteESP View File

@ -0,0 +1 @@
../vendor/emonliteesp/code/lib/EmonLiteESP

+ 1
- 0
code/lib/NoFUSSClient View File

@ -0,0 +1 @@
../vendor/nofuss/client/lib/NoFUSSClient

+ 1
- 0
code/lib/RemoteSwitch View File

@ -0,0 +1 @@
../vendor/RemoteSwitch-arduino-library

+ 0
- 158
code/lib/RemoteSwitch/RemoteReceiver.cpp View File

@ -1,158 +0,0 @@
/*
* RemoteSwitch library v2.0.0 made by Randy Simons http://randysimons.nl
* See RemoteSwitchSender.h for details.
*
* License: "Free BSD license". See license.txt
*/
#include "RemoteReceiver.h"
/************
* RemoteReceiver
************/
unsigned short RemoteReceiver::_interrupt;
volatile int RemoteReceiver::_state;
unsigned short RemoteReceiver::_minRepeats;
RemoteReceiverCallBack RemoteReceiver::_callback;
boolean RemoteReceiver::_inCallback = false;
void RemoteReceiver::init(unsigned short interrupt, unsigned short minRepeats, RemoteReceiverCallBack callback) {
_interrupt = interrupt;
_minRepeats = minRepeats;
_callback = callback;
//enable();
}
void RemoteReceiver::enable() {
_state = -1;
attachInterrupt(_interrupt, interruptHandler, CHANGE);
}
void RemoteReceiver::disable() {
detachInterrupt(_interrupt);
}
void RemoteReceiver::interruptHandler() {
static unsigned int period; //Calculated duration of 1 period
static unsigned short receivedBit; //Contains "bit" currently receiving
static unsigned long receivedCode; //Contains received code
static unsigned long previousCode; //Contains previous received code
static unsigned short repeats = 0; //The number of times the an identical code is received in a row.
static unsigned long lastChange=0; //Timestamp of previous edge
static unsigned int min1Period, max1Period, min3Period, max3Period;
unsigned long currentTime=micros();
unsigned int duration=currentTime-lastChange; //Duration = Time between edges
lastChange=currentTime;
if (_state==-1) { //Waiting for sync-signal
if (duration>3720) { //==31*120 minimal time between two edges before decoding starts.
//Sync signal received.. Preparing for decoding
period=duration/31;
receivedCode=previousCode=repeats=0;
//Allow for large error-margin. ElCheapo-hardware :(
min1Period=period*4/10; //Avoid floating point math; saves memory.
max1Period=period*16/10;
min3Period=period*23/10;
max3Period=period*37/10;
}
else {
return;
}
} else if (_state<48) { //Decoding message
//bit part durations can ONLY be 1 or 3 periods.
if (duration>=min1Period && duration<=max1Period) {
bitClear(receivedBit,_state%4); //Note: this sets the bits in reversed order! Correct order would be: 3-(_state%4), but that's overhead we don't want.
}
else if (duration>=min3Period && duration<=max3Period) {
bitSet(receivedBit,_state%4); //Note: this sets the bits in reversed order!
}
else { //Otherwise the entire sequence is invalid
_state=-1;
return;
}
if ((_state%4)==3) { //Last bit part?
//Shift
receivedCode*=3;
//Decode bit.
if (receivedBit==B1010) { //short long short long == B0101, but bits are set in reversed order, so compare to B1010
//bit "0" received
receivedCode+=0; //I hope the optimizer handles this ;)
}
else if (receivedBit==B0101) { //long short long short == B101, but bits are set in reversed order, so compare to B0101
//bit "1" received
receivedCode+=1;
}
else if (receivedBit==B0110) { //short long long short. Reversed too, but makes no difference.
//bit "f" received
receivedCode+=2;
}
else {
//Bit was rubbish. Abort.
_state=-1;
return;
}
}
} else if (_state==48) { //Waiting for sync bit part 1
//Must be 1 period.
if (duration<min1Period || duration>max1Period) {
_state=-1;
return;
}
} else { //Waiting for sync bit part 2
//Must be 31 periods.
if (duration<period*25 || duration>period*36) {
_state=-1;
return;
}
//receivedCode is a valid code!
if (receivedCode!=previousCode) {
repeats=0;
previousCode=receivedCode;
}
repeats++;
if (repeats>=_minRepeats) {
if (!_inCallback) {
_inCallback = true;
(_callback)(receivedCode, period);
_inCallback = false;
}
//Reset after callback.
_state=-1;
return;
}
//Reset for next round
receivedCode = 0;
_state=0; //no need to wait for another sync-bit!
return;
}
_state++;
return;
}
boolean RemoteReceiver::isReceiving(int waitMillis) {
unsigned long startTime=millis();
int waited; //signed int!
do {
if (_state!=-1) {
return true;
}
waited = (millis()-startTime);
} while(waited>=0 && waited <= waitMillis); //Yes, clock wraps every 50 days. And then you'd have to wait for a looooong time.
return false;
}

+ 0
- 75
code/lib/RemoteSwitch/RemoteReceiver.h View File

@ -1,75 +0,0 @@
/*
* RemoteSwitch library v2.0.0 made by Randy Simons http://randysimons.nl
*
* License: "Free BSD license". See license.txt
*/
#ifndef RemoteReceiver_h
#define RemoteReceiver_h
//#include "WProgram.h"
#include "Arduino.h"
typedef void (*RemoteReceiverCallBack)(unsigned long, unsigned int);
/**
* See RemoteSwitch for introduction.
*
* RemoteReceiver decodes the signal received from a 433MHz-receiver, like the "KlikAanKlikUit"-system
* as well as the signal sent by the RemoteSwtich class. When a correct signal is received,
* a user-defined callback function is called.
*
* Note that in the callback function, the interrupts are still disabled. You can enabled them, if needed.
* A call to the callback must b finished before RemoteReceiver will call the callback function again, thus
* there is no re-entrant problem.
*
* When sending your own code using RemoteSwich, disable() the receiver first.
*
* This is a pure static class, for simplicity and to limit memory-use.
*/
class RemoteReceiver {
public:
/**
* Initializes the decoder.
*
* @param interrupt The interrupt as is used by Arduino's attachInterrupt function. See attachInterrupt for details.
* @param minRepeats The number of times the same code must be received in a row before the callback is calles
* @param callback Pointer to a callback function, with signature void (*func)(unsigned long, unsigned int). First parameter is the decoded data, the second the period of the timing.
*/
static void init(unsigned short interrupt, unsigned short minRepeats, RemoteReceiverCallBack callback);
/**
* Enabled decoding. No need to call enable() after init().
*/
static void enable();
/**
* Disable decoding. You can enable decoding by calling enable();
*/
static void disable();
/**
* Tells wether a signal is being received. Since it makes no sense to transmit while another transmitter is active,
* it's best to wait for isReceiving() to false.
*
* Note: isReceiving() depends on interrupts enabled. Thus, when disabled()'ed, or when interrupts are disabled (as is
* the case in the callback), isReceiving() will not work properly.
* @param waitMillis number of milliseconds to monitor for signal.
* @return boolean If after waitMillis no signal was being processed, returns false. If before expiration a signal was being processed, returns true.
*/
static boolean isReceiving(int waitMillis = 50);
private:
static void interruptHandler();
static unsigned short _interrupt; //Radio input interrupt
volatile static int _state; //State of decoding process. There are 49 states, 1 for "waiting for signal" and 48 for decoding the 48 edges in a valid code.
static unsigned short _minRepeats;
static RemoteReceiverCallBack _callback;
static boolean _inCallback; //When true, the callback function is being executed; prevents re-entrance.
};
#endif

+ 0
- 263
code/lib/RemoteSwitch/RemoteSwitch.cpp View File

@ -1,263 +0,0 @@
/*
* RemoteSwitch library v2.0.0 made by Randy Simons http://randysimons.nl
* See RemoteSwitchSender.h for details.
*
* License: "Free BSD license". See license.txt
*/
#include "RemoteSwitch.h"
/************
* RemoteSwitch
************/
RemoteSwitch::RemoteSwitch(unsigned short pin, unsigned int periodusec, unsigned short repeats) {
_pin=pin;
_periodusec=periodusec;
_repeats=repeats;
pinMode(_pin, OUTPUT);
}
unsigned long RemoteSwitch::encodeTelegram(unsigned short trits[]) {
unsigned long data = 0;
//Encode data
for (unsigned short i=0;i<12;i++) {
data*=3;
data+=trits[i];
}
//Encode period duration
data |= (unsigned long)_periodusec << 23;
//Encode repeats
data |= (unsigned long)_repeats << 20;
return data;
}
void RemoteSwitch::sendTelegram(unsigned short trits[]) {
sendTelegram(encodeTelegram(trits),_pin);
}
/**
* Format data:
* pppppppp|prrrdddd|dddddddd|dddddddd (32 bit)
* p = perioud (9 bit unsigned int
* r = repeats as 2log. Thus, if r = 3, then signal is sent 2^3=8 times
* d = data
*/
void RemoteSwitch::sendTelegram(unsigned long data, unsigned short pin) {
unsigned int periodusec = (unsigned long)data >> 23;
unsigned short repeats = 1 << (((unsigned long)data >> 20) & B111);
data = data & 0xfffff; //truncate to 20 bit
//Convert the base3-code to base4, to avoid lengthy calculations when transmitting.. Messes op timings.
unsigned long dataBase4 = 0;
for (unsigned short i=0; i<12; i++) {
dataBase4<<=2;
dataBase4|=(data%3);
data/=3;
}
for (unsigned short int j=0;j<repeats;j++) {
//Sent one telegram
//Use data-var as working var
data=dataBase4;
for (unsigned short i=0; i<12; i++) {
switch (data & B11) {
case 0:
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec*3);
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec*3);
break;
case 1:
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec*3);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec);
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec*3);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec);
break;
case 2: //AKA: X or float
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec*3);
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec*3);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec);
break;
}
//Next trit
data>>=2;
}
//Send termination/synchronisation-signal. Total length: 32 periods
digitalWrite(pin, HIGH);
delayMicroseconds(periodusec);
digitalWrite(pin, LOW);
delayMicroseconds(periodusec*31);
}
}
boolean RemoteSwitch::isSameCode(unsigned long encodedTelegram, unsigned long receivedData) {
return (receivedData==(encodedTelegram & 0xFFFFF)); //Compare the 20 LSB's
}
/************
* ActionSwitch
************/
ActionSwitch::ActionSwitch(unsigned short pin, unsigned int periodusec) : RemoteSwitch(pin,periodusec,3) {
//Call contructor
}
void ActionSwitch::sendSignal(unsigned short systemCode, char device, boolean on) {
sendTelegram(getTelegram(systemCode,device,on), _pin);
}
unsigned long ActionSwitch::getTelegram(unsigned short systemCode, char device, boolean on) {
unsigned short trits[12];
device-=65;
for (unsigned short i=0; i<5; i++) {
//bits 0-4 contain address (2^5=32 addresses)
trits[i]=(systemCode & 1)?1:2;
systemCode>>=1;
//bits 5-9 contain device. Only one trit has value 0, others have 2 (float)!
trits[i+5]=(i==device?0:2);
}
//switch on or off
trits[10]=(!on?0:2);
trits[11]=(on?0:2);
return encodeTelegram(trits);
}
/************
* BlokkerSwitch
************/
BlokkerSwitch::BlokkerSwitch(unsigned short pin, unsigned int periodusec) : RemoteSwitch(pin,periodusec,3) {
//Call contructor
}
void BlokkerSwitch::sendSignal(unsigned short device, boolean on) {
sendTelegram(getTelegram(device,on), _pin);
}
unsigned long BlokkerSwitch::getTelegram(unsigned short device, boolean on) {
unsigned short trits[12]={0};
device--;
for (unsigned short i=1; i<4; i++) {
//Bits 1-3 contain device
trits[i]=(device & 1)?0:1;
device>>=1;
}
//switch on or off
trits[8]=(on?1:0);
return encodeTelegram(trits);
}
/************
* KaKuSwitch
************/
KaKuSwitch::KaKuSwitch(unsigned short pin, unsigned int periodusec) : RemoteSwitch(pin,periodusec,3) {
//Call contructor
}
void KaKuSwitch::sendSignal(char address, unsigned short device, boolean on) {
sendTelegram(getTelegram(address, device, on), _pin);
}
unsigned long KaKuSwitch::getTelegram(char address, unsigned short device, boolean on) {
unsigned short trits[12];
address-=65;
device-=1;
for (unsigned short i=0; i<4; i++) {
//bits 0-3 contain address (2^4 = 16 addresses)
trits[i]=(address & 1)?2:0;
address>>=1;
//bits 4-8 contain device (2^4 = 16 addresses)
trits[i+4]=(device & 1)?2:0;
device>>=1;
}
//bits 8-10 seem to be fixed
trits[8]=0;
trits[9]=2;
trits[10]=2;
//switch on or off
trits[11]=(on?2:0);
return encodeTelegram(trits);
}
void KaKuSwitch::sendSignal(char address, unsigned short group, unsigned short device, boolean on) {
sendTelegram(getTelegram(address, group, on), _pin);
}
unsigned long KaKuSwitch::getTelegram(char address, unsigned short group, unsigned short device, boolean on) {
unsigned short trits[12], i;
address-=65;
group-=1;
device-=1;
//address. M3E Pin A0-A3
for (i=0; i<4; i++) {
//bits 0-3 contain address (2^4 = 16 addresses)
trits[i]=(address & 1)?2:0;
address>>=1;
}
//device. M3E Pin A4-A5
for (; i<6; i++) {
trits[i]=(device & 1)?2:0;
device>>=1;
}
//group. M3E Pin A6-A7
for (; i<8; i++) {
trits[i]=(group & 1)?2:0;
group>>=1;
}
//bits 8-10 are be fixed. M3E Pin A8/D0-A10/D2
trits[8]=0;
trits[9]=2;
trits[10]=2;
//switch on or off, M3E Pin A11/D3
trits[11]=(on?2:0);
return encodeTelegram(trits);
}

+ 0
- 197
code/lib/RemoteSwitch/RemoteSwitch.h View File

@ -1,197 +0,0 @@
/*
* RemoteSwitch library v2.0.0 made by Randy Simons http://randysimons.nl
*
* License: "Free BSD license". See license.txt
*/
#ifndef RemoteSwitch_h
#define RemoteSwitch_h
//#include "WProgram.h"
#include "Arduino.h"
/**
* RemoteSwitch provides a generic class for simulation of common RF remote controls, like the 'Klik aan Klik uit'-system
* (http://www.klikaanklikuit.nl/), used to remotely switch lights etc.
*
* Many of these remotes seem to use a 433MHz SAW resonator and one of these chips: LP801B, HX2262, PT2262, M3E.
* Datasheet for the HX2262/PT2262 ICs:
* http://www.princeton.com.tw/downloadprocess/downloadfile.asp?mydownload=PT2262_1.pdf
*
* Hardware required for this library: a 433MHz SAW oscillator transmitter, e.g.
* http://www.sparkfun.com/commerce/product_info.php?products_id=7815
* http://www.conrad.nl/goto/?product=130428
*
* Notes:
* - Since these chips use (and send!) tri-state inputs (low, high and floating) I use 'trits' instead of 'bits',
* when appropriate.
* - I measured the period lengths with a scope. Thus: they work for my remotes, but may fail for yours...
* A better way would be to calculate the 'target'-timings using the datasheets and the resistor-values on the remotes.
*/
class RemoteSwitch {
public:
/**
* Constructor.
*
* To obtain the correct period length, an oscilloscope is convenient, but you can also read the
* datasheet of the transmitter, measure the resistor for the oscillator and calculate the freqency.
*
* @param pin output pin on Arduino to which the transmitter is connected
* @param periodsec [0..511] Duration of one period, in microseconds. A trit is 6 periods.
* @param repeats [0..7] The 2log-Number of times the signal is repeated. The actual number of repeats will be 2^repeats. 3 would be a good start.
*/
RemoteSwitch(unsigned short pin, unsigned int periodusec, unsigned short repeats);
/**
* Encodes the data base on the current object and the given trits. The data can be reused, e.g.
* for use with the static version of sendTelegram, so you won't need to instantiate costly objects!
*
* @return The data suited for use with RemoteSwitch::sendTelegram.
*/
unsigned long encodeTelegram(unsigned short trits[]);
/**
* Send a telegram, including synchronisation-part.
*
* @param trits Array of size 12. "trits" should be either 0, 1 or 2, where 2 indicaties "float"
*/
void sendTelegram(unsigned short trits[]);
/**
* Send a telegram, including synchronisation-part. The data-param encodes the period duration, number of repeats and the actual data.
* Note: static method, which allows for use in low-mem situations.
*
* Format data:
* pppppppp|prrrdddd|dddddddd|dddddddd (32 bit)
* p = perioud (9 bit unsigned int
* r = repeats as 2log. Thus, if r = 3, then signal is sent 2^3=8 times
* d = data
*
* @param data data, period and repeats.
* @param pin Pin number of the transmitter.
*/
static void sendTelegram(unsigned long data, unsigned short pin);
/**
* Compares the data received with RemoteReceive with the data obtained by one of the getTelegram-functions.
* Period duration and repetitions are ignored by this function; only the data-payload is compared.
*
* @return true, if the codes are identical (the 20 least significant bits match)
*/
static boolean isSameCode(unsigned long encodedTelegram, unsigned long receivedData);
protected:
unsigned short _pin; //Radio output pin
unsigned int _periodusec; //oscillator period in microseconds
unsigned short _repeats; //Number over repetitions of one telegram
};
/**
* ActionSwitch simulatos a remote, as sold in the Dutch 'Action' stores. But there are many similar systems on the market.
* If your remote has setting for 5 address bits, and can control 5 devices on or off, then you can try to use the ActionSwitch
*/
class ActionSwitch: RemoteSwitch {
public:
/**
* Constructor
*
* @param pin output pin on Arduino to which the transmitter is connected
* @param periodsec Duration of one period, in microseconds. Default is 190usec
* @see RemoteSwitch
*/
ActionSwitch(unsigned short pin, unsigned int periodusec=190);
/**
* Send a on or off signal to a device.
*
* @param systemCode 5-bit addres (dip switches in remote). Range [0..31]
* @param device Device to switch. Range: [A..E] (case sensitive!)
* @param on True, to switch on. False to switch off,
*/
void sendSignal(unsigned short systemCode, char device, boolean on);
/**
* Generates the telegram (data) which can be used for RemoteSwitch::sendTelegram.
* See sendSignal for details on the parameters
*
* @return Encoded data, including repeats and period duration.
*/
unsigned long getTelegram(unsigned short systemCode, char device, boolean on);
};
/**
* BlokkerSwitch simulatos a remote, as sold in the Dutch 'Blokker' stores. But there are many similar systems on the market.
* These remotes have 4 on, 4 off buttons and a switch to switch between device 1-4 and 5-8. No futher configuration
* possible.
*/
class BlokkerSwitch: RemoteSwitch {
public:
/**
* Constructor
*
* @param pin output pin on Arduino to which the transmitter is connected
* @param periodsec Duration of one period, in microseconds. Default is 307usec
* @see RemoteSwitch
*/
BlokkerSwitch(unsigned short pin, unsigned int periodusec=230);
/**
* Send a on or off signal to a device.
*
* @param device Device to switch. Range: [1..8]
* @param on True, to switch on. False to switch off,
*/
void sendSignal(unsigned short device, boolean on);
/**
* @see RemoteSwitch::getTelegram
*/
unsigned long getTelegram(unsigned short device, boolean on);
};
/**
* KaKuSwitch simulates a KlikAanKlikUit-remote, but there are many clones.
* If your transmitter has a address dial with the characters A till P, you can try this class.
*/
class KaKuSwitch: RemoteSwitch {
public:
/**
* Constructor
*
* @param pin output pin on Arduino to which the transmitter is connected
* @param periodsec Duration of one period, in microseconds. Default is 375usec
* @see RemoteSwitch
*/
KaKuSwitch(unsigned short pin, unsigned int periodusec=375);
/**
* Send a on or off signal to a device.
*
* @param address addres (dial switches in remote). Range [A..P] (case sensitive!)
* @param group Group to switch. Range: [1..4]
* @param device Device to switch. Range: [1..4]
* @param on True, to switch on. False to switch off,
*/
void sendSignal(char address, unsigned short group, unsigned short device, boolean on);
/**
* Send a on or off signal to a device.
*
* @param address addres (dip switches in remote). Range [A..P] (case sensitive!)
* @param device device (dial switches in remote). Range [1..16]
* @param on True, to switch on. False to switch off,
*/
void sendSignal(char address, unsigned short device, boolean on);
/**
* @see RemoteSwitch::getTelegram
*/
unsigned long getTelegram(char address, unsigned short group, unsigned short device, boolean on);
/**
* @see RemoteSwitch::getTelegram
*/
unsigned long getTelegram(char address, unsigned short device, boolean on);
};
#endif

+ 0
- 53
code/lib/RemoteSwitch/examples/Light_show/Light_show.pde View File

@ -1,53 +0,0 @@
#include <RemoteSwitch.h>
/*
* Demo for RF remote switch transmitter.
* For details, see RemoteSwitch.h!
*
* This sketch switches some devices on and off in a loop.
*/
//Intantiate a new ActionSwitch remote, use pin 11
ActionSwitch actionSwitch(11);
//Intantiate a new KaKuSwitch remote, also use pin 11 (same transmitter!)
KaKuSwitch kaKuSwitch(11);
//Intantiate a new Blokker remote, also use pin 11 (same transmitter!)
BlokkerSwitch blokkerSwitch(11);
void setup() {
}
void loop() {
//Switch off KaKu-device 10 on address M
kaKuSwitch.sendSignal('M',10,false);
//Switch on Action-device B on system code 1.
actionSwitch.sendSignal(1,'B',true);
//Switch on Blokker-device 7.
blokkerSwitch.sendSignal(7,true);
//wait 2 seconds
delay(2000);
//Switch on KaKu-device 2 of group 3 on address M (which is the same as device 10 on address M!)
kaKuSwitch.sendSignal('M',3,2,true);
//Switch off Action-device B on system code 1.
actionSwitch.sendSignal(1,'B',false);
//Switch off Blokker-device 7.
blokkerSwitch.sendSignal(7,false);
//wait 4 seconds
delay(4000);
}

+ 0
- 58
code/lib/RemoteSwitch/examples/Remote_translator/Remote_translator.pde View File

@ -1,58 +0,0 @@
#include <RemoteReceiver.h>
#include <RemoteSwitch.h>
/*
* Demo for RF remote switch receiver.
* For details, see RemoteReceiver.h!
*
* This sketch "translates" a Action-remote to a Blokker-remote.
* When the A-On-button of the Action-remote is pressed, the Blokker-devices
* 5, 6 and 7 are switched on. The A-Off-button switches the devices off again.
*
* Connect the transmitter to digital pin 11, and the receiver to digital pin 2.
*/
ActionSwitch actionSwitch(11);
BlokkerSwitch blokkerSwitch(11);
//Prepare the code for switch A (system code 1) on and off, for easy comparision later.
unsigned long actionAOn = actionSwitch.getTelegram(1,'A',true);
unsigned long actionAOff = actionSwitch.getTelegram(1,'A',false);
void setup() {
//See example Show_received_code for info on this
RemoteReceiver::init(0, 3, translateCode);
}
void loop() {
}
//Callback function is called only when a valid code is received.
void translateCode(unsigned long receivedCode, unsigned int period) {
//Enabled interrupts, so RemoteReceiver::isReceiving() can be used.
interrupts();
//Compare the signals
if (RemoteSwitch::isSameCode(actionAOn, receivedCode)) {
//A-On-button pressed!
//Wait for a free ether
while(RemoteReceiver::isReceiving());
//Switch devices on
blokkerSwitch.sendSignal(5,true);
blokkerSwitch.sendSignal(6,true);
blokkerSwitch.sendSignal(7,true);
} else if (RemoteSwitch::isSameCode(actionAOff, receivedCode)) {
//A-Off-button pressed!
//Wait for a free ether
while(RemoteReceiver::isReceiving());
//Switch devices off
blokkerSwitch.sendSignal(5,false);
blokkerSwitch.sendSignal(6,false);
blokkerSwitch.sendSignal(7,false);
}
}

+ 0
- 52
code/lib/RemoteSwitch/examples/Retransmitter/Retransmitter.pde View File

@ -1,52 +0,0 @@
#include <RemoteReceiver.h>
#include <RemoteSwitch.h>
/*
* Demo for RF remote switch receiver.
* For details, see RemoteReceiver.h!
*
* This sketch demonstrates how to use the static version of
* RemoteReceiver::sendTelegram, which can be used in low-memory
* situations.
*
* Connect the transmitter to digital pin 11, and the receiver to digital pin 2.
*
* When run, this sketch waits for a valid code from the receiver, decodes it,
* and retransmits it after 5 seconds.
*/
void setup() {
//See example Show_received_code for info on this
RemoteReceiver::init(0, 3, showCode);
}
void loop() {
}
void showCode(unsigned long receivedCode, unsigned int period) {
//Disable the receiver; otherwise it might pick up the retransmit as well.
RemoteReceiver::disable();
//Need interrupts for delay
interrupts();
unsigned long code;
//Copy the received code.
code = receivedCode & 0xFFFFF; //truncate to 20 bits for show; receivedCode is never more than 20 bits..
//Add the period duration to the code. Range: [0..511] (9 bit)
code |= (unsigned long)period << 23;
//Add the number of repeats to the code. Range: [0..7] (3 bit). The actual number of repeats will be 2^(repeats),
//in this case 8
code |= 3L << 20;
//Wait 5 seconds before sending.
delay(5000);
//Retransmit the signal on pin 11. Note: no object was created!
RemoteSwitch::sendTelegram(code,11);
RemoteReceiver::enable();
}

+ 0
- 39
code/lib/RemoteSwitch/examples/Show_received_code/Show_received_code.pde View File

@ -1,39 +0,0 @@
#include <RemoteReceiver.h>
/*
* Demo for RF remote switch receiver.
* For details, see RemoteReceiver.h!
*
* This sketch shows the received signals on the serial port.
* Connect the receiver to digital pin 2.
*/
void setup() {
Serial.begin(115200);
//Initialize receiver on interrupt 0 (= digital pin 2), calls the callback "showCode"
//after 3 identical codes have been received in a row. (thus, keep the button pressed
//for a moment)
//
//See the interrupt-parameter of attachInterrupt for possible values (and pins)
//to connect the receiver.
RemoteReceiver::init(0, 3, showCode);
}
void loop() {
}
//Callback function is called only when a valid code is received.
void showCode(unsigned long receivedCode, unsigned int period) {
//Note: interrupts are disabled. You can re-enable them if needed.
//Print the received code.
Serial.print("Code: ");
Serial.print(receivedCode);
Serial.print(", period duration: ");
Serial.print(period);
Serial.println("us.");
}

+ 0
- 12
code/lib/RemoteSwitch/keywords.txt View File

@ -1,12 +0,0 @@
RemoteSwitch KEYWORD1
ActionSwitch KEYWORD1
BlokkerSwitch KEYWORD1
KaKuSwitch KEYWORD1
sendTelegram KEYWORD2
sendSignal KEYWORD2
isSameCode KEYWORD2
RemoteReceiver KEYWORD1
init KEYWORD2
enable KEYWORD2
disable KEYWORD2
isReceiving KEYWORD2

+ 0
- 25
code/lib/RemoteSwitch/license.txt View File

@ -1,25 +0,0 @@
Copyright 2010 Randy Simons. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY RANDY SIMONS ``AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RANDY SIMONS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the
authors and should not be interpreted as representing official policies, either expressed
or implied, of Randy Simons.

+ 1
- 0
code/lib/WProgram/WProgram.h View File

@ -0,0 +1 @@
#include <Arduino.h>

+ 1
- 2
code/src/rf.ino View File

@ -26,7 +26,7 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
RemoteReceiver::disable(); RemoteReceiver::disable();
} }
} }
void rfLoop() { void rfLoop() {
if (rfCode == 0) return; if (rfCode == 0) return;
#ifdef DEBUG #ifdef DEBUG
@ -79,7 +79,6 @@ Copyright (C) 2016 by Xose Pérez <xose dot perez at gmail dot com>
pinMode(RF_PIN, INPUT_PULLUP); pinMode(RF_PIN, INPUT_PULLUP);
rfBuildCodes(); rfBuildCodes();
RemoteReceiver::init(RF_PIN, 3, rfCallback); RemoteReceiver::init(RF_PIN, 3, rfCallback);
RemoteReceiver::enable();
} }
#endif #endif

+ 1
- 0
code/vendor/RemoteSwitch-arduino-library

@ -0,0 +1 @@
Subproject commit 6a382a72de81fc8a15dde391be174777d7ba80ca

+ 1
- 0
code/vendor/embedis

@ -0,0 +1 @@
Subproject commit abf54647b3f41d85a8fa13e76106e34f4699db55

+ 1
- 0
code/vendor/emonliteesp

@ -0,0 +1 @@
Subproject commit 4f700a6a1067ef289e23d20d02902d2485952b66

+ 1
- 0
code/vendor/nofuss

@ -0,0 +1 @@
Subproject commit 49322fb1927ac465fbfe996af903daaeb3ff7845

Loading…
Cancel
Save