Skip to content

Commit

Permalink
Add support for Kelon ACs
Browse files Browse the repository at this point in the history
  • Loading branch information
depau committed Jun 5, 2021
1 parent 9573cb2 commit 0dc50b2
Show file tree
Hide file tree
Showing 13 changed files with 712 additions and 2 deletions.
65 changes: 65 additions & 0 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ir_Fujitsu.h"
#include "ir_Haier.h"
#include "ir_Hitachi.h"
#include "ir_Kelon.h"
#include "ir_Kelvinator.h"
#include "ir_LG.h"
#include "ir_Midea.h"
Expand Down Expand Up @@ -217,6 +218,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
#if SEND_HITACHI_AC424
case decode_type_t::HITACHI_AC424:
#endif
#if SEND_KELON
case decode_type_t::KELON:
#endif
#if SEND_KELVINATOR
case decode_type_t::KELVINATOR:
#endif
Expand Down Expand Up @@ -1252,6 +1256,36 @@ void IRac::hitachi424(IRHitachiAc424 *ac,
}
#endif // SEND_HITACHI_AC424

#if SEND_KELON
/// Send a Kelon A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRKelonAC object to use.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] sleep Run the device in sleep/quiet mode.
/// @param[in] superCool Run the device in Super cooling mode.
/// @param[in] dryGrade The dehumidification intensity grade
/// @param[in] togglePower Whether to toggle the unit's power
/// @param[in] toggleSwing Whether to toggle the swing setting
void IRac::kelon(IRKelonAC *ac,
const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const bool sleep,
const bool superCool, const int8_t dryGrade,
const bool togglePower = false, const bool toggleSwing = false) {
ac->begin();
ac->setMode(IRKelonAC::convertMode(mode));
ac->setFan(IRKelonAC::convertFan(fan));
ac->setTemp(static_cast<uint8_t>(degrees));
ac->setSleep(sleep);
ac->setSupercool(superCool);

ac->setTogglePower(togglePower);
ac->setToggleSwingVertical(toggleSwing);

ac->send();
}
#endif // SEND_KELON

