reduce buffer size for arduino compilation when using ZaddonDHT

This commit is contained in:
1technophile committed 2017-04-23 22:17:41 +02:00
1 parent 07810d5f61
commit 118bcf2c18
1 file changed
+10 -9
+10 -9
View File
@@ -16,6 +16,7 @@
- 1technophile - 1technophile
- crankyoldgit - crankyoldgit
- Spudtater - Spudtater
- prahjister
- rickybrent - rickybrent
- ekim from Home assistant forum - ekim from Home assistant forum
- ronvl from Home assistant forum - ronvl from Home assistant forum
@@ -37,7 +38,7 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
#include <PubSubClient.h> #include <PubSubClient.h>
// array to store previous received RFs, IRs codes and their timestamps // array to store previous received RFs, IRs codes and their timestamps
unsigned long ReceivedSignal[10][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}}; unsigned long ReceivedSignal[8][2] ={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
//adding this to bypass the problem of the arduino builder issue 50 //adding this to bypass the problem of the arduino builder issue 50
@@ -163,7 +164,7 @@ void loop()
{ {
//MQTT client connexion management //MQTT client connexion management
if (!client.connected()) { // not connected if (!client.connected()) { // not connected
long now = millis(); unsigned long now = millis();
if (now - lastReconnectAttempt > 5000) { if (now - lastReconnectAttempt > 5000) {
lastReconnectAttempt = now; lastReconnectAttempt = now;
trc(F("client mqtt not connected, trying to connect")); trc(F("client mqtt not connected, trying to connect"));
@@ -183,7 +184,7 @@ void loop()
#ifdef ZgatewayRF #ifdef ZgatewayRF
boolean resultRF = RFtoMQTT(); boolean resultRF = RFtoMQTT();
if(resultRF) if(resultRF)
trc(F("RF successfully sent by MQTT")); trc(F("RF successfully sent by MQTT"));
#endif #endif
#ifdef ZgatewayIR #ifdef ZgatewayIR
boolean resultIR = IRtoMQTT(); boolean resultIR = IRtoMQTT();
@@ -196,7 +197,7 @@ void loop()
} }
void storeValue(long MQTTvalue){ void storeValue(long MQTTvalue){
long now = millis(); unsigned long now = millis();
// find oldest value of the buffer // find oldest value of the buffer
int o = getMin(); int o = getMin();
trc(F("Minimum index: ")); trc(F("Minimum index: "));
@@ -207,7 +208,7 @@ void storeValue(long MQTTvalue){
trc(F("store this code :")); trc(F("store this code :"));
trc(String(ReceivedSignal[o][0])+"/"+String(ReceivedSignal[o][1])); trc(String(ReceivedSignal[o][0])+"/"+String(ReceivedSignal[o][1]));
trc(F("Col: value/timestamp")); trc(F("Col: value/timestamp"));
for (int i = 0; i < 10; i++) for (int i = 0; i < 8; i++)
{ {
trc(String(i) + ":" + String(ReceivedSignal[i][0])+"/"+String(ReceivedSignal[i][1])); trc(String(i) + ":" + String(ReceivedSignal[i][0])+"/"+String(ReceivedSignal[i][1]));
} }
@@ -216,7 +217,7 @@ void storeValue(long MQTTvalue){
int getMin(){ int getMin(){
int minimum = ReceivedSignal[0][1]; int minimum = ReceivedSignal[0][1];
int minindex=0; int minindex=0;
for (int i = 0; i < 10; i++) for (int i = 0; i < 8; i++)
{ {
if (ReceivedSignal[i][1] < minimum) { if (ReceivedSignal[i][1] < minimum) {
minimum = ReceivedSignal[i][1]; minimum = ReceivedSignal[i][1];
@@ -229,11 +230,11 @@ int getMin(){
boolean isAduplicate(long value){ boolean isAduplicate(long value){
trc(F("isAduplicate")); trc(F("isAduplicate"));
// check if the value has been already sent during the last time_avoid_duplicate // check if the value has been already sent during the last time_avoid_duplicate
for (int i=0; i<10;i++){ for (int i=0; i<8;i++){
if (ReceivedSignal[i][0] == value){ if (ReceivedSignal[i][0] == value){
long now = millis(); unsigned long now = millis();
if (now - ReceivedSignal[i][1] < time_avoid_duplicate){ // change if (now - ReceivedSignal[i][1] < time_avoid_duplicate){ // change
trc(F("--------------don't send the received code--------------")); trc(F("--------------don't publish the received code duplicate--------------"));
return true; return true;
} }
} }