Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Mitsubishi Remote Controller W001CP R61Y23304 #18

Merged
merged 12 commits into from
Mar 24, 2018
141 changes: 139 additions & 2 deletions HVACDemo/IRremote2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* LG added by Darryl Smith (based on the JVC protocol)
*
* Mitsubishi HVAC protocol added by Vincent Cruvellier.
*
* Mitsubishi HVAC W001CP R61Y23304 protocol added by bt4wang.
*/

#include "IRremote2.h"
Expand Down Expand Up @@ -505,6 +505,143 @@ void IRsend::sendHvacMitsubishi(
}
}

/***************************************************************************/
/* Send IR command to Mitsubishi HVAC - sendHvacMitsubishi
/* Add support for W001CP R61Y23304 Remote Controller
/***************************************************************************/
void IRsend::sendHvacMitsubishi_W001CP(
HvacMode HVAC_Mode, // Example HVAC_HOT. HvacMitsubishiMode
// This type support HVAC_HOT,HVAC_COLD,HVAC_DRY,HVAC_FAN,HVAC_AUTO.
int HVAC_Temp, // Example 21 (°c).
// This type support 17~28 in HVAC_HOT mode, 19~30 in HVAC_COLD and HVAC_DRY mode.
HvacFanMode HVAC_FanMode, // Example FAN_SPEED_AUTO. HvacMitsubishiFanMode
// This type support FAN_SPEED_1,FAN_SPEED_2,FAN_SPEED_3,FAN_SPEED_4.
HvacVanneMode HVAC_VanneMode, // Example VANNE_AUTO_MOVE. HvacMitsubishiVanneMode
// This type support support VANNE_AUTO,VANNE_H1,VANNE_H2,VANNE_H3,VANNE_H4.
int OFF // Example false
)
{

//#define HVAC_MITSUBISHI_DEBUG; // Un comment to access DEBUG information through Serial Interface

byte mask = 1; //our bitmask
byte data[17] = { 0x23, 0xCB, 0x26, 0x21, 0x00, 0x40, 0x52, 0x35, 0x04, 0x00, 0x00, 0xBF, 0xAD, 0xCA, 0xFB, 0xFF, 0xFF };
// byte 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// data array is a valid trame, only byte to be chnaged will be updated.

byte i;

#ifdef HVAC_MITSUBISHI_DEBUG
Serial.println("Packet to send: ");
for (i = 0; i < 17; i++) {
Serial.print("_");
Serial.print(data[i], HEX);
}
Serial.println(".");
#endif

// Byte 5 - On / Off
if (OFF) {
data[5] = (byte) 0x0; // Turn OFF HVAC
} else {
data[5] = (byte) 0x40; // Tuen ON HVAC
}

// Byte 6 - Temperature / Mode
byte tmpTM;

switch (HVAC_Mode) // Mode
{
case HVAC_HOT: tmpTM = (byte) B00000010; break;
case HVAC_COLD: tmpTM = (byte) B00000001; break;
case HVAC_DRY: tmpTM = (byte) B00000101; break;
case HVAC_FAN: tmpTM = (byte) B00000000; break;
case HVAC_AUTO: tmpTM = (byte) B00000011; break;
default: break;
}

byte Temp; // Temperature, support 17~28 in HVAC_HOT mode, 19~30 in HVAC_COLD and HVAC_DRY mode
if (HVAC_Temp > 30 && HVAC_Mode != HVAC_HOT) { Temp = 30;}
else if (HVAC_Temp > 28 && HVAC_Mode == HVAC_HOT) { Temp = 28;}
else if (HVAC_Temp < 19 && HVAC_Mode != HVAC_HOT) { Temp = 19; }
else if (HVAC_Temp < 17 && HVAC_Mode == HVAC_HOT) { Temp = 17; }
else { Temp = HVAC_Temp; };
Temp = (byte) Temp - 16;

data[6] = (byte) Temp * 16 | tmpTM; // Temperature bits are the high 4 bits, Mode bits are the low 4 bits.

// Byte 7 - VANNE / FAN
switch (HVAC_FanMode)
{
case FAN_SPEED_1: data[7] = (byte) B00000001; break;
case FAN_SPEED_2: data[7] = (byte) B00000011; break;
case FAN_SPEED_3: data[7] = (byte) B00000101; break;
case FAN_SPEED_4: data[7] = (byte) B00000111; break;
case FAN_SPEED_5: data[7] = (byte) B00000111; break; // this type doesn't support speed5, set to speed4
case FAN_SPEED_AUTO: data[7] = (byte) B00000101; break; // this type doesn't support auto, set to speed3
case FAN_SPEED_SILENT: data[7] = (byte) B00000001; break; // this type doesn't support slient, set to speed1
default: break;
}

switch (HVAC_VanneMode)
{
case VANNE_AUTO: data[7] = (byte) data[7] | B11000000; break;
case VANNE_H1: data[7] = (byte) data[7] | B00000000; break;
case VANNE_H2: data[7] = (byte) data[7] | B00010000; break;
case VANNE_H3: data[7] = (byte) data[7] | B00100000; break;
case VANNE_H4: data[7] = (byte) data[7] | B00110000; break;
case VANNE_H5: data[7] = (byte) data[7] | B00110000; break; // this type doesn't support vanne5, set to vanne4
case VANNE_AUTO_MOVE: data[7] = (byte) data[7] | B11000000; break; // this type doesn't support automove, set to auto
default: break;
}

// Byte 11 - XOR of Byte 5
data[11] = (byte) B11111111 ^ data[5];

// Byte 12 - XOR of Byte 6
data[12] = (byte) B11111111 ^ data[6];

// Byte 13 - XOR of Byte 7
data[13] = (byte) B11111111 ^ data[7];

#ifdef HVAC_MITSUBISHI_DEBUG
Serial.println("Packet to send: ");
for (i = 0; i < 17; i++) {
Serial.print("_"); Serial.print(data[i], HEX);
}
Serial.println(".");
for (i = 0; i < 17; i++) {
Serial.print(data[i], BIN); Serial.print(" ");
}
Serial.println(".");
#endif

enableIROut(38); // 38khz
space(0);
for (int j = 0; j < 1; j++) { // Mitsubishi W001CP IR protocol only need to send one time
// Header for the Packet
mark(HVAC_MITSUBISHI_HDR_MARK);
space(HVAC_MITSUBISHI_HDR_SPACE);
for (i = 0; i < 18; i++) {
// Send all Bits from Byte Data in Reverse Order
for (mask = 00000001; mask > 0; mask <<= 1) { //iterate through bit mask
if (data[i] & mask) { // Bit ONE
mark(HVAC_MITSUBISHI_BIT_MARK);
space(HVAC_MITSUBISHI_ONE_SPACE);
}
else { // Bit ZERO
mark(HVAC_MITSUBISHI_BIT_MARK);
space(HVAC_MISTUBISHI_ZERO_SPACE);
}
//Next bits
}
}
// End of Packet and retransmission of the Packet
mark(HVAC_MITSUBISHI_RPT_MARK);
space(HVAC_MITSUBISHI_RPT_SPACE);
space(0); // Just to be sure
}
}

