├── Contributors.md ├── IRremoteESP8266.cpp ├── IRremoteESP8266.h ├── IRremoteInt.h ├── LICENSE.txt ├── README.md ├── examples ├── IRServer │ └── IRServer.ino ├── IRrecvDemo │ └── IRrecvDemo.ino ├── IRrecvDump │ └── IRrecvDump.ino ├── IRrecvDumpV2 │ └── IRrecvDumpV2.ino ├── IRsendDemo │ └── IRsendDemo.ino └── JVCPanasonicSendDemo │ └── JVCPanasonicSendDemo.ino ├── keywords.txt ├── library.json └── library.properties /Contributors.md: -------------------------------------------------------------------------------- 1 | ## Contributors of this project 2 | - [Mark Szabo](https://github.com/markszabo/) : IR sending on ESP8266 3 | - [Sébastien Warin](https://github.com/sebastienwarin/) (http://sebastien.warin.fr) : IR receiving on ESP8266 4 | 5 | ## Contributors of the original project (https://github.com/shirriff/Arduino-IRremote/) 6 | These are the active contributors of this project that you may contact if there is anything you need help with or if you have suggestions. 7 | 8 | - [z3t0](https://github.com/z3t0) : Active Contributor and currently also the main contributor. 9 | * Email: zetoslab@gmail.com 10 | * Skype: polarised16 11 | - [shirriff](https://github.com/shirriff) : Owner of repository and creator of library. 12 | - [Informatic](https://github.com/Informatic) : Active contributor 13 | - [fmeschia](https://github.com/fmeschia) : Active contributor 14 | - [PaulStoffregen](https://github.com/paulstroffregen) : Active contributor 15 | - [crash7](https://github.com/crash7) : Active contributor 16 | - [Neco777](https://github.com/neco777) : Active contributor 17 | 18 | Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed. 19 | 20 | 21 | -------------------------------------------------------------------------------- /IRremoteESP8266.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * IRremote for ESP8266 3 | * 4 | * Based on the IRremote library for Arduino by Ken Shirriff 5 | * Version 0.11 August, 2009 6 | * Copyright 2009 Ken Shirriff 7 | * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html 8 | * 9 | * Modified by Paul Stoffregen to support other boards and timers 10 | * Modified by Mitra Ardron 11 | * Added Sanyo and Mitsubishi controllers 12 | * Modified Sony to spot the repeat codes that some Sony's send 13 | * 14 | * Interrupt code based on NECIRrcv by Joe Knapp 15 | * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 16 | * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ 17 | * 18 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 19 | * LG added by Darryl Smith (based on the JVC protocol) 20 | * Whynter A/C ARC-110WD added by Francesco Meschia 21 | * 22 | * Updated by markszabo (https://github.com/markszabo/IRremoteESP8266) for sending IR code on ESP8266 23 | * Updated by Sebastien Warin (http://sebastien.warin.fr) for receiving IR code on ESP8266 24 | * 25 | * GPL license, all text above must be included in any redistribution 26 | ****************************************************/ 27 | 28 | #include "IRremoteESP8266.h" 29 | #include "IRremoteInt.h" 30 | 31 | // These versions of MATCH, MATCH_MARK, and MATCH_SPACE are only for debugging. 32 | // To use them, set DEBUG in IRremoteInt.h 33 | // Normally macros are used for efficiency 34 | #ifdef DEBUG 35 | int MATCH(int measured, int desired) { 36 | Serial.print("Testing: "); 37 | Serial.print(TICKS_LOW(desired), DEC); 38 | Serial.print(" <= "); 39 | Serial.print(measured, DEC); 40 | Serial.print(" <= "); 41 | Serial.println(TICKS_HIGH(desired), DEC); 42 | return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired); 43 | } 44 | 45 | int MATCH_MARK(int measured_ticks, int desired_us) { 46 | Serial.print("Testing mark "); 47 | Serial.print(measured_ticks * USECPERTICK, DEC); 48 | Serial.print(" vs "); 49 | Serial.print(desired_us, DEC); 50 | Serial.print(": "); 51 | Serial.print(TICKS_LOW(desired_us + MARK_EXCESS), DEC); 52 | Serial.print(" <= "); 53 | Serial.print(measured_ticks, DEC); 54 | Serial.print(" <= "); 55 | Serial.println(TICKS_HIGH(desired_us + MARK_EXCESS), DEC); 56 | return measured_ticks >= TICKS_LOW(desired_us + MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS); 57 | } 58 | 59 | int MATCH_SPACE(int measured_ticks, int desired_us) { 60 | Serial.print("Testing space "); 61 | Serial.print(measured_ticks * USECPERTICK, DEC); 62 | Serial.print(" vs "); 63 | Serial.print(desired_us, DEC); 64 | Serial.print(": "); 65 | Serial.print(TICKS_LOW(desired_us - MARK_EXCESS), DEC); 66 | Serial.print(" <= "); 67 | Serial.print(measured_ticks, DEC); 68 | Serial.print(" <= "); 69 | Serial.println(TICKS_HIGH(desired_us - MARK_EXCESS), DEC); 70 | return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS); 71 | } 72 | #else 73 | int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);} 74 | int MATCH_MARK(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));} 75 | int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));} 76 | // Debugging versions are in IRremote.cpp 77 | #endif 78 | 79 | // IRsend ----------------------------------------------------------------------------------- 80 | 81 | IRsend::IRsend(int IRsendPin) 82 | { 83 | IRpin = IRsendPin; 84 | } 85 | 86 | void IRsend::begin() 87 | { 88 | pinMode(IRpin, OUTPUT); 89 | } 90 | 91 | void IRsend::sendNEC(unsigned long data, int nbits) 92 | { 93 | enableIROut(38); 94 | mark(NEC_HDR_MARK); 95 | space(NEC_HDR_SPACE); 96 | for (int i = 0; i < nbits; i++) { 97 | if (data & TOPBIT) { 98 | mark(NEC_BIT_MARK); 99 | space(NEC_ONE_SPACE); 100 | } 101 | else { 102 | mark(NEC_BIT_MARK); 103 | space(NEC_ZERO_SPACE); 104 | } 105 | data <<= 1; 106 | } 107 | mark(NEC_BIT_MARK); 108 | space(0); 109 | } 110 | 111 | void IRsend::sendWhynter(unsigned long data, int nbits) { 112 | enableIROut(38); 113 | mark(WHYNTER_ZERO_MARK); 114 | space(WHYNTER_ZERO_SPACE); 115 | mark(WHYNTER_HDR_MARK); 116 | space(WHYNTER_HDR_SPACE); 117 | for (int i = 0; i < nbits; i++) { 118 | if (data & TOPBIT) { 119 | mark(WHYNTER_ONE_MARK); 120 | space(WHYNTER_ONE_SPACE); 121 | } 122 | else { 123 | mark(WHYNTER_ZERO_MARK); 124 | space(WHYNTER_ZERO_SPACE); 125 | } 126 | data <<= 1; 127 | } 128 | mark(WHYNTER_ZERO_MARK); 129 | space(WHYNTER_ZERO_SPACE); 130 | } 131 | 132 | void IRsend::sendSony(unsigned long data, int nbits) { 133 | enableIROut(40); 134 | mark(SONY_HDR_MARK); 135 | space(SONY_HDR_SPACE); 136 | data = data << (32 - nbits); 137 | for (int i = 0; i < nbits; i++) { 138 | if (data & TOPBIT) { 139 | mark(SONY_ONE_MARK); 140 | space(SONY_HDR_SPACE); 141 | } 142 | else { 143 | mark(SONY_ZERO_MARK); 144 | space(SONY_HDR_SPACE); 145 | } 146 | data <<= 1; 147 | } 148 | } 149 | 150 | void IRsend::sendRaw(unsigned int buf[], int len, int hz) 151 | { 152 | enableIROut(hz); 153 | for (int i = 0; i < len; i++) { 154 | if (i & 1) { 155 | space(buf[i]); 156 | } 157 | else { 158 | mark(buf[i]); 159 | } 160 | } 161 | space(0); // Just to be sure 162 | } 163 | 164 | // Note: first bit must be a one (start bit) 165 | void IRsend::sendRC5(unsigned long data, int nbits) 166 | { 167 | enableIROut(36); 168 | data = data << (32 - nbits); 169 | mark(RC5_T1); // First start bit 170 | space(RC5_T1); // Second start bit 171 | mark(RC5_T1); // Second start bit 172 | for (int i = 0; i < nbits; i++) { 173 | if (data & TOPBIT) { 174 | space(RC5_T1); // 1 is space, then mark 175 | mark(RC5_T1); 176 | } 177 | else { 178 | mark(RC5_T1); 179 | space(RC5_T1); 180 | } 181 | data <<= 1; 182 | } 183 | space(0); // Turn off at end 184 | } 185 | 186 | // Caller needs to take care of flipping the toggle bit 187 | void IRsend::sendRC6(unsigned long data, int nbits) 188 | { 189 | enableIROut(36); 190 | data = data << (32 - nbits); 191 | mark(RC6_HDR_MARK); 192 | space(RC6_HDR_SPACE); 193 | mark(RC6_T1); // start bit 194 | space(RC6_T1); 195 | int t; 196 | for (int i = 0; i < nbits; i++) { 197 | if (i == 3) { 198 | // double-wide trailer bit 199 | t = 2 * RC6_T1; 200 | } 201 | else { 202 | t = RC6_T1; 203 | } 204 | if (data & TOPBIT) { 205 | mark(t); 206 | space(t); 207 | } 208 | else { 209 | space(t); 210 | mark(t); 211 | } 212 | 213 | data <<= 1; 214 | } 215 | space(0); // Turn off at end 216 | } 217 | void IRsend::sendPanasonic(unsigned int address, unsigned long data) { 218 | enableIROut(35); 219 | mark(PANASONIC_HDR_MARK); 220 | space(PANASONIC_HDR_SPACE); 221 | 222 | for(int i=0;i<16;i++) 223 | { 224 | mark(PANASONIC_BIT_MARK); 225 | if (address & 0x8000) { 226 | space(PANASONIC_ONE_SPACE); 227 | } else { 228 | space(PANASONIC_ZERO_SPACE); 229 | } 230 | address <<= 1; 231 | } 232 | for (int i=0; i < 32; i++) { 233 | mark(PANASONIC_BIT_MARK); 234 | if (data & TOPBIT) { 235 | space(PANASONIC_ONE_SPACE); 236 | } else { 237 | space(PANASONIC_ZERO_SPACE); 238 | } 239 | data <<= 1; 240 | } 241 | mark(PANASONIC_BIT_MARK); 242 | space(0); 243 | } 244 | void IRsend::sendJVC(unsigned long data, int nbits, int repeat) 245 | { 246 | enableIROut(38); 247 | data = data << (32 - nbits); 248 | if (!repeat){ 249 | mark(JVC_HDR_MARK); 250 | space(JVC_HDR_SPACE); 251 | } 252 | for (int i = 0; i < nbits; i++) { 253 | if (data & TOPBIT) { 254 | mark(JVC_BIT_MARK); 255 | space(JVC_ONE_SPACE); 256 | } 257 | else { 258 | mark(JVC_BIT_MARK); 259 | space(JVC_ZERO_SPACE); 260 | } 261 | data <<= 1; 262 | } 263 | mark(JVC_BIT_MARK); 264 | space(0); 265 | } 266 | 267 | void IRsend::sendSAMSUNG(unsigned long data, int nbits) 268 | { 269 | enableIROut(38); 270 | mark(SAMSUNG_HDR_MARK); 271 | space(SAMSUNG_HDR_SPACE); 272 | for (int i = 0; i < nbits; i++) { 273 | if (data & TOPBIT) { 274 | mark(SAMSUNG_BIT_MARK); 275 | space(SAMSUNG_ONE_SPACE); 276 | } 277 | else { 278 | mark(SAMSUNG_BIT_MARK); 279 | space(SAMSUNG_ZERO_SPACE); 280 | } 281 | data <<= 1; 282 | } 283 | mark(SAMSUNG_BIT_MARK); 284 | space(0); 285 | } 286 | 287 | void IRsend::mark(int time) { 288 | // Sends an IR mark for the specified number of microseconds. 289 | // The mark output is modulated at the PWM frequency. 290 | long beginning = micros(); 291 | while(micros() - beginning < time){ 292 | digitalWrite(IRpin, HIGH); 293 | delayMicroseconds(halfPeriodicTime); 294 | digitalWrite(IRpin, LOW); 295 | delayMicroseconds(halfPeriodicTime); //38 kHz -> T = 26.31 microsec (periodic time), half of it is 13 296 | } 297 | } 298 | 299 | /* Leave pin off for time (given in microseconds) */ 300 | void IRsend::space(int time) { 301 | // Sends an IR space for the specified number of microseconds. 302 | // A space is no output, so the PWM output is disabled. 303 | digitalWrite(IRpin, LOW); 304 | if (time > 0) delayMicroseconds(time); 305 | } 306 | 307 | void IRsend::enableIROut(int khz) { 308 | // Enables IR output. The khz value controls the modulation frequency in kilohertz. 309 | halfPeriodicTime = 500/khz; // T = 1/f but we need T/2 in microsecond and f is in kHz 310 | } 311 | 312 | 313 | /* Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand ) 314 | 315 | The Dish send function needs to be repeated 4 times, and the Sharp function 316 | has the necessary repeat built in because of the need to invert the signal. 317 | 318 | Sharp protocol documentation: 319 | http://www.sbprojects.com/knowledge/ir/sharp.htm 320 | 321 | Here are the LIRC files that I found that seem to match the remote codes 322 | from the oscilloscope: 323 | 324 | Sharp LCD TV: 325 | http://lirc.sourceforge.net/remotes/sharp/GA538WJSA 326 | 327 | DISH NETWORK (echostar 301): 328 | http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx 329 | 330 | For the DISH codes, only send the last for characters of the hex. 331 | i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the 332 | linked LIRC file. 333 | */ 334 | 335 | void IRsend::sendSharpRaw(unsigned long data, int nbits) { 336 | enableIROut(38); 337 | 338 | // Sending codes in bursts of 3 (normal, inverted, normal) makes transmission 339 | // much more reliable. That's the exact behaviour of CD-S6470 remote control. 340 | for (int n = 0; n < 3; n++) { 341 | for (int i = 1 << (nbits-1); i > 0; i>>=1) { 342 | if (data & i) { 343 | mark(SHARP_BIT_MARK); 344 | space(SHARP_ONE_SPACE); 345 | } 346 | else { 347 | mark(SHARP_BIT_MARK); 348 | space(SHARP_ZERO_SPACE); 349 | } 350 | } 351 | 352 | mark(SHARP_BIT_MARK); 353 | space(SHARP_ZERO_SPACE); 354 | delay(40); 355 | 356 | data = data ^ SHARP_TOGGLE_MASK; 357 | } 358 | } 359 | 360 | // Sharp send compatible with data obtained through decodeSharp 361 | void IRsend::sendSharp(unsigned int address, unsigned int command) { 362 | sendSharpRaw((address << 10) | (command << 2) | 2, 15); 363 | } 364 | 365 | void IRsend::sendDISH(unsigned long data, int nbits) { 366 | enableIROut(56); 367 | mark(DISH_HDR_MARK); 368 | space(DISH_HDR_SPACE); 369 | for (int i = 0; i < nbits; i++) { 370 | if (data & DISH_TOP_BIT) { 371 | mark(DISH_BIT_MARK); 372 | space(DISH_ONE_SPACE); 373 | } 374 | else { 375 | mark(DISH_BIT_MARK); 376 | space(DISH_ZERO_SPACE); 377 | } 378 | data <<= 1; 379 | } 380 | } 381 | 382 | // --------------------------------------------------------------- 383 | 384 | 385 | //IRRecv------------------------------------------------------ 386 | 387 | extern "C" { 388 | #include "user_interface.h" 389 | #include "gpio.h" 390 | } 391 | 392 | static ETSTimer timer; 393 | volatile irparams_t irparams; 394 | 395 | static void ICACHE_FLASH_ATTR read_timeout(void *arg) { 396 | os_intr_lock(); 397 | if (irparams.rawlen) { 398 | irparams.rcvstate = STATE_STOP; 399 | } 400 | os_intr_unlock(); 401 | } 402 | 403 | static void ICACHE_FLASH_ATTR gpio_intr(void *arg) { 404 | uint32_t gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS); 405 | GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status); 406 | 407 | if (irparams.rcvstate == STATE_STOP) { 408 | return; 409 | } 410 | static uint32_t start = 0; 411 | uint32_t now = system_get_time(); 412 | if (irparams.rcvstate == STATE_IDLE) { 413 | irparams.rcvstate = STATE_MARK; 414 | } 415 | else if (irparams.rawlen < RAWBUF) { 416 | irparams.rawbuf[irparams.rawlen++] = (now - start) / USECPERTICK + 1; 417 | } 418 | start = now; 419 | 420 | os_timer_disarm(&timer); 421 | os_timer_arm(&timer, 15, 0); 422 | } 423 | 424 | IRrecv::IRrecv(int recvpin) { 425 | irparams.recvpin = recvpin; 426 | } 427 | 428 | // initialization 429 | void IRrecv::enableIRIn() { 430 | 431 | // initialize state machine variables 432 | irparams.rcvstate = STATE_IDLE; 433 | irparams.rawlen = 0; 434 | 435 | // set pin modes 436 | //PIN_FUNC_SELECT(IR_IN_MUX, IR_IN_FUNC); 437 | GPIO_DIS_OUTPUT(irparams.recvpin); 438 | 439 | // Initialize timer 440 | os_timer_disarm(&timer); 441 | os_timer_setfn(&timer, (os_timer_func_t *)read_timeout, &timer); 442 | 443 | // ESP Attach Interrupt 444 | ETS_GPIO_INTR_DISABLE(); 445 | ETS_GPIO_INTR_ATTACH(gpio_intr, NULL); 446 | gpio_pin_intr_state_set(GPIO_ID_PIN(irparams.recvpin), GPIO_PIN_INTR_ANYEDGE); 447 | ETS_GPIO_INTR_ENABLE(); 448 | //ETS_INTR_UNLOCK(); 449 | 450 | //attachInterrupt(irparams.recvpin, readIR, CHANGE); 451 | //irReadTimer.initializeUs(USECPERTICK, readIR).start(); 452 | //os_timer_arm_us(&irReadTimer, USECPERTICK, 1); 453 | //ets_timer_arm_new(&irReadTimer, USECPERTICK, 1, 0); 454 | } 455 | 456 | void IRrecv::disableIRIn() { 457 | //irReadTimer.stop(); 458 | //os_timer_disarm(&irReadTimer); 459 | ETS_INTR_LOCK(); 460 | ETS_GPIO_INTR_DISABLE(); 461 | } 462 | 463 | void IRrecv::resume() { 464 | irparams.rcvstate = STATE_IDLE; 465 | irparams.rawlen = 0; 466 | } 467 | 468 | // Decodes the received IR message 469 | // Returns 0 if no data ready, 1 if data ready. 470 | // Results of decoding are stored in results 471 | int IRrecv::decode(decode_results *results) { 472 | results->rawbuf = irparams.rawbuf; 473 | results->rawlen = irparams.rawlen; 474 | if (irparams.rcvstate != STATE_STOP) { 475 | return ERR; 476 | } 477 | #ifdef DEBUG 478 | Serial.println("Attempting NEC decode"); 479 | #endif 480 | if (decodeNEC(results)) { 481 | return DECODED; 482 | } 483 | 484 | #ifdef DEBUG 485 | Serial.println("Attempting Sony decode"); 486 | #endif 487 | if (decodeSony(results)) { 488 | return DECODED; 489 | } 490 | /* 491 | #ifdef DEBUG 492 | Serial.println("Attempting Sanyo decode"); 493 | #endif 494 | if (decodeSanyo(results)) { 495 | return DECODED; 496 | }*/ 497 | #ifdef DEBUG 498 | Serial.println("Attempting Mitsubishi decode"); 499 | #endif 500 | if (decodeMitsubishi(results)) { 501 | return DECODED; 502 | } 503 | #ifdef DEBUG 504 | Serial.println("Attempting RC5 decode"); 505 | #endif 506 | if (decodeRC5(results)) { 507 | return DECODED; 508 | } 509 | #ifdef DEBUG 510 | Serial.println("Attempting RC6 decode"); 511 | #endif 512 | if (decodeRC6(results)) { 513 | return DECODED; 514 | } 515 | #ifdef DEBUG 516 | Serial.println("Attempting Panasonic decode"); 517 | #endif 518 | if (decodePanasonic(results)) { 519 | return DECODED; 520 | } 521 | #ifdef DEBUG 522 | Serial.println("Attempting LG decode"); 523 | #endif 524 | if (decodeLG(results)) { 525 | return DECODED; 526 | } 527 | #ifdef DEBUG 528 | Serial.println("Attempting JVC decode"); 529 | #endif 530 | if (decodeJVC(results)) { 531 | return DECODED; 532 | } 533 | #ifdef DEBUG 534 | Serial.println("Attempting SAMSUNG decode"); 535 | #endif 536 | if (decodeSAMSUNG(results)) { 537 | return DECODED; 538 | } 539 | #ifdef DEBUG 540 | Serial.println("Attempting Whynter decode"); 541 | #endif 542 | if (decodeWhynter(results)) { 543 | return DECODED; 544 | } 545 | // decodeHash returns a hash on any input. 546 | // Thus, it needs to be last in the list. 547 | // If you add any decodes, add them before this. 548 | if (decodeHash(results)) { 549 | return DECODED; 550 | } 551 | // Throw away and start over 552 | resume(); 553 | return ERR; 554 | } 555 | 556 | // NECs have a repeat only 4 items long 557 | long IRrecv::decodeNEC(decode_results *results) { 558 | long data = 0; 559 | int offset = 1; // Skip initial space 560 | // Initial mark 561 | if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) { 562 | return ERR; 563 | } 564 | offset++; 565 | // Check for repeat 566 | if (irparams.rawlen == 4 && 567 | MATCH_SPACE(results->rawbuf[offset], NEC_RPT_SPACE) && 568 | MATCH_MARK(results->rawbuf[offset+1], NEC_BIT_MARK)) { 569 | results->bits = 0; 570 | results->value = REPEAT; 571 | results->decode_type = NEC; 572 | return DECODED; 573 | } 574 | if (irparams.rawlen < 2 * NEC_BITS + 4) { 575 | return ERR; 576 | } 577 | // Initial space 578 | if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) { 579 | return ERR; 580 | } 581 | offset++; 582 | for (int i = 0; i < NEC_BITS; i++) { 583 | if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) { 584 | return ERR; 585 | } 586 | offset++; 587 | if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) { 588 | data = (data << 1) | 1; 589 | } 590 | else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) { 591 | data <<= 1; 592 | } 593 | else { 594 | return ERR; 595 | } 596 | offset++; 597 | } 598 | // Success 599 | results->bits = NEC_BITS; 600 | results->value = data; 601 | results->decode_type = NEC; 602 | return DECODED; 603 | } 604 | 605 | long IRrecv::decodeSony(decode_results *results) { 606 | long data = 0; 607 | if (irparams.rawlen < 2 * SONY_BITS + 2) { 608 | return ERR; 609 | } 610 | int offset = 0; // Dont skip first space, check its size 611 | 612 | /* 613 | // Some Sony's deliver repeats fast after first 614 | // unfortunately can't spot difference from of repeat from two fast clicks 615 | if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) { 616 | // Serial.print("IR Gap found: "); 617 | results->bits = 0; 618 | results->value = REPEAT; 619 | results->decode_type = SANYO; 620 | return DECODED; 621 | }*/ 622 | offset++; 623 | 624 | // Initial mark 625 | if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) { 626 | return ERR; 627 | } 628 | offset++; 629 | 630 | while (offset + 1 < irparams.rawlen) { 631 | if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) { 632 | break; 633 | } 634 | offset++; 635 | if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) { 636 | data = (data << 1) | 1; 637 | } 638 | else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) { 639 | data <<= 1; 640 | } 641 | else { 642 | return ERR; 643 | } 644 | offset++; 645 | } 646 | 647 | // Success 648 | results->bits = (offset - 1) / 2; 649 | if (results->bits < 12) { 650 | results->bits = 0; 651 | return ERR; 652 | } 653 | results->value = data; 654 | results->decode_type = SONY; 655 | return DECODED; 656 | } 657 | 658 | long IRrecv::decodeWhynter(decode_results *results) { 659 | long data = 0; 660 | 661 | if (irparams.rawlen < 2 * WHYNTER_BITS + 6) { 662 | return ERR; 663 | } 664 | 665 | int offset = 1; // Skip first space 666 | 667 | 668 | // sequence begins with a bit mark and a zero space 669 | if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { 670 | return ERR; 671 | } 672 | offset++; 673 | if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) { 674 | return ERR; 675 | } 676 | offset++; 677 | 678 | // header mark and space 679 | if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) { 680 | return ERR; 681 | } 682 | offset++; 683 | if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) { 684 | return ERR; 685 | } 686 | offset++; 687 | 688 | // data bits 689 | for (int i = 0; i < WHYNTER_BITS; i++) { 690 | if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { 691 | return ERR; 692 | } 693 | offset++; 694 | if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) { 695 | data = (data << 1) | 1; 696 | } 697 | else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) { 698 | data <<= 1; 699 | } 700 | else { 701 | return ERR; 702 | } 703 | offset++; 704 | } 705 | 706 | // trailing mark 707 | if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { 708 | return ERR; 709 | } 710 | // Success 711 | results->bits = WHYNTER_BITS; 712 | results->value = data; 713 | results->decode_type = WHYNTER; 714 | return DECODED; 715 | } 716 | 717 | // I think this is a Sanyo decoder - serial = SA 8650B 718 | // Looks like Sony except for timings, 48 chars of data and time/space different 719 | long IRrecv::decodeSanyo(decode_results *results) { 720 | long data = 0; 721 | if (irparams.rawlen < 2 * SANYO_BITS + 2) { 722 | return ERR; 723 | } 724 | int offset = 1; // Skip first space 725 | 726 | 727 | // Initial space 728 | /* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay 729 | Serial.print("IR Gap: "); 730 | Serial.println( results->rawbuf[offset]); 731 | Serial.println( "test against:"); 732 | Serial.println(results->rawbuf[offset]); 733 | */ 734 | 735 | if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) { 736 | // Serial.print("IR Gap found: "); 737 | results->bits = 0; 738 | results->value = REPEAT; 739 | results->decode_type = SANYO; 740 | return DECODED; 741 | } 742 | offset++; 743 | 744 | // Initial mark 745 | if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { 746 | return ERR; 747 | } 748 | offset++; 749 | 750 | // Skip Second Mark 751 | if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { 752 | return ERR; 753 | } 754 | offset++; 755 | 756 | while (offset + 1 < irparams.rawlen) { 757 | if (!MATCH_SPACE(results->rawbuf[offset], SANYO_HDR_SPACE)) { 758 | break; 759 | } 760 | offset++; 761 | if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) { 762 | data = (data << 1) | 1; 763 | } 764 | else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) { 765 | data <<= 1; 766 | } 767 | else { 768 | return ERR; 769 | } 770 | offset++; 771 | } 772 | 773 | // Success 774 | results->bits = (offset - 1) / 2; 775 | if (results->bits < 12) { 776 | results->bits = 0; 777 | return ERR; 778 | } 779 | results->value = data; 780 | results->decode_type = SANYO; 781 | return DECODED; 782 | } 783 | 784 | // Looks like Sony except for timings, 48 chars of data and time/space different 785 | long IRrecv::decodeMitsubishi(decode_results *results) { 786 | // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2); 787 | long data = 0; 788 | if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) { 789 | return ERR; 790 | } 791 | int offset = 1; // Skip first space 792 | // Initial space 793 | /* Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay 794 | Serial.print("IR Gap: "); 795 | Serial.println( results->rawbuf[offset]); 796 | Serial.println( "test against:"); 797 | Serial.println(results->rawbuf[offset]); 798 | */ 799 | /* Not seeing double keys from Mitsubishi 800 | if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) { 801 | // Serial.print("IR Gap found: "); 802 | results->bits = 0; 803 | results->value = REPEAT; 804 | results->decode_type = MITSUBISHI; 805 | return DECODED; 806 | } 807 | */ 808 | 809 | offset++; 810 | 811 | // Typical 812 | // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7 813 | 814 | // Initial Space 815 | if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { 816 | return ERR; 817 | } 818 | offset++; 819 | while (offset + 1 < irparams.rawlen) { 820 | if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) { 821 | data = (data << 1) | 1; 822 | } 823 | else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) { 824 | data <<= 1; 825 | } 826 | else { 827 | // Serial.println("A"); Serial.println(offset); Serial.println(results->rawbuf[offset]); 828 | return ERR; 829 | } 830 | offset++; 831 | if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { 832 | // Serial.println("B"); Serial.println(offset); Serial.println(results->rawbuf[offset]); 833 | break; 834 | } 835 | offset++; 836 | } 837 | 838 | // Success 839 | results->bits = (offset - 1) / 2; 840 | if (results->bits < MITSUBISHI_BITS) { 841 | results->bits = 0; 842 | return ERR; 843 | } 844 | results->value = data; 845 | results->decode_type = MITSUBISHI; 846 | return DECODED; 847 | } 848 | 849 | // Gets one undecoded level at a time from the raw buffer. 850 | // The RC5/6 decoding is easier if the data is broken into time intervals. 851 | // E.g. if the buffer has MARK for 2 time intervals and SPACE for 1, 852 | // successive calls to getRClevel will return MARK, MARK, SPACE. 853 | // offset and used are updated to keep track of the current position. 854 | // t1 is the time interval for a single bit in microseconds. 855 | // Returns -1 for error (measured time interval is not a multiple of t1). 856 | int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1) { 857 | if (*offset >= results->rawlen) { 858 | // After end of recorded buffer, assume SPACE. 859 | return SPACE; 860 | } 861 | int width = results->rawbuf[*offset]; 862 | int val = ((*offset) % 2) ? MARK : SPACE; 863 | int correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS; 864 | 865 | int avail; 866 | if (MATCH(width, t1 + correction)) { 867 | avail = 1; 868 | } 869 | else if (MATCH(width, 2*t1 + correction)) { 870 | avail = 2; 871 | } 872 | else if (MATCH(width, 3*t1 + correction)) { 873 | avail = 3; 874 | } 875 | else { 876 | return -1; 877 | } 878 | 879 | (*used)++; 880 | if (*used >= avail) { 881 | *used = 0; 882 | (*offset)++; 883 | } 884 | #ifdef DEBUG 885 | if (val == MARK) { 886 | Serial.println("MARK"); 887 | } 888 | else { 889 | Serial.println("SPACE"); 890 | } 891 | #endif 892 | return val; 893 | } 894 | 895 | long IRrecv::decodeRC5(decode_results *results) { 896 | if (irparams.rawlen < MIN_RC5_SAMPLES + 2) { 897 | return ERR; 898 | } 899 | int offset = 1; // Skip gap space 900 | long data = 0; 901 | int used = 0; 902 | // Get start bits 903 | if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return ERR; 904 | if (getRClevel(results, &offset, &used, RC5_T1) != SPACE) return ERR; 905 | if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return ERR; 906 | int nbits; 907 | for (nbits = 0; offset < irparams.rawlen; nbits++) { 908 | int levelA = getRClevel(results, &offset, &used, RC5_T1); 909 | int levelB = getRClevel(results, &offset, &used, RC5_T1); 910 | if (levelA == SPACE && levelB == MARK) { 911 | // 1 bit 912 | data = (data << 1) | 1; 913 | } 914 | else if (levelA == MARK && levelB == SPACE) { 915 | // zero bit 916 | data <<= 1; 917 | } 918 | else { 919 | return ERR; 920 | } 921 | } 922 | 923 | // Success 924 | results->bits = nbits; 925 | results->value = data; 926 | results->decode_type = RC5; 927 | return DECODED; 928 | } 929 | 930 | long IRrecv::decodeRC6(decode_results *results) { 931 | if (results->rawlen < MIN_RC6_SAMPLES) { 932 | return ERR; 933 | } 934 | int offset = 1; // Skip first space 935 | // Initial mark 936 | if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) { 937 | return ERR; 938 | } 939 | offset++; 940 | if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) { 941 | return ERR; 942 | } 943 | offset++; 944 | long data = 0; 945 | int used = 0; 946 | // Get start bit (1) 947 | if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return ERR; 948 | if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return ERR; 949 | int nbits; 950 | for (nbits = 0; offset < results->rawlen; nbits++) { 951 | int levelA, levelB; // Next two levels 952 | levelA = getRClevel(results, &offset, &used, RC6_T1); 953 | if (nbits == 3) { 954 | // T bit is double wide; make sure second half matches 955 | if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return ERR; 956 | } 957 | levelB = getRClevel(results, &offset, &used, RC6_T1); 958 | if (nbits == 3) { 959 | // T bit is double wide; make sure second half matches 960 | if (levelB != getRClevel(results, &offset, &used, RC6_T1)) return ERR; 961 | } 962 | if (levelA == MARK && levelB == SPACE) { // reversed compared to RC5 963 | // 1 bit 964 | data = (data << 1) | 1; 965 | } 966 | else if (levelA == SPACE && levelB == MARK) { 967 | // zero bit 968 | data <<= 1; 969 | } 970 | else { 971 | return ERR; // Error 972 | } 973 | } 974 | // Success 975 | results->bits = nbits; 976 | results->value = data; 977 | results->decode_type = RC6; 978 | return DECODED; 979 | } 980 | 981 | long IRrecv::decodePanasonic(decode_results *results) { 982 | unsigned long long data = 0; 983 | int offset = 1; // Dont skip first space 984 | /*if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) { 985 | return ERR; 986 | } 987 | offset++;*/ 988 | if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) { 989 | return ERR; 990 | } 991 | offset++; 992 | // decode address 993 | for (int i = 0; i < PANASONIC_BITS; i++) { 994 | if (!MATCH(results->rawbuf[offset++], PANASONIC_BIT_MARK)) { 995 | return ERR; 996 | } 997 | if (MATCH(results->rawbuf[offset],PANASONIC_ONE_SPACE)) { 998 | data = (data << 1) | 1; 999 | } else if (MATCH(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) { 1000 | data <<= 1; 1001 | } else { 1002 | return ERR; 1003 | } 1004 | offset++; 1005 | } 1006 | results->value = (unsigned long)data; 1007 | results->panasonicAddress = (unsigned int)(data >> 32); 1008 | results->decode_type = PANASONIC; 1009 | results->bits = PANASONIC_BITS; 1010 | return DECODED; 1011 | } 1012 | 1013 | long IRrecv::decodeLG(decode_results *results) { 1014 | long data = 0; 1015 | int offset = 1; // Skip first space 1016 | 1017 | // Initial mark 1018 | if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) { 1019 | return ERR; 1020 | } 1021 | offset++; 1022 | if (irparams.rawlen < 2 * LG_BITS + 1 ) { 1023 | return ERR; 1024 | } 1025 | // Initial space 1026 | if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) { 1027 | return ERR; 1028 | } 1029 | offset++; 1030 | for (int i = 0; i < LG_BITS; i++) { 1031 | if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) { 1032 | return ERR; 1033 | } 1034 | offset++; 1035 | if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) { 1036 | data = (data << 1) | 1; 1037 | } 1038 | else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) { 1039 | data <<= 1; 1040 | } 1041 | else { 1042 | return ERR; 1043 | } 1044 | offset++; 1045 | } 1046 | //Stop bit 1047 | if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){ 1048 | return ERR; 1049 | } 1050 | // Success 1051 | results->bits = LG_BITS; 1052 | results->value = data; 1053 | results->decode_type = LG; 1054 | return DECODED; 1055 | } 1056 | 1057 | long IRrecv::decodeJVC(decode_results *results) { 1058 | long data = 0; 1059 | int offset = 1; // Skip first space 1060 | // Check for repeat 1061 | if (irparams.rawlen - 1 == 33 && 1062 | MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK) && 1063 | MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)) { 1064 | results->bits = 0; 1065 | results->value = REPEAT; 1066 | results->decode_type = JVC; 1067 | return DECODED; 1068 | } 1069 | // Initial mark 1070 | if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) { 1071 | return ERR; 1072 | } 1073 | offset++; 1074 | if (irparams.rawlen < 2 * JVC_BITS + 1 ) { 1075 | return ERR; 1076 | } 1077 | // Initial space 1078 | if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) { 1079 | return ERR; 1080 | } 1081 | offset++; 1082 | for (int i = 0; i < JVC_BITS; i++) { 1083 | if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) { 1084 | return ERR; 1085 | } 1086 | offset++; 1087 | if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) { 1088 | data = (data << 1) | 1; 1089 | } 1090 | else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) { 1091 | data <<= 1; 1092 | } 1093 | else { 1094 | return ERR; 1095 | } 1096 | offset++; 1097 | } 1098 | //Stop bit 1099 | if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)){ 1100 | return ERR; 1101 | } 1102 | // Success 1103 | results->bits = JVC_BITS; 1104 | results->value = data; 1105 | results->decode_type = JVC; 1106 | return DECODED; 1107 | } 1108 | 1109 | // SAMSUNGs have a repeat only 4 items long 1110 | long IRrecv::decodeSAMSUNG(decode_results *results) { 1111 | long data = 0; 1112 | int offset = 0; // Dont skip first space 1113 | // Initial mark 1114 | if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) { 1115 | return ERR; 1116 | } 1117 | offset++; 1118 | // Check for repeat 1119 | if (irparams.rawlen == 4 && 1120 | MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE) && 1121 | MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)) { 1122 | results->bits = 0; 1123 | results->value = REPEAT; 1124 | results->decode_type = SAMSUNG; 1125 | return DECODED; 1126 | } 1127 | if (irparams.rawlen < 2 * SAMSUNG_BITS + 2) { 1128 | return ERR; 1129 | } 1130 | // Initial space 1131 | if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) { 1132 | return ERR; 1133 | } 1134 | offset++; 1135 | for (int i = 0; i < SAMSUNG_BITS; i++) { 1136 | if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) { 1137 | return ERR; 1138 | } 1139 | offset++; 1140 | if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) { 1141 | data = (data << 1) | 1; 1142 | } 1143 | else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) { 1144 | data <<= 1; 1145 | } 1146 | else { 1147 | return ERR; 1148 | } 1149 | offset++; 1150 | } 1151 | // Success 1152 | results->bits = SAMSUNG_BITS; 1153 | results->value = data; 1154 | results->decode_type = SAMSUNG; 1155 | return DECODED; 1156 | } 1157 | 1158 | /* ----------------------------------------------------------------------- 1159 | * hashdecode - decode an arbitrary IR code. 1160 | * Instead of decoding using a standard encoding scheme 1161 | * (e.g. Sony, NEC, RC5), the code is hashed to a 32-bit value. 1162 | * 1163 | * The algorithm: look at the sequence of MARK signals, and see if each one 1164 | * is shorter (0), the same length (1), or longer (2) than the previous. 1165 | * Do the same with the SPACE signals. Hszh the resulting sequence of 0's, 1166 | * 1's, and 2's to a 32-bit value. This will give a unique value for each 1167 | * different code (probably), for most code systems. 1168 | * 1169 | * http://arcfn.com/2010/01/using-arbitrary-remotes-with-arduino.html 1170 | */ 1171 | 1172 | // Compare two tick values, returning 0 if newval is shorter, 1173 | // 1 if newval is equal, and 2 if newval is longer 1174 | // Use a tolerance of 20% 1175 | int IRrecv::compare(unsigned int oldval, unsigned int newval) { 1176 | if (newval < oldval * .8) { 1177 | return 0; 1178 | } 1179 | else if (oldval < newval * .8) { 1180 | return 2; 1181 | } 1182 | else { 1183 | return 1; 1184 | } 1185 | } 1186 | 1187 | // Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param 1188 | #define FNV_PRIME_32 16777619 1189 | #define FNV_BASIS_32 2166136261 1190 | 1191 | /* Converts the raw code values into a 32-bit hash code. 1192 | * Hopefully this code is unique for each button. 1193 | * This isn't a "real" decoding, just an arbitrary value. 1194 | */ 1195 | long IRrecv::decodeHash(decode_results *results) { 1196 | // Require at least 6 samples to prevent triggering on noise 1197 | if (results->rawlen < 6) { 1198 | return ERR; 1199 | } 1200 | long hash = FNV_BASIS_32; 1201 | for (int i = 1; i+2 < results->rawlen; i++) { 1202 | int value = compare(results->rawbuf[i], results->rawbuf[i+2]); 1203 | // Add value into the hash 1204 | hash = (hash * FNV_PRIME_32) ^ value; 1205 | } 1206 | results->value = hash; 1207 | results->bits = 32; 1208 | results->decode_type = UNKNOWN; 1209 | return DECODED; 1210 | } 1211 | 1212 | // --------------------------------------------------------------- 1213 | -------------------------------------------------------------------------------- /IRremoteESP8266.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * IRremote for ESP8266 3 | * 4 | * Based on the IRremote library for Arduino by Ken Shirriff 5 | * Version 0.11 August, 2009 6 | * Copyright 2009 Ken Shirriff 7 | * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html 8 | * 9 | * Edited by Mitra to add new controller SANYO 10 | * 11 | * Interrupt code based on NECIRrcv by Joe Knapp 12 | * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 13 | * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ 14 | * 15 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 16 | * LG added by Darryl Smith (based on the JVC protocol) 17 | * Whynter A/C ARC-110WD added by Francesco Meschia 18 | * 19 | * Updated by markszabo (https://github.com/markszabo/IRremoteESP8266) for sending IR code on ESP8266 20 | * Updated by Sebastien Warin (http://sebastien.warin.fr) for receiving IR code on ESP8266 21 | * 22 | * GPL license, all text above must be included in any redistribution 23 | ****************************************************/ 24 | 25 | #ifndef IRremote_h 26 | #define IRremote_h 27 | 28 | // The following are compile-time library options. 29 | // If you change them, recompile the library. 30 | // If DEBUG is defined, a lot of debugging output will be printed during decoding. 31 | // TEST must be defined for the IRtest unittests to work. It will make some 32 | // methods virtual, which will be slightly slower, which is why it is optional. 33 | //#define DEBUG 34 | //#define TEST 35 | 36 | enum decode_type_t { 37 | NEC = 1, 38 | SONY = 2, 39 | RC5 = 3, 40 | RC6 = 4, 41 | DISH = 5, 42 | SHARP = 6, 43 | PANASONIC = 7, 44 | JVC = 8, 45 | SANYO = 9, 46 | MITSUBISHI = 10, 47 | SAMSUNG = 11, 48 | LG = 12, 49 | WHYNTER = 13, 50 | AIWA_RC_T501 = 14, 51 | 52 | UNKNOWN = -1 53 | }; 54 | 55 | // Results returned from the decoder 56 | class decode_results { 57 | public: 58 | int decode_type; // NEC, SONY, RC5, UNKNOWN 59 | union { // This is used for decoding Panasonic and Sharp data 60 | unsigned int panasonicAddress; 61 | unsigned int sharpAddress; 62 | }; 63 | unsigned long value; // Decoded value 64 | int bits; // Number of bits in decoded value 65 | volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks 66 | int rawlen; // Number of records in rawbuf. 67 | }; 68 | 69 | // Values for decode_type 70 | #define NEC 1 71 | #define SONY 2 72 | #define RC5 3 73 | #define RC6 4 74 | #define DISH 5 75 | #define SHARP 6 76 | #define PANASONIC 7 77 | #define JVC 8 78 | #define SANYO 9 79 | #define MITSUBISHI 10 80 | #define SAMSUNG 11 81 | #define LG 12 82 | #define WHYNTER 13 83 | #define UNKNOWN -1 84 | 85 | // Decoded value for NEC when a repeat code is received 86 | #define REPEAT 0xffffffff 87 | 88 | // main class for receiving IR 89 | class IRrecv 90 | { 91 | public: 92 | IRrecv(int recvpin); 93 | int decode(decode_results *results); 94 | void enableIRIn(); 95 | void disableIRIn(); 96 | void resume(); 97 | private: 98 | // These are called by decode 99 | int getRClevel(decode_results *results, int *offset, int *used, int t1); 100 | long decodeNEC(decode_results *results); 101 | long decodeSony(decode_results *results); 102 | long decodeSanyo(decode_results *results); 103 | long decodeMitsubishi(decode_results *results); 104 | long decodeRC5(decode_results *results); 105 | long decodeRC6(decode_results *results); 106 | long decodePanasonic(decode_results *results); 107 | long decodeLG(decode_results *results); 108 | long decodeJVC(decode_results *results); 109 | long decodeSAMSUNG(decode_results *results); 110 | long decodeWhynter(decode_results *results); 111 | long decodeHash(decode_results *results); 112 | int compare(unsigned int oldval, unsigned int newval); 113 | }; 114 | 115 | // Only used for testing; can remove virtual for shorter code 116 | #ifdef TEST 117 | #define VIRTUAL virtual 118 | #else 119 | #define VIRTUAL 120 | #endif 121 | class IRsend 122 | { 123 | public: 124 | IRsend(int IRsendPin); 125 | void begin(); 126 | void sendWhynter(unsigned long data, int nbits); 127 | void sendNEC(unsigned long data, int nbits); 128 | void sendSony(unsigned long data, int nbits); 129 | // Neither Sanyo nor Mitsubishi send is implemented yet 130 | // void sendSanyo(unsigned long data, int nbits); 131 | // void sendMitsubishi(unsigned long data, int nbits); 132 | void sendRaw(unsigned int buf[], int len, int hz); 133 | void sendRC5(unsigned long data, int nbits); 134 | void sendRC6(unsigned long data, int nbits); 135 | void sendDISH(unsigned long data, int nbits); 136 | void sendSharp(unsigned int address, unsigned int command); 137 | void sendSharpRaw(unsigned long data, int nbits); 138 | void sendPanasonic(unsigned int address, unsigned long data); 139 | 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. 140 | void sendSAMSUNG(unsigned long data, int nbits); 141 | void enableIROut(int khz); 142 | VIRTUAL void mark(int usec); 143 | VIRTUAL void space(int usec); 144 | private: 145 | int halfPeriodicTime; 146 | int IRpin; 147 | } ; 148 | 149 | // Some useful constants 150 | #define USECPERTICK 50 // microseconds per clock interrupt tick 151 | #define RAWBUF 100 // Length of raw duration buffer 152 | 153 | // Marks tend to be 100us too long, and spaces 100us too short 154 | // when received due to sensor lag. 155 | #define MARK_EXCESS 100 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /IRremoteInt.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * IRremote for ESP8266 3 | * 4 | * Based on the IRremote library for Arduino by Ken Shirriff 5 | * Version 0.11 August, 2009 6 | * Copyright 2009 Ken Shirriff 7 | * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html 8 | * 9 | * Modified by Paul Stoffregen to support other boards and timers 10 | * 11 | * Interrupt code based on NECIRrcv by Joe Knapp 12 | * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 13 | * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ 14 | * 15 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 16 | * Whynter A/C ARC-110WD added by Francesco Meschia 17 | * 18 | * 09/23/2015 : Samsung pulse parameters updated by Sebastien Warin to be compatible with EUxxD6200 19 | * 20 | * GPL license, all text above must be included in any redistribution 21 | ****************************************************/ 22 | 23 | #ifndef IRremoteint_h 24 | #define IRremoteint_h 25 | 26 | #if defined(ARDUINO) && ARDUINO >= 100 27 | #include 28 | #else 29 | #include 30 | #endif 31 | 32 | // Pulse parms are *50-100 for the Mark and *50+100 for the space 33 | // First MARK is the one after the long gap 34 | // pulse parameters in usec 35 | #define WHYNTER_HDR_MARK 2850 36 | #define WHYNTER_HDR_SPACE 2850 37 | #define WHYNTER_BIT_MARK 750 38 | #define WHYNTER_ONE_MARK 750 39 | #define WHYNTER_ONE_SPACE 2150 40 | #define WHYNTER_ZERO_MARK 750 41 | #define WHYNTER_ZERO_SPACE 750 42 | 43 | #define NEC_HDR_MARK 9000 44 | #define NEC_HDR_SPACE 4500 45 | #define NEC_BIT_MARK 560 46 | #define NEC_ONE_SPACE 1690 47 | #define NEC_ZERO_SPACE 560 48 | #define NEC_RPT_SPACE 2250 49 | 50 | #define SONY_HDR_MARK 2400 51 | #define SONY_HDR_SPACE 600 52 | #define SONY_ONE_MARK 1200 53 | #define SONY_ZERO_MARK 600 54 | #define SONY_RPT_LENGTH 45000 55 | #define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround 56 | 57 | // SA 8650B 58 | #define SANYO_HDR_MARK 3500 // seen range 3500 59 | #define SANYO_HDR_SPACE 950 // seen 950 60 | #define SANYO_ONE_MARK 2400 // seen 2400 61 | #define SANYO_ZERO_MARK 700 // seen 700 62 | #define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround 63 | #define SANYO_RPT_LENGTH 45000 64 | 65 | // Mitsubishi RM 75501 66 | // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7 67 | 68 | // #define MITSUBISHI_HDR_MARK 250 // seen range 3500 69 | #define MITSUBISHI_HDR_SPACE 350 // 7*50+100 70 | #define MITSUBISHI_ONE_MARK 1950 // 41*50-100 71 | #define MITSUBISHI_ZERO_MARK 750 // 17*50-100 72 | // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround 73 | // #define MITSUBISHI_RPT_LENGTH 45000 74 | 75 | 76 | #define RC5_T1 889 77 | #define RC5_RPT_LENGTH 46000 78 | 79 | #define RC6_HDR_MARK 2666 80 | #define RC6_HDR_SPACE 889 81 | #define RC6_T1 444 82 | #define RC6_RPT_LENGTH 46000 83 | 84 | #define SHARP_BIT_MARK 245 85 | #define SHARP_ONE_SPACE 1805 86 | #define SHARP_ZERO_SPACE 795 87 | #define SHARP_GAP 600000 88 | #define SHARP_TOGGLE_MASK 0x3FF 89 | #define SHARP_RPT_SPACE 3000 90 | 91 | #define DISH_HDR_MARK 400 92 | #define DISH_HDR_SPACE 6100 93 | #define DISH_BIT_MARK 400 94 | #define DISH_ONE_SPACE 1700 95 | #define DISH_ZERO_SPACE 2800 96 | #define DISH_RPT_SPACE 6200 97 | #define DISH_TOP_BIT 0x8000 98 | 99 | #define PANASONIC_HDR_MARK 3502 100 | #define PANASONIC_HDR_SPACE 1750 101 | #define PANASONIC_BIT_MARK 502 102 | #define PANASONIC_ONE_SPACE 1244 103 | #define PANASONIC_ZERO_SPACE 400 104 | 105 | #define JVC_HDR_MARK 8000 106 | #define JVC_HDR_SPACE 4000 107 | #define JVC_BIT_MARK 600 108 | #define JVC_ONE_SPACE 1600 109 | #define JVC_ZERO_SPACE 550 110 | #define JVC_RPT_LENGTH 60000 111 | 112 | #define LG_HDR_MARK 8000 113 | #define LG_HDR_SPACE 4000 114 | #define LG_BIT_MARK 600 115 | #define LG_ONE_SPACE 1600 116 | #define LG_ZERO_SPACE 550 117 | #define LG_RPT_LENGTH 60000 118 | 119 | /* 120 | #define SAMSUNG_HDR_MARK 5000 121 | #define SAMSUNG_HDR_SPACE 5000 122 | #define SAMSUNG_BIT_MARK 560 123 | #define SAMSUNG_ONE_SPACE 1600 124 | #define SAMSUNG_ZERO_SPACE 560 125 | #define SAMSUNG_RPT_SPACE 2250 126 | */ 127 | 128 | // Update by Sebastien Warin for my EU46D6200 129 | #define SAMSUNG_HDR_MARK 4500 130 | #define SAMSUNG_HDR_SPACE 4500 131 | #define SAMSUNG_BIT_MARK 590 132 | #define SAMSUNG_ONE_SPACE 1690 133 | #define SAMSUNG_ZERO_SPACE 590 134 | #define SAMSUNG_RPT_SPACE 2250 135 | 136 | #define SHARP_BITS 15 137 | #define DISH_BITS 16 138 | 139 | #define TOLERANCE 25 // percent tolerance in measurements 140 | #define LTOL (1.0 - TOLERANCE/100.) 141 | #define UTOL (1.0 + TOLERANCE/100.) 142 | 143 | #define _GAP 5000 // Minimum map between transmissions 144 | #define GAP_TICKS (_GAP/USECPERTICK) 145 | 146 | #define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK)) 147 | #define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1)) 148 | 149 | // receiver states 150 | #define STATE_IDLE 2 151 | #define STATE_MARK 3 152 | #define STATE_SPACE 4 153 | #define STATE_STOP 5 154 | 155 | #define ERR 0 156 | #define DECODED 1 157 | 158 | // information for the interrupt handler 159 | typedef struct { 160 | uint8_t recvpin; // pin for IR data from detector 161 | uint8_t rcvstate; // state machine 162 | unsigned int timer; // state timer, counts 50uS ticks. 163 | unsigned int rawbuf[RAWBUF]; // raw data 164 | uint8_t rawlen; // counter of entries in rawbuf 165 | } 166 | irparams_t; 167 | 168 | // Defined in IRremote.cpp 169 | extern volatile irparams_t irparams; 170 | 171 | // IR detector output is active low 172 | #define MARK 0 173 | #define SPACE 1 174 | 175 | #define TOPBIT 0x80000000 176 | 177 | #define NEC_BITS 32 178 | #define SONY_BITS 12 179 | #define SANYO_BITS 12 180 | #define MITSUBISHI_BITS 16 181 | #define MIN_RC5_SAMPLES 11 182 | #define MIN_RC6_SAMPLES 1 183 | #define PANASONIC_BITS 48 184 | #define JVC_BITS 16 185 | #define LG_BITS 28 186 | #define SAMSUNG_BITS 32 187 | #define WHYNTER_BITS 32 188 | 189 | #endif 190 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | GNU LESSER GENERAL PUBLIC LICENSE 3 | Version 2.1, February 1999 4 | 5 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 6 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | [This is the first released version of the Lesser GPL. It also counts 11 | as the successor of the GNU Library Public License, version 2, hence 12 | the version number 2.1.] 13 | 14 | Preamble 15 | 16 | The licenses for most software are designed to take away your 17 | freedom to share and change it. By contrast, the GNU General Public 18 | Licenses are intended to guarantee your freedom to share and change 19 | free software--to make sure the software is free for all its users. 20 | 21 | This license, the Lesser General Public License, applies to some 22 | specially designated software packages--typically libraries--of the 23 | Free Software Foundation and other authors who decide to use it. You 24 | can use it too, but we suggest you first think carefully about whether 25 | this license or the ordinary General Public License is the better 26 | strategy to use in any particular case, based on the explanations below. 27 | 28 | When we speak of free software, we are referring to freedom of use, 29 | not price. Our General Public Licenses are designed to make sure that 30 | you have the freedom to distribute copies of free software (and charge 31 | for this service if you wish); that you receive source code or can get 32 | it if you want it; that you can change the software and use pieces of 33 | it in new free programs; and that you are informed that you can do 34 | these things. 35 | 36 | To protect your rights, we need to make restrictions that forbid 37 | distributors to deny you these rights or to ask you to surrender these 38 | rights. These restrictions translate to certain responsibilities for 39 | you if you distribute copies of the library or if you modify it. 40 | 41 | For example, if you distribute copies of the library, whether gratis 42 | or for a fee, you must give the recipients all the rights that we gave 43 | you. You must make sure that they, too, receive or can get the source 44 | code. If you link other code with the library, you must provide 45 | complete object files to the recipients, so that they can relink them 46 | with the library after making changes to the library and recompiling 47 | it. And you must show them these terms so they know their rights. 48 | 49 | We protect your rights with a two-step method: (1) we copyright the 50 | library, and (2) we offer you this license, which gives you legal 51 | permission to copy, distribute and/or modify the library. 52 | 53 | To protect each distributor, we want to make it very clear that 54 | there is no warranty for the free library. Also, if the library is 55 | modified by someone else and passed on, the recipients should know 56 | that what they have is not the original version, so that the original 57 | author's reputation will not be affected by problems that might be 58 | introduced by others. 59 | 60 | Finally, software patents pose a constant threat to the existence of 61 | any free program. We wish to make sure that a company cannot 62 | effectively restrict the users of a free program by obtaining a 63 | restrictive license from a patent holder. Therefore, we insist that 64 | any patent license obtained for a version of the library must be 65 | consistent with the full freedom of use specified in this license. 66 | 67 | Most GNU software, including some libraries, is covered by the 68 | ordinary GNU General Public License. This license, the GNU Lesser 69 | General Public License, applies to certain designated libraries, and 70 | is quite different from the ordinary General Public License. We use 71 | this license for certain libraries in order to permit linking those 72 | libraries into non-free programs. 73 | 74 | When a program is linked with a library, whether statically or using 75 | a shared library, the combination of the two is legally speaking a 76 | combined work, a derivative of the original library. The ordinary 77 | General Public License therefore permits such linking only if the 78 | entire combination fits its criteria of freedom. The Lesser General 79 | Public License permits more lax criteria for linking other code with 80 | the library. 81 | 82 | We call this license the "Lesser" General Public License because it 83 | does Less to protect the user's freedom than the ordinary General 84 | Public License. It also provides other free software developers Less 85 | of an advantage over competing non-free programs. These disadvantages 86 | are the reason we use the ordinary General Public License for many 87 | libraries. However, the Lesser license provides advantages in certain 88 | special circumstances. 89 | 90 | For example, on rare occasions, there may be a special need to 91 | encourage the widest possible use of a certain library, so that it becomes 92 | a de-facto standard. To achieve this, non-free programs must be 93 | allowed to use the library. A more frequent case is that a free 94 | library does the same job as widely used non-free libraries. In this 95 | case, there is little to gain by limiting the free library to free 96 | software only, so we use the Lesser General Public License. 97 | 98 | In other cases, permission to use a particular library in non-free 99 | programs enables a greater number of people to use a large body of 100 | free software. For example, permission to use the GNU C Library in 101 | non-free programs enables many more people to use the whole GNU 102 | operating system, as well as its variant, the GNU/Linux operating 103 | system. 104 | 105 | Although the Lesser General Public License is Less protective of the 106 | users' freedom, it does ensure that the user of a program that is 107 | linked with the Library has the freedom and the wherewithal to run 108 | that program using a modified version of the Library. 109 | 110 | The precise terms and conditions for copying, distribution and 111 | modification follow. Pay close attention to the difference between a 112 | "work based on the library" and a "work that uses the library". The 113 | former contains code derived from the library, whereas the latter must 114 | be combined with the library in order to run. 115 | 116 | GNU LESSER GENERAL PUBLIC LICENSE 117 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 118 | 119 | 0. This License Agreement applies to any software library or other 120 | program which contains a notice placed by the copyright holder or 121 | other authorized party saying it may be distributed under the terms of 122 | this Lesser General Public License (also called "this License"). 123 | Each licensee is addressed as "you". 124 | 125 | A "library" means a collection of software functions and/or data 126 | prepared so as to be conveniently linked with application programs 127 | (which use some of those functions and data) to form executables. 128 | 129 | The "Library", below, refers to any such software library or work 130 | which has been distributed under these terms. A "work based on the 131 | Library" means either the Library or any derivative work under 132 | copyright law: that is to say, a work containing the Library or a 133 | portion of it, either verbatim or with modifications and/or translated 134 | straightforwardly into another language. (Hereinafter, translation is 135 | included without limitation in the term "modification".) 136 | 137 | "Source code" for a work means the preferred form of the work for 138 | making modifications to it. For a library, complete source code means 139 | all the source code for all modules it contains, plus any associated 140 | interface definition files, plus the scripts used to control compilation 141 | and installation of the library. 142 | 143 | Activities other than copying, distribution and modification are not 144 | covered by this License; they are outside its scope. The act of 145 | running a program using the Library is not restricted, and output from 146 | such a program is covered only if its contents constitute a work based 147 | on the Library (independent of the use of the Library in a tool for 148 | writing it). Whether that is true depends on what the Library does 149 | and what the program that uses the Library does. 150 | 151 | 1. You may copy and distribute verbatim copies of the Library's 152 | complete source code as you receive it, in any medium, provided that 153 | you conspicuously and appropriately publish on each copy an 154 | appropriate copyright notice and disclaimer of warranty; keep intact 155 | all the notices that refer to this License and to the absence of any 156 | warranty; and distribute a copy of this License along with the 157 | Library. 158 | 159 | You may charge a fee for the physical act of transferring a copy, 160 | and you may at your option offer warranty protection in exchange for a 161 | fee. 162 | 163 | 2. You may modify your copy or copies of the Library or any portion 164 | of it, thus forming a work based on the Library, and copy and 165 | distribute such modifications or work under the terms of Section 1 166 | above, provided that you also meet all of these conditions: 167 | 168 | a) The modified work must itself be a software library. 169 | 170 | b) You must cause the files modified to carry prominent notices 171 | stating that you changed the files and the date of any change. 172 | 173 | c) You must cause the whole of the work to be licensed at no 174 | charge to all third parties under the terms of this License. 175 | 176 | d) If a facility in the modified Library refers to a function or a 177 | table of data to be supplied by an application program that uses 178 | the facility, other than as an argument passed when the facility 179 | is invoked, then you must make a good faith effort to ensure that, 180 | in the event an application does not supply such function or 181 | table, the facility still operates, and performs whatever part of 182 | its purpose remains meaningful. 183 | 184 | (For example, a function in a library to compute square roots has 185 | a purpose that is entirely well-defined independent of the 186 | application. Therefore, Subsection 2d requires that any 187 | application-supplied function or table used by this function must 188 | be optional: if the application does not supply it, the square 189 | root function must still compute square roots.) 190 | 191 | These requirements apply to the modified work as a whole. If 192 | identifiable sections of that work are not derived from the Library, 193 | and can be reasonably considered independent and separate works in 194 | themselves, then this License, and its terms, do not apply to those 195 | sections when you distribute them as separate works. But when you 196 | distribute the same sections as part of a whole which is a work based 197 | on the Library, the distribution of the whole must be on the terms of 198 | this License, whose permissions for other licensees extend to the 199 | entire whole, and thus to each and every part regardless of who wrote 200 | it. 201 | 202 | Thus, it is not the intent of this section to claim rights or contest 203 | your rights to work written entirely by you; rather, the intent is to 204 | exercise the right to control the distribution of derivative or 205 | collective works based on the Library. 206 | 207 | In addition, mere aggregation of another work not based on the Library 208 | with the Library (or with a work based on the Library) on a volume of 209 | a storage or distribution medium does not bring the other work under 210 | the scope of this License. 211 | 212 | 3. You may opt to apply the terms of the ordinary GNU General Public 213 | License instead of this License to a given copy of the Library. To do 214 | this, you must alter all the notices that refer to this License, so 215 | that they refer to the ordinary GNU General Public License, version 2, 216 | instead of to this License. (If a newer version than version 2 of the 217 | ordinary GNU General Public License has appeared, then you can specify 218 | that version instead if you wish.) Do not make any other change in 219 | these notices. 220 | 221 | Once this change is made in a given copy, it is irreversible for 222 | that copy, so the ordinary GNU General Public License applies to all 223 | subsequent copies and derivative works made from that copy. 224 | 225 | This option is useful when you wish to copy part of the code of 226 | the Library into a program that is not a library. 227 | 228 | 4. You may copy and distribute the Library (or a portion or 229 | derivative of it, under Section 2) in object code or executable form 230 | under the terms of Sections 1 and 2 above provided that you accompany 231 | it with the complete corresponding machine-readable source code, which 232 | must be distributed under the terms of Sections 1 and 2 above on a 233 | medium customarily used for software interchange. 234 | 235 | If distribution of object code is made by offering access to copy 236 | from a designated place, then offering equivalent access to copy the 237 | source code from the same place satisfies the requirement to 238 | distribute the source code, even though third parties are not 239 | compelled to copy the source along with the object code. 240 | 241 | 5. A program that contains no derivative of any portion of the 242 | Library, but is designed to work with the Library by being compiled or 243 | linked with it, is called a "work that uses the Library". Such a 244 | work, in isolation, is not a derivative work of the Library, and 245 | therefore falls outside the scope of this License. 246 | 247 | However, linking a "work that uses the Library" with the Library 248 | creates an executable that is a derivative of the Library (because it 249 | contains portions of the Library), rather than a "work that uses the 250 | library". The executable is therefore covered by this License. 251 | Section 6 states terms for distribution of such executables. 252 | 253 | When a "work that uses the Library" uses material from a header file 254 | that is part of the Library, the object code for the work may be a 255 | derivative work of the Library even though the source code is not. 256 | Whether this is true is especially significant if the work can be 257 | linked without the Library, or if the work is itself a library. The 258 | threshold for this to be true is not precisely defined by law. 259 | 260 | If such an object file uses only numerical parameters, data 261 | structure layouts and accessors, and small macros and small inline 262 | functions (ten lines or less in length), then the use of the object 263 | file is unrestricted, regardless of whether it is legally a derivative 264 | work. (Executables containing this object code plus portions of the 265 | Library will still fall under Section 6.) 266 | 267 | Otherwise, if the work is a derivative of the Library, you may 268 | distribute the object code for the work under the terms of Section 6. 269 | Any executables containing that work also fall under Section 6, 270 | whether or not they are linked directly with the Library itself. 271 | 272 | 6. As an exception to the Sections above, you may also combine or 273 | link a "work that uses the Library" with the Library to produce a 274 | work containing portions of the Library, and distribute that work 275 | under terms of your choice, provided that the terms permit 276 | modification of the work for the customer's own use and reverse 277 | engineering for debugging such modifications. 278 | 279 | You must give prominent notice with each copy of the work that the 280 | Library is used in it and that the Library and its use are covered by 281 | this License. You must supply a copy of this License. If the work 282 | during execution displays copyright notices, you must include the 283 | copyright notice for the Library among them, as well as a reference 284 | directing the user to the copy of this License. Also, you must do one 285 | of these things: 286 | 287 | a) Accompany the work with the complete corresponding 288 | machine-readable source code for the Library including whatever 289 | changes were used in the work (which must be distributed under 290 | Sections 1 and 2 above); and, if the work is an executable linked 291 | with the Library, with the complete machine-readable "work that 292 | uses the Library", as object code and/or source code, so that the 293 | user can modify the Library and then relink to produce a modified 294 | executable containing the modified Library. (It is understood 295 | that the user who changes the contents of definitions files in the 296 | Library will not necessarily be able to recompile the application 297 | to use the modified definitions.) 298 | 299 | b) Use a suitable shared library mechanism for linking with the 300 | Library. A suitable mechanism is one that (1) uses at run time a 301 | copy of the library already present on the user's computer system, 302 | rather than copying library functions into the executable, and (2) 303 | will operate properly with a modified version of the library, if 304 | the user installs one, as long as the modified version is 305 | interface-compatible with the version that the work was made with. 306 | 307 | c) Accompany the work with a written offer, valid for at 308 | least three years, to give the same user the materials 309 | specified in Subsection 6a, above, for a charge no more 310 | than the cost of performing this distribution. 311 | 312 | d) If distribution of the work is made by offering access to copy 313 | from a designated place, offer equivalent access to copy the above 314 | specified materials from the same place. 315 | 316 | e) Verify that the user has already received a copy of these 317 | materials or that you have already sent this user a copy. 318 | 319 | For an executable, the required form of the "work that uses the 320 | Library" must include any data and utility programs needed for 321 | reproducing the executable from it. However, as a special exception, 322 | the materials to be distributed need not include anything that is 323 | normally distributed (in either source or binary form) with the major 324 | components (compiler, kernel, and so on) of the operating system on 325 | which the executable runs, unless that component itself accompanies 326 | the executable. 327 | 328 | It may happen that this requirement contradicts the license 329 | restrictions of other proprietary libraries that do not normally 330 | accompany the operating system. Such a contradiction means you cannot 331 | use both them and the Library together in an executable that you 332 | distribute. 333 | 334 | 7. You may place library facilities that are a work based on the 335 | Library side-by-side in a single library together with other library 336 | facilities not covered by this License, and distribute such a combined 337 | library, provided that the separate distribution of the work based on 338 | the Library and of the other library facilities is otherwise 339 | permitted, and provided that you do these two things: 340 | 341 | a) Accompany the combined library with a copy of the same work 342 | based on the Library, uncombined with any other library 343 | facilities. This must be distributed under the terms of the 344 | Sections above. 345 | 346 | b) Give prominent notice with the combined library of the fact 347 | that part of it is a work based on the Library, and explaining 348 | where to find the accompanying uncombined form of the same work. 349 | 350 | 8. You may not copy, modify, sublicense, link with, or distribute 351 | the Library except as expressly provided under this License. Any 352 | attempt otherwise to copy, modify, sublicense, link with, or 353 | distribute the Library is void, and will automatically terminate your 354 | rights under this License. However, parties who have received copies, 355 | or rights, from you under this License will not have their licenses 356 | terminated so long as such parties remain in full compliance. 357 | 358 | 9. You are not required to accept this License, since you have not 359 | signed it. However, nothing else grants you permission to modify or 360 | distribute the Library or its derivative works. These actions are 361 | prohibited by law if you do not accept this License. Therefore, by 362 | modifying or distributing the Library (or any work based on the 363 | Library), you indicate your acceptance of this License to do so, and 364 | all its terms and conditions for copying, distributing or modifying 365 | the Library or works based on it. 366 | 367 | 10. Each time you redistribute the Library (or any work based on the 368 | Library), the recipient automatically receives a license from the 369 | original licensor to copy, distribute, link with or modify the Library 370 | subject to these terms and conditions. You may not impose any further 371 | restrictions on the recipients' exercise of the rights granted herein. 372 | You are not responsible for enforcing compliance by third parties with 373 | this License. 374 | 375 | 11. If, as a consequence of a court judgment or allegation of patent 376 | infringement or for any other reason (not limited to patent issues), 377 | conditions are imposed on you (whether by court order, agreement or 378 | otherwise) that contradict the conditions of this License, they do not 379 | excuse you from the conditions of this License. If you cannot 380 | distribute so as to satisfy simultaneously your obligations under this 381 | License and any other pertinent obligations, then as a consequence you 382 | may not distribute the Library at all. For example, if a patent 383 | license would not permit royalty-free redistribution of the Library by 384 | all those who receive copies directly or indirectly through you, then 385 | the only way you could satisfy both it and this License would be to 386 | refrain entirely from distribution of the Library. 387 | 388 | If any portion of this section is held invalid or unenforceable under any 389 | particular circumstance, the balance of the section is intended to apply, 390 | and the section as a whole is intended to apply in other circumstances. 391 | 392 | It is not the purpose of this section to induce you to infringe any 393 | patents or other property right claims or to contest validity of any 394 | such claims; this section has the sole purpose of protecting the 395 | integrity of the free software distribution system which is 396 | implemented by public license practices. Many people have made 397 | generous contributions to the wide range of software distributed 398 | through that system in reliance on consistent application of that 399 | system; it is up to the author/donor to decide if he or she is willing 400 | to distribute software through any other system and a licensee cannot 401 | impose that choice. 402 | 403 | This section is intended to make thoroughly clear what is believed to 404 | be a consequence of the rest of this License. 405 | 406 | 12. If the distribution and/or use of the Library is restricted in 407 | certain countries either by patents or by copyrighted interfaces, the 408 | original copyright holder who places the Library under this License may add 409 | an explicit geographical distribution limitation excluding those countries, 410 | so that distribution is permitted only in or among countries not thus 411 | excluded. In such case, this License incorporates the limitation as if 412 | written in the body of this License. 413 | 414 | 13. The Free Software Foundation may publish revised and/or new 415 | versions of the Lesser General Public License from time to time. 416 | Such new versions will be similar in spirit to the present version, 417 | but may differ in detail to address new problems or concerns. 418 | 419 | Each version is given a distinguishing version number. If the Library 420 | specifies a version number of this License which applies to it and 421 | "any later version", you have the option of following the terms and 422 | conditions either of that version or of any later version published by 423 | the Free Software Foundation. If the Library does not specify a 424 | license version number, you may choose any version ever published by 425 | the Free Software Foundation. 426 | 427 | 14. If you wish to incorporate parts of the Library into other free 428 | programs whose distribution conditions are incompatible with these, 429 | write to the author to ask for permission. For software which is 430 | copyrighted by the Free Software Foundation, write to the Free 431 | Software Foundation; we sometimes make exceptions for this. Our 432 | decision will be guided by the two goals of preserving the free status 433 | of all derivatives of our free software and of promoting the sharing 434 | and reuse of software generally. 435 | 436 | NO WARRANTY 437 | 438 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 439 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 440 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 441 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 442 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 443 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 444 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 445 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 446 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 447 | 448 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 449 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 450 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 451 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 452 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 453 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 454 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 455 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 456 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 457 | DAMAGES. 458 | 459 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IRremote ESP8266 Library 2 | 3 | This library enables you to **send and receive** infra-red signals on an ESP8266 using Arduino framework (https://github.com/esp8266/Arduino) 4 | 5 | This library is based on Ken Shirriff's work (https://github.com/shirriff/Arduino-IRremote/) 6 | 7 | [Mark Szabo](https://github.com/markszabo/IRremoteESP8266) has updated the IRsend class to work on ESP8266 and [Sebastien Warin](https://github.com/sebastienwarin/IRremoteESP8266) the receiving & decoding part (IRrecv class). 8 | 9 | Seb's notes : I also changed the pulse parameters for Samsung, update the Panasonic and Samsung decoders and remove the SANYO decoders. The IR decoder was successfully tested with Panasonic and Samsung remote controls. 10 | 11 | ## Installation 12 | 1. Click "Download ZIP" 13 | 2. Extract the downloaded zip file 14 | 3. Rename the extracted folder to "IRremoteESP8266" 15 | 4. Move this folder to your libraries directory (under windows: C:\Users\YOURNAME\Documents\Arduino\libraries\) 16 | 5. Restart your Arduino ide 17 | 6. Check out the examples 18 | 19 | ## Contributing 20 | If you want to contribute to this project: 21 | - Report bugs and errors 22 | - Ask for enhancements 23 | - Create issues and pull requests 24 | - Tell other people about this library 25 | 26 | ## Contributors 27 | Check [here](Contributors.md) 28 | -------------------------------------------------------------------------------- /examples/IRServer/IRServer.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IRremoteESP8266: IRServer - demonstrates sending IR codes controlled from a webserver 3 | * An IR LED must be connected to ESP8266 pin 0. 4 | * Version 0.1 June, 2015 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | const char* ssid = "....."; 14 | const char* password = "....."; 15 | MDNSResponder mdns; 16 | 17 | ESP8266WebServer server(80); 18 | 19 | IRsend irsend(0); 20 | 21 | void handleRoot() { 22 | server.send(200, "text/html", " ESP8266 Demo

