From 3d90bfb2bd0a2661bf3ddd784aaf57b4c5513853 Mon Sep 17 00:00:00 2001 From: ToniA Date: Mon, 28 Nov 2016 18:41:24 +0200 Subject: [PATCH] Panasonic LKE support --- PanasonicHeatpumpIR.cpp | 61 +++++++++++++++++++++++++------------- PanasonicHeatpumpIR.h | 7 +++++ examples/simple/simple.ino | 3 +- keywords.txt | 1 + 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/PanasonicHeatpumpIR.cpp b/PanasonicHeatpumpIR.cpp index 22b5239..084b5f6 100644 --- a/PanasonicHeatpumpIR.cpp +++ b/PanasonicHeatpumpIR.cpp @@ -40,6 +40,17 @@ PanasonicNKEHeatpumpIR::PanasonicNKEHeatpumpIR() : PanasonicHeatpumpIR() _panasonicModel = PANASONIC_NKE; } +PanasonicLKEHeatpumpIR::PanasonicLKEHeatpumpIR() : PanasonicHeatpumpIR() +{ + static const char PROGMEM model[] PROGMEM = "panasonic_lke"; + static const char PROGMEM info[] PROGMEM = "{\"mdl\":\"panasonic_lke\",\"dn\":\"Panasonic LKE\",\"mT\":16,\"xT\":30,\"fs\":6,\"maint\":[8,10]}"; + + _model = model; + _info = info; + + _panasonicModel = PANASONIC_LKE; +} + // Panasonic DKE/NKE/JKE numeric values to command bytes void PanasonicHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd) @@ -165,7 +176,7 @@ void PanasonicHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t opera } // Quiet & powerful, both cannot be set at the same time - + if ( quietCmd == true ) { profile = PANASONIC_AIRCON2_QUIET; @@ -173,7 +184,7 @@ void PanasonicHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t opera { profile = PANASONIC_AIRCON2_POWERFUL; } - + // NKE has +8 / + 10 maintenance heating, which also means MAX fanspeed if ( _panasonicModel == PANASONIC_NKE ) { @@ -187,34 +198,42 @@ void PanasonicHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t opera sendPanasonic(IR, operatingMode, fanSpeed, temperature, swingV, swingH, profile); } -// Send the Panasonic DKE/JKE/NKE code +// Send the Panasonic DKE/JKE/NKE/LKE code void PanasonicHeatpumpIR::sendPanasonic(IRSender& IR, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV, uint8_t swingH, uint8_t profile) { - // Only bytes 13, 14, 16, 17 and 26 are modified, DKE and JKE seem to share the same template? - static const uint8_t panasonicProgmemTemplate[][27] PROGMEM = { - // DKE, model 0 - { 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00 }, - // JKE, model 1 - { 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00 }, - // NKE, model 2 - { 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x06, 0x00, 0x0E, 0xE0, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00 } - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 + // Only bytes 13, 14, 16, 17 and 26 are modified + static const uint8_t panasonicProgmemTemplate[27] PROGMEM = { + 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x06, 0x02, 0x20, 0xE0, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x0E, 0xE0, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 }; - // Save some SRAM by only having one copy of the template on the SRAM + // Save some SRAM by having the template in flash uint8_t panasonicTemplate[27]; - memcpy_P(panasonicTemplate, panasonicProgmemTemplate[_panasonicModel], sizeof(panasonicTemplate)); + memcpy_P(panasonicTemplate, panasonicProgmemTemplate, sizeof(panasonicTemplate)); - panasonicTemplate[13] = operatingMode; + switch(_panasonicModel) + { + case PANASONIC_DKE: + panasonicTemplate[17] = swingH; // Only the DKE model has a setting for the horizontal air flow + panasonicTemplate[23] = 0x01; + panasonicTemplate[25] = 0x06; + break; + case PANASONIC_JKE: + break; + case PANASONIC_NKE: + panasonicTemplate[17] = 0x06; + break; + case PANASONIC_LKE: + panasonicTemplate[17] = 0x06; + panasonicTemplate[13] = 0x02; + break; + } + + panasonicTemplate[13] |= operatingMode; panasonicTemplate[14] = temperature << 1; panasonicTemplate[16] = fanSpeed | swingV; panasonicTemplate[21] = profile; - // Only the DKE model has a setting for the horizontal air flow - if ( _panasonicModel == PANASONIC_DKE) { - panasonicTemplate[17] = swingH; - } - // Checksum calculation uint8_t checksum = 0xF4; @@ -224,7 +243,7 @@ void PanasonicHeatpumpIR::sendPanasonic(IRSender& IR, uint8_t operatingMode, uin panasonicTemplate[26] = checksum; - // 40 kHz PWM frequency + // 38 kHz PWM frequency IR.setFrequency(38); // Header diff --git a/PanasonicHeatpumpIR.h b/PanasonicHeatpumpIR.h index 56a5264..f8eb983 100644 --- a/PanasonicHeatpumpIR.h +++ b/PanasonicHeatpumpIR.h @@ -49,6 +49,7 @@ #define PANASONIC_DKE 0 #define PANASONIC_JKE 1 #define PANASONIC_NKE 2 +#define PANASONIC_LKE 3 class PanasonicHeatpumpIR : public HeatpumpIR @@ -83,4 +84,10 @@ class PanasonicNKEHeatpumpIR : public PanasonicHeatpumpIR PanasonicNKEHeatpumpIR(); }; +class PanasonicLKEHeatpumpIR : public PanasonicHeatpumpIR +{ + public: + PanasonicLKEHeatpumpIR(); +}; + #endif \ No newline at end of file diff --git a/examples/simple/simple.ino b/examples/simple/simple.ino index a3c69fc..27af482 100644 --- a/examples/simple/simple.ino +++ b/examples/simple/simple.ino @@ -27,7 +27,8 @@ IRSenderBitBang irSender(1); // IR led on ESP8266 GPIO pin 1 // Array with all supported heatpumps HeatpumpIR *heatpumpIR[] = {new PanasonicCKPHeatpumpIR(), new PanasonicDKEHeatpumpIR(), new PanasonicJKEHeatpumpIR(), - new PanasonicNKEHeatpumpIR(), new CarrierNQVHeatpumpIR(), new CarrierMCAHeatpumpIR(), + new PanasonicNKEHeatpumpIR(), new PanasonicLKEHeatpumpIR(), + new CarrierNQVHeatpumpIR(), new CarrierMCAHeatpumpIR(), new MideaHeatpumpIR(), new FujitsuHeatpumpIR(), new MitsubishiFDHeatpumpIR(), new MitsubishiFEHeatpumpIR(), new MitsubishiMSYHeatpumpIR(), new SamsungHeatpumpIR(), new SharpHeatpumpIR(), new DaikinHeatpumpIR(), diff --git a/keywords.txt b/keywords.txt index f1ac4a2..cc3aaa3 100644 --- a/keywords.txt +++ b/keywords.txt @@ -4,6 +4,7 @@ PanasonicCKPHeatpumpIR KEYWORD1 PanasonicDKEHeatpumpIR KEYWORD1 PanasonicJKEHeatpumpIR KEYWORD1 PanasonicNKEHeatpumpIR KEYWORD1 +PanasonicLKEHeatpumpIR KEYWORD1 CarrierHeatpumpIR KEYWORD1 CarrierNQVHeatpumpIR KEYWORD1 CarrierMCAHeatpumpIR KEYWORD1