Hyundai support

This commit is contained in:
ToniA 2016-01-30 14:27:08 +02:00
parent 76f1a428a0
commit 01c09badc2
5 changed files with 168 additions and 1 deletions

118
HyundaiHeatpumpIR.cpp Normal file
View File

@ -0,0 +1,118 @@
#include <HyundaiHeatpumpIR.h>
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<sizeof(HyundaiTemplate); i++) {
IR.sendIRbyte(HyundaiTemplate[i], HYUNDAI_AIRCON1_BIT_MARK, HYUNDAI_AIRCON1_ZERO_SPACE, HYUNDAI_AIRCON1_ONE_SPACE);
}
// Hyundai protocol has 35 bits, i.e. 4 bytes + 3 bits
// The last bits are always '010'
IR.mark(HYUNDAI_AIRCON1_BIT_MARK);
IR.space(HYUNDAI_AIRCON1_ZERO_SPACE);
IR.mark(HYUNDAI_AIRCON1_BIT_MARK);
IR.space(HYUNDAI_AIRCON1_ONE_SPACE);
IR.mark(HYUNDAI_AIRCON1_BIT_MARK);
IR.space(HYUNDAI_AIRCON1_ZERO_SPACE);
// End mark
IR.mark(HYUNDAI_AIRCON1_BIT_MARK);
IR.space(0);
}

44
HyundaiHeatpumpIR.h Normal file
View File

@ -0,0 +1,44 @@
/*
Hyundai heatpump control (remote control P/N Y512F2)
*/
#ifndef HyundaiHeatpumpIR_h
#define HyundaiHeatpumpIR_h
#include <HeatpumpIR.h>
// 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

View File

@ -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

View File

@ -10,6 +10,7 @@
#include <SharpHeatpumpIR.h>
#include <DaikinHeatpumpIR.h>
#include <MitsubishiHeavyHeatpumpIR.h>
#include <HyundaiHeatpumpIR.h>
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()
{

View File

@ -17,6 +17,7 @@ DaikinHeatpumpIR KEYWORD1
MitsubishiHeavyHeatpumpIR KEYWORD1
MitsubishiHeavyZJHeatpumpIR KEYWORD1
MitsubishiHeavyZMHeatpumpIR KEYWORD1
HyundaiHeatpumpIR KEYWORD1
IRSender KEYWORD1