From 97078a581a6c8f199902077fe18e682eb0fc6714 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Sat, 22 Aug 2015 19:06:22 +0900 Subject: [PATCH 01/20] adding SEND_LG --- IRremote.h | 4 +- examples/LGACSendDemo/LGACSendDemo.ino | 249 +++++++++++++++++++++++++ examples/LGACSendDemo/LGACSendDemo.md | 35 ++++ ir_LG.cpp | 26 +++ 4 files changed, 312 insertions(+), 2 deletions(-) create mode 100644 examples/LGACSendDemo/LGACSendDemo.ino create mode 100644 examples/LGACSendDemo/LGACSendDemo.md diff --git a/IRremote.h b/IRremote.h index 898bd15..ce404a6 100644 --- a/IRremote.h +++ b/IRremote.h @@ -56,7 +56,7 @@ #define SEND_AIWA_RC_T501 1 #define DECODE_LG 1 -#define SEND_LG 0 // NOT WRITTEN +#define SEND_LG 1 #define DECODE_SANYO 1 #define SEND_SANYO 0 // NOT WRITTEN @@ -300,7 +300,7 @@ class IRsend # endif //...................................................................... # if SEND_LG - void sendLG ( ) ; // NOT WRITTEN + void sendLG (unsigned long data, int nbits) ; # endif //...................................................................... # if SEND_SANYO diff --git a/examples/LGACSendDemo/LGACSendDemo.ino b/examples/LGACSendDemo/LGACSendDemo.ino new file mode 100644 index 0000000..66d5025 --- /dev/null +++ b/examples/LGACSendDemo/LGACSendDemo.ino @@ -0,0 +1,249 @@ +#include +#include + + +IRsend irsend; +// not used +int RECV_PIN = 11; +IRrecv irrecv (RECV_PIN); + +const int AC_TYPE = 0; +// 0 : TOWER +// 1 : WALL + +int AC_POWER_ON = 0; +// 0 : off +// 1 : on + +int AC_AIR_ACLEAN = 0; +// 0 : off +// 1 : on --> power on + +int AC_TEMPERATURE = 27; +// temperature : 18 ~ 30 + +int AC_FLOW = 1; +// 0 : low +// 1 : mid +// 2 : high +// if AC_TYPE =1, 3 : change + +const int AC_FLOW_TOWER[3] = {0, 4, 6}; +const int AC_FLOW_WALL[4] = {0, 2, 4, 5}; + +unsigned long AC_CODE_TO_SEND; + +int r = LOW; +int o_r = LOW; + +byte a, b; + +void ac_send_code(unsigned long code) +{ + Serial.print("code to send : "); + Serial.print(code, BIN); + Serial.print(" : "); + Serial.println(code, HEX); + + irsend.sendLG(code, 28); +} + +void ac_activate(int temperature, int air_flow) +{ + + int AC_MSBITS1 = 8; + int AC_MSBITS2 = 8; + int AC_MSBITS3 = 0; + int AC_MSBITS4 = 0; + int AC_MSBITS5 = temperature - 15; + int AC_MSBITS6 ; + + if ( AC_TYPE == 0) { + AC_MSBITS6 = AC_FLOW_TOWER[air_flow]; + } else { + AC_MSBITS6 = AC_FLOW_WALL[air_flow]; + } + + int AC_MSBITS7 = (AC_MSBITS3 + AC_MSBITS4 + AC_MSBITS5 + AC_MSBITS6) & B00001111; + + AC_CODE_TO_SEND = AC_MSBITS1 << 4 ; + AC_CODE_TO_SEND = (AC_CODE_TO_SEND + AC_MSBITS2) << 4; + AC_CODE_TO_SEND = (AC_CODE_TO_SEND + AC_MSBITS3) << 4; + AC_CODE_TO_SEND = (AC_CODE_TO_SEND + AC_MSBITS4) << 4; + AC_CODE_TO_SEND = (AC_CODE_TO_SEND + AC_MSBITS5) << 4; + AC_CODE_TO_SEND = (AC_CODE_TO_SEND + AC_MSBITS6) << 4; + AC_CODE_TO_SEND = (AC_CODE_TO_SEND + AC_MSBITS7); + + ac_send_code(AC_CODE_TO_SEND); + + AC_POWER_ON = 1; + AC_TEMPERATURE = temperature; + AC_FLOW = air_flow; +} + +void ac_change_air_swing(int air_swing) +{ + if ( AC_TYPE == 0) { + if ( air_swing == 1) { + AC_CODE_TO_SEND = 0x881316B; + } else { + AC_CODE_TO_SEND = 0x881317C; + } + } else { + if ( air_swing == 1) { + AC_CODE_TO_SEND = 0x8813149; + } else { + AC_CODE_TO_SEND = 0x881315A; + } + } + + ac_send_code(AC_CODE_TO_SEND); +} + +void ac_power_down() +{ + AC_CODE_TO_SEND = 0x88C0051; + + ac_send_code(AC_CODE_TO_SEND); + + AC_POWER_ON = 0; +} + +void ac_air_clean(int air_clean) +{ + if ( air_clean == 1) { + AC_CODE_TO_SEND = 0x88C000C; + } else { + AC_CODE_TO_SEND = 0x88C0084; + } + + ac_send_code(AC_CODE_TO_SEND); + + AC_AIR_ACLEAN = air_clean; +} + +void setup() +{ + Serial.begin(38400); + delay(1000); + Wire.begin(7); + Wire.onReceive(receiveEvent); + + Serial.println(" - - - T E S T - - - "); + +/* test + ac_activate(25, 1); + delay(5000); + ac_activate(27, 2); + delay(5000); + +*/ +} + +void loop() +{ + + + ac_activate(25, 1); + delay(5000); + ac_activate(27, 0); + delay(5000); + + + if ( r != o_r) { + + /* + # a : mode or temp b : air_flow, temp, swing, clean + # 18 ~ 30 : temp 0 ~ 2 : flow // on + # 0 : off 0 + # 1 : on 0 + # 2 : air_swing 0 or 1 + # 3 : air_clean 0 or 1 + # 4 : air_flow 0 ~ 2 : flow + # 5 : temp 18 ~ 30 + # + : temp + 1 + # - : temp - 1 + # m : change cooling to air clean, air clean to cooling + */ + Serial.print("a : "); + Serial.print(a); + Serial.print(" b : "); + Serial.println(b); + + switch (a) { + case 0: // off + ac_power_down(); + break; + case 1: // on + ac_activate(AC_TEMPERATURE, AC_FLOW); + break; + case 2: + if ( b == 0 | b == 1 ) { + ac_change_air_swing(b); + } + break; + case 3: // 1 : clean on, power on + if ( b == 0 | b == 1 ) { + ac_air_clean(b); + } + break; + case 4: + if ( 0 <= b && b <= 2 ) { + ac_activate(AC_TEMPERATURE, b); + } + break; + case 5: + if (18 <= b && b <= 30 ) { + ac_activate(b, AC_FLOW); + } + break; + case '+': + if ( 18 <= AC_TEMPERATURE && AC_TEMPERATURE <= 29 ) { + ac_activate((AC_TEMPERATURE + 1), AC_FLOW); + } + break; + case '-': + if ( 19 <= AC_TEMPERATURE && AC_TEMPERATURE <= 30 ) { + ac_activate((AC_TEMPERATURE - 1), AC_FLOW); + } + break; + case 'm': + /* + if ac is on, 1) turn off, 2) turn on ac_air_clean(1) + if ac is off, 1) turn on, 2) turn off ac_air_clean(0) + */ + if ( AC_POWER_ON == 1 ) { + ac_power_down(); + delay(100); + ac_air_clean(1); + } else { + if ( AC_AIR_ACLEAN == 1) { + ac_air_clean(0); + delay(100); + } + ac_activate(AC_TEMPERATURE, AC_FLOW); + } + break; + default: + if ( 18 <= a && a <= 30 ) { + if ( 0 <= b && b <= 2 ) { + ac_activate(a, b); + } + } + } + + o_r = r ; + } + delay(100); +} + + + +void receiveEvent(int howMany) +{ + a = Wire.read(); + b = Wire.read(); + r = !r ; +} + + diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md new file mode 100644 index 0000000..1bff51f --- /dev/null +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -0,0 +1,35 @@ +1) Sample raw code : https://gist.github.com/chaeplin/ab2a7ad1533c41260f0d +2) send raw code : https://gist.github.com/chaeplin/7c800d3166463bb51be4 + + +=== *** === +- (1) : fixed +- (2) : fixed +- (3) : special(power, swing, air clean) +- (4) : change air flow, temperature +- (5) : temperature ( 15 + (5) = ) +- (6) : air flow +- (7) : crc ( 3 + 4 + 5 + 6 ) & B00001111 + +=== *** === + +| status | (1)| (2)| (3)| (4)| (5)| (6)| (7) +|----------------|----|----|----|----|----|----|---- +| on / 25 / mid |1000|1000|0000|0000|1010|0010|1100 +| on / 26 / mid |1000|1000|0000|0000|1011|0010|1101 +| on / 27 / mid |1000|1000|0000|0000|1100|0010|1110 +| on / 28 / mid |1000|1000|0000|0000|1101|0010|1111 +| on / 25 / high |1000|1000|0000|0000|1010|0100|1110 +| on / 26 / high |1000|1000|0000|0000|1011|0100|1111 +| on / 27 / high |1000|1000|0000|0000|1100|0100|0000 +| on / 28 / high |1000|1000|0000|0000|1101|0100|0001 +| 1 up |1000|1000|0000|1000|1101|0100|1001 +| Cool power |1000|1000|0001|0000|0000|1100|1101 +| energy saving |1000|1000|0001|0000|0000|0100|0101 +| power |1000|1000|0001|0000|0000|1000|1001 +| flow/up/down |1000|1000|0001|0011|0001|0100|1001 +| up/down off |1000|1000|0001|0011|0001|0101|1010 +| flow/left/right|1000|1000|0001|0011|0001|0110|1011 +| left/right off |1000|1000|0001|0011|0001|0111|1100 +| Air clean |1000|1000|1100|0000|0000|0000|1100 +| off |1000|1000|1100|0000|0000|0101|0001 \ No newline at end of file diff --git a/ir_LG.cpp b/ir_LG.cpp index 4e8dd82..ba532cb 100644 --- a/ir_LG.cpp +++ b/ir_LG.cpp @@ -52,3 +52,29 @@ bool IRrecv::decodeLG (decode_results *results) } #endif +//+============================================================================= +#if SEND_LG +void IRsend::sendLG (unsigned long data, int nbits) +{ + // Set IR carrier frequency + enableIROut(38); + + // Header + mark(LG_HDR_MARK); + space(LG_HDR_SPACE); + mark(LG_BIT_MARK); + + // Data + for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { + if (data & mask) { + space(LG_ONE_SPACE); + mark(LG_BIT_MARK); + } else { + space(LG_ZERO_SPACE); + mark(LG_BIT_MARK); + } + } + space(0); // Always end with the LED off +} +#endif + From 934ad53aad1fb16c7bc74ebd104c7d76e1522cbb Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Wed, 26 Aug 2015 16:14:26 -0600 Subject: [PATCH 02/20] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ec1aecc..9dee657 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Check [here](http://z3t0.github.io/Arduino-IRremote/) for tutorials and more inf 2. Download the latest release. 3. Extract the zip file 4. Move the "IRremote" folder that has been extracted to your libraries directory. +5. Make sure to delete Arduino_Root/libraries/RobotIRRemote. Where Arduino_Root refers to the install directory of Arduino. The library RobotIRRemote has similar definitions to IRremote and causes errors. ## Usage - TODO (Check examples for now) From bba4ed8065ba902ac748cbce1e74355e5a025d2f Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Wed, 26 Aug 2015 16:16:26 -0600 Subject: [PATCH 03/20] corrected a typo --- IRremote.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRremote.h b/IRremote.h index ce404a6..4af944a 100644 --- a/IRremote.h +++ b/IRremote.h @@ -324,7 +324,7 @@ class IRsend void sendDenon (unsigned long data, int nbits) ; # endif //...................................................................... -# if SEND_Pronto +# if SEND_PRONTO void sendPronto (char* code, bool repeat, bool fallback) ; # endif } ; From 594722ad4d4251292c28f6ea10656bfa9d594064 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Thu, 27 Aug 2015 20:55:40 +0900 Subject: [PATCH 04/20] heating --- examples/LGACSendDemo/LGACSendDemo.md | 86 ++++++++++++++++++++------- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 1bff51f..3fe73c6 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -3,33 +3,75 @@ === *** === +- (0) : Cooling or Heating - (1) : fixed - (2) : fixed - (3) : special(power, swing, air clean) -- (4) : change air flow, temperature +- (4) : change air flow, temperature, coolingi(0)/heating(4) - (5) : temperature ( 15 + (5) = ) - (6) : air flow - (7) : crc ( 3 + 4 + 5 + 6 ) & B00001111 -=== *** === -| status | (1)| (2)| (3)| (4)| (5)| (6)| (7) -|----------------|----|----|----|----|----|----|---- -| on / 25 / mid |1000|1000|0000|0000|1010|0010|1100 -| on / 26 / mid |1000|1000|0000|0000|1011|0010|1101 -| on / 27 / mid |1000|1000|0000|0000|1100|0010|1110 -| on / 28 / mid |1000|1000|0000|0000|1101|0010|1111 -| on / 25 / high |1000|1000|0000|0000|1010|0100|1110 -| on / 26 / high |1000|1000|0000|0000|1011|0100|1111 -| on / 27 / high |1000|1000|0000|0000|1100|0100|0000 -| on / 28 / high |1000|1000|0000|0000|1101|0100|0001 -| 1 up |1000|1000|0000|1000|1101|0100|1001 -| Cool power |1000|1000|0001|0000|0000|1100|1101 -| energy saving |1000|1000|0001|0000|0000|0100|0101 -| power |1000|1000|0001|0000|0000|1000|1001 -| flow/up/down |1000|1000|0001|0011|0001|0100|1001 -| up/down off |1000|1000|0001|0011|0001|0101|1010 -| flow/left/right|1000|1000|0001|0011|0001|0110|1011 -| left/right off |1000|1000|0001|0011|0001|0111|1100 -| Air clean |1000|1000|1100|0000|0000|0000|1100 -| off |1000|1000|1100|0000|0000|0101|0001 \ No newline at end of file +°F = °C × 1.8 + 32 +°C = (°F − 32) / 1.8 + + +=== *** === +* remote / Korea / without heating +| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) +|----------------|---|----|----|----|----|----|----|---- +| on / 25 / mid | C |1000|1000|0000|0000|1010|0010|1100 +| on / 26 / mid | C |1000|1000|0000|0000|1011|0010|1101 +| on / 27 / mid | C |1000|1000|0000|0000|1100|0010|1110 +| on / 28 / mid | C |1000|1000|0000|0000|1101|0010|1111 +| on / 25 / high | C |1000|1000|0000|0000|1010|0100|1110 +| on / 26 / high | C |1000|1000|0000|0000|1011|0100|1111 +| on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000 +| on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001 +| 1 up | C |1000|1000|0000|1000|1101|0100|1001 +| Cool power | C |1000|1000|0001|0000|0000|1100|1101 +| energy saving | C |1000|1000|0001|0000|0000|0100|0101 +| power | C |1000|1000|0001|0000|0000|1000|1001 +| flow/up/down | C |1000|1000|0001|0011|0001|0100|1001 +| up/down off | C |1000|1000|0001|0011|0001|0101|1010 +| flow/left/right| C |1000|1000|0001|0011|0001|0110|1011 +| left/right off | C |1000|1000|0001|0011|0001|0111|1100 +| Air clean | C |1000|1000|1100|0000|0000|0000|1100 +| off | C |1000|1000|1100|0000|0000|0101|0001 + + + +* remote / with heating +* converted from raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf + +| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) +|----------------|---|----|----|----|----|----|----|---- +| on | C |1000|1000|0000|0000|1011|0010|1101 +| of | C |1000|1000|1100|0000|0000|0101|0001 +|----------------|---|----|----|----|----|----|----|---- +| 64 | C |1000|1000|0000|0000|0011|0100|0111 +| 66 | C |1000|1000|0000|0000|0100|0100|1000 +| 68 | C |1000|1000|0000|0000|0101|0100|1001 +| 70 | C |1000|1000|0000|0000|0110|0100|1010 +| 72 | C |1000|1000|0000|0000|0111|0100|1011 +| 74 | C |1000|1000|0000|0000|1000|0100|1100 +| 76 | C |1000|1000|0000|0000|1010|0100|1110 +| 78 | C |1000|1000|0000|0000|1011|0100|1111 +| 80 | C |1000|1000|0000|0000|1100|0100|0000 +| 82 | C |1000|1000|0000|0000|1101|0100|0001 +| 84 | C |1000|1000|0000|0000|1110|0100|0010 +| 86 | C |1000|1000|0000|0000|1111|0100|0011 +| heat64 | H |1000|1000|0000|0100|0011|0100|1011 +| heat66 | H |1000|1000|0000|0100|0100|0100|1100 +| heat68 | H |1000|1000|0000|0100|0101|0100|1101 +| heat70 | H |1000|1000|0000|0100|0110|0100|1110 +| heat72 | H |1000|1000|0000|0100|0111|0100|1111 +| heat74 | H |1000|1000|0000|0100|1000|0100|0000 +| heat76 | H |1000|1000|0000|0100|1001|0100|0001 +| heat78 | H |1000|1000|0000|0100|1011|0100|0011 +| heat80 | H |1000|1000|0000|0100|1100|0100|0100 +| heat82 | H |1000|1000|0000|0100|1101|0100|0101 +| heat84 | H |1000|1000|0000|0100|1110|0100|0110 +| heat86 | H |1000|1000|0000|0100|1111|0100|0111 + From ee067b1cb3f68ba4648281ccc087fb6beb01ee7d Mon Sep 17 00:00:00 2001 From: chaeplin Date: Thu, 27 Aug 2015 20:58:00 +0900 Subject: [PATCH 05/20] Revert "heating" This reverts commit 594722ad4d4251292c28f6ea10656bfa9d594064. --- examples/LGACSendDemo/LGACSendDemo.md | 84 +++++++-------------------- 1 file changed, 21 insertions(+), 63 deletions(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 3fe73c6..1bff51f 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -3,75 +3,33 @@ === *** === -- (0) : Cooling or Heating - (1) : fixed - (2) : fixed - (3) : special(power, swing, air clean) -- (4) : change air flow, temperature, coolingi(0)/heating(4) +- (4) : change air flow, temperature - (5) : temperature ( 15 + (5) = ) - (6) : air flow - (7) : crc ( 3 + 4 + 5 + 6 ) & B00001111 - -°F = °C × 1.8 + 32 -°C = (°F − 32) / 1.8 - - === *** === -* remote / Korea / without heating -| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) -|----------------|---|----|----|----|----|----|----|---- -| on / 25 / mid | C |1000|1000|0000|0000|1010|0010|1100 -| on / 26 / mid | C |1000|1000|0000|0000|1011|0010|1101 -| on / 27 / mid | C |1000|1000|0000|0000|1100|0010|1110 -| on / 28 / mid | C |1000|1000|0000|0000|1101|0010|1111 -| on / 25 / high | C |1000|1000|0000|0000|1010|0100|1110 -| on / 26 / high | C |1000|1000|0000|0000|1011|0100|1111 -| on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000 -| on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001 -| 1 up | C |1000|1000|0000|1000|1101|0100|1001 -| Cool power | C |1000|1000|0001|0000|0000|1100|1101 -| energy saving | C |1000|1000|0001|0000|0000|0100|0101 -| power | C |1000|1000|0001|0000|0000|1000|1001 -| flow/up/down | C |1000|1000|0001|0011|0001|0100|1001 -| up/down off | C |1000|1000|0001|0011|0001|0101|1010 -| flow/left/right| C |1000|1000|0001|0011|0001|0110|1011 -| left/right off | C |1000|1000|0001|0011|0001|0111|1100 -| Air clean | C |1000|1000|1100|0000|0000|0000|1100 -| off | C |1000|1000|1100|0000|0000|0101|0001 - - - -* remote / with heating -* converted from raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf - -| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) -|----------------|---|----|----|----|----|----|----|---- -| on | C |1000|1000|0000|0000|1011|0010|1101 -| of | C |1000|1000|1100|0000|0000|0101|0001 -|----------------|---|----|----|----|----|----|----|---- -| 64 | C |1000|1000|0000|0000|0011|0100|0111 -| 66 | C |1000|1000|0000|0000|0100|0100|1000 -| 68 | C |1000|1000|0000|0000|0101|0100|1001 -| 70 | C |1000|1000|0000|0000|0110|0100|1010 -| 72 | C |1000|1000|0000|0000|0111|0100|1011 -| 74 | C |1000|1000|0000|0000|1000|0100|1100 -| 76 | C |1000|1000|0000|0000|1010|0100|1110 -| 78 | C |1000|1000|0000|0000|1011|0100|1111 -| 80 | C |1000|1000|0000|0000|1100|0100|0000 -| 82 | C |1000|1000|0000|0000|1101|0100|0001 -| 84 | C |1000|1000|0000|0000|1110|0100|0010 -| 86 | C |1000|1000|0000|0000|1111|0100|0011 -| heat64 | H |1000|1000|0000|0100|0011|0100|1011 -| heat66 | H |1000|1000|0000|0100|0100|0100|1100 -| heat68 | H |1000|1000|0000|0100|0101|0100|1101 -| heat70 | H |1000|1000|0000|0100|0110|0100|1110 -| heat72 | H |1000|1000|0000|0100|0111|0100|1111 -| heat74 | H |1000|1000|0000|0100|1000|0100|0000 -| heat76 | H |1000|1000|0000|0100|1001|0100|0001 -| heat78 | H |1000|1000|0000|0100|1011|0100|0011 -| heat80 | H |1000|1000|0000|0100|1100|0100|0100 -| heat82 | H |1000|1000|0000|0100|1101|0100|0101 -| heat84 | H |1000|1000|0000|0100|1110|0100|0110 -| heat86 | H |1000|1000|0000|0100|1111|0100|0111 +| status | (1)| (2)| (3)| (4)| (5)| (6)| (7) +|----------------|----|----|----|----|----|----|---- +| on / 25 / mid |1000|1000|0000|0000|1010|0010|1100 +| on / 26 / mid |1000|1000|0000|0000|1011|0010|1101 +| on / 27 / mid |1000|1000|0000|0000|1100|0010|1110 +| on / 28 / mid |1000|1000|0000|0000|1101|0010|1111 +| on / 25 / high |1000|1000|0000|0000|1010|0100|1110 +| on / 26 / high |1000|1000|0000|0000|1011|0100|1111 +| on / 27 / high |1000|1000|0000|0000|1100|0100|0000 +| on / 28 / high |1000|1000|0000|0000|1101|0100|0001 +| 1 up |1000|1000|0000|1000|1101|0100|1001 +| Cool power |1000|1000|0001|0000|0000|1100|1101 +| energy saving |1000|1000|0001|0000|0000|0100|0101 +| power |1000|1000|0001|0000|0000|1000|1001 +| flow/up/down |1000|1000|0001|0011|0001|0100|1001 +| up/down off |1000|1000|0001|0011|0001|0101|1010 +| flow/left/right|1000|1000|0001|0011|0001|0110|1011 +| left/right off |1000|1000|0001|0011|0001|0111|1100 +| Air clean |1000|1000|1100|0000|0000|0000|1100 +| off |1000|1000|1100|0000|0000|0101|0001 \ No newline at end of file From 969b34fcc4284e0c1ac6a27d0964a4d4dacccea8 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Thu, 27 Aug 2015 20:58:38 +0900 Subject: [PATCH 06/20] Revert "Revert "heating"" This reverts commit ee067b1cb3f68ba4648281ccc087fb6beb01ee7d. --- examples/LGACSendDemo/LGACSendDemo.md | 86 ++++++++++++++++++++------- 1 file changed, 64 insertions(+), 22 deletions(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 1bff51f..3fe73c6 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -3,33 +3,75 @@ === *** === +- (0) : Cooling or Heating - (1) : fixed - (2) : fixed - (3) : special(power, swing, air clean) -- (4) : change air flow, temperature +- (4) : change air flow, temperature, coolingi(0)/heating(4) - (5) : temperature ( 15 + (5) = ) - (6) : air flow - (7) : crc ( 3 + 4 + 5 + 6 ) & B00001111 -=== *** === -| status | (1)| (2)| (3)| (4)| (5)| (6)| (7) -|----------------|----|----|----|----|----|----|---- -| on / 25 / mid |1000|1000|0000|0000|1010|0010|1100 -| on / 26 / mid |1000|1000|0000|0000|1011|0010|1101 -| on / 27 / mid |1000|1000|0000|0000|1100|0010|1110 -| on / 28 / mid |1000|1000|0000|0000|1101|0010|1111 -| on / 25 / high |1000|1000|0000|0000|1010|0100|1110 -| on / 26 / high |1000|1000|0000|0000|1011|0100|1111 -| on / 27 / high |1000|1000|0000|0000|1100|0100|0000 -| on / 28 / high |1000|1000|0000|0000|1101|0100|0001 -| 1 up |1000|1000|0000|1000|1101|0100|1001 -| Cool power |1000|1000|0001|0000|0000|1100|1101 -| energy saving |1000|1000|0001|0000|0000|0100|0101 -| power |1000|1000|0001|0000|0000|1000|1001 -| flow/up/down |1000|1000|0001|0011|0001|0100|1001 -| up/down off |1000|1000|0001|0011|0001|0101|1010 -| flow/left/right|1000|1000|0001|0011|0001|0110|1011 -| left/right off |1000|1000|0001|0011|0001|0111|1100 -| Air clean |1000|1000|1100|0000|0000|0000|1100 -| off |1000|1000|1100|0000|0000|0101|0001 \ No newline at end of file +°F = °C × 1.8 + 32 +°C = (°F − 32) / 1.8 + + +=== *** === +* remote / Korea / without heating +| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) +|----------------|---|----|----|----|----|----|----|---- +| on / 25 / mid | C |1000|1000|0000|0000|1010|0010|1100 +| on / 26 / mid | C |1000|1000|0000|0000|1011|0010|1101 +| on / 27 / mid | C |1000|1000|0000|0000|1100|0010|1110 +| on / 28 / mid | C |1000|1000|0000|0000|1101|0010|1111 +| on / 25 / high | C |1000|1000|0000|0000|1010|0100|1110 +| on / 26 / high | C |1000|1000|0000|0000|1011|0100|1111 +| on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000 +| on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001 +| 1 up | C |1000|1000|0000|1000|1101|0100|1001 +| Cool power | C |1000|1000|0001|0000|0000|1100|1101 +| energy saving | C |1000|1000|0001|0000|0000|0100|0101 +| power | C |1000|1000|0001|0000|0000|1000|1001 +| flow/up/down | C |1000|1000|0001|0011|0001|0100|1001 +| up/down off | C |1000|1000|0001|0011|0001|0101|1010 +| flow/left/right| C |1000|1000|0001|0011|0001|0110|1011 +| left/right off | C |1000|1000|0001|0011|0001|0111|1100 +| Air clean | C |1000|1000|1100|0000|0000|0000|1100 +| off | C |1000|1000|1100|0000|0000|0101|0001 + + + +* remote / with heating +* converted from raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf + +| status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) +|----------------|---|----|----|----|----|----|----|---- +| on | C |1000|1000|0000|0000|1011|0010|1101 +| of | C |1000|1000|1100|0000|0000|0101|0001 +|----------------|---|----|----|----|----|----|----|---- +| 64 | C |1000|1000|0000|0000|0011|0100|0111 +| 66 | C |1000|1000|0000|0000|0100|0100|1000 +| 68 | C |1000|1000|0000|0000|0101|0100|1001 +| 70 | C |1000|1000|0000|0000|0110|0100|1010 +| 72 | C |1000|1000|0000|0000|0111|0100|1011 +| 74 | C |1000|1000|0000|0000|1000|0100|1100 +| 76 | C |1000|1000|0000|0000|1010|0100|1110 +| 78 | C |1000|1000|0000|0000|1011|0100|1111 +| 80 | C |1000|1000|0000|0000|1100|0100|0000 +| 82 | C |1000|1000|0000|0000|1101|0100|0001 +| 84 | C |1000|1000|0000|0000|1110|0100|0010 +| 86 | C |1000|1000|0000|0000|1111|0100|0011 +| heat64 | H |1000|1000|0000|0100|0011|0100|1011 +| heat66 | H |1000|1000|0000|0100|0100|0100|1100 +| heat68 | H |1000|1000|0000|0100|0101|0100|1101 +| heat70 | H |1000|1000|0000|0100|0110|0100|1110 +| heat72 | H |1000|1000|0000|0100|0111|0100|1111 +| heat74 | H |1000|1000|0000|0100|1000|0100|0000 +| heat76 | H |1000|1000|0000|0100|1001|0100|0001 +| heat78 | H |1000|1000|0000|0100|1011|0100|0011 +| heat80 | H |1000|1000|0000|0100|1100|0100|0100 +| heat82 | H |1000|1000|0000|0100|1101|0100|0101 +| heat84 | H |1000|1000|0000|0100|1110|0100|0110 +| heat86 | H |1000|1000|0000|0100|1111|0100|0111 + From 0f03eeeaf23bbafbd443eed1625e9971eae0c7ad Mon Sep 17 00:00:00 2001 From: chaeplin Date: Thu, 27 Aug 2015 21:01:26 +0900 Subject: [PATCH 07/20] heating --- examples/LGACSendDemo/LGACSendDemo.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 3fe73c6..4ed3042 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -1,5 +1,6 @@ -1) Sample raw code : https://gist.github.com/chaeplin/ab2a7ad1533c41260f0d -2) send raw code : https://gist.github.com/chaeplin/7c800d3166463bb51be4 +=== *** === +- 1) Sample raw code : https://gist.github.com/chaeplin/ab2a7ad1533c41260f0d +- 2) send raw code : https://gist.github.com/chaeplin/7c800d3166463bb51be4 === *** === @@ -19,6 +20,7 @@ === *** === * remote / Korea / without heating + | status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) |----------------|---|----|----|----|----|----|----|---- | on / 25 / mid | C |1000|1000|0000|0000|1010|0010|1100 @@ -28,7 +30,8 @@ | on / 25 / high | C |1000|1000|0000|0000|1010|0100|1110 | on / 26 / high | C |1000|1000|0000|0000|1011|0100|1111 | on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000 -| on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001 +| on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001 +|----------------|---|----|----|----|----|----|----|---- | 1 up | C |1000|1000|0000|1000|1101|0100|1001 | Cool power | C |1000|1000|0001|0000|0000|1100|1101 | energy saving | C |1000|1000|0001|0000|0000|0100|0101 @@ -74,4 +77,3 @@ | heat82 | H |1000|1000|0000|0100|1101|0100|0101 | heat84 | H |1000|1000|0000|0100|1110|0100|0110 | heat86 | H |1000|1000|0000|0100|1111|0100|0111 - From 72d3d4dc26bdb16a6a8d0d522793637c5d9da4ca Mon Sep 17 00:00:00 2001 From: chaeplin Date: Thu, 27 Aug 2015 21:04:34 +0900 Subject: [PATCH 08/20] typo --- examples/LGACSendDemo/LGACSendDemo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 4ed3042..230701a 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -8,7 +8,7 @@ - (1) : fixed - (2) : fixed - (3) : special(power, swing, air clean) -- (4) : change air flow, temperature, coolingi(0)/heating(4) +- (4) : change air flow, temperature, cooling(0)/heating(4) - (5) : temperature ( 15 + (5) = ) - (6) : air flow - (7) : crc ( 3 + 4 + 5 + 6 ) & B00001111 From ac1b2d28dd45cd6acc45738d04103241b11fe704 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Thu, 27 Aug 2015 21:09:30 +0900 Subject: [PATCH 09/20] add heating --- examples/LGACSendDemo/LGACSendDemo.ino | 28 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.ino b/examples/LGACSendDemo/LGACSendDemo.ino index 66d5025..8dfb804 100644 --- a/examples/LGACSendDemo/LGACSendDemo.ino +++ b/examples/LGACSendDemo/LGACSendDemo.ino @@ -10,6 +10,11 @@ IRrecv irrecv (RECV_PIN); const int AC_TYPE = 0; // 0 : TOWER // 1 : WALL +// + +const int AC_HEAT = 0; +// 0 : cooling +// 1 : heating int AC_POWER_ON = 0; // 0 : off @@ -27,6 +32,8 @@ int AC_FLOW = 1; // 1 : mid // 2 : high // if AC_TYPE =1, 3 : change +// + const int AC_FLOW_TOWER[3] = {0, 4, 6}; const int AC_FLOW_WALL[4] = {0, 2, 4, 5}; @@ -54,7 +61,12 @@ void ac_activate(int temperature, int air_flow) int AC_MSBITS1 = 8; int AC_MSBITS2 = 8; int AC_MSBITS3 = 0; - int AC_MSBITS4 = 0; + int AC_MSBITS4 ; + if ( AC_HEAT == 1 ) { + AC_MSBITS4 = 4; + } else { + AC_MSBITS4 = 0; + } int AC_MSBITS5 = temperature - 15; int AC_MSBITS6 ; @@ -131,13 +143,13 @@ void setup() Serial.println(" - - - T E S T - - - "); -/* test - ac_activate(25, 1); - delay(5000); - ac_activate(27, 2); - delay(5000); + /* test + ac_activate(25, 1); + delay(5000); + ac_activate(27, 2); + delay(5000); -*/ + */ } void loop() @@ -149,7 +161,7 @@ void loop() ac_activate(27, 0); delay(5000); - + if ( r != o_r) { /* From 67f0bf2f9a299c6dee752cc73af8fa6b7e31c3c5 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Fri, 28 Aug 2015 03:36:26 +0900 Subject: [PATCH 10/20] Fahrenheit --- examples/LGACSendDemo/LGACSendDemo.ino | 6 ++-- examples/LGACSendDemo/LGACSendDemo.md | 39 +++++++++++++++----------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.ino b/examples/LGACSendDemo/LGACSendDemo.ino index 8dfb804..da5db37 100644 --- a/examples/LGACSendDemo/LGACSendDemo.ino +++ b/examples/LGACSendDemo/LGACSendDemo.ino @@ -12,7 +12,7 @@ const int AC_TYPE = 0; // 1 : WALL // -const int AC_HEAT = 0; +int AC_HEAT = 0; // 0 : cooling // 1 : heating @@ -63,8 +63,10 @@ void ac_activate(int temperature, int air_flow) int AC_MSBITS3 = 0; int AC_MSBITS4 ; if ( AC_HEAT == 1 ) { + // heating AC_MSBITS4 = 4; } else { + // cooling AC_MSBITS4 = 0; } int AC_MSBITS5 = temperature - 15; @@ -165,7 +167,7 @@ void loop() if ( r != o_r) { /* - # a : mode or temp b : air_flow, temp, swing, clean + # a : mode or temp b : air_flow, temp, swing, clean, cooling/heating # 18 ~ 30 : temp 0 ~ 2 : flow // on # 0 : off 0 # 1 : on 0 diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 230701a..7f859d1 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -32,39 +32,44 @@ | on / 27 / high | C |1000|1000|0000|0000|1100|0100|0000 | on / 28 / high | C |1000|1000|0000|0000|1101|0100|0001 |----------------|---|----|----|----|----|----|----|---- -| 1 up | C |1000|1000|0000|1000|1101|0100|1001 +| 1 up | C |1000|1000|0000|1000|1101|0100|1001 +|----------------|---|----|----|----|----|----|----|---- | Cool power | C |1000|1000|0001|0000|0000|1100|1101 | energy saving | C |1000|1000|0001|0000|0000|0100|0101 | power | C |1000|1000|0001|0000|0000|1000|1001 | flow/up/down | C |1000|1000|0001|0011|0001|0100|1001 | up/down off | C |1000|1000|0001|0011|0001|0101|1010 | flow/left/right| C |1000|1000|0001|0011|0001|0110|1011 -| left/right off | C |1000|1000|0001|0011|0001|0111|1100 -| Air clean | C |1000|1000|1100|0000|0000|0000|1100 +| left/right off | C |1000|1000|0001|0011|0001|0111|1100 +|----------------|---|----|----|----|----|----|----|---- +| Air clean | C |1000|1000|1100|0000|0000|0000|1100 +|----------------|---|----|----|----|----|----|----|---- | off | C |1000|1000|1100|0000|0000|0101|0001 * remote / with heating -* converted from raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf +* converted using raw code at https://github.com/chaeplin/RaspAC/blob/master/lircd.conf | status |(0)| (1)| (2)| (3)| (4)| (5)| (6)| (7) |----------------|---|----|----|----|----|----|----|---- | on | C |1000|1000|0000|0000|1011|0010|1101 -| of | C |1000|1000|1100|0000|0000|0101|0001 |----------------|---|----|----|----|----|----|----|---- -| 64 | C |1000|1000|0000|0000|0011|0100|0111 -| 66 | C |1000|1000|0000|0000|0100|0100|1000 -| 68 | C |1000|1000|0000|0000|0101|0100|1001 -| 70 | C |1000|1000|0000|0000|0110|0100|1010 -| 72 | C |1000|1000|0000|0000|0111|0100|1011 -| 74 | C |1000|1000|0000|0000|1000|0100|1100 -| 76 | C |1000|1000|0000|0000|1010|0100|1110 -| 78 | C |1000|1000|0000|0000|1011|0100|1111 -| 80 | C |1000|1000|0000|0000|1100|0100|0000 -| 82 | C |1000|1000|0000|0000|1101|0100|0001 -| 84 | C |1000|1000|0000|0000|1110|0100|0010 -| 86 | C |1000|1000|0000|0000|1111|0100|0011 +| off | C |1000|1000|1100|0000|0000|0101|0001 +|----------------|---|----|----|----|----|----|----|---- +| 64 / 18 | C |1000|1000|0000|0000|0011|0100|0111 +| 66 / 19 | C |1000|1000|0000|0000|0100|0100|1000 +| 68 / 20 | C |1000|1000|0000|0000|0101|0100|1001 +| 70 / 21 | C |1000|1000|0000|0000|0110|0100|1010 +| 72 / 22 | C |1000|1000|0000|0000|0111|0100|1011 +| 74 / 23 | C |1000|1000|0000|0000|1000|0100|1100 +| 76 / 25 | C |1000|1000|0000|0000|1010|0100|1110 +| 78 / 26 | C |1000|1000|0000|0000|1011|0100|1111 +| 80 / 27 | C |1000|1000|0000|0000|1100|0100|0000 +| 82 / 28 | C |1000|1000|0000|0000|1101|0100|0001 +| 84 / 29 | C |1000|1000|0000|0000|1110|0100|0010 +| 86 / 20 | C |1000|1000|0000|0000|1111|0100|0011 +|----------------|---|----|----|----|----|----|----|---- | heat64 | H |1000|1000|0000|0100|0011|0100|1011 | heat66 | H |1000|1000|0000|0100|0100|0100|1100 | heat68 | H |1000|1000|0000|0100|0101|0100|1101 From 79d9cc78c52c1ce834407ba463f5e730006a7767 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Fri, 28 Aug 2015 04:02:47 +0900 Subject: [PATCH 11/20] decoding for LG A/C --- examples/LGACSendDemo/LGACSendDemo.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index 7f859d1..c82a22b 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -1,3 +1,12 @@ +=== decoding for LG A/C ==== +- 1) remote of LG AC has two type of HDR mark/space, 8000/4000 and 3100/10000 +- 2) HDR 8000/4000 is decoded using decodeLG(IRrecvDumpV2) without problem +- 3) for HDR 3100/10000, use AnalysIR's code : http://www.analysir.com/blog/2014/03/19/air-conditioners-problems-recording-long-infrared-remote-control-signals-arduino/ +- 4) for bin output based on AnalysIR's code : https://gist.github.com/chaeplin/a3a4b4b6b887c663bfe8 +- 5) remove first two byte(11) +- 6) sample rawcode with bin output : https://gist.github.com/chaeplin/134d232e0b8cfb898860 + + === *** === - 1) Sample raw code : https://gist.github.com/chaeplin/ab2a7ad1533c41260f0d - 2) send raw code : https://gist.github.com/chaeplin/7c800d3166463bb51be4 From c326a4e0738abfded23c39e0fff91d1fa9ac9a82 Mon Sep 17 00:00:00 2001 From: chaeplin Date: Fri, 28 Aug 2015 04:15:04 +0900 Subject: [PATCH 12/20] typo 86 / 30 --- examples/LGACSendDemo/LGACSendDemo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/LGACSendDemo/LGACSendDemo.md b/examples/LGACSendDemo/LGACSendDemo.md index c82a22b..62c7073 100644 --- a/examples/LGACSendDemo/LGACSendDemo.md +++ b/examples/LGACSendDemo/LGACSendDemo.md @@ -77,7 +77,7 @@ | 80 / 27 | C |1000|1000|0000|0000|1100|0100|0000 | 82 / 28 | C |1000|1000|0000|0000|1101|0100|0001 | 84 / 29 | C |1000|1000|0000|0000|1110|0100|0010 -| 86 / 20 | C |1000|1000|0000|0000|1111|0100|0011 +| 86 / 30 | C |1000|1000|0000|0000|1111|0100|0011 |----------------|---|----|----|----|----|----|----|---- | heat64 | H |1000|1000|0000|0100|0011|0100|1011 | heat66 | H |1000|1000|0000|0100|0100|0100|1100 From dcea4b32cec85f867031d27c4281eb75a5615c8f Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Wed, 2 Sep 2015 20:19:03 +0100 Subject: [PATCH 13/20] Merge back irISR.cpp into irRemote.cpp to avoid an issue due to the absence of exported symbols from irISR.cpp see https://github.com/z3t0/Arduino-IRremote/issues/214 https://github.com/sudar/Arduino-Makefile/issues/376 In some circumstances the linker skips irISR.cpp irRemote.cpp is always included (by the linker). Andrea --- IRremote.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ irISR.cpp | 88 ---------------------------------------------------- 2 files changed, 86 insertions(+), 88 deletions(-) delete mode 100644 irISR.cpp diff --git a/IRremote.cpp b/IRremote.cpp index e4fb94b..e079ece 100644 --- a/IRremote.cpp +++ b/IRremote.cpp @@ -18,6 +18,8 @@ // Whynter A/C ARC-110WD added by Francesco Meschia //****************************************************************************** +#include + // Defining IR_GLOBAL here allows us to declare the instantiation of global variables #define IR_GLOBAL # include "IRremote.h" @@ -88,3 +90,87 @@ int MATCH_SPACE (int measured_ticks, int desired_us) return ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS)) && (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS))); } + +//+============================================================================= +// Interrupt Service Routine - Fires every 50uS +// TIMER2 interrupt code to collect raw data. +// Widths of alternating SPACE, MARK are recorded in rawbuf. +// Recorded in ticks of 50uS [microseconds, 0.000050 seconds] +// 'rawlen' counts the number of entries recorded so far. +// First entry is the SPACE between transmissions. +// As soon as a the first [SPACE] entry gets long: +// Ready is set; State switches to IDLE; Timing of SPACE continues. +// As soon as first MARK arrives: +// Gap width is recorded; Ready is cleared; New logging starts +// +ISR (TIMER_INTR_NAME) +{ + TIMER_RESET; + + // Read if IR Receiver -> SPACE [xmt LED off] or a MARK [xmt LED on] + // digitalRead() is very slow. Optimisation is possible, but makes the code unportable + uint8_t irdata = (uint8_t)digitalRead(irparams.recvpin); + + irparams.timer++; // One more 50uS tick + if (irparams.rawlen >= RAWBUF) irparams.rcvstate = STATE_OVERFLOW ; // Buffer overflow + + switch(irparams.rcvstate) { + //...................................................................... + case STATE_IDLE: // In the middle of a gap + if (irdata == MARK) { + if (irparams.timer < GAP_TICKS) { // Not big enough to be a gap. + irparams.timer = 0; + + } else { + // Gap just ended; Record duration; Start recording transmission + irparams.overflow = false; + irparams.rawlen = 0; + irparams.rawbuf[irparams.rawlen++] = irparams.timer; + irparams.timer = 0; + irparams.rcvstate = STATE_MARK; + } + } + break; + //...................................................................... + case STATE_MARK: // Timing Mark + if (irdata == SPACE) { // Mark ended; Record time + irparams.rawbuf[irparams.rawlen++] = irparams.timer; + irparams.timer = 0; + irparams.rcvstate = STATE_SPACE; + } + break; + //...................................................................... + case STATE_SPACE: // Timing Space + if (irdata == MARK) { // Space just ended; Record time + irparams.rawbuf[irparams.rawlen++] = irparams.timer; + irparams.timer = 0; + irparams.rcvstate = STATE_MARK; + + } else if (irparams.timer > GAP_TICKS) { // Space + // A long Space, indicates gap between codes + // Flag the current code as ready for processing + // Switch to STOP + // Don't reset timer; keep counting Space width + irparams.rcvstate = STATE_STOP; + } + break; + //...................................................................... + case STATE_STOP: // Waiting; Measuring Gap + if (irdata == MARK) irparams.timer = 0 ; // Reset gap timer + break; + //...................................................................... + case STATE_OVERFLOW: // Flag up a read overflow; Stop the State Machine + irparams.overflow = true; + irparams.rcvstate = STATE_STOP; + break; + } + + // If requested, flash LED while receiving IR data + if (irparams.blinkflag) { + if (irdata == MARK) + if (irparams.blinkpin) digitalWrite(irparams.blinkpin, HIGH); // Turn user defined pin LED on + else BLINKLED_ON() ; // if no user defined LED pin, turn default LED pin for the hardware on + else if (irparams.blinkpin) digitalWrite(irparams.blinkpin, LOW); // Turn user defined pin LED on + else BLINKLED_OFF() ; // if no user defined LED pin, turn default LED pin for the hardware on + } +} diff --git a/irISR.cpp b/irISR.cpp deleted file mode 100644 index e3bc1c3..0000000 --- a/irISR.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include - -#include "IRremote.h" -#include "IRremoteInt.h" - -//+============================================================================= -// Interrupt Service Routine - Fires every 50uS -// TIMER2 interrupt code to collect raw data. -// Widths of alternating SPACE, MARK are recorded in rawbuf. -// Recorded in ticks of 50uS [microseconds, 0.000050 seconds] -// 'rawlen' counts the number of entries recorded so far. -// First entry is the SPACE between transmissions. -// As soon as a the first [SPACE] entry gets long: -// Ready is set; State switches to IDLE; Timing of SPACE continues. -// As soon as first MARK arrives: -// Gap width is recorded; Ready is cleared; New logging starts -// -ISR (TIMER_INTR_NAME) -{ - TIMER_RESET; - - // Read if IR Receiver -> SPACE [xmt LED off] or a MARK [xmt LED on] - // digitalRead() is very slow. Optimisation is possible, but makes the code unportable - uint8_t irdata = (uint8_t)digitalRead(irparams.recvpin); - - irparams.timer++; // One more 50uS tick - if (irparams.rawlen >= RAWBUF) irparams.rcvstate = STATE_OVERFLOW ; // Buffer overflow - - switch(irparams.rcvstate) { - //...................................................................... - case STATE_IDLE: // In the middle of a gap - if (irdata == MARK) { - if (irparams.timer < GAP_TICKS) { // Not big enough to be a gap. - irparams.timer = 0; - - } else { - // Gap just ended; Record duration; Start recording transmission - irparams.overflow = false; - irparams.rawlen = 0; - irparams.rawbuf[irparams.rawlen++] = irparams.timer; - irparams.timer = 0; - irparams.rcvstate = STATE_MARK; - } - } - break; - //...................................................................... - case STATE_MARK: // Timing Mark - if (irdata == SPACE) { // Mark ended; Record time - irparams.rawbuf[irparams.rawlen++] = irparams.timer; - irparams.timer = 0; - irparams.rcvstate = STATE_SPACE; - } - break; - //...................................................................... - case STATE_SPACE: // Timing Space - if (irdata == MARK) { // Space just ended; Record time - irparams.rawbuf[irparams.rawlen++] = irparams.timer; - irparams.timer = 0; - irparams.rcvstate = STATE_MARK; - - } else if (irparams.timer > GAP_TICKS) { // Space - // A long Space, indicates gap between codes - // Flag the current code as ready for processing - // Switch to STOP - // Don't reset timer; keep counting Space width - irparams.rcvstate = STATE_STOP; - } - break; - //...................................................................... - case STATE_STOP: // Waiting; Measuring Gap - if (irdata == MARK) irparams.timer = 0 ; // Reset gap timer - break; - //...................................................................... - case STATE_OVERFLOW: // Flag up a read overflow; Stop the State Machine - irparams.overflow = true; - irparams.rcvstate = STATE_STOP; - break; - } - - // If requested, flash LED while receiving IR data - if (irparams.blinkflag) { - if (irdata == MARK) - if (irparams.blinkpin) digitalWrite(irparams.blinkpin, HIGH); // Turn user defined pin LED on - else BLINKLED_ON() ; // if no user defined LED pin, turn default LED pin for the hardware on - else if (irparams.blinkpin) digitalWrite(irparams.blinkpin, LOW); // Turn user defined pin LED on - else BLINKLED_OFF() ; // if no user defined LED pin, turn default LED pin for the hardware on - } -} From aeb49b5a553f0057f132789f2c5fa5c794e9868c Mon Sep 17 00:00:00 2001 From: Bernhard Essl Date: Wed, 9 Sep 2015 10:47:28 +0200 Subject: [PATCH 14/20] Changed library name "RobotIRremote" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9dee657..a64eef4 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Check [here](http://z3t0.github.io/Arduino-IRremote/) for tutorials and more inf 2. Download the latest release. 3. Extract the zip file 4. Move the "IRremote" folder that has been extracted to your libraries directory. -5. Make sure to delete Arduino_Root/libraries/RobotIRRemote. Where Arduino_Root refers to the install directory of Arduino. The library RobotIRRemote has similar definitions to IRremote and causes errors. +5. Make sure to delete Arduino_Root/libraries/RobotIRremote. Where Arduino_Root refers to the install directory of Arduino. The library RobotIRremote has similar definitions to IRremote and causes errors. ## Usage - TODO (Check examples for now) From ea8112124f2b69617498e9d9cf463c38f7cc1a52 Mon Sep 17 00:00:00 2001 From: Paolo P Date: Thu, 24 Sep 2015 11:43:33 +0200 Subject: [PATCH 15/20] Update version to 2.0.1 Update to version 2.0.1 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 094b283..3553dc1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=IRremote -version=1.0 +version=2.0.1 author=shirriff maintainer=shirriff sentence=Send and receive infrared signals with multiple protocols From e3a5f01b042cb7a1c122d4ce9c495b26b91a5c69 Mon Sep 17 00:00:00 2001 From: Paolo Paolucci Date: Fri, 25 Sep 2015 09:22:25 +0200 Subject: [PATCH 16/20] Errata corrige keyword file --- keywords.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 808c7ea..6fd016f 100644 --- a/keywords.txt +++ b/keywords.txt @@ -32,7 +32,6 @@ sendSharpRaw KEYWORD2 sendPanasonic KEYWORD2 sendJVC KEYWORD2 -# ####################################### # Constants (LITERAL1) ####################################### From e07c8456764e51b9cb997b7fd564fd86cc9cec5b Mon Sep 17 00:00:00 2001 From: Paolo Paolucci Date: Fri, 25 Sep 2015 09:23:22 +0200 Subject: [PATCH 17/20] Update version to 2.0.1 --- IRremote.cpp | 2 +- IRremote.h | 2 +- IRremoteInt.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/IRremote.cpp b/IRremote.cpp index e079ece..466a4fb 100644 --- a/IRremote.cpp +++ b/IRremote.cpp @@ -1,6 +1,6 @@ //****************************************************************************** // IRremote -// Version 0.11 August, 2009 +// Version 2.0.1 June, 2015 // Copyright 2009 Ken Shirriff // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html // diff --git a/IRremote.h b/IRremote.h index 4af944a..86815b4 100644 --- a/IRremote.h +++ b/IRremote.h @@ -1,7 +1,7 @@ //****************************************************************************** // IRremote -// Version 0.1 July, 2009 +// Version 2.0.1 June, 2015 // Copyright 2009 Ken Shirriff // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html // Edited by Mitra to add new controller SANYO diff --git a/IRremoteInt.h b/IRremoteInt.h index 32515c3..125eb72 100644 --- a/IRremoteInt.h +++ b/IRremoteInt.h @@ -1,6 +1,6 @@ //****************************************************************************** // IRremote -// Version 0.1 July, 2009 +// Version 2.0.1 June, 2015 // Copyright 2009 Ken Shirriff // For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html // From 2c1ea568e4894713aee6569ee82be7860c7e8bb6 Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Mon, 28 Sep 2015 20:45:55 -0600 Subject: [PATCH 18/20] Contact info @readme.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index a64eef4..fe7fa25 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ If you want to contribute to this project: - Create issues and pull requests - Tell other people about this library - Contribute new protocols +- + +## Contact +The only way to contact me at the moment is by email: zetoslab@gmail.com +I am not currently monitoring any PRs or Issues due to other issues but will respond to all emails. If anyone wants contributor access, feel free to email me. Or if you find any Issues/PRs to be of importance that my attention is needed please email me. ## Contributors Check [here](Contributors.md) From e85aefd4cd20773406d34c01963791832e32e8d0 Mon Sep 17 00:00:00 2001 From: ram-0000 Date: Sun, 8 Nov 2015 19:38:54 +0100 Subject: [PATCH 19/20] Update ir_Aiwa.cpp Remove unused mask variable line 31 --- ir_Aiwa.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ir_Aiwa.cpp b/ir_Aiwa.cpp index bd5ba89..9cc5656 100644 --- a/ir_Aiwa.cpp +++ b/ir_Aiwa.cpp @@ -28,7 +28,6 @@ void IRsend::sendAiwaRCT501 (int code) { unsigned long pre = 0x0227EEC0; // 26-bits - int mask; // Set IR carrier frequency enableIROut(AIWA_RC_T501_HZ); From 6ed1d49b19b5928b92317cf947af1b05e6752c28 Mon Sep 17 00:00:00 2001 From: Rafi Khan Date: Tue, 10 Nov 2015 15:02:32 -0600 Subject: [PATCH 20/20] Update ir_Aiwa.cpp fixed typo in line 12 --- ir_Aiwa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_Aiwa.cpp b/ir_Aiwa.cpp index 9cc5656..50ec58d 100644 --- a/ir_Aiwa.cpp +++ b/ir_Aiwa.cpp @@ -9,7 +9,7 @@ // A A IIIII WWW A A //============================================================================== -// Baszed off the RC-T501 RCU +// Based off the RC-T501 RCU // Lirc file http://lirc.sourceforge.net/remotes/aiwa/RC-T501 #define AIWA_RC_T501_HZ 38