From cdc37918171702213ce1129cf4c03ca65aa25b80 Mon Sep 17 00:00:00 2001 From: 1technophile Date: Mon, 1 May 2017 16:38:11 +0200 Subject: [PATCH] sram optimization following platform --- OpenMQTTGateway.ino | 14 ++++++++++---- User_config.h | 29 ++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/OpenMQTTGateway.ino b/OpenMQTTGateway.ino index 9ac0414..0a66137 100644 --- a/OpenMQTTGateway.ino +++ b/OpenMQTTGateway.ino @@ -39,7 +39,13 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT #include // array to store previous received RFs, IRs codes and their timestamps -unsigned long ReceivedSignal[8][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; +#ifdef ESP8266 +#define array_size 12 +unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; +#else +#define array_size 4 +unsigned long ReceivedSignal[array_size][2] ={{0,0},{0,0},{0,0},{0,0}}; +#endif /*------------------------------------------------------------------------*/ //adding this to bypass the problem of the arduino builder issue 50 @@ -217,7 +223,7 @@ void storeValue(long MQTTvalue){ trc(F("store this code :")); trc(String(ReceivedSignal[o][0])+"/"+String(ReceivedSignal[o][1])); trc(F("Col: value/timestamp")); - for (int i = 0; i < 8; i++) + for (int i = 0; i < array_size; i++) { trc(String(i) + ":" + String(ReceivedSignal[i][0])+"/"+String(ReceivedSignal[i][1])); } @@ -226,7 +232,7 @@ void storeValue(long MQTTvalue){ int getMin(){ int minimum = ReceivedSignal[0][1]; int minindex=0; - for (int i = 0; i < 8; i++) + for (int i = 0; i < array_size; i++) { if (ReceivedSignal[i][1] < minimum) { minimum = ReceivedSignal[i][1]; @@ -239,7 +245,7 @@ int getMin(){ boolean isAduplicate(long value){ trc(F("isAduplicate")); // check if the value has been already sent during the last time_avoid_duplicate -for (int i=0; i<8;i++){ +for (int i = 0; i < array_size;i++){ if (ReceivedSignal[i][0] == value){ unsigned long now = millis(); if (now - ReceivedSignal[i][1] < time_avoid_duplicate){ // change diff --git a/User_config.h b/User_config.h index 0707e29..60b2566 100644 --- a/User_config.h +++ b/User_config.h @@ -103,15 +103,26 @@ RF supported protocols #define subjectMultiGTWIR "+/IRtoMQTT" #define pubIRunknownPrtcl false // key to avoid mqtt publication of unknown IR protocol (set to true if you want to publish unknown protocol) -//IR supported protocols uncomment if you want to send with this protocol, NEC protocol is available per default -#define IR_COOLIX -#define IR_Whynter -#define IR_LG -#define IR_Sony -#define IR_DISH -#define IR_RC5 -#define IR_Sharp -#define IR_SAMSUNG + +#ifdef ESP8266 //IR supported protocols on ESP8266, all supported per default + #define IR_COOLIX + #define IR_Whynter + #define IR_LG + #define IR_Sony + #define IR_DISH + #define IR_RC5 + #define IR_Sharp + #define IR_SAMSUNG +#else //IR supported protocols on arduino uncomment if you want to send with this protocol, NEC protocol is available per default + //#define IR_COOLIX + //#define IR_Whynter + //#define IR_LG + //#define IR_Sony + //#define IR_DISH + //#define IR_RC5 + //#define IR_Sharp + #define IR_SAMSUNG +#endif /*----------------------BT topics-------------------------*/ #define subjectBTtoMQTT "home/BTtoMQTT/"