#if SEND_KELVINATOR
/// Send a Kelvinator A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRKelvinatorAC object to use.
Expand Down Expand Up @@ -2264,6 +2298,14 @@ stdAc::state_t IRac::handleToggles(const stdAc::state_t desired,
if (desired.model == panasonic_ac_remote_model_t::kPanasonicCkp)
result.power = desired.power ^ prev->power;
break;
case decode_type_t::KELON:
result.power = desired.power ^ prev->power;
if ((desired.swingv == stdAc::swingv_t::kOff) ^
(prev->swingv == stdAc::swingv_t::kOff)) // It changed, so toggle.
result.swingv = stdAc::swingv_t::kAuto;
else
result.swingv = stdAc::swingv_t::kOff; // No change, so no toggle.
break;
default:
{};
}
Expand Down Expand Up @@ -2574,6 +2616,14 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
break;
}
#endif // SEND_HITACHI_AC424
#if SEND_KELON
case KELON: {
IRKelonAC ac(_pin, _inverted, _modulation);
kelon(&ac, send.mode, send.degrees, send.fanspeed, send.sleep,
send.turbo, 0, send.power, send.swingv != stdAc::swingv_t::kOff);
break;
}
#endif
#if SEND_KELVINATOR
case KELVINATOR:
{
Expand Down Expand Up @@ -3283,6 +3333,13 @@ namespace IRAcUtils {
return ac.toString();
}
#endif // DECODE_FUJITSU_AC
#if DECODE_KELON
case decode_type_t::KELON: {
IRKelonAC ac(kGpioUnused);
ac.setRaw(result->state);
return ac.toString();
}
#endif // DECODE_KELON
#if DECODE_KELVINATOR
case decode_type_t::KELVINATOR: {
IRKelvinatorAC ac(kGpioUnused);
Expand Down Expand Up @@ -3768,6 +3825,14 @@ namespace IRAcUtils {
break;
}
#endif // DECODE_HITACHI_AC424
#if DECODE_KELON
case decode_type_t::KELON: {
IRKelonAC ac(kGpioUnused);
ac.setRaw(decode->state);
*result = ac.toCommon();
break;
}
#endif
#if DECODE_KELVINATOR
case decode_type_t::KELVINATOR: {
IRKelvinatorAC ac(kGpioUnused);
Expand Down
7 changes: 7 additions & 0 deletions src/IRac.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "ir_Gree.h"
#include "ir_Haier.h"
#include "ir_Hitachi.h"
#include "ir_Kelon.h"
#include "ir_Kelvinator.h"
#include "ir_LG.h"
#include "ir_Midea.h"
Expand Down Expand Up @@ -289,6 +290,12 @@ void electra(IRElectraAc *ac,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv);
#endif // SEND_HITACHI_AC424
#if SEND_KELON
void kelon(IRKelonAC *ac,
const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const bool sleep, const bool superCool,
const int8_t dryGrade, const bool togglePower, const bool toggleSwing);
#endif // SEND_KELON
#if SEND_KELVINATOR
void kelvinator(IRKelvinatorAC *ac,
const bool on, const stdAc::opmode_t mode,
Expand Down
4 changes: 4 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting XMP decode");
if (decodeXmp(results, offset, kXmpBits)) return true;
#endif // DECODE_XMP
#if DECODE_KELON
DPRINTLN("Attempting Kelon decode");
if (decodeKelon(results, offset, kKelonBits)) return true;
#endif // DECODE_KELON
// Typically new protocols are added above this line.
}
#if DECODE_HASH
Expand Down
4 changes: 4 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,10 @@ class IRrecv {
bool decodeTruma(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kTrumaBits, const bool strict = true);
#endif // DECODE_TRUMA
#if DECODE_KELON
bool decodeKelon(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kKelonBits, const bool strict = true);
#endif // DECODE_KELON
};

#endif // IRRECV_H_
15 changes: 13 additions & 2 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Vestel AC code by Erdem U. Altınyurt
* Teco AC code by Fabien Valthier (hcoohb)
* Mitsubishi 112 AC Code by kuchel77
* Kelon AC code by Davide Depau (Depau)
*
* GPL license, all text above must be included in any redistribution
****************************************************/
Expand Down Expand Up @@ -754,6 +755,13 @@
#define SEND_HAIER_AC176 _IR_ENABLE_DEFAULT_
#endif // SEND_HAIER_AC176

#ifndef DECODE_KELON
#define DECODE_KELON _IR_ENABLE_DEFAULT_
#endif // DECODE_KELON
#ifndef SEND_KELON
#define SEND_KELON _IR_ENABLE_DEFAULT_
#endif // SEND_KELON

#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
Expand All @@ -766,7 +774,7 @@
DECODE_AMCOR || DECODE_DAIKIN152 || DECODE_MITSUBISHI136 || \
DECODE_MITSUBISHI112 || DECODE_HITACHI_AC424 || DECODE_HITACHI_AC3 || \
DECODE_HITACHI_AC344 || DECODE_CORONA_AC || DECODE_SANYO_AC || \
DECODE_VOLTAS || DECODE_MIRAGE || DECODE_HAIER_AC176)
DECODE_VOLTAS || DECODE_MIRAGE || DECODE_HAIER_AC176 || DECODE_KELON)
// Add any DECODE to the above if it uses result->state (see kStateSizeMax)
// you might also want to add the protocol to hasACState function
#define DECODE_AC true // We need some common infrastructure for decoding A/Cs.
Expand Down Expand Up @@ -907,8 +915,9 @@ enum decode_type_t {
XMP,
TRUMA, // 100
HAIER_AC176,
KELON,
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = HAIER_AC176,
kLastDecodeType = KELON,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -1021,6 +1030,8 @@ const uint16_t kHitachiAc424Bits = kHitachiAc424StateLength * 8;
const uint16_t kInaxBits = 24;
const uint16_t kInaxMinRepeat = kSingleRepeat;
const uint16_t kJvcBits = 16;
const uint16_t kKelonStateLength = 6;
const uint16_t kKelonBits = kKelonStateLength * 8;
const uint16_t kKelvinatorStateLength = 16;
const uint16_t kKelvinatorBits = kKelvinatorStateLength * 8;
const uint16_t kKelvinatorDefaultRepeat = kNoRepeat;
Expand Down
5 changes: 5 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
sendHitachiAc424(state, nbytes);
break;
#endif // SEND_HITACHI_AC424
#if SEND_KELON
case KELON:
sendKelon(state, nbytes);
break;
#endif // SEND_KELON
#if SEND_KELVINATOR
case KELVINATOR:
sendKelvinator(state, nbytes);
Expand Down
4 changes: 4 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ class IRsend {
void sendTruma(const uint64_t data, const uint16_t nbits = kTrumaBits,
const uint16_t repeat = kNoRepeat);
#endif // SEND_TRUMA
#if SEND_KELON
void sendKelon(const unsigned char data[], const uint16_t nbytes = kKelonStateLength,
const uint16_t repeat = kNoRepeat);
#endif // SEND_KELON

protected:
#ifdef UNIT_TEST
Expand Down
2 changes: 2 additions & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const PROGMEM char* k6thSenseStr = D_STR_6THSENSE; ///< "6th Sense"
const PROGMEM char* kTypeStr = D_STR_TYPE; ///< "Type"
const PROGMEM char* kSpecialStr = D_STR_SPECIAL; ///< "Special"
const PROGMEM char* kIdStr = D_STR_ID; ///< "Id" / Device Identifier
const PROGMEM char* kDryGradeStr = D_STR_DRY_GRADE;

const PROGMEM char* kAutoStr = D_STR_AUTO; ///< "Auto"
const PROGMEM char* kAutomaticStr = D_STR_AUTOMATIC; ///< "Automatic"
Expand Down Expand Up @@ -286,5 +287,6 @@ const PROGMEM char *kAllProtocolNamesStr =
D_STR_XMP "\x0"
D_STR_TRUMA "\x0"
D_STR_HAIER_AC176 "\x0"
D_STR_KELON "\x0"
///< New protocol strings should be added just above this line.
"\x0"; ///< This string requires double null termination.
1 change: 1 addition & 0 deletions src/IRtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern const char* kDayStr;
extern const char* kDisplayTempStr;
extern const char* kDownStr;
extern const char* kDryStr;
extern const char* kDryGradeStr;
extern const char* kEconoStr;
extern const char* kEconoToggleStr;
extern const char* kEyeAutoStr;
Expand Down
1 change: 1 addition & 0 deletions src/IRutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ bool hasACState(const decode_type_t protocol) {
case HITACHI_AC3:
case HITACHI_AC344:
case HITACHI_AC424:
case KELON:
case KELVINATOR:
case MIRAGE:
case MITSUBISHI136:
Expand Down
Loading

0 comments on commit 0dc50b2

Please sign in to comment.