diff --git a/HyundaiHeatpumpIR.cpp b/HyundaiHeatpumpIR.cpp new file mode 100644 index 0000000..d54c13e --- /dev/null +++ b/HyundaiHeatpumpIR.cpp @@ -0,0 +1,118 @@ +#include + +HyundaiHeatpumpIR::HyundaiHeatpumpIR() : HeatpumpIR() +{ + static const char PROGMEM model[] PROGMEM = "hyundai"; + static const char PROGMEM info[] PROGMEM = "{\"mdl\":\"hyundai\",\"dn\":\"Hyundai\",\"mT\":16,\"xT\":30,\"fs\":3}"; + + _model = model; + _info = info; +} + + +void HyundaiHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd) +{ + // Sensible defaults for the heat pump mode + uint8_t powerMode = HYUNDAI_AIRCON1_MODE_ON; + uint8_t operatingMode = HYUNDAI_AIRCON1_MODE_HEAT; + uint8_t fanSpeed = HYUNDAI_AIRCON1_FAN_AUTO; + uint8_t temperature = 23; + uint8_t swingV = HYUNDAI_AIRCON1_VS_AUTO; + uint8_t swingH = 0; + + (void)swingHCmd; + + if (powerModeCmd == 0) + { + powerMode = HYUNDAI_AIRCON1_MODE_OFF; + } + + switch (operatingModeCmd) + { + case MODE_AUTO: + operatingMode = HYUNDAI_AIRCON1_MODE_AUTO; + break; + case MODE_HEAT: + operatingMode = HYUNDAI_AIRCON1_MODE_HEAT; + break; + case MODE_COOL: + operatingMode = HYUNDAI_AIRCON1_MODE_COOL; + break; + case MODE_DRY: + operatingMode = HYUNDAI_AIRCON1_MODE_DRY; + break; + case MODE_FAN: + operatingMode = HYUNDAI_AIRCON1_MODE_FAN; + temperatureCmd = 24; + break; + } + + switch (fanSpeedCmd) + { + case FAN_AUTO: + fanSpeed = HYUNDAI_AIRCON1_FAN_AUTO; + break; + case FAN_1: + fanSpeed = HYUNDAI_AIRCON1_FAN1; + break; + case FAN_2: + fanSpeed = HYUNDAI_AIRCON1_FAN2; + break; + case FAN_3: + fanSpeed = HYUNDAI_AIRCON1_FAN3; + break; + } + + if ( temperatureCmd > 15 && temperatureCmd < 31) + { + temperature = temperatureCmd; + } + + switch (swingVCmd) + { + case VDIR_SWING: + swingV = HYUNDAI_AIRCON1_VS_SWING; + break; + } + + sendHyundai(IR, powerMode, operatingMode, fanSpeed, temperature, swingV, swingH); +} + +void HyundaiHeatpumpIR::sendHyundai(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV, uint8_t swingH) +{ + uint8_t HyundaiTemplate[] = { 0x00, 0x00, 0x00, 0x50 }; + // 0 1 2 3 + + (void)swingH; + + // Almost everything goes in the first byte... + HyundaiTemplate[0] = swingV | fanSpeed | powerMode | operatingMode; + + // Temperature + HyundaiTemplate[1] = temperature - 16; + + // 38 kHz PWM frequency + IR.setFrequency(38); + + // Header + IR.mark(HYUNDAI_AIRCON1_HDR_MARK); + IR.space(HYUNDAI_AIRCON1_HDR_SPACE); + + // Data + for (unsigned int i=0; i + + +// Hyundai timing constants +#define HYUNDAI_AIRCON1_HDR_MARK 8840 // 8700 +#define HYUNDAI_AIRCON1_HDR_SPACE 4440 // 4200 +#define HYUNDAI_AIRCON1_BIT_MARK 640 // 580 +#define HYUNDAI_AIRCON1_ONE_SPACE 1670 // 1530 +#define HYUNDAI_AIRCON1_ZERO_SPACE 570 // 460 + +// Hyundai codes +#define HYUNDAI_AIRCON1_MODE_AUTO 0x00 // Operating mode +#define HYUNDAI_AIRCON1_MODE_HEAT 0x04 +#define HYUNDAI_AIRCON1_MODE_COOL 0x01 +#define HYUNDAI_AIRCON1_MODE_DRY 0x02 +#define HYUNDAI_AIRCON1_MODE_FAN 0x03 +#define HYUNDAI_AIRCON1_MODE_OFF 0x00 // Power OFF +#define HYUNDAI_AIRCON1_MODE_ON 0x08 // Power ON +#define HYUNDAI_AIRCON1_FAN_AUTO 0x00 // Fan speed +#define HYUNDAI_AIRCON1_FAN1 0x10 +#define HYUNDAI_AIRCON1_FAN2 0x20 +#define HYUNDAI_AIRCON1_FAN3 0x30 + +#define HYUNDAI_AIRCON1_VS_SWING 0x40 // Vertical swing +#define HYUNDAI_AIRCON1_VS_AUTO 0x00 // Automatic setting + + +class HyundaiHeatpumpIR : public HeatpumpIR +{ + public: + HyundaiHeatpumpIR(); + void send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd); + + private: + void sendHyundai(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingVCmd, uint8_t swingHCmd); +}; + +#endif diff --git a/README.md b/README.md index 189c85e..38cfb7d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ Currently supports at least these models * Daikin RXS25G2V1B / FVXS25FV1B (Remote control P/N ARC452A1) * Mitsubishi Heavy SRKxxZJ-S (Remote control P/N RKX502A001C) * Mitsubishi Heavy SRKxxZM-S (Remote Control P/N RLA502A700B) +* Hyundai (Remote Control P/N Y512F2) + * This is probably a generic Gree model ## Instructions diff --git a/examples/simple/simple.ino b/examples/simple/simple.ino index 2b41aca..b9075c9 100644 --- a/examples/simple/simple.ino +++ b/examples/simple/simple.ino @@ -10,6 +10,7 @@ #include #include #include +#include IRSenderPWM irSender(3); // IR led on Duemilanove digital pin 3, using Arduino PWM @@ -23,7 +24,8 @@ HeatpumpIR *heatpumpIR[] = {new PanasonicCKPHeatpumpIR(), new PanasonicDKEHeatpu new FujitsuHeatpumpIR(), new MitsubishiFDHeatpumpIR(), new MitsubishiFEHeatpumpIR(), new MitsubishiMSYHeatpumpIR(), new SamsungHeatpumpIR(), new SharpHeatpumpIR(), new DaikinHeatpumpIR(), - new MitsubishiHeavyZJHeatpumpIR(), new MitsubishiHeavyZMHeatpumpIR(), NULL}; + new MitsubishiHeavyZJHeatpumpIR(), new MitsubishiHeavyZMHeatpumpIR(), + new HyundaiHeatpumpIR(), NULL}; void setup() { diff --git a/keywords.txt b/keywords.txt index b7f89d4..9cbf45d 100644 --- a/keywords.txt +++ b/keywords.txt @@ -17,6 +17,7 @@ DaikinHeatpumpIR KEYWORD1 MitsubishiHeavyHeatpumpIR KEYWORD1 MitsubishiHeavyZJHeatpumpIR KEYWORD1 MitsubishiHeavyZMHeatpumpIR KEYWORD1 +HyundaiHeatpumpIR KEYWORD1 IRSender KEYWORD1