Hello from ESP8266, you can send NEC encoded IR signals from here!

Send 0xFFE01F

Send 0xFAB123

Send 0xFFE896

"); 23 | } 24 | 25 | void handleIr(){ 26 | for (uint8_t i=0; i 9 | 10 | int RECV_PIN = 2; //an IR detector/demodulatord is connected to GPIO pin 2 11 | 12 | IRrecv irrecv(RECV_PIN); 13 | 14 | decode_results results; 15 | 16 | void setup() 17 | { 18 | Serial.begin(9600); 19 | irrecv.enableIRIn(); // Start the receiver 20 | } 21 | 22 | void loop() { 23 | if (irrecv.decode(&results)) { 24 | Serial.println(results.value, HEX); 25 | irrecv.resume(); // Receive the next value 26 | } 27 | delay(100); 28 | } 29 | -------------------------------------------------------------------------------- /examples/IRrecvDump/IRrecvDump.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IRremoteESP8266: IRrecvDump - dump details of IR codes with IRrecv 3 | * An IR detector/demodulator must be connected to the input RECV_PIN. 4 | * Version 0.1 Sept, 2015 5 | * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com 6 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 7 | * LG added by Darryl Smith (based on the JVC protocol) 8 | */ 9 | 10 | #include 11 | 12 | int RECV_PIN = 2; //an IR detector/demodulatord is connected to GPIO pin 2 13 | 14 | IRrecv irrecv(RECV_PIN); 15 | 16 | decode_results results; 17 | 18 | void setup() 19 | { 20 | Serial.begin(9600); 21 | irrecv.enableIRIn(); // Start the receiver 22 | } 23 | 24 | 25 | void dump(decode_results *results) { 26 | // Dumps out the decode_results structure. 27 | // Call this after IRrecv::decode() 28 | int count = results->rawlen; 29 | if (results->decode_type == UNKNOWN) { 30 | Serial.print("Unknown encoding: "); 31 | } 32 | else if (results->decode_type == NEC) { 33 | Serial.print("Decoded NEC: "); 34 | 35 | } 36 | else if (results->decode_type == SONY) { 37 | Serial.print("Decoded SONY: "); 38 | } 39 | else if (results->decode_type == RC5) { 40 | Serial.print("Decoded RC5: "); 41 | } 42 | else if (results->decode_type == RC6) { 43 | Serial.print("Decoded RC6: "); 44 | } 45 | else if (results->decode_type == PANASONIC) { 46 | Serial.print("Decoded PANASONIC - Address: "); 47 | Serial.print(results->panasonicAddress, HEX); 48 | Serial.print(" Value: "); 49 | } 50 | else if (results->decode_type == LG) { 51 | Serial.print("Decoded LG: "); 52 | } 53 | else if (results->decode_type == JVC) { 54 | Serial.print("Decoded JVC: "); 55 | } 56 | else if (results->decode_type == AIWA_RC_T501) { 57 | Serial.print("Decoded AIWA RC T501: "); 58 | } 59 | else if (results->decode_type == WHYNTER) { 60 | Serial.print("Decoded Whynter: "); 61 | } 62 | Serial.print(results->value, HEX); 63 | Serial.print(" ("); 64 | Serial.print(results->bits, DEC); 65 | Serial.println(" bits)"); 66 | Serial.print("Raw ("); 67 | Serial.print(count, DEC); 68 | Serial.print("): "); 69 | 70 | for (int i = 1; i < count; i++) { 71 | if (i & 1) { 72 | Serial.print(results->rawbuf[i]*USECPERTICK, DEC); 73 | } 74 | else { 75 | Serial.write('-'); 76 | Serial.print((unsigned long) results->rawbuf[i]*USECPERTICK, DEC); 77 | } 78 | Serial.print(" "); 79 | } 80 | Serial.println(); 81 | } 82 | 83 | void loop() { 84 | if (irrecv.decode(&results)) { 85 | Serial.println(results.value, HEX); 86 | dump(&results); 87 | irrecv.resume(); // Receive the next value 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /examples/IRrecvDumpV2/IRrecvDumpV2.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IRremoteESP8266: IRrecvDumpV2 - dump details of IR codes with IRrecv 3 | * An IR detector/demodulator must be connected to the input RECV_PIN. 4 | * Version 0.1 Sept, 2015 5 | * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com 6 | */ 7 | 8 | #include 9 | 10 | int RECV_PIN = 2; //an IR detector/demodulator is connected to GPIO pin 2 11 | 12 | IRrecv irrecv(RECV_PIN); 13 | 14 | void setup ( ) 15 | { 16 | Serial.begin(9600); // Status message will be sent to PC at 9600 baud 17 | irrecv.enableIRIn(); // Start the receiver 18 | } 19 | 20 | //+============================================================================= 21 | // Display IR code 22 | // 23 | void ircode (decode_results *results) 24 | { 25 | // Panasonic has an Address 26 | if (results->decode_type == PANASONIC) { 27 | Serial.print(results->panasonicAddress, HEX); 28 | Serial.print(":"); 29 | } 30 | 31 | // Print Code 32 | Serial.print(results->value, HEX); 33 | } 34 | 35 | //+============================================================================= 36 | // Display encoding type 37 | // 38 | void encoding (decode_results *results) 39 | { 40 | switch (results->decode_type) { 41 | default: 42 | case UNKNOWN: Serial.print("UNKNOWN"); break ; 43 | case NEC: Serial.print("NEC"); break ; 44 | case SONY: Serial.print("SONY"); break ; 45 | case RC5: Serial.print("RC5"); break ; 46 | case RC6: Serial.print("RC6"); break ; 47 | case DISH: Serial.print("DISH"); break ; 48 | case SHARP: Serial.print("SHARP"); break ; 49 | case JVC: Serial.print("JVC"); break ; 50 | case SANYO: Serial.print("SANYO"); break ; 51 | case MITSUBISHI: Serial.print("MITSUBISHI"); break ; 52 | case SAMSUNG: Serial.print("SAMSUNG"); break ; 53 | case LG: Serial.print("LG"); break ; 54 | case WHYNTER: Serial.print("WHYNTER"); break ; 55 | case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ; 56 | case PANASONIC: Serial.print("PANASONIC"); break ; 57 | } 58 | } 59 | 60 | //+============================================================================= 61 | // Dump out the decode_results structure. 62 | // 63 | void dumpInfo (decode_results *results) 64 | { 65 | // Show Encoding standard 66 | Serial.print("Encoding : "); 67 | encoding(results); 68 | Serial.println(""); 69 | 70 | // Show Code & length 71 | Serial.print("Code : "); 72 | ircode(results); 73 | Serial.print(" ("); 74 | Serial.print(results->bits, DEC); 75 | Serial.println(" bits)"); 76 | } 77 | 78 | //+============================================================================= 79 | // Dump out the decode_results structure. 80 | // 81 | void dumpRaw (decode_results *results) 82 | { 83 | // Print Raw data 84 | Serial.print("Timing["); 85 | Serial.print(results->rawlen-1, DEC); 86 | Serial.println("]: "); 87 | 88 | for (int i = 1; i < results->rawlen; i++) { 89 | unsigned long x = results->rawbuf[i] * USECPERTICK; 90 | if (!(i & 1)) { // even 91 | Serial.print("-"); 92 | if (x < 1000) Serial.print(" ") ; 93 | if (x < 100) Serial.print(" ") ; 94 | Serial.print(x, DEC); 95 | } else { // odd 96 | Serial.print(" "); 97 | Serial.print("+"); 98 | if (x < 1000) Serial.print(" ") ; 99 | if (x < 100) Serial.print(" ") ; 100 | Serial.print(x, DEC); 101 | if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one 102 | } 103 | if (!(i % 8)) Serial.println(""); 104 | } 105 | Serial.println(""); // Newline 106 | } 107 | 108 | //+============================================================================= 109 | // Dump out the decode_results structure. 110 | // 111 | void dumpCode (decode_results *results) 112 | { 113 | // Start declaration 114 | Serial.print("unsigned int "); // variable type 115 | Serial.print("rawData["); // array name 116 | Serial.print(results->rawlen - 1, DEC); // array size 117 | Serial.print("] = {"); // Start declaration 118 | 119 | // Dump data 120 | for (int i = 1; i < results->rawlen; i++) { 121 | Serial.print(results->rawbuf[i] * USECPERTICK, DEC); 122 | if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one 123 | if (!(i & 1)) Serial.print(" "); 124 | } 125 | 126 | // End declaration 127 | Serial.print("};"); // 128 | 129 | // Comment 130 | Serial.print(" // "); 131 | encoding(results); 132 | Serial.print(" "); 133 | ircode(results); 134 | 135 | // Newline 136 | Serial.println(""); 137 | 138 | // Now dump "known" codes 139 | if (results->decode_type != UNKNOWN) { 140 | 141 | // Some protocols have an address 142 | if (results->decode_type == PANASONIC) { 143 | Serial.print("unsigned int addr = 0x"); 144 | Serial.print(results->panasonicAddress, HEX); 145 | Serial.println(";"); 146 | } 147 | 148 | // All protocols have data 149 | Serial.print("unsigned int data = 0x"); 150 | Serial.print(results->value, HEX); 151 | Serial.println(";"); 152 | } 153 | } 154 | 155 | //+============================================================================= 156 | // The repeating section of the code 157 | // 158 | void loop ( ) 159 | { 160 | decode_results results; // Somewhere to store the results 161 | 162 | if (irrecv.decode(&results)) { // Grab an IR code 163 | dumpInfo(&results); // Output the results 164 | dumpRaw(&results); // Output the results in RAW format 165 | dumpCode(&results); // Output the results as source code 166 | Serial.println(""); // Blank line between entries 167 | irrecv.resume(); // Prepare for the next value 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /examples/IRsendDemo/IRsendDemo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend 3 | * An IR LED must be connected to ESP8266 pin 0. 4 | * Version 0.1 June, 2015 5 | * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com 6 | */ 7 | 8 | #include 9 | 10 | IRsend irsend(0); //an IR led is connected to GPIO pin 0 11 | 12 | void setup() 13 | { 14 | irsend.begin(); 15 | Serial.begin(9600); 16 | } 17 | 18 | void loop() { 19 | Serial.println("NEC"); 20 | irsend.sendNEC(0x00FFE01F, 36); 21 | delay(2000); 22 | Serial.println("Sony"); 23 | irsend.sendSony(0xa90, 12); 24 | delay(2000); 25 | } 26 | -------------------------------------------------------------------------------- /examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend 3 | * An IR LED must be connected to ESP8266 pin 0. 4 | * Version 0.1 June, 2015 5 | * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com 6 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 7 | */ 8 | #include 9 | 10 | #define PanasonicAddress 0x4004 // Panasonic address (Pre data) 11 | #define PanasonicPower 0x100BCBD // Panasonic Power button 12 | 13 | #define JVCPower 0xC5E8 14 | 15 | IRsend irsend(0); //an IR led is connected to GPIO pin 0 16 | 17 | void setup() 18 | { 19 | irsend.begin(); 20 | } 21 | 22 | void loop() { 23 | irsend.sendPanasonic(PanasonicAddress,PanasonicPower); // This should turn your TV on and off 24 | 25 | irsend.sendJVC(JVCPower, 16,0); // hex value, 16 bits, no repeat 26 | delayMicroseconds(50); // see http://www.sbprojects.com/knowledge/ir/jvc.php for information 27 | irsend.sendJVC(JVCPower, 16,1); // hex value, 16 bits, repeat 28 | delayMicroseconds(50); 29 | } 30 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For IRremote 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | decode_results KEYWORD1 10 | IRrecv KEYWORD1 11 | IRsend KEYWORD1 12 | 13 | ####################################### 14 | # Methods and Functions (KEYWORD2) 15 | ####################################### 16 | 17 | decode KEYWORD2 18 | enableIRIn KEYWORD2 19 | disableIRIn KEYWORD2 20 | resume KEYWORD2 21 | begin KEYWORD2 22 | enableIROut KEYWORD2 23 | sendNEC KEYWORD2 24 | sendSony KEYWORD2 25 | sendSanyo KEYWORD2 26 | sendMitsubishi KEYWORD2 27 | sendRaw KEYWORD2 28 | sendRC5 KEYWORD2 29 | sendRC6 KEYWORD2 30 | sendDISH KEYWORD2 31 | sendSharp KEYWORD2 32 | sendSharpRaw KEYWORD2 33 | sendPanasonic KEYWORD2 34 | sendJVC KEYWORD2 35 | sendWhynter KEYWORD2 36 | sendSAMSUNG KEYWORD2 37 | 38 | ####################################### 39 | # Constants (LITERAL1) 40 | ####################################### 41 | 42 | NEC LITERAL1 43 | SONY LITERAL1 44 | SANYO LITERAL1 45 | MITSUBISHI LITERAL1 46 | RC5 LITERAL1 47 | RC6 LITERAL1 48 | DISH LITERAL1 49 | SHARP LITERAL1 50 | PANASONIC LITERAL1 51 | JVC LITERAL1 52 | LG LITERAL1 53 | SAMSUNG LITERAL1 54 | WHYNTER LITERAL1 55 | AIWA_RC_T501 LITERAL1 56 | UNKNOWN LITERAL1 57 | REPEAT LITERAL1 -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "IRremoteESP8266", 3 | "keywords": "infrared, ir, remote", 4 | "description": "Send and receive infrared signals with multiple protocols (ESP8266)", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/sebastienwarin/IRremoteESP8266.git" 9 | }, 10 | "authors": [ 11 | { 12 | "name": "Ken Shirriff", 13 | "email": "zetoslab@gmail.com" 14 | }, 15 | { 16 | "name": "Mark Szabo", 17 | "url": "http://nomartini-noparty.blogspot.com/" 18 | }, 19 | { 20 | "name": "Sebastien Warin", 21 | "url": "http://sebastien.warin.fr", 22 | "maintainer": true 23 | } 24 | ], 25 | "frameworks": "arduino", 26 | "platforms": "espressif" 27 | } 28 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=IRremoteESP8266 2 | version=1.0.0 3 | author=Sebastien Warin, Mark Szabo, Ken Shirriff 4 | maintainer=Sebastien Warin 5 | sentence=Send and receive infrared signals with multiple protocols. 6 | paragraph=This library enables you to send and receive infra-red signals on an ESP8266. 7 | category=Device Control 8 | url=https://github.com/sebastienwarin/IRremoteESP8266 9 | architectures=esp8266 10 | --------------------------------------------------------------------------------