/****************************************************************************
/* Send IR command to Mitsubishi HVAC - sendHvacMitsubishi
Expand Down Expand Up @@ -673,7 +810,7 @@ void IRsend::sendHvacMitsubishiFD(
}


/****************************************************************************
/***************************************************************************/
/* Send IR command to Toshiba HVAC - sendHvacToshiba
/***************************************************************************/
void IRsend::sendHvacToshiba(
Expand Down
15 changes: 13 additions & 2 deletions HVACDemo/IRremote2.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* LG added by Darryl Smith (based on the JVC protocol)
*
* Mitsubishi HVAC protocol added by Vincent Cruvellier.
*
* Mitsubishi HVAC W001CP R61Y23304 protocol added by bt4wang.
*/

#ifndef IRremote_h
Expand Down Expand Up @@ -169,6 +169,18 @@ class IRsend
HvacVanneMode HVAC_VanneMode, // Example VANNE_AUTO_MOVE HvacMitsubishiVanneMode
int OFF // Example false
);
// Add support for W001CP R61Y23304 Remote Controller
void sendHvacMitsubishi_W001CP(
HvacMode HVAC_Mode, // Example HVAC_HOT. HvacMitsubishiMode
// This type support HVAC_HOT,HVAC_COLD,HVAC_DRY,HVAC_FAN,HVAC_AUTO.
int HVAC_Temp, // Example 21 (°c).
// This type support 17~28 in HVAC_HOT mode, 19~30 in HVAC_COLD and HVAC_DRY mode.
HvacFanMode HVAC_FanMode, // Example FAN_SPEED_AUTO. HvacMitsubishiFanMode
// This type support FAN_SPEED_1,FAN_SPEED_2,FAN_SPEED_3,FAN_SPEED_4.
HvacVanneMode HVAC_VanneMode, // Example VANNE_AUTO_MOVE. HvacMitsubishiVanneMode
// This type support support VANNE_AUTO,VANNE_H1,VANNE_H2,VANNE_H3,VANNE_H4.
int OFF // Example false
);
void sendHvacMitsubishiFD(
HvacMode HVAC_Mode, // Example HVAC_HOT HvacMitsubishiMode
int HVAC_Temp, // Example 21 (°c)
Expand All @@ -195,7 +207,6 @@ class IRsend
HvacFanMode HVAC_FanMode, // Example FAN_SPEED_AUTO
int OFF // Example false
);


void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
// private:
Expand Down
Binary file not shown.