diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..3698bc19 --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/code/arduino/code/code.ino b/code/arduino/code/code.ino deleted file mode 120000 index 9ef97e0f..00000000 --- a/code/arduino/code/code.ino +++ /dev/null @@ -1 +0,0 @@ -../../src/code.ino \ No newline at end of file diff --git a/code/arduino/code/data b/code/arduino/code/data deleted file mode 120000 index e67b4559..00000000 --- a/code/arduino/code/data +++ /dev/null @@ -1 +0,0 @@ -../../data \ No newline at end of file diff --git a/code/lib/Embedis b/code/lib/Embedis new file mode 120000 index 00000000..284c28c0 --- /dev/null +++ b/code/lib/Embedis @@ -0,0 +1 @@ +../vendor/embedis/src \ No newline at end of file diff --git a/code/lib/EmonLiteESP b/code/lib/EmonLiteESP new file mode 120000 index 00000000..048e3b79 --- /dev/null +++ b/code/lib/EmonLiteESP @@ -0,0 +1 @@ +../vendor/emonliteesp/code/lib/EmonLiteESP \ No newline at end of file diff --git a/code/lib/NoFUSSClient b/code/lib/NoFUSSClient new file mode 120000 index 00000000..51a070f9 --- /dev/null +++ b/code/lib/NoFUSSClient @@ -0,0 +1 @@ +../vendor/nofuss/client/lib/NoFUSSClient \ No newline at end of file diff --git a/code/lib/RemoteSwitch b/code/lib/RemoteSwitch new file mode 120000 index 00000000..a3467d9d --- /dev/null +++ b/code/lib/RemoteSwitch @@ -0,0 +1 @@ +../vendor/RemoteSwitch-arduino-library \ No newline at end of file diff --git a/code/lib/RemoteSwitch/RemoteReceiver.cpp b/code/lib/RemoteSwitch/RemoteReceiver.cpp deleted file mode 100644 index 6195cf4c..00000000 --- a/code/lib/RemoteSwitch/RemoteReceiver.cpp +++ /dev/null @@ -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 (durationmax1Period) { - _state=-1; - return; - } - } else { //Waiting for sync bit part 2 - //Must be 31 periods. - if (durationperiod*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; -} diff --git a/code/lib/RemoteSwitch/RemoteReceiver.h b/code/lib/RemoteSwitch/RemoteReceiver.h deleted file mode 100644 index 357d92db..00000000 --- a/code/lib/RemoteSwitch/RemoteReceiver.h +++ /dev/null @@ -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 diff --git a/code/lib/RemoteSwitch/RemoteSwitch.cpp b/code/lib/RemoteSwitch/RemoteSwitch.cpp deleted file mode 100644 index 96828012..00000000 --- a/code/lib/RemoteSwitch/RemoteSwitch.cpp +++ /dev/null @@ -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>=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); -} diff --git a/code/lib/RemoteSwitch/RemoteSwitch.h b/code/lib/RemoteSwitch/RemoteSwitch.h deleted file mode 100644 index 762ae979..00000000 --- a/code/lib/RemoteSwitch/RemoteSwitch.h +++ /dev/null @@ -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 diff --git a/code/lib/RemoteSwitch/examples/Light_show/Light_show.pde b/code/lib/RemoteSwitch/examples/Light_show/Light_show.pde deleted file mode 100644 index 20077ff9..00000000 --- a/code/lib/RemoteSwitch/examples/Light_show/Light_show.pde +++ /dev/null @@ -1,53 +0,0 @@ -#include - -/* -* 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); -} diff --git a/code/lib/RemoteSwitch/examples/Remote_translator/Remote_translator.pde b/code/lib/RemoteSwitch/examples/Remote_translator/Remote_translator.pde deleted file mode 100644 index 5f0188bf..00000000 --- a/code/lib/RemoteSwitch/examples/Remote_translator/Remote_translator.pde +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include - -/* -* 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); - } -} diff --git a/code/lib/RemoteSwitch/examples/Retransmitter/Retransmitter.pde b/code/lib/RemoteSwitch/examples/Retransmitter/Retransmitter.pde deleted file mode 100644 index a1197d75..00000000 --- a/code/lib/RemoteSwitch/examples/Retransmitter/Retransmitter.pde +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include - -/* -* 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(); -} diff --git a/code/lib/RemoteSwitch/examples/Show_received_code/Show_received_code.pde b/code/lib/RemoteSwitch/examples/Show_received_code/Show_received_code.pde deleted file mode 100644 index 6a4d8dbc..00000000 --- a/code/lib/RemoteSwitch/examples/Show_received_code/Show_received_code.pde +++ /dev/null @@ -1,39 +0,0 @@ -#include - -/* -* 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."); -} - - diff --git a/code/lib/RemoteSwitch/keywords.txt b/code/lib/RemoteSwitch/keywords.txt deleted file mode 100644 index bf1c60ff..00000000 --- a/code/lib/RemoteSwitch/keywords.txt +++ /dev/null @@ -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 diff --git a/code/lib/RemoteSwitch/license.txt b/code/lib/RemoteSwitch/license.txt deleted file mode 100644 index fd9cb841..00000000 --- a/code/lib/RemoteSwitch/license.txt +++ /dev/null @@ -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. \ No newline at end of file diff --git a/code/lib/WProgram/WProgram.h b/code/lib/WProgram/WProgram.h new file mode 100644 index 00000000..dca27d86 --- /dev/null +++ b/code/lib/WProgram/WProgram.h @@ -0,0 +1 @@ +#include diff --git a/code/src/rf.ino b/code/src/rf.ino index 689997c9..92cdfed1 100644 --- a/code/src/rf.ino +++ b/code/src/rf.ino @@ -26,7 +26,7 @@ Copyright (C) 2016 by Xose Pérez RemoteReceiver::disable(); } } - + void rfLoop() { if (rfCode == 0) return; #ifdef DEBUG @@ -79,7 +79,6 @@ Copyright (C) 2016 by Xose Pérez pinMode(RF_PIN, INPUT_PULLUP); rfBuildCodes(); RemoteReceiver::init(RF_PIN, 3, rfCallback); - RemoteReceiver::enable(); } #endif diff --git a/code/vendor/RemoteSwitch-arduino-library b/code/vendor/RemoteSwitch-arduino-library new file mode 160000 index 00000000..6a382a72 --- /dev/null +++ b/code/vendor/RemoteSwitch-arduino-library @@ -0,0 +1 @@ +Subproject commit 6a382a72de81fc8a15dde391be174777d7ba80ca diff --git a/code/vendor/embedis b/code/vendor/embedis new file mode 160000 index 00000000..abf54647 --- /dev/null +++ b/code/vendor/embedis @@ -0,0 +1 @@ +Subproject commit abf54647b3f41d85a8fa13e76106e34f4699db55 diff --git a/code/vendor/emonliteesp b/code/vendor/emonliteesp new file mode 160000 index 00000000..4f700a6a --- /dev/null +++ b/code/vendor/emonliteesp @@ -0,0 +1 @@ +Subproject commit 4f700a6a1067ef289e23d20d02902d2485952b66 diff --git a/code/vendor/nofuss b/code/vendor/nofuss new file mode 160000 index 00000000..49322fb1 --- /dev/null +++ b/code/vendor/nofuss @@ -0,0 +1 @@ +Subproject commit 49322fb1927ac465fbfe996af903daaeb3ff7845