From 3bee160b4841ddf17aad7df11e069cda97a2ed4b Mon Sep 17 00:00:00 2001 From: Florian <1technophile@users.noreply.github.com> Date: Fri, 19 Jun 2020 13:11:15 -0500 Subject: [PATCH] IRRemote ESP8266 Lib update and add new protocols (#641) --- main/ZgatewayIR.ino | 124 +++++++++++++++++++++++++++++++++++++++++--- main/config_IR.h | 11 ++++ platformio.ini | 2 +- 3 files changed, 130 insertions(+), 7 deletions(-) diff --git a/main/ZgatewayIR.ino b/main/ZgatewayIR.ino index ed71060b..a9e6eb9c 100644 --- a/main/ZgatewayIR.ino +++ b/main/ZgatewayIR.ino @@ -46,7 +46,7 @@ IRrecv irrecv(IR_RECEIVER_GPIO); IRsend irsend; //connect IR emitter pin to D9 on arduino, you need to comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library IRremote.h so as to free pin D3 for RF RECEIVER PIN # endif -// IR protocol bits definition for Arduino (for ESP9266 they are defined in IRRemoteESP8266.h) +// IR protocol bits definition for Arduino (for ESP8266 they are defined in IRRemoteESP8266.h) # ifndef NEC_BITS # define NEC_BITS 32U # endif @@ -65,6 +65,9 @@ IRsend irsend; //connect IR emitter pin to D9 on arduino, you need to comment #d # ifndef DISH_BITS # define DISH_BITS 16U # endif +# ifndef SONY_20_BITS +# define SONY_20_BITS 20 +# endif # ifndef SONY_12_BITS # define SONY_12_BITS 12U # endif @@ -252,7 +255,7 @@ void MQTTtoIR(char* topicOri, JsonObject& IRdata) { signalSent = true; } # endif - } else if (protocol_name && (strcmp(protocol_name, "NEC") != 1)) { + } else if (protocol_name && (strcmp(protocol_name, "NEC") != 0)) { Log.trace(F("Using Identified Protocol: %s bits: %d repeat: %d" CR), protocol_name, valueBITS, valueRPT); signalSent = sendIdentifiedProtocol(protocol_name, data, hex, valueBITS, valueRPT); } else { @@ -324,11 +327,13 @@ bool sendIdentifiedProtocol(const char* protocol_name, unsigned long long data, # ifdef IR_SONY if (strcmp(protocol_name, "SONY") == 0) { Log.notice(F("Sending IR signal with %s" CR), protocol_name); - if (valueBITS == 0) - valueBITS = SONY_12_BITS; # if defined(ESP8266) || defined(ESP32) + if (valueBITS == 0) + valueBITS = SONY_20_BITS; irsend.sendSony(data, valueBITS, valueRPT); # else + if (valueBITS == 0) + valueBITS = SONY_12_BITS; for (int i = 0; i <= valueRPT; i++) irsend.sendSony(data, valueBITS); # endif @@ -1012,7 +1017,6 @@ bool sendIdentifiedProtocol(const char* protocol_name, unsigned long long data, # endif # ifdef IR_HITACHI_AC424 if (strcmp(protocol_name, "HITACHI_AC424") == 0) { - Log.notice(F("Sending IR signal with %s" CR), protocol_name); Log.notice(F("Sending IR signal with %s" CR), protocol_name); if (valueBITS == 0) valueBITS = kHitachiAc424StateLength; @@ -1022,7 +1026,115 @@ bool sendIdentifiedProtocol(const char* protocol_name, unsigned long long data, return true; } # endif - Log.trace(F("At the end" CR)); +# ifdef IR_SONY_38K + if (strcmp(protocol_name, "SONY_38K") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, (uint16_t)(kSonyMinRepeat + 1)); + if (valueBITS == 0) + valueBITS = kSony20Bits; + irsend.sendSony38(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_EPSON + if (strcmp(protocol_name, "EPSON") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kEpsonMinRepeat); + if (valueBITS == 0) + valueBITS = kEpsonBits; + irsend.sendEpson(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_SYMPHONY + if (strcmp(protocol_name, "SYMPHONY") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kSymphonyDefaultRepeat); + if (valueBITS == 0) + valueBITS = kSymphonyBits; + irsend.sendSymphony(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_HITACHI_AC3 + if (strcmp(protocol_name, "HITACHI_AC3") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kHitachiAcDefaultRepeat); + if (valueBITS == 0) + Log.error(F("For this protocol you should have a BIT number as there is no default one defined" CR)); + irsend.sendHitachiAc3(dataarray, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_DAIKIN64 + if (strcmp(protocol_name, "DAIKIN64") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kDaikin64DefaultRepeat); + if (valueBITS == 0) + valueBITS = kDaikin64Bits; + irsend.sendDaikin64(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_AIRWELL + if (strcmp(protocol_name, "AIRWELL") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kAirwellMinRepeats); + if (valueBITS == 0) + valueBITS = kAirwellBits; + irsend.sendAirwell(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_DELONGHI_AC + if (strcmp(protocol_name, "DELONGHI_AC") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kDelonghiAcDefaultRepeat); + if (valueBITS == 0) + valueBITS = kDelonghiAcBits; + irsend.sendDelonghiAc(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_DOSHISHA + if (strcmp(protocol_name, "DOSHISHA") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueBITS == 0) + valueBITS = kDoshishaBits; + irsend.sendDoshisha(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_CARRIER_AC40 + if (strcmp(protocol_name, "CARRIER_AC40") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kCarrierAc40MinRepeat); + if (valueBITS == 0) + valueBITS = kCarrierAc40Bits; + irsend.sendCarrierAC40(data, valueBITS, valueRPT); + return true; + } +# endif +# ifdef IR_CARRIER_AC64 + if (strcmp(protocol_name, "CARRIER_AC64") == 0) { + Log.notice(F("Sending IR signal with %s" CR), protocol_name); + if (valueRPT == repeatIRwNumber) + valueRPT = std::max(valueRPT, kCarrierAc64MinRepeat); + if (valueBITS == 0) + valueBITS = kCarrierAc64Bits; + irsend.sendCarrierAC64(data, valueBITS, valueRPT); + return true; + } +# endif + Log.warning(F("Unknown IR protocol" CR)); return false; # endif } diff --git a/main/config_IR.h b/main/config_IR.h index e24ea822..47d519b2 100644 --- a/main/config_IR.h +++ b/main/config_IR.h @@ -120,6 +120,17 @@ extern void MQTTtoIR(char* topicOri, JsonObject& RFdata); # define IR_MITSUBISHI136 # define IR_MITSUBISHI112 # define IR_HITACHI_AC424 +# define IR_SONY_38K +# define IR_EPSON +# define IR_SYMPHONY +# define IR_HITACHI_AC3 +# define IR_DAIKIN64 +# define IR_AIRWELL +# define IR_DELONGHI_AC +# define IR_DOSHISHA +# define IR_MULTIBRACKETS +# define IR_CARRIER_AC40 +# define IR_CARRIER_AC64 #elif __AVR_ATmega2560__ # define IR_COOLIX # define IR_Whynter diff --git a/platformio.ini b/platformio.ini index 567653b5..c5e18dc1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -70,7 +70,7 @@ pubsubclient = PubSubClient@2.8 rc-switch = 1technophile/rc-switch#90adb34 newremoteswitch = 1technophile/NewRemoteSwitch#8eb980e ble = eos1d3/ESP32_BLE#9d6c1ed -irremoteesp = IRremoteESP8266@2.7.0 +irremoteesp = IRremoteESP8266@2.7.7 irremote = IRremote lora = sandeepmistry/arduino-LoRa#f4a1d27 esppilight = ESPiLight@0.16.2