diff --git a/HVACDemo/IRremote2.cpp b/HVACDemo/IRremote2.cpp index a4da1ea..3092cf6 100644 --- a/HVACDemo/IRremote2.cpp +++ b/HVACDemo/IRremote2.cpp @@ -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" @@ -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 @@ -673,7 +810,7 @@ void IRsend::sendHvacMitsubishiFD( } -/**************************************************************************** +/***************************************************************************/ /* Send IR command to Toshiba HVAC - sendHvacToshiba /***************************************************************************/ void IRsend::sendHvacToshiba( diff --git a/HVACDemo/IRremote2.h b/HVACDemo/IRremote2.h index b878bb0..b887757 100644 --- a/HVACDemo/IRremote2.h +++ b/HVACDemo/IRremote2.h @@ -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 @@ -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) @@ -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: diff --git a/Protocol/Mitsubishi_W001CP_IR_Packet_Data_v1.0-FULL.pdf b/Protocol/Mitsubishi_W001CP_IR_Packet_Data_v1.0-FULL.pdf new file mode 100644 index 0000000..3b7bbac Binary files /dev/null and b/Protocol/Mitsubishi_W001CP_IR_Packet_Data_v1.0-FULL.pdf differ