From 81eb44aa8ce65d6d0100499e79fdd405b0ebe84d Mon Sep 17 00:00:00 2001 From: arendst Date: Wed, 29 Mar 2017 18:24:57 +0200 Subject: [PATCH] Revert "Updated library" This reverts commit 659fa926108051b298a5ede872db179c030b41ea. --- lib/IRremoteESP8266-1.0.2a/.travis.yml | 33 - lib/IRremoteESP8266-1.0.2a/Contributors.md | 13 - lib/IRremoteESP8266-1.0.2a/IRDaikinESP.cpp | 152 -- lib/IRremoteESP8266-1.0.2a/IRDaikinESP.h | 100 - lib/IRremoteESP8266-1.0.2a/IRKelvinator.cpp | 233 --- lib/IRremoteESP8266-1.0.2a/IRKelvinator.h | 160 -- lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.cpp | 149 -- lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.h | 52 - .../IRremoteESP8266.cpp | 1647 ----------------- lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.h | 221 --- .../examples/IRGCSendDemo/IRGCSendDemo.ino | 26 - .../examples/IRGCTCPServer/IRGCTCPServer.ino | 85 - .../TurnOnDaikinAC/TurnOnDaikinAC.ino | 27 - .../TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino | 52 - .../TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino | 42 - lib/IRremoteESP8266-1.0.2a/library.json | 44 - lib/IRremoteESP8266-1.0.2a/library.properties | 9 - lib/IRremoteESP8266/Contributors.md | 20 + lib/IRremoteESP8266/IRremoteESP8266.cpp | 1212 ++++++++++++ lib/IRremoteESP8266/IRremoteESP8266.h | 157 ++ .../IRremoteInt.h | 72 +- .../LICENSE.txt | 0 .../README.md | 2 - .../examples/IRServer/IRServer.ino | 2 +- .../examples/IRrecvDemo/IRrecvDemo.ino | 0 .../examples/IRrecvDump/IRrecvDump.ino | 0 .../examples/IRrecvDumpV2/IRrecvDumpV2.ino | 5 - .../examples/IRsendDemo/IRsendDemo.ino | 2 +- .../JVCPanasonicSendDemo.ino | 0 .../keywords.txt | 37 +- lib/IRremoteESP8266/library.json | 12 + lib/IRremoteESP8266/library.properties | 9 + 32 files changed, 1437 insertions(+), 3138 deletions(-) delete mode 100644 lib/IRremoteESP8266-1.0.2a/.travis.yml delete mode 100644 lib/IRremoteESP8266-1.0.2a/Contributors.md delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRDaikinESP.cpp delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRDaikinESP.h delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRKelvinator.cpp delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRKelvinator.h delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.cpp delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.h delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.cpp delete mode 100644 lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.h delete mode 100644 lib/IRremoteESP8266-1.0.2a/examples/IRGCSendDemo/IRGCSendDemo.ino delete mode 100644 lib/IRremoteESP8266-1.0.2a/examples/IRGCTCPServer/IRGCTCPServer.ino delete mode 100644 lib/IRremoteESP8266-1.0.2a/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino delete mode 100644 lib/IRremoteESP8266-1.0.2a/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino delete mode 100644 lib/IRremoteESP8266-1.0.2a/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino delete mode 100644 lib/IRremoteESP8266-1.0.2a/library.json delete mode 100644 lib/IRremoteESP8266-1.0.2a/library.properties create mode 100644 lib/IRremoteESP8266/Contributors.md create mode 100644 lib/IRremoteESP8266/IRremoteESP8266.cpp create mode 100644 lib/IRremoteESP8266/IRremoteESP8266.h rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/IRremoteInt.h (65%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/LICENSE.txt (100%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/README.md (90%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/examples/IRServer/IRServer.ino (98%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/examples/IRrecvDemo/IRrecvDemo.ino (100%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/examples/IRrecvDump/IRrecvDump.ino (100%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/examples/IRrecvDumpV2/IRrecvDumpV2.ino (97%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/examples/IRsendDemo/IRsendDemo.ino (93%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino (100%) rename lib/{IRremoteESP8266-1.0.2a => IRremoteESP8266}/keywords.txt (66%) create mode 100644 lib/IRremoteESP8266/library.json create mode 100644 lib/IRremoteESP8266/library.properties diff --git a/lib/IRremoteESP8266-1.0.2a/.travis.yml b/lib/IRremoteESP8266-1.0.2a/.travis.yml deleted file mode 100644 index a4539ffd8..000000000 --- a/lib/IRremoteESP8266-1.0.2a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: c -env: - - BD=esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M -before_install: - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16" - - sleep 3 - - export DISPLAY=:1.0 - - wget http://downloads.arduino.cc/arduino-1.8.1-linux64.tar.xz - - tar xf arduino-1.8.1-linux64.tar.xz - - sudo mv arduino-1.8.1 /usr/local/share/arduino - - sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino -install: - - ln -s $PWD /usr/local/share/arduino/libraries/ - - arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json" --save-prefs - - arduino --install-boards esp8266:esp8266 - - arduino --board $BD --save-prefs - - arduino --pref "compiler.warning_level=all" --save-prefs -script: - - arduino --verify --board $BD $PWD/examples/IRrecvDemo/IRrecvDemo.ino - - arduino --verify --board $BD $PWD/examples/IRGCSendDemo/IRGCSendDemo.ino - - arduino --verify --board $BD $PWD/examples/IRGCTCPServer/IRGCTCPServer.ino - - arduino --verify --board $BD $PWD/examples/IRServer/IRServer.ino - - arduino --verify --board $BD $PWD/examples/IRrecvDumpV2/IRrecvDumpV2.ino - - arduino --verify --board $BD $PWD/examples/IRsendDemo/IRsendDemo.ino - - arduino --verify --board $BD $PWD/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino - - arduino --verify --board $BD $PWD/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino - - arduino --verify --board $BD $PWD/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino - - arduino --verify --board $BD $PWD/examples/TurnOnKelvinatorAC/TurnOnMitsubishiAC.ino - -notifications: - email: - on_success: change - on_failure: change diff --git a/lib/IRremoteESP8266-1.0.2a/Contributors.md b/lib/IRremoteESP8266-1.0.2a/Contributors.md deleted file mode 100644 index 92717ee10..000000000 --- a/lib/IRremoteESP8266-1.0.2a/Contributors.md +++ /dev/null @@ -1,13 +0,0 @@ -## Contributors of this project -### Main contributors & maintainers -- [Mark Szabo](https://github.com/markszabo/) : Initial IR sending on ESP8266 -- [Sébastien Warin](https://github.com/sebastienwarin/) (http://sebastien.warin.fr) : Initial IR receiving on ESP8266 -- [David Conran](https://github.com/crankyoldgit/) -- [Roi Dayan](https://github.com/roidayan/) -- [Marcos de Alcântara Marinho](https://github.com/marcosamarinho/) -- [Massimiliano Pinto](https://github.com/pintomax/) -- [Darsh Patel](https://github.com/darshkpatel/) - -All contributors can be found on the [contributors site](https://github.com/markszabo/IRremoteESP8266/graphs/contributors). - -### Contributors of the [original project](https://github.com/z3t0/Arduino-IRremote) can be found on the [original project's contributors page](https://github.com/z3t0/Arduino-IRremote/blob/master/Contributors.md) diff --git a/lib/IRremoteESP8266-1.0.2a/IRDaikinESP.cpp b/lib/IRremoteESP8266-1.0.2a/IRDaikinESP.cpp deleted file mode 100644 index 02fd25cf3..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRDaikinESP.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -An Arduino sketch to emulate IR Daikin ARC433** remote control unit -Read more on http://harizanov.com/2012/02/control-daikin-air-conditioner-over-the-internet/ -*/ - -#include - -IRDaikinESP::IRDaikinESP(int pin) : _irsend(pin) -{ -} - -void IRDaikinESP::begin() -{ - _irsend.begin(); -} - -void IRDaikinESP::send() -{ - _irsend.sendDaikin(daikin); -} - -void IRDaikinESP::checksum() -{ - uint8_t sum = 0; - uint8_t i; - - for(i = 0; i <= 6; i++){ - sum += daikin[i]; - } - - daikin[7] = sum &0xFF; - sum=0; - for(i = 8; i <= 25; i++){ - sum += daikin[i]; - } - daikin[26] = sum &0xFF; -} - -void IRDaikinESP::on() -{ - //state = ON; - daikin[13] |= 0x01; - checksum(); -} - -void IRDaikinESP::off() -{ - //state = OFF; - daikin[13] &= 0xFE; - checksum(); -} - -uint8_t IRDaikinESP::getPower() -{ - return (daikin[13])&0x01; -} - -// DAIKIN_SILENT or DAIKIN_POWERFUL -void IRDaikinESP::setAux(uint8_t aux) -{ - daikin[21] = aux; - checksum(); -} - -uint8_t IRDaikinESP::getAux(){ - return daikin[21]; -} - - -// Set the temp in deg C -void IRDaikinESP::setTemp(uint8_t temp) -{ - if (temp < 18) - temp = 18; - else if (temp > 32) - temp = 32; - daikin[14] = (temp)*2; - checksum(); -} - -uint8_t IRDaikinESP::getTemp() -{ - return (daikin[14])/2; -} - -// Set the speed of the fan, 0-5, 0 is auto, 1-5 is the speed -void IRDaikinESP::setFan(uint8_t fan) -{ - // Set the fan speed bits, leave low 4 bits alone - uint8_t fanset; - daikin[16] = daikin[16] & 0x0F; - if (fan >= 1 && fan <= 5) - fanset = 0x20 + (0x10 * fan); - else - fanset = 0xA0; - daikin[16] = daikin[16] | fanset; - checksum(); -} - -uint8_t IRDaikinESP::getFan() -{ - uint8_t fan = daikin[16] >> 4; - fan = fan - 2; - if (fan > 5) - fan = 0; - return fan; -} - -uint8_t IRDaikinESP::getMode() -{/* - DAIKIN_COOL - DAIKIN_HEAT - DAIKIN_FAN - DAIKIN_AUTO - DAIKIN_DRY - */ - return (daikin[13])>>4; -} - -void IRDaikinESP::setMode(uint8_t mode) -{ - daikin[13]=mode<<4 | getPower(); - checksum(); -} - -void IRDaikinESP::setSwingVertical(uint8_t swing) -{ - if (swing) - daikin[16] = daikin[16] | 0x0F; - else - daikin[16] = daikin[16] & 0xF0; - checksum(); -} - -uint8_t IRDaikinESP::getSwingVertical() -{ - return (daikin[16])&0x01; -} - -void IRDaikinESP::setSwingHorizontal(uint8_t swing) -{ - if (swing) - daikin[17] = daikin[17] | 0x0F; - else - daikin[17] = daikin[17] & 0xF0; - checksum(); -} - -uint8_t IRDaikinESP::getSwingHorizontal() -{ - return (daikin[17])&0x01; -} diff --git a/lib/IRremoteESP8266-1.0.2a/IRDaikinESP.h b/lib/IRremoteESP8266-1.0.2a/IRDaikinESP.h deleted file mode 100644 index 59327675f..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRDaikinESP.h +++ /dev/null @@ -1,100 +0,0 @@ - -#include -#include - -#define DAIKIN_COOL B011 -#define DAIKIN_HEAT B100 -#define DAIKIN_FAN B110 -#define DAIKIN_AUTO B000 -#define DAIKIN_DRY B010 - -#define DAIKIN_POWERFUL B00000010 -#define DAIKIN_SILENT B00100000 - -/* - Daikin AC map - byte 7= checksum of the first part (and last byte before a 29ms pause) - byte 13=mode - b7 = 0 - b6+b5+b4 = Mode - Modes: b6+b5+b4 - 011 = Cool - 100 = Heat (temp 23) - 110 = FAN (temp not shown, but 25) - 000 = Fully Automatic (temp 25) - 010 = DRY (temp 0xc0 = 96 degrees c) - b3 = 0 - b2 = OFF timer set - b1 = ON timer set - b0 = Air Conditioner ON - byte 14=temp*2 (Temp should be between 18 - 32) - byte 16=Fan - FAN control - b7+b6+b5+b4 = Fan speed - Fan: b7+b6+b5+b4 - 0×30 = 1 bar - 0×40 = 2 bar - 0×50 = 3 bar - 0×60 = 4 bar - 0×70 = 5 bar - 0xa0 = Auto - 0xb0 = Not auto, moon + tree - b3+b2+b1+b0 = Swing control up/down - Swing control up/down: - 0000 = Swing up/down off - 1111 = Swing up/down on - byte 17 - Swing control left/right: - 0000 = Swing left/right off - 1111 = Swing left/right on - byte 21=Aux -> Powerful (bit 1), Silent (bit 5) - byte 24=Aux2 -> Intelligent eye on (bit 7) - byte 26= checksum of the second part -*/ - -#define DAIKIN_COMMAND_LENGTH 27 - -class IRDaikinESP -{ - public: - IRDaikinESP(int pin); - //: IRsend(pin){}; - - void send(); - - void begin(); - void on(); - void off(); - uint8_t getPower(); - - void setAux(uint8_t aux); - uint8_t getAux(); - - void setTemp(uint8_t temp); - uint8_t getTemp(); - - void setFan(uint8_t fan); - uint8_t getFan(); - - uint8_t getMode(); - void setMode(uint8_t mode); - - void setSwingVertical(uint8_t swing); - uint8_t getSwingVertical(); - void setSwingHorizontal(uint8_t swing); - uint8_t getSwingHorizontal(); - - private: - // # of bytes per command - unsigned char daikin[DAIKIN_COMMAND_LENGTH] = { - 0x11,0xDA,0x27,0xF0,0x00,0x00,0x00,0x20, - //0 1 2 3 4 5 6 7 - 0x11,0xDA,0x27,0x00,0x00,0x41,0x1E,0x00, - //8 9 10 11 12 13 14 15 - 0xB0,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0xE3 }; - //16 17 18 19 20 21 22 23 24 25 26 - - void checksum(); - - IRsend _irsend; -}; diff --git a/lib/IRremoteESP8266-1.0.2a/IRKelvinator.cpp b/lib/IRremoteESP8266-1.0.2a/IRKelvinator.cpp deleted file mode 100644 index c4a13199a..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRKelvinator.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* -Code to emulate IR Kelvinator YALIF remote control unit, which should control -at least the following Kelvinator A/C units: - KSV26CRC, KSV26HRC, KSV35CRC, KSV35HRC, KSV53HRC, KSV62HRC, KSV70CRC, - KSV70HRC, KSV80HRC. - -Note: - * Unsupported: - - All Sleep modes. - - All Timer modes. - - "I Feel" button & mode. - - Energy Saving mode. - - Low Heat mode. - - Farenheit. -*/ - -#include - -IRKelvinatorAC::IRKelvinatorAC(int pin) : _irsend(pin) { - stateReset(); -} - -void IRKelvinatorAC::stateReset() { - for (uint8_t i = 0; i < KELVINATOR_STATE_LENGTH; i++) - remote_state[i] = 0x0; - remote_state[3] = 0x50; - remote_state[11] = 0x70; -} - -void IRKelvinatorAC::begin() { - _irsend.begin(); -} - -void IRKelvinatorAC::fixup() { - // X-Fan mode is only valid in COOL or DRY modes. - if (getMode() != KELVINATOR_COOL && getMode() != KELVINATOR_DRY) - setXFan(false); - checksum(); // Calculate the checksums -} - -void IRKelvinatorAC::send() { - fixup(); // Ensure correct settings before sending. - _irsend.sendKelvinator(remote_state); -} - -uint8_t* IRKelvinatorAC::getRaw() { - fixup(); // Ensure correct settings before sending. - return remote_state; -} - -// Many Bothans died to bring us this information. -void IRKelvinatorAC::checksum() { - // For each command + options block. - for (uint8_t offset = 0; offset < KELVINATOR_STATE_LENGTH; offset += 8) { - uint8_t sum = KELVINATOR_CHECKSUM_START; - // Sum the lower half of the first 4 bytes of this block. - for(uint8_t i = 0; i < 4; i++) { - sum += (remote_state[i + offset] & 0xFU); - } - // then sum the upper half of the next 3 bytes. - for(uint8_t i = 4; i < 7; i++) { - sum += (remote_state[i + offset] >> 4); - } - // Trim it down to fit into the 4 bits allowed. i.e. Mod 16. - sum &= 0xFU; - // Place it into the IR code in the top half of the 8th & 16th byte. - remote_state[7 + offset] = (sum << 4) | (remote_state[7 + offset] & 0xFU); - } -} - -void IRKelvinatorAC::on() { - //state = ON; - remote_state[0] |= KELVINATOR_POWER; - remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk. -} - -void IRKelvinatorAC::off() { - //state = OFF; - remote_state[0] &= ~KELVINATOR_POWER; - remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk. -} - -void IRKelvinatorAC::setPower(bool state) { - if (state) - on(); - else - off(); -} - -bool IRKelvinatorAC::getPower() { - return ((remote_state[0] & KELVINATOR_POWER) != 0); -} - -// Set the temp. in deg C -void IRKelvinatorAC::setTemp(uint8_t temp) { - temp = max(KELVINATOR_MIN_TEMP, temp); - temp = min(KELVINATOR_MAX_TEMP, temp); - remote_state[1] = (remote_state[1] & 0xF0U) | (temp - KELVINATOR_MIN_TEMP); - remote_state[9] = remote_state[1]; // Duplicate to the 2nd command chunk. -} - -// Return the set temp. in deg C -uint8_t IRKelvinatorAC::getTemp() { - return ((remote_state[1] & 0xFU) + KELVINATOR_MIN_TEMP); -} - -// Set the speed of the fan, 0-5, 0 is auto, 1-5 is the speed -void IRKelvinatorAC::setFan(uint8_t fan) { - fan = min(KELVINATOR_FAN_MAX, fan); // Bounds check - - // Only change things if we need to. - if (fan != getFan()) { - // Set the basic fan values. - uint8_t fan_basic = min(KELVINATOR_BASIC_FAN_MAX, fan); - remote_state[0] = (remote_state[0] & KELVINATOR_BASIC_FAN_MASK) | - (fan_basic << KELVINATOR_FAN_OFFSET); - remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk. - // Set the advanced(?) fan value. - remote_state[14] = (remote_state[14] & KELVINATOR_FAN_MASK) | - (fan << KELVINATOR_FAN_OFFSET); - setTurbo(false); // Turbo mode is turned off if we change the fan settings. - } -} - -uint8_t IRKelvinatorAC::getFan() { - return ((remote_state[14] & ~KELVINATOR_FAN_MASK) >> KELVINATOR_FAN_OFFSET); -} - -uint8_t IRKelvinatorAC::getMode() { - /* - KELVINATOR_AUTO - KELVINATOR_COOL - KELVINATOR_DRY - KELVINATOR_FAN - KELVINATOR_HEAT - */ - return (remote_state[0] & ~KELVINATOR_MODE_MASK); -} - -void IRKelvinatorAC::setMode(uint8_t mode) { - // If we get an unexpected mode, default to AUTO. - if (mode > KELVINATOR_HEAT) mode = KELVINATOR_AUTO; - remote_state[0] = (remote_state[0] & KELVINATOR_MODE_MASK) | mode; - remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk. - if (mode == KELVINATOR_AUTO) - // When the remote is set to Auto, it defaults to 25C and doesn't show it. - setTemp(KELVINATOR_AUTO_TEMP); -} - -void IRKelvinatorAC::setSwingVertical(bool state) { - if (state) { - remote_state[0] |= KELVINATOR_VENT_SWING; - remote_state[4] |= KELVINATOR_VENT_SWING_V; - } - else { - remote_state[4] &= ~KELVINATOR_VENT_SWING_V; - if (! getSwingHorizontal()) - remote_state[0] &= ~KELVINATOR_VENT_SWING; - } - remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk. -} - -bool IRKelvinatorAC::getSwingVertical() { - return ((remote_state[4] & KELVINATOR_VENT_SWING_V) != 0); -} - -void IRKelvinatorAC::setSwingHorizontal(bool state) { - if (state) { - remote_state[0] |= KELVINATOR_VENT_SWING; - remote_state[4] |= KELVINATOR_VENT_SWING_H; - } - else { - remote_state[4] &= ~KELVINATOR_VENT_SWING_H; - if (! getSwingVertical()) - remote_state[0] &= ~KELVINATOR_VENT_SWING; - } - remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk. -} - -bool IRKelvinatorAC::getSwingHorizontal() { - return ((remote_state[4] & KELVINATOR_VENT_SWING_H) != 0); -} - -void IRKelvinatorAC::setQuiet(bool state) { - remote_state[12] &= ~KELVINATOR_QUIET; - remote_state[12] |= (state << KELVINATOR_QUIET_OFFSET); -} - -bool IRKelvinatorAC::getQuiet() { - return ((remote_state[12] & KELVINATOR_QUIET) != 0); -} - -void IRKelvinatorAC::setIonFilter(bool state) { - remote_state[2] &= ~KELVINATOR_ION_FILTER; - remote_state[2] |= (state << KELVINATOR_ION_FILTER_OFFSET); - remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk. -} - -bool IRKelvinatorAC::getIonFilter() { - return ((remote_state[2] & KELVINATOR_ION_FILTER) != 0); -} - -void IRKelvinatorAC::setLight(bool state) { - remote_state[2] &= ~KELVINATOR_LIGHT; - remote_state[2] |= (state << KELVINATOR_LIGHT_OFFSET); - remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk. -} - -bool IRKelvinatorAC::getLight() { - return ((remote_state[2] & KELVINATOR_LIGHT) != 0); -} - -// Note: XFan mode is only valid in Cool or Dry mode. -void IRKelvinatorAC::setXFan(bool state) { - remote_state[2] &= ~KELVINATOR_XFAN; - remote_state[2] |= (state << KELVINATOR_XFAN_OFFSET); - remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk. -} - -bool IRKelvinatorAC::getXFan() { - return ((remote_state[2] & KELVINATOR_XFAN) != 0); -} - -// Note: Turbo mode is turned off if the fan speed is changed. -void IRKelvinatorAC::setTurbo(bool state) { - remote_state[2] &= ~KELVINATOR_TURBO; - remote_state[2] |= (state << KELVINATOR_TURBO_OFFSET); - remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk. -} - -bool IRKelvinatorAC::getTurbo() { - return ((remote_state[2] & KELVINATOR_TURBO) != 0); -} diff --git a/lib/IRremoteESP8266-1.0.2a/IRKelvinator.h b/lib/IRremoteESP8266-1.0.2a/IRKelvinator.h deleted file mode 100644 index d9345a6c2..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRKelvinator.h +++ /dev/null @@ -1,160 +0,0 @@ - -#include -#include - -#define KELVINATOR_AUTO 0U -#define KELVINATOR_COOL 1U -#define KELVINATOR_DRY 2U -#define KELVINATOR_FAN 3U -#define KELVINATOR_HEAT 4U -#define KELVINATOR_MODE_MASK 0xF8U -#define KELVINATOR_POWER 8U -#define KELVINATOR_FAN_OFFSET 4U -#define KELVINATOR_BASIC_FAN_MAX 3U -#define KELVINATOR_BASIC_FAN_MASK uint8_t(0xFFU ^ (3U << KELVINATOR_FAN_OFFSET)) -#define KELVINATOR_FAN_MASK uint8_t(0xFFU ^ (7U << KELVINATOR_FAN_OFFSET)) -#define KELVINATOR_FAN_MAX 5U -#define KELVINATOR_VENT_SWING_OFFSET 6U -#define KELVINATOR_VENT_SWING uint8_t(1U << KELVINATOR_VENT_SWING_OFFSET) -#define KELVINATOR_VENT_SWING_V uint8_t(1U) -#define KELVINATOR_VENT_SWING_H uint8_t(1U << 4) -#define KELVINATOR_SLEEP_1_AND_3 uint8_t(1U << 7) -#define KELVINATOR_MIN_TEMP 16U // 16C -#define KELVINATOR_MAX_TEMP 30U // 30C -#define KELVINATOR_AUTO_TEMP 25U // 25C -#define KELVINATOR_CHECKSUM_START 10U -#define KELVINATOR_QUIET_OFFSET 7U -#define KELVINATOR_QUIET uint8_t(1U << KELVINATOR_QUIET_OFFSET) -#define KELVINATOR_ION_FILTER_OFFSET 6U -#define KELVINATOR_ION_FILTER uint8_t(1U << KELVINATOR_ION_FILTER_OFFSET) -#define KELVINATOR_LIGHT_OFFSET 5U -#define KELVINATOR_LIGHT uint8_t(1U << KELVINATOR_LIGHT_OFFSET) -#define KELVINATOR_XFAN_OFFSET 7U -#define KELVINATOR_XFAN uint8_t(1U << KELVINATOR_XFAN_OFFSET) -#define KELVINATOR_TURBO_OFFSET 4U -#define KELVINATOR_TURBO uint8_t(1U << KELVINATOR_TURBO_OFFSET) - - -/* - Kelvinator AC map - - (header mark and space) - byte 0 = Basic Modes - b2-0 = Modes - Modes: - 000 = Auto (temp = 25C) - 001 = Cool - 010 = Dry (temp = 25C, but not shown) - 011 = Fan - 100 = Heat - b3 = Power Status (1 = On, 0 = Off) - b5-4 = Fan (Basic modes) - Fan: - 00 = Auto - 01 = Fan 1 - 10 = Fan 2 - 11 = Fan 3 or higher (See byte 14) - b6 = Vent swing (1 = On, 0 = Off) (See byte 4) - b7 = Sleep Modes 1 & 3 (1 = On, 0 = Off) - byte 1 = Temperature - b3-0: Degrees C. - 0000 (0) = 16C - 0001 (1) = 17C - 0010 (2) = 18C - ... - 1101 (13) = 29C - 1110 (14) = 30C - byte 2 = Extras - b3-0 = UNKNOWN, typically 0. - b4 = Turbo Fan (1 = On, 0 = Off) - b5 = Light (Display) (1 = On, 0 = Off) - b6 = Ion Filter (1 = On, 0 = Off) - b7 = X-Fan (Fan runs for a while after power off) (1 = On, 0 = Off) - byte 3 = Section Indicator - b3-0 = Unused (Typically 0) - b5-4 = Unknown (possibly timer related) (Typically B01) - b7-6 = End of command block (B01) - (B010 marker and a gap of 20ms) - byte 4 = Extended options - b0 = Swing Vent Vertical (1 = On, 0 = Off) - b4 = Swing Vent Horizontal (1 = On, 0 = Off) - byte 5-6 = Timer related. Typically 0 except when timer in use. - byte 7 = checksum - b3-0 = Unknown (Used in Timer mode) - b7-4 = checksum of the previous bytes (0-6) - (gap of 40ms) - (header mark and space) - byte 8 = Repeat of byte 0 - byte 9 = Repeat of byte 1 - byte 10 = Repeat of byte 2 - byte 11 = Section Indicator - b3-0 = Unused (Typically 0) - b5-4 = Unknown (possibly timer related) (Typically B11) - b7-6 = End of command block (B01) - (B010 marker and a gap of 20ms) - byte 12 = Extended options - b0 = Sleep mode 2 (1 = On, 0=Off) - b6-1 = Unknown (Used in Sleep Mode 3, Typically B000000) - b7 = Quiet Mode (1 = On, 0=Off) - byte 13 = Unknown (Sleep Mode 3 related, Typically 0x00) - byte 14 = Fan control - b3-0 = Unknown (Sleep Mode 3 related, Typically B0000) - b6-4 = Fan speed - B000 (0) = Automatic - B001 (1) = Fan 1 - B010 (2) = Fan 2 - B011 (3) = Fan 3 - B100 (4) = Fan 4 - B101 (5) = Fan 5 - byte 15 = checksum - b3-0 = Unknown (Typically B0000) - b7-4 = checksum of the previous bytes (8-14) -*/ - -#define KELVINATOR_STATE_LENGTH 16 - -class IRKelvinatorAC -{ - public: - IRKelvinatorAC(int pin); - //: IRsend(pin){}; - - void stateReset(); - void send(); - - void begin(); - void on(); - void off(); - void setPower(bool state); - bool getPower(); - void setTemp(uint8_t temp); - uint8_t getTemp(); - void setFan(uint8_t fan); - uint8_t getFan(); - void setMode(uint8_t mode); - uint8_t getMode(); - void setSwingVertical(bool state); - bool getSwingVertical(); - void setSwingHorizontal(bool state); - bool getSwingHorizontal(); - void setQuiet(bool state); - bool getQuiet(); - void setIonFilter(bool state); - bool getIonFilter(); - void setLight(bool state); - bool getLight(); - void setXFan(bool state); - bool getXFan(); - void setTurbo(bool state); - bool getTurbo(); - uint8_t* getRaw(); - - - private: - // The state of the IR remote in IR code form. - uint8_t remote_state[KELVINATOR_STATE_LENGTH]; - - void checksum(); - void fixup(); - IRsend _irsend; -}; diff --git a/lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.cpp b/lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.cpp deleted file mode 100644 index b3ebaae0c..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* -Code to emulate Mitsubishi A/C IR remote control unit. -Inspired and derived from the work done at: - https://github.com/r45635/HVAC-IR-Control - -Warning: Consider this very alpha code. Seems to work, but not validated. - -Equipment it seems compatible with: - * -*/ - -#include - -// Initialise the object. -IRMitsubishiAC::IRMitsubishiAC(int pin) : _irsend(pin) { - stateReset(); -} - -// Reset the state of the remote to a known good state/sequence. -void IRMitsubishiAC::stateReset() { - for (uint8_t i = 0; i < MITSUBISHI_AC_STATE_LENGTH; i++) - remote_state[i] = known_good_state[i]; - checksum(); // Calculate the checksum -} - -// Configure the pin for output. -void IRMitsubishiAC::begin() { - _irsend.begin(); -} - -// Send the current desired state to the IR LED. -void IRMitsubishiAC::send() { - checksum(); // Ensure correct checksum before sending. - _irsend.sendMitsubishiAC(remote_state); -} - -// Return a pointer to the internal state date of the remote. -uint8_t* IRMitsubishiAC::getRaw() { - checksum(); - return remote_state; -} - -// Calculate the checksum for the current internal state of the remote. -void IRMitsubishiAC::checksum() { - uint8_t sum = 0; - // Checksum is simple addition of all previous bytes stored - // as a 8 bit value. - for (uint8_t i = 0; i < 17; i++) - sum += remote_state[i]; - remote_state[17] = sum & 0xFFU; -} - -// Set the requested power state of the A/C to off. -void IRMitsubishiAC::on() { - //state = ON; - remote_state[5] |= MITSUBISHI_AC_POWER; -} - -// Set the requested power state of the A/C to off. -void IRMitsubishiAC::off() { - //state = OFF; - remote_state[5] &= ~MITSUBISHI_AC_POWER; -} - -// Set the requested power state of the A/C. -void IRMitsubishiAC::setPower(bool state) { - if (state) - on(); - else - off(); -} - -// Return the requested power state of the A/C. -bool IRMitsubishiAC::getPower() { - return((remote_state[5] & MITSUBISHI_AC_POWER) != 0); -} - -// Set the temp. in deg C -void IRMitsubishiAC::setTemp(uint8_t temp) { - temp = max(MITSUBISHI_AC_MIN_TEMP, temp); - temp = min(MITSUBISHI_AC_MAX_TEMP, temp); - remote_state[7] = temp - MITSUBISHI_AC_MIN_TEMP; -} - -// Return the set temp. in deg C -uint8_t IRMitsubishiAC::getTemp() { - return(remote_state[7] + MITSUBISHI_AC_MIN_TEMP); -} - -// Set the speed of the fan, 0-6. -// 0 is auto, 1-5 is the speed, 6 is silent. -void IRMitsubishiAC::setFan(uint8_t fan) { - // Bounds check - if (fan > MITSUBISHI_AC_FAN_SILENT) - fan = MITSUBISHI_AC_FAN_MAX; // Set the fan to maximum if out of range. - if (fan == MITSUBISHI_AC_FAN_AUTO) { // Automatic is a special case. - remote_state[9] = B10000000 | (remote_state[9] & B01111000); - return; - } else if (fan >= MITSUBISHI_AC_FAN_MAX) { - fan--; // There is no spoon^H^H^Heed 5 (max), pretend it doesn't exist. - } -// remote_state[9] |= fan; - remote_state[9] = (remote_state[9] & B11111000) | fan; -} - -// Return the requested state of the unit's fan. -uint8_t IRMitsubishiAC::getFan() { - uint8_t fan = remote_state[9] & B111; - if (fan == MITSUBISHI_AC_FAN_MAX) - return MITSUBISHI_AC_FAN_SILENT; - return fan; -} - -// Return the requested climate operation mode of the a/c unit. -uint8_t IRMitsubishiAC::getMode() { - /* - MITSUBISHI_AC_AUTO - MITSUBISHI_AC_COOL - MITSUBISHI_AC_DRY - MITSUBISHI_AC_HEAT - */ - return(remote_state[6]); -} - -// Set the requested climate operation mode of the a/c unit. -void IRMitsubishiAC::setMode(uint8_t mode) { - // If we get an unexpected mode, default to AUTO. - switch (mode) { - case MITSUBISHI_AC_AUTO: break; - case MITSUBISHI_AC_COOL: break; - case MITSUBISHI_AC_DRY: break; - case MITSUBISHI_AC_HEAT: break; - default: mode = MITSUBISHI_AC_AUTO; - } - remote_state[6] = mode; -} - -// Set the requested vane operation mode of the a/c unit. -void IRMitsubishiAC::setVane(uint8_t mode) { - mode = max(mode, B111); // bounds check - mode |= B1000; - mode <<= 3; - remote_state[9] |= mode; -} - -// Return the requested vane operation mode of the a/c unit. -uint8_t IRMitsubishiAC::getVane() { - return ((remote_state[9] & B00111000) >> 3); -} diff --git a/lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.h b/lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.h deleted file mode 100644 index 339d79955..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRMitsubishiAC.h +++ /dev/null @@ -1,52 +0,0 @@ - -#include -#include - -#define MITSUBISHI_AC_AUTO 0x20U -#define MITSUBISHI_AC_COOL 0x18U -#define MITSUBISHI_AC_DRY 0x10U -#define MITSUBISHI_AC_HEAT 0x08U -#define MITSUBISHI_AC_POWER 0x20U -#define MITSUBISHI_AC_FAN_AUTO 0U -#define MITSUBISHI_AC_FAN_MAX 5U -#define MITSUBISHI_AC_FAN_SILENT 6U -#define MITSUBISHI_AC_MIN_TEMP 16U // 16C -#define MITSUBISHI_AC_MAX_TEMP 31U // 31C -#define MITSUBISHI_AC_VANE_AUTO 0U -#define MITSUBISHI_AC_VANE_AUTO_MOVE 7U -#define MITSUBISHI_AC_STATE_LENGTH 18 - -class IRMitsubishiAC -{ - public: - IRMitsubishiAC(int pin); - - void stateReset(); - void send(); - - void begin(); - void on(); - void off(); - void setPower(bool state); - bool getPower(); - void setTemp(uint8_t temp); - uint8_t getTemp(); - void setFan(uint8_t fan); - uint8_t getFan(); - void setMode(uint8_t mode); - uint8_t getMode(); - void setVane(uint8_t mode); - uint8_t getVane(); - uint8_t* getRaw(); - - - private: - // The state of the IR remote in IR code form. - // Known good state obtained from: - // https://github.com/r45635/HVAC-IR-Control/blob/master/HVAC_ESP8266/HVAC_ESP8266.ino#L108 - uint8_t known_good_state[MITSUBISHI_AC_STATE_LENGTH] = { 0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x08, 0x06, 0x30, 0x45, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F }; - uint8_t remote_state[MITSUBISHI_AC_STATE_LENGTH]; - - void checksum(); - IRsend _irsend; -}; diff --git a/lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.cpp b/lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.cpp deleted file mode 100644 index 493e8d49e..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.cpp +++ /dev/null @@ -1,1647 +0,0 @@ - /*************************************************** - * IRremote for ESP8266 - * - * Based on the IRremote library for Arduino by Ken Shirriff - * Version 0.11 August, 2009 - * Copyright 2009 Ken Shirriff - * For details, see - * http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html - * - * Modified by Paul Stoffregen to support other boards and - * timers - * Modified by Mitra Ardron - * Added Sanyo and Mitsubishi controllers - * Modified Sony to spot the repeat codes that some Sony's send - * - * Interrupt code based on NECIRrcv by Joe Knapp - * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 - * Also influenced by - * http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ - * - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and - * other people at the original blog post) - * LG added by Darryl Smith (based on the JVC protocol) - * Whynter A/C ARC-110WD added by Francesco Meschia - * Global Cache IR format sender added by Hisham Khalifa - * (http://www.hishamkhalifa.com) - * Coolix A/C / heatpump added by bakrus - * Denon: sendDenon, decodeDenon added by Massimiliano Pinto - * (from https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Denon.cpp) - * Kelvinator A/C and Sherwood added by crankyoldgit - * Mitsubishi A/C added by crankyoldgit - * (derived from https://github.com/r45635/HVAC-IR-Control) - * - * Updated by markszabo (https://github.com/markszabo/IRremoteESP8266) for - * sending IR code on ESP8266 - * Updated by Sebastien Warin (http://sebastien.warin.fr) for receiving IR code - * on ESP8266 - * - * GPL license, all text above must be included in any redistribution - ****************************************************/ - -#include "IRremoteESP8266.h" -#include "IRremoteInt.h" -#include "IRKelvinator.h" -#include "IRMitsubishiAC.h" - -// These versions of MATCH, MATCH_MARK, and MATCH_SPACE are only for debugging. -// To use them, set DEBUG in IRremoteInt.h -// Normally macros are used for efficiency -#ifdef DEBUG -int MATCH(int measured, int desired) { - Serial.print("Testing: "); - Serial.print(TICKS_LOW(desired), DEC); - Serial.print(" <= "); - Serial.print(measured, DEC); - Serial.print(" <= "); - Serial.println(TICKS_HIGH(desired), DEC); - return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired); -} - -int MATCH_MARK(int measured_ticks, int desired_us) { - Serial.print("Testing mark "); - Serial.print(measured_ticks * USECPERTICK, DEC); - Serial.print(" vs "); - Serial.print(desired_us, DEC); - Serial.print(": "); - Serial.print(TICKS_LOW(desired_us + MARK_EXCESS), DEC); - Serial.print(" <= "); - Serial.print(measured_ticks, DEC); - Serial.print(" <= "); - Serial.println(TICKS_HIGH(desired_us + MARK_EXCESS), DEC); - return measured_ticks >= TICKS_LOW(desired_us + MARK_EXCESS) && - measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS); -} - -int MATCH_SPACE(int measured_ticks, int desired_us) { - Serial.print("Testing space "); - Serial.print(measured_ticks * USECPERTICK, DEC); - Serial.print(" vs "); - Serial.print(desired_us, DEC); - Serial.print(": "); - Serial.print(TICKS_LOW(desired_us - MARK_EXCESS), DEC); - Serial.print(" <= "); - Serial.print(measured_ticks, DEC); - Serial.print(" <= "); - Serial.println(TICKS_HIGH(desired_us - MARK_EXCESS), DEC); - return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && - measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS); -} -#else -int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && - measured <= TICKS_HIGH(desired);} -int MATCH_MARK(int measured_ticks, int desired_us) - {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));} -int MATCH_SPACE(int measured_ticks, int desired_us) - {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));} -// Debugging versions are in IRremote.cpp -#endif - -// IRtimer --------------------------------------------------------------------- -// This class performs a simple time in useconds since instantiated. -// Handles when the system timer wraps around (once). - -IRtimer::IRtimer() { - reset(); -} - -void IRtimer::reset() { - start = micros(); -} - -uint32_t IRtimer::elapsed() { - uint32_t now = micros(); - if (start <= now) // Check if the system timer has wrapped. - return (now - start); // No wrap. - else - return (0xFFFFFFFF - start + now); // Has wrapped. -} - -// IRsend ---------------------------------------------------------------------- - -IRsend::IRsend(int IRsendPin) { - IRpin = IRsendPin; -} - -void IRsend::begin() { - pinMode(IRpin, OUTPUT); -} -// Generic method for sending data that is common to most protocols. -// Default to transmitting the Most Significant Bit (MSB) first. -void IRsend::sendData(uint16_t onemark, uint32_t onespace, - uint16_t zeromark, uint32_t zerospace, - uint32_t data, uint8_t nbits, bool MSBfirst) { - if (MSBfirst) // Send the MSB first. - for (uint32_t mask = 1UL << (nbits - 1); mask; mask >>= 1) - if (data & mask) { // 1 - mark(onemark); - space(onespace); - } else { // 0 - mark(zeromark); - space(zerospace); - } - else { // Send the Least Significant Bit (LSB) first / MSB last. - for (uint8_t bit = 0; bit < nbits; bit++, data >>= 1) - if (data & 1) { // 1 - mark(onemark); - space(onespace); - } else { // 0 - mark(zeromark); - space(zerospace); - } - } -} - -void IRsend::sendCOOLIX(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(38); - // Header - mark(COOLIX_HDR_MARK); - space(COOLIX_HDR_SPACE); - // Data - // Sending 3 bytes of data. Each byte first being sent straight, then followed - // by an inverted version. - unsigned long COOLIXmask; - bool invert = 0; // Initializing - for (int j = 0; j < COOLIX_NBYTES * 2; j++) { - for (int i = nbits; i > nbits-8; i--) { - // Type cast necessary to perform correct for the one byte above 16bit - COOLIXmask = (unsigned long) 1 << (i-1); - if (data & COOLIXmask) { // 1 - mark(COOLIX_BIT_MARK); - space(COOLIX_ONE_SPACE); - } else { // 0 - mark(COOLIX_BIT_MARK); - space(COOLIX_ZERO_SPACE); - } - } - // Inverts all of the data each time we need to send an inverted byte - data ^= 0xFFFFFFFF; - invert = !invert; - // Subtract 8 from nbits each time we switch to a new byte. - nbits -= invert ? 0 : 8; - } - // Footer - mark(COOLIX_BIT_MARK); - space(COOLIX_ZERO_SPACE); // Stop bit (0) - space(COOLIX_HDR_SPACE); // Pause before repeating -} - -void IRsend::sendNEC (unsigned long data, int nbits, unsigned int repeat) { - // Details about timings can be found at: - // http://www.sbprojects.com/knowledge/ir/nec.php - - // Set IR carrier frequency - enableIROut(38); - IRtimer usecs = IRtimer(); - // Header - mark(NEC_HDR_MARK); - space(NEC_HDR_SPACE); - // Data - sendData(NEC_BIT_MARK, NEC_ONE_SPACE, NEC_BIT_MARK, NEC_ZERO_SPACE, - data, nbits, true); - // Footer - mark(NEC_BIT_MARK); - // Gap to next command. - space(NEC_MIN_COMMAND_LENGTH - usecs.elapsed()); - - // Optional command repeat sequence. - for (unsigned int i = 0; i < repeat; i++) { - usecs.reset(); - mark(NEC_HDR_MARK); - space(NEC_RPT_SPACE); - mark(NEC_BIT_MARK); - // Gap till next command. - space(NEC_MIN_COMMAND_LENGTH - usecs.elapsed()); - } -} - -void IRsend::sendLG (unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(38); - // Header - mark(LG_HDR_MARK); - space(LG_HDR_SPACE); - mark(LG_BIT_MARK); - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - space(LG_ONE_SPACE); - mark(LG_BIT_MARK); - } else { // 0 - space(LG_ZERO_SPACE); - mark(LG_BIT_MARK); - } - } - // Footer - ledOff(); -} - -void IRsend::sendWhynter(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(38); - // Header - mark(WHYNTER_ZERO_MARK); - space(WHYNTER_ZERO_SPACE); - mark(WHYNTER_HDR_MARK); - space(WHYNTER_HDR_SPACE); - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - mark(WHYNTER_ONE_MARK); - space(WHYNTER_ONE_SPACE); - } else { // 0 - mark(WHYNTER_ZERO_MARK); - space(WHYNTER_ZERO_SPACE); - } - } - // Footer - mark(WHYNTER_ZERO_MARK); - space(WHYNTER_ZERO_SPACE); -} - -void IRsend::sendSony(unsigned long data, int nbits, unsigned int repeat) { - // Send an IR command to a compatible Sony device. - // - // Args: - // data: IR command to be sent. - // nbits: Nr. of bits of the IR command to be sent. - // repeat: Nr. of additional times the IR command is to be sent. - // - // sendSony() should typically be called with repeat=2 as Sony devices - // expect the code to be sent at least 3 times. - // - // Timings and details are taken from: - // http://www.sbprojects.com/knowledge/ir/sirc.php - - enableIROut(40); // Sony devices use a 40kHz IR carrier frequency. - IRtimer usecs = IRtimer(); - - for (uint16_t i = 0; i <= repeat; i++) { // Typically loop 3 or more times. - usecs.reset(); - // Header - mark(SONY_HDR_MARK); - space(SONY_HDR_SPACE); - // Data - sendData(SONY_ONE_MARK, SONY_HDR_SPACE, SONY_ZERO_MARK, SONY_HDR_SPACE, - data, nbits, true); - // Footer - // The Sony protocol requires us to wait 45ms from start of a code to the - // start of the next one. A 10ms minimum gap is also required. - space(max(10000, 45000 - usecs.elapsed())); - } - // A space() is always performed last, so no need to turn off the LED. -} - -void IRsend::sendRaw(unsigned int buf[], int len, int hz) { - // Set IR carrier frequency - enableIROut(hz); - for (int i = 0; i < len; i++) { - if (i & 1) { // Odd bit. - space(buf[i]); - } else { // Even bit. - mark(buf[i]); - } - } - ledOff(); -} - -// Global Cache format w/o emitter ID or request ID. Starts from hertz, -// followed by number of times to emit (count), -// followed by offset for repeats, followed by code as units of periodic time. -void IRsend::sendGC(unsigned int buf[], int len) { - int khz = buf[0]/1000; // GC data starts with frequency in Hz. - enableIROut(khz); - int periodic_time = 1000/khz; - int count = buf[1]; // Max 50 as per GC. - // Data - for (int i = 0; i < count; i++) { - // Account for offset if we're repeating, otherwise start at index 3. - int j = i > 0 ? buf[2] + 2 : 3; - for (; j < len; j++) { - // Convert periodic units to microseconds. Minimum is 80 for actual GC - // units. - int microseconds = buf[j] * periodic_time; - if (j & 1) { // Odd bit. - // Our codes start at an odd index (not even as with sendRaw). - mark(microseconds); - } else { // Even bit. - space(microseconds); - } - } - } - // Footer - ledOff(); -} - -// Note: first bit must be a one (start bit) -void IRsend::sendRC5(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(36); - // Header - mark(RC5_T1); // First start bit - space(RC5_T1); // Second start bit - mark(RC5_T1); // Second start bit - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - space(RC5_T1); // 1 is space, then mark - mark(RC5_T1); - } else { // 0 - mark(RC5_T1); - space(RC5_T1); - } - } - // Footer - ledOff(); -} - -// Caller needs to take care of flipping the toggle bit -void IRsend::sendRC6(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(36); - // Header - mark(RC6_HDR_MARK); - space(RC6_HDR_SPACE); - mark(RC6_T1); // Start bit - space(RC6_T1); - int t; - // Data - for (unsigned long i = 0, mask = 1UL << (nbits - 1); mask; i++, mask >>= 1) { - // The fourth bit we send is a "double width trailer bit". - if (i == 3) { - // double-wide trailer bit - t = 2 * RC6_T1; - } else { - t = RC6_T1; - } - if (data & mask) { // 1 - mark(t); - space(t); - } else { // 0 - space(t); - mark(t); - } - } - // Footer - ledOff(); -} - -void IRsend::sendPanasonic(unsigned int address, unsigned long data) { - // Set IR carrier frequency - enableIROut(35); - // Header - mark(PANASONIC_HDR_MARK); - space(PANASONIC_HDR_SPACE); - // Address (16 bits) - sendData(PANASONIC_BIT_MARK, PANASONIC_ONE_SPACE, - PANASONIC_BIT_MARK, PANASONIC_ZERO_SPACE, - address, 16, true); - // Data (32 bits) - sendData(PANASONIC_BIT_MARK, PANASONIC_ONE_SPACE, - PANASONIC_BIT_MARK, PANASONIC_ZERO_SPACE, - data, 32, true); - // Footer - mark(PANASONIC_BIT_MARK); - ledOff(); -} - -void IRsend::sendJVC(unsigned long data, int nbits, int repeat) { - // Set IR carrier frequency - enableIROut(38); - // Header - if (!repeat) { - mark(JVC_HDR_MARK); - space(JVC_HDR_SPACE); - } - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - mark(JVC_BIT_MARK); - space(JVC_ONE_SPACE); - } else { // 0 - mark(JVC_BIT_MARK); - space(JVC_ZERO_SPACE); - } - } - // Footer - mark(JVC_BIT_MARK); - ledOff(); -} - -void IRsend::sendSAMSUNG(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(38); - // Header - mark(SAMSUNG_HDR_MARK); - space(SAMSUNG_HDR_SPACE); - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - mark(SAMSUNG_BIT_MARK); - space(SAMSUNG_ONE_SPACE); - } else { // 0 - mark(SAMSUNG_BIT_MARK); - space(SAMSUNG_ZERO_SPACE); - } - } - // Footer - mark(SAMSUNG_BIT_MARK); - ledOff(); -} - -// Denon, from https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Denon.cpp -void IRsend::sendDenon (unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(38); - // Header - mark(DENON_HDR_MARK); - space(DENON_HDR_SPACE); - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - mark (DENON_BIT_MARK); - space(DENON_ONE_SPACE); - } else { // 0 - mark (DENON_BIT_MARK); - space(DENON_ZERO_SPACE); - } - } - // Footer - mark(DENON_BIT_MARK); - ledOff(); -} - -void IRsend::mark(unsigned int usec) { - // Sends an IR mark for the specified number of microseconds. - // The mark output is modulated at the PWM frequency. - IRtimer usecTimer = IRtimer(); - while (usecTimer.elapsed() < usec) { - digitalWrite(IRpin, HIGH); - delayMicroseconds(halfPeriodicTime); - digitalWrite(IRpin, LOW); - // e.g. 38 kHz -> T = 26.31 microsec (periodic time), half of it is 13 - delayMicroseconds(halfPeriodicTime); - } -} - -void IRsend::ledOff() { - digitalWrite(IRpin, LOW); -} - -/* Leave pin off for time (given in microseconds) */ -void IRsend::space(unsigned long time) { - // Sends an IR space for the specified number of microseconds. - // A space is no output, so the PWM output is disabled. - ledOff(); - if (time == 0) return; - if (time <= 16383) // delayMicroseconds is only accurate to 16383us. - delayMicroseconds(time); - else { - // Invoke a delay(), where possible, to avoid triggering the WDT. - delay(time / 1000UL); // Delay for as many whole ms as we can. - delayMicroseconds((int) time % 1000UL); // Delay the remaining sub-msecond. - } -} - -void IRsend::enableIROut(int khz) { - // Enables IR output. - // The khz value controls the modulation frequency in kilohertz. - - // T = 1/f but we need T/2 in microsecond and f is in kHz - halfPeriodicTime = 500/khz; -} - - -/* Sharp and DISH support by Todd Treece -( http://unionbridge.org/design/ircommand ) - -The Dish send function needs to be repeated 4 times, and the Sharp function -has the necessary repeat built in because of the need to invert the signal. - -Sharp protocol documentation: -http://www.sbprojects.com/knowledge/ir/sharp.htm - -Here are the LIRC files that I found that seem to match the remote codes -from the oscilloscope: - -Sharp LCD TV: -http://lirc.sourceforge.net/remotes/sharp/GA538WJSA - -DISH NETWORK (echostar 301): -http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx - -For the DISH codes, only send the last for characters of the hex. -i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the -linked LIRC file. -*/ - -void IRsend::sendSharpRaw(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(38); - // Sending codes in bursts of 3 (normal, inverted, normal) makes transmission - // much more reliable. That's the exact behaviour of CD-S6470 remote control. - for (int n = 0; n < 3; n++) { - // Data - for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { - if (data & mask) { // 1 - mark(SHARP_BIT_MARK); - space(SHARP_ONE_SPACE); - } else { // 0 - mark(SHARP_BIT_MARK); - space(SHARP_ZERO_SPACE); - } - } - // Footer - mark(SHARP_BIT_MARK); - space(SHARP_ZERO_SPACE); - delay(40); - - data = data ^ SHARP_TOGGLE_MASK; - } -} - -// Sharp send compatible with data obtained through decodeSharp -void IRsend::sendSharp(unsigned int address, unsigned int command) { - sendSharpRaw((address << 10) | (command << 2) | 2, 15); -} - -void IRsend::sendDISH(unsigned long data, int nbits) { - // Set IR carrier frequency - enableIROut(56); - // Header - mark(DISH_HDR_MARK); - space(DISH_HDR_SPACE); - for (int i = 0; i < nbits; i++) { - if (data & DISH_TOP_BIT) { - mark(DISH_BIT_MARK); - space(DISH_ONE_SPACE); - } else { - mark(DISH_BIT_MARK); - space(DISH_ZERO_SPACE); - } - data <<= 1; - } - // Footer - ledOff(); -} - -// From https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet/tree/master/IRremote -void IRsend::sendDaikin(unsigned char daikin[]) { - sendDaikinChunk(daikin, 8,0); - delay(29); - sendDaikinChunk(daikin, 19,8); -} - -void IRsend::sendDaikinChunk(unsigned char buf[], int len, int start) { - int data2; - // Set IR carrier frequency - enableIROut(38); - // Header - mark(DAIKIN_HDR_MARK); - space(DAIKIN_HDR_SPACE); - // Data - for (int i = start; i < start+len; i++) { - data2=buf[i]; - - for (int j = 0; j < 8; j++) { - if ((1 << j & data2)) { - mark(DAIKIN_ONE_MARK); - space(DAIKIN_ONE_SPACE); - } else { - mark(DAIKIN_ZERO_MARK); - space(DAIKIN_ZERO_SPACE); - } - } - } - // Footer - mark(DAIKIN_ONE_MARK); - space(DAIKIN_ZERO_SPACE); -} - -void IRsend::sendKelvinator(unsigned char data[]) { - uint8_t i = 0; - // Set IR carrier frequency - enableIROut(38); - // Header #1 - mark(KELVINATOR_HDR_MARK); - space(KELVINATOR_HDR_SPACE); - // Data (command) - // Send the first command data (4 bytes) - for (; i < 4; i++) - sendData(KELVINATOR_BIT_MARK, KELVINATOR_ONE_SPACE, KELVINATOR_BIT_MARK, - KELVINATOR_ZERO_SPACE, data[i], 8, false); - // Send Footer for the command data (3 bits (B010)) - sendData(KELVINATOR_BIT_MARK, KELVINATOR_ONE_SPACE, KELVINATOR_BIT_MARK, - KELVINATOR_ZERO_SPACE, KELVINATOR_CMD_FOOTER, 3, false); - // Send an interdata gap. - mark(KELVINATOR_BIT_MARK); - space(KELVINATOR_GAP_SPACE); - // Data (options) - // Send the 1st option chunk of data (4 bytes). - for (; i < 8; i++) - sendData(KELVINATOR_BIT_MARK, KELVINATOR_ONE_SPACE, KELVINATOR_BIT_MARK, - KELVINATOR_ZERO_SPACE, data[i], 8, false); - // Send a double data gap to signify we are starting a new command sequence. - mark(KELVINATOR_BIT_MARK); - space(KELVINATOR_GAP_SPACE * 2); - // Header #2 - mark(KELVINATOR_HDR_MARK); - space(KELVINATOR_HDR_SPACE); - // Data (command) - // Send the 2nd command data (4 bytes). - // Basically an almost identical repeat of the earlier command data. - for (; i < 12; i++) - sendData(KELVINATOR_BIT_MARK, KELVINATOR_ONE_SPACE, KELVINATOR_BIT_MARK, - KELVINATOR_ZERO_SPACE, data[i], 8, false); - // Send Footer for the command data (3 bits (B010)) - sendData(KELVINATOR_BIT_MARK, KELVINATOR_ONE_SPACE, KELVINATOR_BIT_MARK, - KELVINATOR_ZERO_SPACE, KELVINATOR_CMD_FOOTER, 3, false); - // Send an interdata gap. - mark(KELVINATOR_BIT_MARK); - space(KELVINATOR_GAP_SPACE); - // Data (options) - // Send the 2nd option chunk of data (4 bytes). - // Unlike the commands, definately not a repeat of the earlier option data. - for (; i < KELVINATOR_STATE_LENGTH; i++) - sendData(KELVINATOR_BIT_MARK, KELVINATOR_ONE_SPACE, KELVINATOR_BIT_MARK, - KELVINATOR_ZERO_SPACE, data[i], 8, false); - // Footer - mark(KELVINATOR_BIT_MARK); - ledOff(); -} - -void IRsend::sendSherwood(unsigned long data, int nbits, unsigned int repeat) { - // Sherwood remote codes appear to be NEC codes with a manditory repeat code. - // i.e. repeat should be >= 1. - sendNEC(data, nbits, max(1, repeat)); -} - -void IRsend::sendMitsubishiACChunk(uint8_t data) { - // send a chunk(byte) of Mitsubishi AC data - for (uint8_t bit = 0; bit < 8; bit++, data >>= 1) { - if (data & B1) { // 1 - mark(MITSUBISHI_AC_BIT_MARK); - space(MITSUBISHI_AC_ONE_SPACE); - } else { // 0 - mark(MITSUBISHI_AC_BIT_MARK); - space(MITSUBISHI_AC_ZERO_SPACE); - } - } -} - -void IRsend::sendMitsubishiAC(unsigned char data[]) { - // Set IR carrier frequency - enableIROut(38); - // Mitsubishi AC remote sends the packet twice. - for (uint8_t count = 0; count < 2; count++) { - // Header - mark(MITSUBISHI_AC_HDR_MARK); - space(MITSUBISHI_AC_HDR_SPACE); - // Data - for (uint8_t i = 0; i < MITSUBISHI_AC_STATE_LENGTH; i++) - sendMitsubishiACChunk(data[i]); - // Footer - mark(MITSUBISHI_AC_RPT_MARK); - space(MITSUBISHI_AC_RPT_SPACE); - } -} -// --------------------------------------------------------------- - - -//IRRecv------------------------------------------------------ - -extern "C" { - #include "user_interface.h" - #include "gpio.h" -} - -static ETSTimer timer; -volatile irparams_t irparams; - -static void ICACHE_RAM_ATTR read_timeout(void *arg __attribute__((unused))) { - os_intr_lock(); - if (irparams.rawlen) { - irparams.rcvstate = STATE_STOP; - } - os_intr_unlock(); -} - -static void ICACHE_RAM_ATTR gpio_intr() { - uint32_t now = system_get_time(); - uint32_t gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS); - static uint32_t start = 0; - - os_timer_disarm(&timer); - GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status); - - if (irparams.rawlen >= RAWBUF) { - irparams.overflow = true; - irparams.rcvstate = STATE_STOP; - } - - if (irparams.rcvstate == STATE_STOP) { - return; - } - - if (irparams.rcvstate == STATE_IDLE) { - irparams.overflow = false; - irparams.rcvstate = STATE_MARK; - irparams.rawbuf[irparams.rawlen++] = 1; - } else { - if (now < start) - irparams.rawbuf[irparams.rawlen++] = (0xFFFFFFFF - start + now) / USECPERTICK + 1; - else - irparams.rawbuf[irparams.rawlen++] = (now - start) / USECPERTICK + 1; - } - - start = now; - #define ONCE 0 - os_timer_arm(&timer, 15, ONCE); -} - -IRrecv::IRrecv(int recvpin) { - irparams.recvpin = recvpin; -} - -// initialization -void IRrecv::enableIRIn() { - // initialize state machine variables - irparams.rcvstate = STATE_IDLE; - irparams.rawlen = 0; - - // Initialize timer - os_timer_disarm(&timer); - os_timer_setfn(&timer, (os_timer_func_t *)read_timeout, NULL); - - // Attach Interrupt - attachInterrupt(irparams.recvpin, gpio_intr, CHANGE); -} - -void IRrecv::disableIRIn() { - os_timer_disarm(&timer); - detachInterrupt(irparams.recvpin); -} - -void IRrecv::resume() { - irparams.rcvstate = STATE_IDLE; - irparams.rawlen = 0; -} - -// Decodes the received IR message -// Returns true if is data ready -// Results of decoding are stored in results -bool IRrecv::decode(decode_results *results) { - results->rawbuf = irparams.rawbuf; - results->rawlen = irparams.rawlen; - results->overflow = irparams.overflow; - - if (irparams.rcvstate != STATE_STOP) { - return false; - } - -#ifdef DEBUG - Serial.println("Attempting NEC decode"); -#endif - if (decodeNEC(results)) { - return true; - } - -#ifdef DEBUG - Serial.println("Attempting Sony decode"); -#endif - if (decodeSony(results)) { - return true; - } - /* -#ifdef DEBUG - Serial.println("Attempting Sanyo decode"); -#endif - if (decodeSanyo(results)) { - return true; - }*/ -#ifdef DEBUG - Serial.println("Attempting Mitsubishi decode"); -#endif - if (decodeMitsubishi(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting RC5 decode"); -#endif - if (decodeRC5(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting RC6 decode"); -#endif - if (decodeRC6(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting Panasonic decode"); -#endif - if (decodePanasonic(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting LG decode"); -#endif - if (decodeLG(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting JVC decode"); -#endif - if (decodeJVC(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting SAMSUNG decode"); -#endif - if (decodeSAMSUNG(results)) { - return true; - } -#ifdef DEBUG - Serial.println("Attempting Whynter decode"); -#endif - if (decodeWhynter(results)) { - return true; - } - // decodeHash returns a hash on any input. - // Thus, it needs to be last in the list. - // If you add any decodes, add them before this. - if (decodeHash(results)) { - return true; - } - // Throw away and start over - resume(); - return false; -} - -// NECs have a repeat only 4 items long -bool IRrecv::decodeNEC(decode_results *results) { - long data = 0; - int offset = 1; // Skip initial space - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) { - return false; - } - offset++; - // Check for repeat - if (irparams.rawlen == 4 && - MATCH_SPACE(results->rawbuf[offset], NEC_RPT_SPACE) && - MATCH_MARK(results->rawbuf[offset+1], NEC_BIT_MARK)) { - results->bits = 0; - results->value = REPEAT; - results->decode_type = NEC; - return true; - } - if (irparams.rawlen < 2 * NEC_BITS + 4) { - return false; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) { - return false; - } - offset++; - for (int i = 0; i < NEC_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - // Success - results->bits = NEC_BITS; - results->value = data; - results->decode_type = NEC; - return true; -} - -bool IRrecv::decodeSony(decode_results *results) { - long data = 0; - if (irparams.rawlen < 2 * SONY_BITS + 2) { - return false; - } - int offset = 0; // Dont skip first space, check its size - - /* - // Some Sony's deliver repeats fast after first - // unfortunately can't spot difference from of repeat from two fast clicks - if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) { - // Serial.print("IR Gap found: "); - results->bits = 0; - results->value = REPEAT; - results->decode_type = SANYO; - return true; - }*/ - offset++; - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) { - return false; - } - offset++; - - while (offset + 1 < irparams.rawlen) { - if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) { - break; - } - offset++; - if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) { - data = (data << 1) | 1; - } else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) { - data <<= 1; - } else { - return false; - } - offset++; - } - - // Success - results->bits = (offset - 1) / 2; - if (results->bits < 12) { - results->bits = 0; - return false; - } - results->value = data; - results->decode_type = SONY; - return true; -} - -bool IRrecv::decodeWhynter(decode_results *results) { - long data = 0; - - if (irparams.rawlen < 2 * WHYNTER_BITS + 6) { - return false; - } - - int offset = 1; // Skip first space - - - // sequence begins with a bit mark and a zero space - if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { - return false; - } - offset++; - if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) { - return false; - } - offset++; - - // header mark and space - if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) { - return false; - } - offset++; - if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) { - return false; - } - offset++; - - // data bits - for (int i = 0; i < WHYNTER_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - - // trailing mark - if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { - return false; - } - // Success - results->bits = WHYNTER_BITS; - results->value = data; - results->decode_type = WHYNTER; - return true; -} - -// I think this is a Sanyo decoder - serial = SA 8650B -// Looks like Sony except for timings, 48 chars of data and time/space different -bool IRrecv::decodeSanyo(decode_results *results) { - long data = 0; - if (irparams.rawlen < 2 * SANYO_BITS + 2) { - return false; - } - int offset = 1; // Skip first space - - - // Initial space - /* 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 - Serial.print("IR Gap: "); - Serial.println( results->rawbuf[offset]); - Serial.println( "test against:"); - Serial.println(results->rawbuf[offset]); - */ - - if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) { - // Serial.print("IR Gap found: "); - results->bits = 0; - results->value = REPEAT; - results->decode_type = SANYO; - return true; - } - offset++; - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { - return false; - } - offset++; - - // Skip Second Mark - if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { - return false; - } - offset++; - - while (offset + 1 < irparams.rawlen) { - if (!MATCH_SPACE(results->rawbuf[offset], SANYO_HDR_SPACE)) { - break; - } - offset++; - if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) { - data = (data << 1) | 1; - } else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) { - data <<= 1; - } else { - return false; - } - offset++; - } - - // Success - results->bits = (offset - 1) / 2; - if (results->bits < 12) { - results->bits = 0; - return false; - } - results->value = data; - results->decode_type = SANYO; - return true; -} - -// Looks like Sony except for timings, 48 chars of data and time/space different -bool IRrecv::decodeMitsubishi(decode_results *results) { - // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); - // Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2); - long data = 0; - if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) { - return false; - } - int offset = 1; // Skip first space - // Initial space - /* 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 - Serial.print("IR Gap: "); - Serial.println( results->rawbuf[offset]); - Serial.println( "test against:"); - Serial.println(results->rawbuf[offset]); - */ - /* Not seeing double keys from Mitsubishi - if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) { - // Serial.print("IR Gap found: "); - results->bits = 0; - results->value = REPEAT; - results->decode_type = MITSUBISHI; - return true; - } - */ - - offset++; - - // Typical - // 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 - - // Initial Space - if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { - return false; - } - offset++; - while (offset + 1 < irparams.rawlen) { - if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) { - data = (data << 1) | 1; - } else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) { - data <<= 1; - } else { - // Serial.println("A"); Serial.println(offset); Serial.println(results->rawbuf[offset]); - return false; - } - offset++; - if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { - // Serial.println("B"); Serial.println(offset); Serial.println(results->rawbuf[offset]); - break; - } - offset++; - } - - // Success - results->bits = (offset - 1) / 2; - if (results->bits < MITSUBISHI_BITS) { - results->bits = 0; - return false; - } - results->value = data; - results->decode_type = MITSUBISHI; - return true; -} - -// Gets one undecoded level at a time from the raw buffer. -// The RC5/6 decoding is easier if the data is broken into time intervals. -// E.g. if the buffer has MARK for 2 time intervals and SPACE for 1, -// successive calls to getRClevel will return MARK, MARK, SPACE. -// offset and used are updated to keep track of the current position. -// t1 is the time interval for a single bit in microseconds. -// Returns -1 for error (measured time interval is not a multiple of t1). -int IRrecv::getRClevel(decode_results *results, int *offset, int *used, - int t1) { - if (*offset >= results->rawlen) { - // After end of recorded buffer, assume SPACE. - return SPACE; - } - int width = results->rawbuf[*offset]; - int val = ((*offset) % 2) ? MARK : SPACE; - int correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS; - - int avail; - if (MATCH(width, t1 + correction)) { - avail = 1; - } else if (MATCH(width, 2*t1 + correction)) { - avail = 2; - } else if (MATCH(width, 3*t1 + correction)) { - avail = 3; - } else { - return -1; - } - - (*used)++; - if (*used >= avail) { - *used = 0; - (*offset)++; - } -#ifdef DEBUG - if (val == MARK) { - Serial.println("MARK"); - } else { - Serial.println("SPACE"); - } -#endif - return val; -} - -bool IRrecv::decodeRC5(decode_results *results) { - if (irparams.rawlen < MIN_RC5_SAMPLES + 2) { - return false; - } - int offset = 1; // Skip gap space - long data = 0; - int used = 0; - // Get start bits - if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return false; - if (getRClevel(results, &offset, &used, RC5_T1) != SPACE) return false; - if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return false; - int nbits; - for (nbits = 0; offset < irparams.rawlen; nbits++) { - int levelA = getRClevel(results, &offset, &used, RC5_T1); - int levelB = getRClevel(results, &offset, &used, RC5_T1); - if (levelA == SPACE && levelB == MARK) { - // 1 bit - data = (data << 1) | 1; - } else if (levelA == MARK && levelB == SPACE) { - // zero bit - data <<= 1; - } else { - return false; - } - } - - // Success - results->bits = nbits; - results->value = data; - results->decode_type = RC5; - return true; -} - -bool IRrecv::decodeRC6(decode_results *results) { - if (results->rawlen < MIN_RC6_SAMPLES) { - return false; - } - int offset = 1; // Skip first space - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) { - return false; - } - offset++; - if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) { - return false; - } - offset++; - long data = 0; - int used = 0; - // Get start bit (1) - if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return false; - if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return false; - int nbits; - for (nbits = 0; offset < results->rawlen; nbits++) { - int levelA, levelB; // Next two levels - levelA = getRClevel(results, &offset, &used, RC6_T1); - if (nbits == 3) { - // T bit is double wide; make sure second half matches - if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return false; - } - levelB = getRClevel(results, &offset, &used, RC6_T1); - if (nbits == 3) { - // T bit is double wide; make sure second half matches - if (levelB != getRClevel(results, &offset, &used, RC6_T1)) return false; - } - if (levelA == MARK && levelB == SPACE) { // reversed compared to RC5 - // 1 bit - data = (data << 1) | 1; - } else if (levelA == SPACE && levelB == MARK) { - // zero bit - data <<= 1; - } else { - return false; // Error - } - } - // Success - results->bits = nbits; - results->value = data; - results->decode_type = RC6; - return true; -} - -bool IRrecv::decodePanasonic(decode_results *results) { - unsigned long long data = 0; - int offset = 1; // Dont skip first space - if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) { - return false; - } - offset++; - if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) { - return false; - } - offset++; - // decode address - for (int i = 0; i < PANASONIC_BITS; i++) { - if (!MATCH(results->rawbuf[offset++], PANASONIC_BIT_MARK)) { - return false; - } - if (MATCH(results->rawbuf[offset],PANASONIC_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - results->value = (unsigned long)data; - results->panasonicAddress = (unsigned int)(data >> 32); - results->decode_type = PANASONIC; - results->bits = PANASONIC_BITS; - return true; -} - -bool IRrecv::decodeLG(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) { - return false; - } - offset++; - if (irparams.rawlen < 2 * LG_BITS + 1 ) { - return false; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) { - return false; - } - offset++; - for (int i = 0; i < LG_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - //Stop bit - if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){ - return false; - } - // Success - results->bits = LG_BITS; - results->value = data; - results->decode_type = LG; - return true; -} - -bool IRrecv::decodeJVC(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - // Check for repeat - if (irparams.rawlen - 1 == 33 && - MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK) && - MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)) { - results->bits = 0; - results->value = REPEAT; - results->decode_type = JVC; - return true; - } - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) { - return false; - } - offset++; - if (irparams.rawlen < 2 * JVC_BITS + 1 ) { - return false; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) { - return false; - } - offset++; - for (int i = 0; i < JVC_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - //Stop bit - if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) { - return false; - } - // Success - results->bits = JVC_BITS; - results->value = data; - results->decode_type = JVC; - return true; -} - -// SAMSUNGs have a repeat only 4 items long -bool IRrecv::decodeSAMSUNG(decode_results *results) { - long data = 0; - int offset = 1; // Dont skip first space - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) { - return false; - } - offset++; - // Check for repeat - if (irparams.rawlen == 4 && - MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE) && - MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)) { - results->bits = 0; - results->value = REPEAT; - results->decode_type = SAMSUNG; - return true; - } - if (irparams.rawlen < 2 * SAMSUNG_BITS + 2) { - return false; - } - // Initial space - if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) { - return false; - } - offset++; - for (int i = 0; i < SAMSUNG_BITS; i++) { - if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - // Success - results->bits = SAMSUNG_BITS; - results->value = data; - results->decode_type = SAMSUNG; - return true; -} - -// From https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet/tree/master/IRremote -// decoding not actually tested -bool IRrecv::decodeDaikin(decode_results *results) { - long data = 0; - int offset = 1; // Skip first space - - if (irparams.rawlen < 2 * DAIKIN_BITS + 4) { - //return false; - } - - // Initial mark - if (!MATCH_MARK(results->rawbuf[offset], DAIKIN_HDR_MARK)) { - return false; - } - offset++; - - if (!MATCH_SPACE(results->rawbuf[offset], DAIKIN_HDR_SPACE)) { - return false; - } - offset++; - - for (int i = 0; i < 32; i++) { - if (!MATCH_MARK(results->rawbuf[offset], DAIKIN_ONE_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], DAIKIN_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], DAIKIN_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - - unsigned long number = data ; // some number... - int bits = 32 ; // nr of bits in some number - unsigned long reversed = 0; - for ( int b=0 ; b < bits ; b++ ) { - reversed = ( reversed << 1 ) | ( 0x0001 & ( number >> b ) ); - } - - Serial.print ("Code "); - Serial.println (reversed, HEX); - - //========== - - for (int i = 0; i < 32; i++) { - if (!MATCH_MARK(results->rawbuf[offset], DAIKIN_ONE_MARK)) { - return false; - } - offset++; - if (MATCH_SPACE(results->rawbuf[offset], DAIKIN_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], DAIKIN_ZERO_SPACE)) { - data <<= 1; - } else { - return false; - } - offset++; - } - - number = data ; // some number... - bits = 32 ; // nr of bits in some number - reversed = 0; - for ( int b=0 ; b < bits ; b++ ) { - reversed = ( reversed << 1 ) | ( 0x0001 & ( number >> b ) ); - } - - //Serial.print ("Code2 "); - //Serial.println (reversed, HEX); - - //=========== - if (!MATCH_SPACE(results->rawbuf[offset], 29000)) { - //Serial.println ("no gap"); - return false; - } - offset++; - - // Success - results->bits = DAIKIN_BITS; - results->value = reversed; - results->decode_type = DAIKIN; - return true; -} - -// Denon, from https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Denon.cpp -bool IRrecv::decodeDenon (decode_results *results) { - unsigned long data = 0; // Somewhere to build our code - int offset = 1; // Skip the Gap reading - - // Check we have the right amount of data - if (irparams.rawlen != 1 + 2 + (2 * DENON_BITS) + 1) { - return false; - } - - // Check initial Mark+Space match - if (!MATCH_MARK (results->rawbuf[offset++], DENON_HDR_MARK )) { - return false; - } - if (!MATCH_SPACE(results->rawbuf[offset++], DENON_HDR_SPACE)) { - return false; - } - - // Read the bits in - for (int i = 0; i < DENON_BITS; i++) { - // Each bit looks like: DENON_MARK + DENON_SPACE_1 -> 1 - // or : DENON_MARK + DENON_SPACE_0 -> 0 - if (!MATCH_MARK(results->rawbuf[offset++], DENON_BIT_MARK)) { - return false; - } - - // IR data is big-endian, so we shuffle it in from the right: - if (MATCH_SPACE(results->rawbuf[offset], DENON_ONE_SPACE)) { - data = (data << 1) | 1; - } else if (MATCH_SPACE(results->rawbuf[offset], DENON_ZERO_SPACE)) { - data = (data << 1) | 0; - } else { - return false; - } - offset++; - } - - // Success - results->bits = DENON_BITS; - results->value = data; - results->decode_type = DENON; - return true; -} - - -/* ----------------------------------------------------------------------- - * hashdecode - decode an arbitrary IR code. - * Instead of decoding using a standard encoding scheme - * (e.g. Sony, NEC, RC5), the code is hashed to a 32-bit value. - * - * The algorithm: look at the sequence of MARK signals, and see if each one - * is shorter (0), the same length (1), or longer (2) than the previous. - * Do the same with the SPACE signals. Hszh the resulting sequence of 0's, - * 1's, and 2's to a 32-bit value. This will give a unique value for each - * different code (probably), for most code systems. - * - * http://arcfn.com/2010/01/using-arbitrary-remotes-with-arduino.html - */ - -// Compare two tick values, returning 0 if newval is shorter, -// 1 if newval is equal, and 2 if newval is longer -// Use a tolerance of 20% -int IRrecv::compare(unsigned int oldval, unsigned int newval) { - if (newval < oldval * .8) { - return 0; - } else if (oldval < newval * .8) { - return 2; - } else { - return 1; - } -} - -// Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param -#define FNV_PRIME_32 16777619 -#define FNV_BASIS_32 2166136261 - -/* Converts the raw code values into a 32-bit hash code. - * Hopefully this code is unique for each button. - * This isn't a "real" decoding, just an arbitrary value. - */ -bool IRrecv::decodeHash(decode_results *results) { - // Require at least 6 samples to prevent triggering on noise - if (results->rawlen < 6) { - return false; - } - long hash = FNV_BASIS_32; - for (int i = 1; i+2 < results->rawlen; i++) { - int value = compare(results->rawbuf[i], results->rawbuf[i+2]); - // Add value into the hash - hash = (hash * FNV_PRIME_32) ^ value; - } - results->value = hash; - results->bits = 32; - results->decode_type = UNKNOWN; - return true; -} - -// --------------------------------------------------------------- diff --git a/lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.h b/lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.h deleted file mode 100644 index 247920f62..000000000 --- a/lib/IRremoteESP8266-1.0.2a/IRremoteESP8266.h +++ /dev/null @@ -1,221 +0,0 @@ - /*************************************************** - * IRremote for ESP8266 - * - * Based on the IRremote library for Arduino by Ken Shirriff - * Version 0.11 August, 2009 - * Copyright 2009 Ken Shirriff - * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html - * - * Edited by Mitra to add new controller SANYO - * - * Interrupt code based on NECIRrcv by Joe Knapp - * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 - * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ - * - * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) - * LG added by Darryl Smith (based on the JVC protocol) - * Whynter A/C ARC-110WD added by Francesco Meschia - * Coolix A/C / heatpump added by bakrus - * Denon: sendDenon, decodeDenon added by Massimiliano Pinto - (from https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Denon.cpp) - * Kelvinator A/C and Sherwood added by crankyoldgit - * Updated by markszabo (https://github.com/markszabo/IRremoteESP8266) for sending IR code on ESP8266 - * Updated by Sebastien Warin (http://sebastien.warin.fr) for receiving IR code on ESP8266 - * - * Updated by sillyfrog for Daikin, adopted from - * (https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet/) - * - * GPL license, all text above must be included in any redistribution - ****************************************************/ - -#ifndef IRremote_h -#define IRremote_h - -#include - -// The following are compile-time library options. -// If you change them, recompile the library. -// If DEBUG is defined, a lot of debugging output will be printed during decoding. -// TEST must be defined for the IRtest unittests to work. It will make some -// methods virtual, which will be slightly slower, which is why it is optional. -//#define DEBUG -//#define TEST - -/* - * Always add to the end of the list and should never remove entries - * or change order. Projects may save the type number for later usage - * so numbering should always stay the same. - */ -enum decode_type_t { - UNKNOWN = -1, - UNUSED = 0, - RC5, - RC6, - NEC, - SONY, - PANASONIC, - JVC, - SAMSUNG, - WHYNTER, - AIWA_RC_T501, - LG, - SANYO, - MITSUBISHI, - DISH, - SHARP, - COOLIX, - DAIKIN, - DENON, - KELVINATOR, - SHERWOOD, - MITSUBISHI_AC -}; - -// Results returned from the decoder -class decode_results { -public: - int decode_type; // NEC, SONY, RC5, UNKNOWN - union { // This is used for decoding Panasonic and Sharp data - unsigned int panasonicAddress; - unsigned int sharpAddress; - }; - unsigned long value; // Decoded value - int bits; // Number of bits in decoded value - volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks - int rawlen; // Number of records in rawbuf. - bool overflow; -}; - -// Decoded value for NEC when a repeat code is received -#define REPEAT 0xffffffff - -#define SEND_PROTOCOL_NEC case NEC: sendNEC(data, nbits); break; -#define SEND_PROTOCOL_SONY case SONY: sendSony(data, nbits); break; -#define SEND_PROTOCOL_RC5 case RC5: sendRC5(data, nbits); break; -#define SEND_PROTOCOL_RC6 case RC6: sendRC6(data, nbits); break; -#define SEND_PROTOCOL_DISH case DISH: sendDISH(data, nbits); break; -#define SEND_PROTOCOL_JVC case JVC: sendJVC(data, nbits, 0); break; -#define SEND_PROTOCOL_SAMSUNG case SAMSUNG: sendSAMSUNG(data, nbits); break; -#define SEND_PROTOCOL_LG case LG: sendLG(data, nbits); break; -#define SEND_PROTOCOL_WHYNTER case WHYNTER: sendWhynter(data, nbits); break; -#define SEND_PROTOCOL_COOLIX case COOLIX: sendCOOLIX(data, nbits); break; -#define SEND_PROTOCOL_DENON case DENON: sendDenon(data, nbits); break; -#define SEND_PROTOCOL_SHERWOOD case SHERWOOD: sendSherwood(data, nbits); break; - -// main class for receiving IR -class IRrecv -{ -public: - IRrecv(int recvpin); - bool decode(decode_results *results); - void enableIRIn(); - void disableIRIn(); - void resume(); - private: - // These are called by decode - int getRClevel(decode_results *results, int *offset, int *used, int t1); - bool decodeNEC(decode_results *results); - bool decodeSony(decode_results *results); - bool decodeSanyo(decode_results *results); - bool decodeMitsubishi(decode_results *results); - bool decodeRC5(decode_results *results); - bool decodeRC6(decode_results *results); - bool decodePanasonic(decode_results *results); - bool decodeLG(decode_results *results); - bool decodeJVC(decode_results *results); - bool decodeSAMSUNG(decode_results *results); - bool decodeWhynter(decode_results *results); - bool decodeHash(decode_results *results); - // COOLIX decode is not implemented yet - // bool decodeCOOLIX(decode_results *results); - bool decodeDaikin(decode_results *results); - bool decodeDenon(decode_results *results); - int compare(unsigned int oldval, unsigned int newval); -}; - -// Only used for testing; can remove virtual for shorter code -#ifdef TEST -#define VIRTUAL virtual -#else -#define VIRTUAL -#endif -class IRsend -{ -public: - IRsend(int IRsendPin); - void begin(); - void send(int type, unsigned long data, int nbits) { - switch (type) { - SEND_PROTOCOL_NEC - SEND_PROTOCOL_SONY - SEND_PROTOCOL_RC5 - SEND_PROTOCOL_RC6 - SEND_PROTOCOL_DISH - SEND_PROTOCOL_JVC - SEND_PROTOCOL_SAMSUNG - SEND_PROTOCOL_LG - SEND_PROTOCOL_WHYNTER - SEND_PROTOCOL_COOLIX - SEND_PROTOCOL_DENON - SEND_PROTOCOL_SHERWOOD - } - }; - void sendCOOLIX(unsigned long data, int nbits); - void sendWhynter(unsigned long data, int nbits); - void sendNEC(unsigned long data, int nbits=32, unsigned int repeat=0); - void sendLG(unsigned long data, int nbits); - // sendSony() should typically be called with repeat=2 as Sony devices - // expect the code to be sent at least 3 times. (code + 2 repeats = 3 codes) - // As the legacy use of this procedure was only to send a single code - // it defaults to repeat=0 for backward compatiblity. - void sendSony(unsigned long data, int nbits, unsigned int repeat=0); - // Neither Sanyo nor Mitsubishi send is implemented yet - // void sendSanyo(unsigned long data, int nbits); - // void sendMitsubishi(unsigned long data, int nbits); - void sendRaw(unsigned int buf[], int len, int hz); - void sendGC(unsigned int buf[], int len); - void sendRC5(unsigned long data, int nbits); - void sendRC6(unsigned long data, int nbits); - void sendDISH(unsigned long data, int nbits); - void sendSharp(unsigned int address, unsigned int command); - void sendSharpRaw(unsigned long data, int nbits); - void sendPanasonic(unsigned int address, unsigned long data); - 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. - void sendSAMSUNG(unsigned long data, int nbits); - void sendDaikin(unsigned char daikin[]); - void sendDaikinChunk(unsigned char buf[], int len, int start); - void sendDenon(unsigned long data, int nbits); - void sendKelvinator(unsigned char data[]); - void sendSherwood(unsigned long data, int nbits=32, unsigned int repeat=1); - void sendMitsubishiAC(unsigned char data[]); - void enableIROut(int khz); - VIRTUAL void mark(unsigned int usec); - VIRTUAL void space(unsigned long usec); -private: - int halfPeriodicTime; - int IRpin; - void sendMitsubishiACChunk(unsigned char data); - void sendData(uint16_t onemark, uint32_t onespace, - uint16_t zeromark, uint32_t zerospace, - uint32_t data, uint8_t nbits, bool MSBfirst=true); - void ledOff(); -} ; - -class IRtimer { -public: - IRtimer(); - void reset(); - uint32_t elapsed(); -private: - uint32_t start; -}; - -// Some useful constants -#define USECPERTICK 50 // microseconds per clock interrupt tick -#define RAWBUF 100 // Length of raw duration buffer - -// Marks tend to be 100us too long, and spaces 100us too short -// when received due to sensor lag. -#define MARK_EXCESS 100 - -#endif diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRGCSendDemo/IRGCSendDemo.ino b/lib/IRremoteESP8266-1.0.2a/examples/IRGCSendDemo/IRGCSendDemo.ino deleted file mode 100644 index e0534414e..000000000 --- a/lib/IRremoteESP8266-1.0.2a/examples/IRGCSendDemo/IRGCSendDemo.ino +++ /dev/null @@ -1,26 +0,0 @@ -/* - * IRremoteESP8266: IRsendGCDemo - demonstrates sending Global Cache-formatted IR codes with IRsend - * An IR LED must be connected to ESP8266 pin 0. - * Version 0.1 30 March, 2016 - * Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com - */ - -#include - -// Codes are in Global Cache format less the emitter ID and request ID. These codes can be found in GC's Control Tower database. - -unsigned int Samsung_power_toggle[71] = {38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798}; - -IRsend irsend(4); //an IR emitter led is connected to GPIO pin 4 - -void setup() -{ - irsend.begin(); - Serial.begin(115200); -} - -void loop() { - Serial.println("Toggling power"); - irsend.sendGC(Samsung_power_toggle, 71); - delay(10000); -} \ No newline at end of file diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRGCTCPServer/IRGCTCPServer.ino b/lib/IRremoteESP8266-1.0.2a/examples/IRGCTCPServer/IRGCTCPServer.ino deleted file mode 100644 index b5ea42294..000000000 --- a/lib/IRremoteESP8266-1.0.2a/examples/IRGCTCPServer/IRGCTCPServer.ino +++ /dev/null @@ -1,85 +0,0 @@ -/* - * IRremoteESP8266: IRGCTCPServer - send Global Cache-formatted codes via TCP. - * An IR emitter must be connected to GPIO pin 4. - * Version 0.1 1 April, 2016 - * Hisham Khalifa, http://www.hishamkhalifa.com - * - * Example command - Samsung TV power toggle: 38000,1,1,170,170,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,63,20,63,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,20,20,20,20,20,20,20,20,20,20,63,20,20,20,63,20,63,20,63,20,63,20,63,20,63,20,1798\r\n - */ - -#include -#include - -#include -#include -#include - -const char* ssid = "..."; -const char* password = "..."; - -WiFiServer server(4998); // Uses port 4998. -WiFiClient client; - -unsigned int *codeArray; -IRsend irsend(4); //an IR emitter led is connected to GPIO pin 4 - -void parseString(String str) { - int nextIndex; - int codeLength = 1; - int currentIndex = 0; - nextIndex = str.indexOf(','); - - // change to do/until and remove superfluous repetition below... - while (nextIndex != -1) { - if (codeLength > 1) { - codeArray = (unsigned int*) realloc(codeArray, codeLength * sizeof(unsigned int)); - } else { - codeArray = (unsigned int*) malloc(codeLength * sizeof(unsigned int)); - } - - codeArray[codeLength-1] = (unsigned int) (str.substring(currentIndex, nextIndex).toInt()); - - codeLength++; - currentIndex = nextIndex + 1; - nextIndex = str.indexOf(',', currentIndex); - } - codeArray = (unsigned int*) realloc(codeArray, codeLength * sizeof(unsigned int)); - codeArray[codeLength-1] = (unsigned int) (str.substring(currentIndex, nextIndex).toInt()); - - irsend.sendGC(codeArray,codeLength); -} - -void setup() { - // initialize serial: - Serial.begin(115200); - Serial.println(" "); - Serial.println("IR TCP Server"); - - while (WiFi.status() != WL_CONNECTED) { - delay(900); - Serial.print("."); - } - - server.begin(); - IPAddress myAddress = WiFi.localIP(); - Serial.println(myAddress); - irsend.begin(); -} - -void loop() { - while(!client) { - client = server.available(); - } - - while(!client.connected()){ - delay(900); - client = server.available(); - } - - if(client.available()){ - String irCode = client.readStringUntil('\r'); // Exclusive of \r - client.readStringUntil('\n'); // Skip new line as well - client.flush(); - parseString(irCode); - } -} \ No newline at end of file diff --git a/lib/IRremoteESP8266-1.0.2a/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino b/lib/IRremoteESP8266-1.0.2a/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino deleted file mode 100644 index ef5c7f282..000000000 --- a/lib/IRremoteESP8266-1.0.2a/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino +++ /dev/null @@ -1,27 +0,0 @@ - -#include - -IRDaikinESP dakinir(D1); - -void setup(){ - dakinir.begin(); - Serial.begin(115200); -} - - -void loop(){ - Serial.println("Sending..."); - - // Set up what we want to send. See IRDaikinESP.cpp for all the options. - dakinir.on(); - dakinir.setFan(1); - dakinir.setMode(DAIKIN_COOL); - dakinir.setTemp(25); - dakinir.setSwingVertical(0); - dakinir.setSwingHorizontal(0); - - // Now send the IR signal. - dakinir.send(); - - delay(5000); -} diff --git a/lib/IRremoteESP8266-1.0.2a/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino b/lib/IRremoteESP8266-1.0.2a/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino deleted file mode 100644 index 155c4db40..000000000 --- a/lib/IRremoteESP8266-1.0.2a/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino +++ /dev/null @@ -1,52 +0,0 @@ - -#include - -IRKelvinatorAC kelvir(D1); // IR led controlled by Pin D1. - -void printState() { - // Display the settings. - Serial.println("Kelvinator A/C remote is in the following state:"); - Serial.printf(" Basic\n Power: %d, Mode: %d, Temp: %dC, Fan Speed: %d\n", - kelvir.getPower(), kelvir.getMode(), kelvir.getTemp(), - kelvir.getFan()); - Serial.printf(" Options\n X-Fan: %d, Light: %d, Ion Filter: %d\n", - kelvir.getXFan(), kelvir.getLight(), kelvir.getIonFilter()); - Serial.printf(" Swing (V): %d, Swing (H): %d, Turbo: %d, Quiet: %d\n", - kelvir.getSwingVertical(), kelvir.getSwingHorizontal(), - kelvir.getTurbo(), kelvir.getQuiet()); - // Display the encoded IR sequence. - unsigned char* ir_code = kelvir.getRaw(); - Serial.print("IR Code: 0x"); - for (int i = 0; i < KELVINATOR_STATE_LENGTH; i++) - Serial.printf("%02X", ir_code[i]); - Serial.println(); -} - -void setup(){ - kelvir.begin(); - Serial.begin(115200); - delay(200); - - // Set up what we want to send. See IRKelvinator.cpp for all the options. - // Most things default to off. - Serial.println("Default state of the remote."); - printState(); - Serial.println("Setting desired state for A/C."); - kelvir.on(); - kelvir.setFan(1); - kelvir.setMode(KELVINATOR_COOL); - kelvir.setTemp(26); - kelvir.setSwingVertical(false); - kelvir.setSwingHorizontal(true); - kelvir.setXFan(true); - kelvir.setIonFilter(false); - kelvir.setLight(true); -} - -void loop() { - // Now send the IR signal. - Serial.println("Sending IR command to A/C ..."); - kelvir.send(); - printState(); - delay(5000); -} diff --git a/lib/IRremoteESP8266-1.0.2a/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino b/lib/IRremoteESP8266-1.0.2a/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino deleted file mode 100644 index 5a0d17824..000000000 --- a/lib/IRremoteESP8266-1.0.2a/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino +++ /dev/null @@ -1,42 +0,0 @@ - -#include - -IRMitsubishiAC mitsubir(D1); // IR led controlled by Pin D1. - -void printState() { - // Display the settings. - Serial.println("Mitsubishi A/C remote is in the following state:"); - Serial.printf(" Power: %d, Mode: %d, Temp: %dC, Fan Speed: %d, Vane Mode: %d\n", - mitsubir.getPower(), mitsubir.getMode(), mitsubir.getTemp(), - mitsubir.getFan(), mitsubir.getVane()); - // Display the encoded IR sequence. - unsigned char* ir_code = mitsubir.getRaw(); - Serial.print("IR Code: 0x"); - for (int i = 0; i < MITSUBISHI_AC_STATE_LENGTH; i++) - Serial.printf("%02X", ir_code[i]); - Serial.println(); -} - -void setup(){ - mitsubir.begin(); - Serial.begin(115200); - delay(200); - - // Set up what we want to send. See IRMitsubishiAC.cpp for all the options. - Serial.println("Default state of the remote."); - printState(); - Serial.println("Setting desired state for A/C."); - mitsubir.on(); - mitsubir.setFan(1); - mitsubir.setMode(MITSUBISHI_AC_COOL); - mitsubir.setTemp(26); - mitsubir.setVane(MITSUBISHI_AC_VANE_AUTO); -} - -void loop() { - // Now send the IR signal. - Serial.println("Sending IR command to A/C ..."); - mitsubir.send(); - printState(); - delay(5000); -} diff --git a/lib/IRremoteESP8266-1.0.2a/library.json b/lib/IRremoteESP8266-1.0.2a/library.json deleted file mode 100644 index 776e3c3b6..000000000 --- a/lib/IRremoteESP8266-1.0.2a/library.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "IRremoteESP8266", - "version": "1.0.2", - "keywords": "infrared, ir, remote, esp8266", - "description": "Send and receive infrared signals with multiple protocols (ESP8266)", - "repository": - { - "type": "git", - "url": "https://github.com/markszabo/IRremoteESP8266.git" - }, - "authors": [ - { - "name": "Ken Shirriff", - "email": "zetoslab@gmail.com" - }, - { - "name": "Mark Szabo", - "url": "http://nomartini-noparty.blogspot.com/", - "maintainer": true - }, - { - "name": "Sebastien Warin", - "url": "http://sebastien.warin.fr", - "maintainer": true - }, - { - "name": "David Conran", - "url": "https://plus.google.com/+davidconran", - "maintainer": true - }, - { - "name": "Roi Dayan", - "url": "https://github.com/roidayan/", - "maintainer": true - }, - { - "name": "Massimiliano Pinto", - "url": "https://github.com/pintomax/", - "maintainer": true - } - ], - "frameworks": "arduino", - "platforms": "espressif8266" -} diff --git a/lib/IRremoteESP8266-1.0.2a/library.properties b/lib/IRremoteESP8266-1.0.2a/library.properties deleted file mode 100644 index 403f88cd2..000000000 --- a/lib/IRremoteESP8266-1.0.2a/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=IRremoteESP8266 -version=1.0.2 -author=Sebastien Warin, Mark Szabo, Ken Shirriff, David Conran -maintainer=Mark Szabo, David Conran, Sebastien Warin, Roi Dayan, Massimiliano Pinto -sentence=Send and receive infrared signals with multiple protocols (ESP8266) -paragraph=This library enables you to send and receive infra-red signals on an ESP8266. -category=Device Control -url=https://github.com/markszabo/IRremoteESP8266 -architectures=esp8266 diff --git a/lib/IRremoteESP8266/Contributors.md b/lib/IRremoteESP8266/Contributors.md new file mode 100644 index 000000000..67e85bacd --- /dev/null +++ b/lib/IRremoteESP8266/Contributors.md @@ -0,0 +1,20 @@ +## Contributors of this project +- [Mark Szabo](https://github.com/markszabo/) : IR sending on ESP8266 +- [Sébastien Warin](https://github.com/sebastienwarin/) (http://sebastien.warin.fr) : IR receiving on ESP8266 + +## Contributors of the original project (https://github.com/shirriff/Arduino-IRremote/) +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. + +- [z3t0](https://github.com/z3t0) : Active Contributor and currently also the main contributor. + * Email: zetoslab@gmail.com + * Skype: polarised16 +- [shirriff](https://github.com/shirriff) : Owner of repository and creator of library. +- [Informatic](https://github.com/Informatic) : Active contributor +- [fmeschia](https://github.com/fmeschia) : Active contributor +- [PaulStoffregen](https://github.com/paulstroffregen) : Active contributor +- [crash7](https://github.com/crash7) : Active contributor +- [Neco777](https://github.com/neco777) : Active contributor + +Note: This list is being updated constantly so please let [z3t0](https://github.com/z3t0) know if you have been missed. + + diff --git a/lib/IRremoteESP8266/IRremoteESP8266.cpp b/lib/IRremoteESP8266/IRremoteESP8266.cpp new file mode 100644 index 000000000..105ef630d --- /dev/null +++ b/lib/IRremoteESP8266/IRremoteESP8266.cpp @@ -0,0 +1,1212 @@ + /*************************************************** + * IRremote for ESP8266 + * + * Based on the IRremote library for Arduino by Ken Shirriff + * Version 0.11 August, 2009 + * Copyright 2009 Ken Shirriff + * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html + * + * Modified by Paul Stoffregen to support other boards and timers + * Modified by Mitra Ardron + * Added Sanyo and Mitsubishi controllers + * Modified Sony to spot the repeat codes that some Sony's send + * + * Interrupt code based on NECIRrcv by Joe Knapp + * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 + * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ + * + * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) + * LG added by Darryl Smith (based on the JVC protocol) + * Whynter A/C ARC-110WD added by Francesco Meschia + * + * Updated by markszabo (https://github.com/markszabo/IRremoteESP8266) for sending IR code on ESP8266 + * Updated by Sebastien Warin (http://sebastien.warin.fr) for receiving IR code on ESP8266 + * + * GPL license, all text above must be included in any redistribution + ****************************************************/ + +#include "IRremoteESP8266.h" +#include "IRremoteInt.h" + +// These versions of MATCH, MATCH_MARK, and MATCH_SPACE are only for debugging. +// To use them, set DEBUG in IRremoteInt.h +// Normally macros are used for efficiency +#ifdef DEBUG +int MATCH(int measured, int desired) { + Serial.print("Testing: "); + Serial.print(TICKS_LOW(desired), DEC); + Serial.print(" <= "); + Serial.print(measured, DEC); + Serial.print(" <= "); + Serial.println(TICKS_HIGH(desired), DEC); + return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired); +} + +int MATCH_MARK(int measured_ticks, int desired_us) { + Serial.print("Testing mark "); + Serial.print(measured_ticks * USECPERTICK, DEC); + Serial.print(" vs "); + Serial.print(desired_us, DEC); + Serial.print(": "); + Serial.print(TICKS_LOW(desired_us + MARK_EXCESS), DEC); + Serial.print(" <= "); + Serial.print(measured_ticks, DEC); + Serial.print(" <= "); + Serial.println(TICKS_HIGH(desired_us + MARK_EXCESS), DEC); + return measured_ticks >= TICKS_LOW(desired_us + MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS); +} + +int MATCH_SPACE(int measured_ticks, int desired_us) { + Serial.print("Testing space "); + Serial.print(measured_ticks * USECPERTICK, DEC); + Serial.print(" vs "); + Serial.print(desired_us, DEC); + Serial.print(": "); + Serial.print(TICKS_LOW(desired_us - MARK_EXCESS), DEC); + Serial.print(" <= "); + Serial.print(measured_ticks, DEC); + Serial.print(" <= "); + Serial.println(TICKS_HIGH(desired_us - MARK_EXCESS), DEC); + return measured_ticks >= TICKS_LOW(desired_us - MARK_EXCESS) && measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS); +} +#else +int MATCH(int measured, int desired) {return measured >= TICKS_LOW(desired) && measured <= TICKS_HIGH(desired);} +int MATCH_MARK(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us + MARK_EXCESS));} +int MATCH_SPACE(int measured_ticks, int desired_us) {return MATCH(measured_ticks, (desired_us - MARK_EXCESS));} +// Debugging versions are in IRremote.cpp +#endif + +// IRsend ----------------------------------------------------------------------------------- + +IRsend::IRsend(int IRsendPin) +{ + IRpin = IRsendPin; +} + +void IRsend::begin() +{ + pinMode(IRpin, OUTPUT); +} + +void IRsend::sendNEC(unsigned long data, int nbits) +{ + enableIROut(38); + mark(NEC_HDR_MARK); + space(NEC_HDR_SPACE); + for (int i = 0; i < nbits; i++) { + if (data & TOPBIT) { + mark(NEC_BIT_MARK); + space(NEC_ONE_SPACE); + } + else { + mark(NEC_BIT_MARK); + space(NEC_ZERO_SPACE); + } + data <<= 1; + } + mark(NEC_BIT_MARK); + space(0); +} + +void IRsend::sendWhynter(unsigned long data, int nbits) { + enableIROut(38); + mark(WHYNTER_ZERO_MARK); + space(WHYNTER_ZERO_SPACE); + mark(WHYNTER_HDR_MARK); + space(WHYNTER_HDR_SPACE); + for (int i = 0; i < nbits; i++) { + if (data & TOPBIT) { + mark(WHYNTER_ONE_MARK); + space(WHYNTER_ONE_SPACE); + } + else { + mark(WHYNTER_ZERO_MARK); + space(WHYNTER_ZERO_SPACE); + } + data <<= 1; + } + mark(WHYNTER_ZERO_MARK); + space(WHYNTER_ZERO_SPACE); +} + +void IRsend::sendSony(unsigned long data, int nbits) { + enableIROut(40); + mark(SONY_HDR_MARK); + space(SONY_HDR_SPACE); + data = data << (32 - nbits); + for (int i = 0; i < nbits; i++) { + if (data & TOPBIT) { + mark(SONY_ONE_MARK); + space(SONY_HDR_SPACE); + } + else { + mark(SONY_ZERO_MARK); + space(SONY_HDR_SPACE); + } + data <<= 1; + } +} + +void IRsend::sendRaw(unsigned int buf[], int len, int hz) +{ + enableIROut(hz); + for (int i = 0; i < len; i++) { + if (i & 1) { + space(buf[i]); + } + else { + mark(buf[i]); + } + } + space(0); // Just to be sure +} + +// Note: first bit must be a one (start bit) +void IRsend::sendRC5(unsigned long data, int nbits) +{ + enableIROut(36); + data = data << (32 - nbits); + mark(RC5_T1); // First start bit + space(RC5_T1); // Second start bit + mark(RC5_T1); // Second start bit + for (int i = 0; i < nbits; i++) { + if (data & TOPBIT) { + space(RC5_T1); // 1 is space, then mark + mark(RC5_T1); + } + else { + mark(RC5_T1); + space(RC5_T1); + } + data <<= 1; + } + space(0); // Turn off at end +} + +// Caller needs to take care of flipping the toggle bit +void IRsend::sendRC6(unsigned long data, int nbits) +{ + enableIROut(36); + data = data << (32 - nbits); + mark(RC6_HDR_MARK); + space(RC6_HDR_SPACE); + mark(RC6_T1); // start bit + space(RC6_T1); + int t; + for (int i = 0; i < nbits; i++) { + if (i == 3) { + // double-wide trailer bit + t = 2 * RC6_T1; + } + else { + t = RC6_T1; + } + if (data & TOPBIT) { + mark(t); + space(t); + } + else { + space(t); + mark(t); + } + + data <<= 1; + } + space(0); // Turn off at end +} +void IRsend::sendPanasonic(unsigned int address, unsigned long data) { + enableIROut(35); + mark(PANASONIC_HDR_MARK); + space(PANASONIC_HDR_SPACE); + + for(int i=0;i<16;i++) + { + mark(PANASONIC_BIT_MARK); + if (address & 0x8000) { + space(PANASONIC_ONE_SPACE); + } else { + space(PANASONIC_ZERO_SPACE); + } + address <<= 1; + } + for (int i=0; i < 32; i++) { + mark(PANASONIC_BIT_MARK); + if (data & TOPBIT) { + space(PANASONIC_ONE_SPACE); + } else { + space(PANASONIC_ZERO_SPACE); + } + data <<= 1; + } + mark(PANASONIC_BIT_MARK); + space(0); +} +void IRsend::sendJVC(unsigned long data, int nbits, int repeat) +{ + enableIROut(38); + data = data << (32 - nbits); + if (!repeat){ + mark(JVC_HDR_MARK); + space(JVC_HDR_SPACE); + } + for (int i = 0; i < nbits; i++) { + if (data & TOPBIT) { + mark(JVC_BIT_MARK); + space(JVC_ONE_SPACE); + } + else { + mark(JVC_BIT_MARK); + space(JVC_ZERO_SPACE); + } + data <<= 1; + } + mark(JVC_BIT_MARK); + space(0); +} + +void IRsend::sendSAMSUNG(unsigned long data, int nbits) +{ + enableIROut(38); + mark(SAMSUNG_HDR_MARK); + space(SAMSUNG_HDR_SPACE); + for (int i = 0; i < nbits; i++) { + if (data & TOPBIT) { + mark(SAMSUNG_BIT_MARK); + space(SAMSUNG_ONE_SPACE); + } + else { + mark(SAMSUNG_BIT_MARK); + space(SAMSUNG_ZERO_SPACE); + } + data <<= 1; + } + mark(SAMSUNG_BIT_MARK); + space(0); +} + +void IRsend::mark(int time) { + // Sends an IR mark for the specified number of microseconds. + // The mark output is modulated at the PWM frequency. + long beginning = micros(); + while(micros() - beginning < time){ + digitalWrite(IRpin, HIGH); + delayMicroseconds(halfPeriodicTime); + digitalWrite(IRpin, LOW); + delayMicroseconds(halfPeriodicTime); //38 kHz -> T = 26.31 microsec (periodic time), half of it is 13 + } +} + +/* Leave pin off for time (given in microseconds) */ +void IRsend::space(int time) { + // Sends an IR space for the specified number of microseconds. + // A space is no output, so the PWM output is disabled. + digitalWrite(IRpin, LOW); + if (time > 0) delayMicroseconds(time); +} + +void IRsend::enableIROut(int khz) { + // Enables IR output. The khz value controls the modulation frequency in kilohertz. + halfPeriodicTime = 500/khz; // T = 1/f but we need T/2 in microsecond and f is in kHz +} + + +/* Sharp and DISH support by Todd Treece ( http://unionbridge.org/design/ircommand ) + +The Dish send function needs to be repeated 4 times, and the Sharp function +has the necessary repeat built in because of the need to invert the signal. + +Sharp protocol documentation: +http://www.sbprojects.com/knowledge/ir/sharp.htm + +Here are the LIRC files that I found that seem to match the remote codes +from the oscilloscope: + +Sharp LCD TV: +http://lirc.sourceforge.net/remotes/sharp/GA538WJSA + +DISH NETWORK (echostar 301): +http://lirc.sourceforge.net/remotes/echostar/301_501_3100_5100_58xx_59xx + +For the DISH codes, only send the last for characters of the hex. +i.e. use 0x1C10 instead of 0x0000000000001C10 which is listed in the +linked LIRC file. +*/ + +void IRsend::sendSharpRaw(unsigned long data, int nbits) { + enableIROut(38); + + // Sending codes in bursts of 3 (normal, inverted, normal) makes transmission + // much more reliable. That's the exact behaviour of CD-S6470 remote control. + for (int n = 0; n < 3; n++) { + for (int i = 1 << (nbits-1); i > 0; i>>=1) { + if (data & i) { + mark(SHARP_BIT_MARK); + space(SHARP_ONE_SPACE); + } + else { + mark(SHARP_BIT_MARK); + space(SHARP_ZERO_SPACE); + } + } + + mark(SHARP_BIT_MARK); + space(SHARP_ZERO_SPACE); + delay(40); + + data = data ^ SHARP_TOGGLE_MASK; + } +} + +// Sharp send compatible with data obtained through decodeSharp +void IRsend::sendSharp(unsigned int address, unsigned int command) { + sendSharpRaw((address << 10) | (command << 2) | 2, 15); +} + +void IRsend::sendDISH(unsigned long data, int nbits) { + enableIROut(56); + mark(DISH_HDR_MARK); + space(DISH_HDR_SPACE); + for (int i = 0; i < nbits; i++) { + if (data & DISH_TOP_BIT) { + mark(DISH_BIT_MARK); + space(DISH_ONE_SPACE); + } + else { + mark(DISH_BIT_MARK); + space(DISH_ZERO_SPACE); + } + data <<= 1; + } +} + +// --------------------------------------------------------------- + + +//IRRecv------------------------------------------------------ + +extern "C" { + #include "user_interface.h" + #include "gpio.h" +} + +static ETSTimer timer; +volatile irparams_t irparams; + +static void ICACHE_FLASH_ATTR read_timeout(void *arg) { + os_intr_lock(); + if (irparams.rawlen) { + irparams.rcvstate = STATE_STOP; + } + os_intr_unlock(); +} + +static void ICACHE_FLASH_ATTR gpio_intr(void *arg) { + uint32_t gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS); + GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status); + + if (irparams.rcvstate == STATE_STOP) { + return; + } + static uint32_t start = 0; + uint32_t now = system_get_time(); + if (irparams.rcvstate == STATE_IDLE) { + irparams.rcvstate = STATE_MARK; + } + else if (irparams.rawlen < RAWBUF) { + irparams.rawbuf[irparams.rawlen++] = (now - start) / USECPERTICK + 1; + } + start = now; + + os_timer_disarm(&timer); + os_timer_arm(&timer, 15, 0); +} + +IRrecv::IRrecv(int recvpin) { + irparams.recvpin = recvpin; +} + +// initialization +void IRrecv::enableIRIn() { + + // initialize state machine variables + irparams.rcvstate = STATE_IDLE; + irparams.rawlen = 0; + + // set pin modes + //PIN_FUNC_SELECT(IR_IN_MUX, IR_IN_FUNC); + GPIO_DIS_OUTPUT(irparams.recvpin); + + // Initialize timer + os_timer_disarm(&timer); + os_timer_setfn(&timer, (os_timer_func_t *)read_timeout, &timer); + + // ESP Attach Interrupt + ETS_GPIO_INTR_DISABLE(); + ETS_GPIO_INTR_ATTACH(gpio_intr, NULL); + gpio_pin_intr_state_set(GPIO_ID_PIN(irparams.recvpin), GPIO_PIN_INTR_ANYEDGE); + ETS_GPIO_INTR_ENABLE(); + //ETS_INTR_UNLOCK(); + + //attachInterrupt(irparams.recvpin, readIR, CHANGE); + //irReadTimer.initializeUs(USECPERTICK, readIR).start(); + //os_timer_arm_us(&irReadTimer, USECPERTICK, 1); + //ets_timer_arm_new(&irReadTimer, USECPERTICK, 1, 0); +} + +void IRrecv::disableIRIn() { + //irReadTimer.stop(); + //os_timer_disarm(&irReadTimer); + ETS_INTR_LOCK(); + ETS_GPIO_INTR_DISABLE(); +} + +void IRrecv::resume() { + irparams.rcvstate = STATE_IDLE; + irparams.rawlen = 0; +} + +// Decodes the received IR message +// Returns 0 if no data ready, 1 if data ready. +// Results of decoding are stored in results +int IRrecv::decode(decode_results *results) { + results->rawbuf = irparams.rawbuf; + results->rawlen = irparams.rawlen; + if (irparams.rcvstate != STATE_STOP) { + return ERR; + } +#ifdef DEBUG + Serial.println("Attempting NEC decode"); +#endif + if (decodeNEC(results)) { + return DECODED; + } + +#ifdef DEBUG + Serial.println("Attempting Sony decode"); +#endif + if (decodeSony(results)) { + return DECODED; + } + /* +#ifdef DEBUG + Serial.println("Attempting Sanyo decode"); +#endif + if (decodeSanyo(results)) { + return DECODED; + }*/ +#ifdef DEBUG + Serial.println("Attempting Mitsubishi decode"); +#endif + if (decodeMitsubishi(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting RC5 decode"); +#endif + if (decodeRC5(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting RC6 decode"); +#endif + if (decodeRC6(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting Panasonic decode"); +#endif + if (decodePanasonic(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting LG decode"); +#endif + if (decodeLG(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting JVC decode"); +#endif + if (decodeJVC(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting SAMSUNG decode"); +#endif + if (decodeSAMSUNG(results)) { + return DECODED; + } +#ifdef DEBUG + Serial.println("Attempting Whynter decode"); +#endif + if (decodeWhynter(results)) { + return DECODED; + } + // decodeHash returns a hash on any input. + // Thus, it needs to be last in the list. + // If you add any decodes, add them before this. + if (decodeHash(results)) { + return DECODED; + } + // Throw away and start over + resume(); + return ERR; +} + +// NECs have a repeat only 4 items long +long IRrecv::decodeNEC(decode_results *results) { + long data = 0; + int offset = 1; // Skip initial space + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], NEC_HDR_MARK)) { + return ERR; + } + offset++; + // Check for repeat + if (irparams.rawlen == 4 && + MATCH_SPACE(results->rawbuf[offset], NEC_RPT_SPACE) && + MATCH_MARK(results->rawbuf[offset+1], NEC_BIT_MARK)) { + results->bits = 0; + results->value = REPEAT; + results->decode_type = NEC; + return DECODED; + } + if (irparams.rawlen < 2 * NEC_BITS + 4) { + return ERR; + } + // Initial space + if (!MATCH_SPACE(results->rawbuf[offset], NEC_HDR_SPACE)) { + return ERR; + } + offset++; + for (int i = 0; i < NEC_BITS; i++) { + if (!MATCH_MARK(results->rawbuf[offset], NEC_BIT_MARK)) { + return ERR; + } + offset++; + if (MATCH_SPACE(results->rawbuf[offset], NEC_ONE_SPACE)) { + data = (data << 1) | 1; + } + else if (MATCH_SPACE(results->rawbuf[offset], NEC_ZERO_SPACE)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + // Success + results->bits = NEC_BITS; + results->value = data; + results->decode_type = NEC; + return DECODED; +} + +long IRrecv::decodeSony(decode_results *results) { + long data = 0; + if (irparams.rawlen < 2 * SONY_BITS + 2) { + return ERR; + } + int offset = 0; // Dont skip first space, check its size + + /* + // Some Sony's deliver repeats fast after first + // unfortunately can't spot difference from of repeat from two fast clicks + if (results->rawbuf[offset] < SONY_DOUBLE_SPACE_USECS) { + // Serial.print("IR Gap found: "); + results->bits = 0; + results->value = REPEAT; + results->decode_type = SANYO; + return DECODED; + }*/ + offset++; + + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], SONY_HDR_MARK)) { + return ERR; + } + offset++; + + while (offset + 1 < irparams.rawlen) { + if (!MATCH_SPACE(results->rawbuf[offset], SONY_HDR_SPACE)) { + break; + } + offset++; + if (MATCH_MARK(results->rawbuf[offset], SONY_ONE_MARK)) { + data = (data << 1) | 1; + } + else if (MATCH_MARK(results->rawbuf[offset], SONY_ZERO_MARK)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + + // Success + results->bits = (offset - 1) / 2; + if (results->bits < 12) { + results->bits = 0; + return ERR; + } + results->value = data; + results->decode_type = SONY; + return DECODED; +} + +long IRrecv::decodeWhynter(decode_results *results) { + long data = 0; + + if (irparams.rawlen < 2 * WHYNTER_BITS + 6) { + return ERR; + } + + int offset = 1; // Skip first space + + + // sequence begins with a bit mark and a zero space + if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { + return ERR; + } + offset++; + if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_ZERO_SPACE)) { + return ERR; + } + offset++; + + // header mark and space + if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_HDR_MARK)) { + return ERR; + } + offset++; + if (!MATCH_SPACE(results->rawbuf[offset], WHYNTER_HDR_SPACE)) { + return ERR; + } + offset++; + + // data bits + for (int i = 0; i < WHYNTER_BITS; i++) { + if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { + return ERR; + } + offset++; + if (MATCH_SPACE(results->rawbuf[offset], WHYNTER_ONE_SPACE)) { + data = (data << 1) | 1; + } + else if (MATCH_SPACE(results->rawbuf[offset],WHYNTER_ZERO_SPACE)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + + // trailing mark + if (!MATCH_MARK(results->rawbuf[offset], WHYNTER_BIT_MARK)) { + return ERR; + } + // Success + results->bits = WHYNTER_BITS; + results->value = data; + results->decode_type = WHYNTER; + return DECODED; +} + +// I think this is a Sanyo decoder - serial = SA 8650B +// Looks like Sony except for timings, 48 chars of data and time/space different +long IRrecv::decodeSanyo(decode_results *results) { + long data = 0; + if (irparams.rawlen < 2 * SANYO_BITS + 2) { + return ERR; + } + int offset = 1; // Skip first space + + + // Initial space + /* 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 + Serial.print("IR Gap: "); + Serial.println( results->rawbuf[offset]); + Serial.println( "test against:"); + Serial.println(results->rawbuf[offset]); + */ + + if (results->rawbuf[offset] < SANYO_DOUBLE_SPACE_USECS) { + // Serial.print("IR Gap found: "); + results->bits = 0; + results->value = REPEAT; + results->decode_type = SANYO; + return DECODED; + } + offset++; + + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { + return ERR; + } + offset++; + + // Skip Second Mark + if (!MATCH_MARK(results->rawbuf[offset], SANYO_HDR_MARK)) { + return ERR; + } + offset++; + + while (offset + 1 < irparams.rawlen) { + if (!MATCH_SPACE(results->rawbuf[offset], SANYO_HDR_SPACE)) { + break; + } + offset++; + if (MATCH_MARK(results->rawbuf[offset], SANYO_ONE_MARK)) { + data = (data << 1) | 1; + } + else if (MATCH_MARK(results->rawbuf[offset], SANYO_ZERO_MARK)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + + // Success + results->bits = (offset - 1) / 2; + if (results->bits < 12) { + results->bits = 0; + return ERR; + } + results->value = data; + results->decode_type = SANYO; + return DECODED; +} + +// Looks like Sony except for timings, 48 chars of data and time/space different +long IRrecv::decodeMitsubishi(decode_results *results) { + // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2); + long data = 0; + if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) { + return ERR; + } + int offset = 1; // Skip first space + // Initial space + /* 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 + Serial.print("IR Gap: "); + Serial.println( results->rawbuf[offset]); + Serial.println( "test against:"); + Serial.println(results->rawbuf[offset]); + */ + /* Not seeing double keys from Mitsubishi + if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) { + // Serial.print("IR Gap found: "); + results->bits = 0; + results->value = REPEAT; + results->decode_type = MITSUBISHI; + return DECODED; + } + */ + + offset++; + + // Typical + // 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 + + // Initial Space + if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { + return ERR; + } + offset++; + while (offset + 1 < irparams.rawlen) { + if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) { + data = (data << 1) | 1; + } + else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) { + data <<= 1; + } + else { + // Serial.println("A"); Serial.println(offset); Serial.println(results->rawbuf[offset]); + return ERR; + } + offset++; + if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) { + // Serial.println("B"); Serial.println(offset); Serial.println(results->rawbuf[offset]); + break; + } + offset++; + } + + // Success + results->bits = (offset - 1) / 2; + if (results->bits < MITSUBISHI_BITS) { + results->bits = 0; + return ERR; + } + results->value = data; + results->decode_type = MITSUBISHI; + return DECODED; +} + +// Gets one undecoded level at a time from the raw buffer. +// The RC5/6 decoding is easier if the data is broken into time intervals. +// E.g. if the buffer has MARK for 2 time intervals and SPACE for 1, +// successive calls to getRClevel will return MARK, MARK, SPACE. +// offset and used are updated to keep track of the current position. +// t1 is the time interval for a single bit in microseconds. +// Returns -1 for error (measured time interval is not a multiple of t1). +int IRrecv::getRClevel(decode_results *results, int *offset, int *used, int t1) { + if (*offset >= results->rawlen) { + // After end of recorded buffer, assume SPACE. + return SPACE; + } + int width = results->rawbuf[*offset]; + int val = ((*offset) % 2) ? MARK : SPACE; + int correction = (val == MARK) ? MARK_EXCESS : - MARK_EXCESS; + + int avail; + if (MATCH(width, t1 + correction)) { + avail = 1; + } + else if (MATCH(width, 2*t1 + correction)) { + avail = 2; + } + else if (MATCH(width, 3*t1 + correction)) { + avail = 3; + } + else { + return -1; + } + + (*used)++; + if (*used >= avail) { + *used = 0; + (*offset)++; + } +#ifdef DEBUG + if (val == MARK) { + Serial.println("MARK"); + } + else { + Serial.println("SPACE"); + } +#endif + return val; +} + +long IRrecv::decodeRC5(decode_results *results) { + if (irparams.rawlen < MIN_RC5_SAMPLES + 2) { + return ERR; + } + int offset = 1; // Skip gap space + long data = 0; + int used = 0; + // Get start bits + if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return ERR; + if (getRClevel(results, &offset, &used, RC5_T1) != SPACE) return ERR; + if (getRClevel(results, &offset, &used, RC5_T1) != MARK) return ERR; + int nbits; + for (nbits = 0; offset < irparams.rawlen; nbits++) { + int levelA = getRClevel(results, &offset, &used, RC5_T1); + int levelB = getRClevel(results, &offset, &used, RC5_T1); + if (levelA == SPACE && levelB == MARK) { + // 1 bit + data = (data << 1) | 1; + } + else if (levelA == MARK && levelB == SPACE) { + // zero bit + data <<= 1; + } + else { + return ERR; + } + } + + // Success + results->bits = nbits; + results->value = data; + results->decode_type = RC5; + return DECODED; +} + +long IRrecv::decodeRC6(decode_results *results) { + if (results->rawlen < MIN_RC6_SAMPLES) { + return ERR; + } + int offset = 1; // Skip first space + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], RC6_HDR_MARK)) { + return ERR; + } + offset++; + if (!MATCH_SPACE(results->rawbuf[offset], RC6_HDR_SPACE)) { + return ERR; + } + offset++; + long data = 0; + int used = 0; + // Get start bit (1) + if (getRClevel(results, &offset, &used, RC6_T1) != MARK) return ERR; + if (getRClevel(results, &offset, &used, RC6_T1) != SPACE) return ERR; + int nbits; + for (nbits = 0; offset < results->rawlen; nbits++) { + int levelA, levelB; // Next two levels + levelA = getRClevel(results, &offset, &used, RC6_T1); + if (nbits == 3) { + // T bit is double wide; make sure second half matches + if (levelA != getRClevel(results, &offset, &used, RC6_T1)) return ERR; + } + levelB = getRClevel(results, &offset, &used, RC6_T1); + if (nbits == 3) { + // T bit is double wide; make sure second half matches + if (levelB != getRClevel(results, &offset, &used, RC6_T1)) return ERR; + } + if (levelA == MARK && levelB == SPACE) { // reversed compared to RC5 + // 1 bit + data = (data << 1) | 1; + } + else if (levelA == SPACE && levelB == MARK) { + // zero bit + data <<= 1; + } + else { + return ERR; // Error + } + } + // Success + results->bits = nbits; + results->value = data; + results->decode_type = RC6; + return DECODED; +} + +long IRrecv::decodePanasonic(decode_results *results) { + unsigned long long data = 0; + int offset = 1; // Dont skip first space + /*if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) { + return ERR; + } + offset++;*/ + if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) { + return ERR; + } + offset++; + // decode address + for (int i = 0; i < PANASONIC_BITS; i++) { + if (!MATCH(results->rawbuf[offset++], PANASONIC_BIT_MARK)) { + return ERR; + } + if (MATCH(results->rawbuf[offset],PANASONIC_ONE_SPACE)) { + data = (data << 1) | 1; + } else if (MATCH(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) { + data <<= 1; + } else { + return ERR; + } + offset++; + } + results->value = (unsigned long)data; + results->panasonicAddress = (unsigned int)(data >> 32); + results->decode_type = PANASONIC; + results->bits = PANASONIC_BITS; + return DECODED; +} + +long IRrecv::decodeLG(decode_results *results) { + long data = 0; + int offset = 1; // Skip first space + + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], LG_HDR_MARK)) { + return ERR; + } + offset++; + if (irparams.rawlen < 2 * LG_BITS + 1 ) { + return ERR; + } + // Initial space + if (!MATCH_SPACE(results->rawbuf[offset], LG_HDR_SPACE)) { + return ERR; + } + offset++; + for (int i = 0; i < LG_BITS; i++) { + if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)) { + return ERR; + } + offset++; + if (MATCH_SPACE(results->rawbuf[offset], LG_ONE_SPACE)) { + data = (data << 1) | 1; + } + else if (MATCH_SPACE(results->rawbuf[offset], LG_ZERO_SPACE)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + //Stop bit + if (!MATCH_MARK(results->rawbuf[offset], LG_BIT_MARK)){ + return ERR; + } + // Success + results->bits = LG_BITS; + results->value = data; + results->decode_type = LG; + return DECODED; +} + +long IRrecv::decodeJVC(decode_results *results) { + long data = 0; + int offset = 1; // Skip first space + // Check for repeat + if (irparams.rawlen - 1 == 33 && + MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK) && + MATCH_MARK(results->rawbuf[irparams.rawlen-1], JVC_BIT_MARK)) { + results->bits = 0; + results->value = REPEAT; + results->decode_type = JVC; + return DECODED; + } + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], JVC_HDR_MARK)) { + return ERR; + } + offset++; + if (irparams.rawlen < 2 * JVC_BITS + 1 ) { + return ERR; + } + // Initial space + if (!MATCH_SPACE(results->rawbuf[offset], JVC_HDR_SPACE)) { + return ERR; + } + offset++; + for (int i = 0; i < JVC_BITS; i++) { + if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)) { + return ERR; + } + offset++; + if (MATCH_SPACE(results->rawbuf[offset], JVC_ONE_SPACE)) { + data = (data << 1) | 1; + } + else if (MATCH_SPACE(results->rawbuf[offset], JVC_ZERO_SPACE)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + //Stop bit + if (!MATCH_MARK(results->rawbuf[offset], JVC_BIT_MARK)){ + return ERR; + } + // Success + results->bits = JVC_BITS; + results->value = data; + results->decode_type = JVC; + return DECODED; +} + +// SAMSUNGs have a repeat only 4 items long +long IRrecv::decodeSAMSUNG(decode_results *results) { + long data = 0; + int offset = 0; // Dont skip first space + // Initial mark + if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_HDR_MARK)) { + return ERR; + } + offset++; + // Check for repeat + if (irparams.rawlen == 4 && + MATCH_SPACE(results->rawbuf[offset], SAMSUNG_RPT_SPACE) && + MATCH_MARK(results->rawbuf[offset+1], SAMSUNG_BIT_MARK)) { + results->bits = 0; + results->value = REPEAT; + results->decode_type = SAMSUNG; + return DECODED; + } + if (irparams.rawlen < 2 * SAMSUNG_BITS + 2) { + return ERR; + } + // Initial space + if (!MATCH_SPACE(results->rawbuf[offset], SAMSUNG_HDR_SPACE)) { + return ERR; + } + offset++; + for (int i = 0; i < SAMSUNG_BITS; i++) { + if (!MATCH_MARK(results->rawbuf[offset], SAMSUNG_BIT_MARK)) { + return ERR; + } + offset++; + if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ONE_SPACE)) { + data = (data << 1) | 1; + } + else if (MATCH_SPACE(results->rawbuf[offset], SAMSUNG_ZERO_SPACE)) { + data <<= 1; + } + else { + return ERR; + } + offset++; + } + // Success + results->bits = SAMSUNG_BITS; + results->value = data; + results->decode_type = SAMSUNG; + return DECODED; +} + +/* ----------------------------------------------------------------------- + * hashdecode - decode an arbitrary IR code. + * Instead of decoding using a standard encoding scheme + * (e.g. Sony, NEC, RC5), the code is hashed to a 32-bit value. + * + * The algorithm: look at the sequence of MARK signals, and see if each one + * is shorter (0), the same length (1), or longer (2) than the previous. + * Do the same with the SPACE signals. Hszh the resulting sequence of 0's, + * 1's, and 2's to a 32-bit value. This will give a unique value for each + * different code (probably), for most code systems. + * + * http://arcfn.com/2010/01/using-arbitrary-remotes-with-arduino.html + */ + +// Compare two tick values, returning 0 if newval is shorter, +// 1 if newval is equal, and 2 if newval is longer +// Use a tolerance of 20% +int IRrecv::compare(unsigned int oldval, unsigned int newval) { + if (newval < oldval * .8) { + return 0; + } + else if (oldval < newval * .8) { + return 2; + } + else { + return 1; + } +} + +// Use FNV hash algorithm: http://isthe.com/chongo/tech/comp/fnv/#FNV-param +#define FNV_PRIME_32 16777619 +#define FNV_BASIS_32 2166136261 + +/* Converts the raw code values into a 32-bit hash code. + * Hopefully this code is unique for each button. + * This isn't a "real" decoding, just an arbitrary value. + */ +long IRrecv::decodeHash(decode_results *results) { + // Require at least 6 samples to prevent triggering on noise + if (results->rawlen < 6) { + return ERR; + } + long hash = FNV_BASIS_32; + for (int i = 1; i+2 < results->rawlen; i++) { + int value = compare(results->rawbuf[i], results->rawbuf[i+2]); + // Add value into the hash + hash = (hash * FNV_PRIME_32) ^ value; + } + results->value = hash; + results->bits = 32; + results->decode_type = UNKNOWN; + return DECODED; +} + +// --------------------------------------------------------------- diff --git a/lib/IRremoteESP8266/IRremoteESP8266.h b/lib/IRremoteESP8266/IRremoteESP8266.h new file mode 100644 index 000000000..3868c0778 --- /dev/null +++ b/lib/IRremoteESP8266/IRremoteESP8266.h @@ -0,0 +1,157 @@ + /*************************************************** + * IRremote for ESP8266 + * + * Based on the IRremote library for Arduino by Ken Shirriff + * Version 0.11 August, 2009 + * Copyright 2009 Ken Shirriff + * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html + * + * Edited by Mitra to add new controller SANYO + * + * Interrupt code based on NECIRrcv by Joe Knapp + * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 + * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ + * + * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) + * LG added by Darryl Smith (based on the JVC protocol) + * Whynter A/C ARC-110WD added by Francesco Meschia + * + * Updated by markszabo (https://github.com/markszabo/IRremoteESP8266) for sending IR code on ESP8266 + * Updated by Sebastien Warin (http://sebastien.warin.fr) for receiving IR code on ESP8266 + * + * GPL license, all text above must be included in any redistribution + ****************************************************/ + +#ifndef IRremote_h +#define IRremote_h + +// The following are compile-time library options. +// If you change them, recompile the library. +// If DEBUG is defined, a lot of debugging output will be printed during decoding. +// TEST must be defined for the IRtest unittests to work. It will make some +// methods virtual, which will be slightly slower, which is why it is optional. +//#define DEBUG +//#define TEST + +enum decode_type_t { + NEC = 1, + SONY = 2, + RC5 = 3, + RC6 = 4, + DISH = 5, + SHARP = 6, + PANASONIC = 7, + JVC = 8, + SANYO = 9, + MITSUBISHI = 10, + SAMSUNG = 11, + LG = 12, + WHYNTER = 13, + AIWA_RC_T501 = 14, + + UNKNOWN = -1 +}; + +// Results returned from the decoder +class decode_results { +public: + int decode_type; // NEC, SONY, RC5, UNKNOWN + union { // This is used for decoding Panasonic and Sharp data + unsigned int panasonicAddress; + unsigned int sharpAddress; + }; + unsigned long value; // Decoded value + int bits; // Number of bits in decoded value + volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks + int rawlen; // Number of records in rawbuf. +}; + +// Values for decode_type +#define NEC 1 +#define SONY 2 +#define RC5 3 +#define RC6 4 +#define DISH 5 +#define SHARP 6 +#define PANASONIC 7 +#define JVC 8 +#define SANYO 9 +#define MITSUBISHI 10 +#define SAMSUNG 11 +#define LG 12 +#define WHYNTER 13 +#define UNKNOWN -1 + +// Decoded value for NEC when a repeat code is received +#define REPEAT 0xffffffff + +// main class for receiving IR +class IRrecv +{ +public: + IRrecv(int recvpin); + int decode(decode_results *results); + void enableIRIn(); + void disableIRIn(); + void resume(); + private: + // These are called by decode + int getRClevel(decode_results *results, int *offset, int *used, int t1); + long decodeNEC(decode_results *results); + long decodeSony(decode_results *results); + long decodeSanyo(decode_results *results); + long decodeMitsubishi(decode_results *results); + long decodeRC5(decode_results *results); + long decodeRC6(decode_results *results); + long decodePanasonic(decode_results *results); + long decodeLG(decode_results *results); + long decodeJVC(decode_results *results); + long decodeSAMSUNG(decode_results *results); + long decodeWhynter(decode_results *results); + long decodeHash(decode_results *results); + int compare(unsigned int oldval, unsigned int newval); +}; + +// Only used for testing; can remove virtual for shorter code +#ifdef TEST +#define VIRTUAL virtual +#else +#define VIRTUAL +#endif +class IRsend +{ +public: + IRsend(int IRsendPin); + void begin(); + void sendWhynter(unsigned long data, int nbits); + void sendNEC(unsigned long data, int nbits); + void sendSony(unsigned long data, int nbits); + // Neither Sanyo nor Mitsubishi send is implemented yet + // void sendSanyo(unsigned long data, int nbits); + // void sendMitsubishi(unsigned long data, int nbits); + void sendRaw(unsigned int buf[], int len, int hz); + void sendRC5(unsigned long data, int nbits); + void sendRC6(unsigned long data, int nbits); + void sendDISH(unsigned long data, int nbits); + void sendSharp(unsigned int address, unsigned int command); + void sendSharpRaw(unsigned long data, int nbits); + void sendPanasonic(unsigned int address, unsigned long data); + 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. + void sendSAMSUNG(unsigned long data, int nbits); + void enableIROut(int khz); + VIRTUAL void mark(int usec); + VIRTUAL void space(int usec); +private: + int halfPeriodicTime; + int IRpin; +} ; + +// Some useful constants +#define USECPERTICK 50 // microseconds per clock interrupt tick +#define RAWBUF 100 // Length of raw duration buffer + +// Marks tend to be 100us too long, and spaces 100us too short +// when received due to sensor lag. +#define MARK_EXCESS 100 + +#endif diff --git a/lib/IRremoteESP8266-1.0.2a/IRremoteInt.h b/lib/IRremoteESP8266/IRremoteInt.h similarity index 65% rename from lib/IRremoteESP8266-1.0.2a/IRremoteInt.h rename to lib/IRremoteESP8266/IRremoteInt.h index ade21d5db..801702efd 100644 --- a/lib/IRremoteESP8266-1.0.2a/IRremoteInt.h +++ b/lib/IRremoteESP8266/IRremoteInt.h @@ -1,7 +1,7 @@ /*************************************************** * IRremote for ESP8266 * - * Based on the IRremote library for Arduino by Ken Shirriff + * Based on the IRremote library for Arduino by Ken Shirriff * Version 0.11 August, 2009 * Copyright 2009 Ken Shirriff * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html @@ -14,14 +14,8 @@ * * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) * Whynter A/C ARC-110WD added by Francesco Meschia - * Coolix A/C / heatpump added by bakrus - * Denon: sendDenon, decodeDenon added by Massimiliano Pinto - (from https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Denon.cpp) - * Kelvinator A/C added by crankyoldgit - * Mitsubishi A/C added by crankyoldgit - * (based on https://github.com/r45635/HVAC-IR-Control) * - * 09/23/2015 : Samsung pulse parameters updated by Sebastien Warin to be compatible with EUxxD6200 + * 09/23/2015 : Samsung pulse parameters updated by Sebastien Warin to be compatible with EUxxD6200 * * GPL license, all text above must be included in any redistribution ****************************************************/ @@ -38,12 +32,6 @@ // Pulse parms are *50-100 for the Mark and *50+100 for the space // First MARK is the one after the long gap // pulse parameters in usec -#define COOLIX_BIT_MARK 560 // Approximately 21 cycles at 38kHz -#define COOLIX_ONE_SPACE COOLIX_BIT_MARK * 3 -#define COOLIX_ZERO_SPACE COOLIX_BIT_MARK * 1 -#define COOLIX_HDR_MARK COOLIX_BIT_MARK * 8 -#define COOLIX_HDR_SPACE COOLIX_BIT_MARK * 8 - #define WHYNTER_HDR_MARK 2850 #define WHYNTER_HDR_SPACE 2850 #define WHYNTER_BIT_MARK 750 @@ -58,25 +46,24 @@ #define NEC_ONE_SPACE 1690 #define NEC_ZERO_SPACE 560 #define NEC_RPT_SPACE 2250 -#define NEC_MIN_COMMAND_LENGTH 108000UL #define SONY_HDR_MARK 2400 #define SONY_HDR_SPACE 600 #define SONY_ONE_MARK 1200 #define SONY_ZERO_MARK 600 #define SONY_RPT_LENGTH 45000 -#define SONY_DOUBLE_SPACE_USECS 500 // usually see 713 - not using ticks as get number wrapround +#define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround // SA 8650B #define SANYO_HDR_MARK 3500 // seen range 3500 #define SANYO_HDR_SPACE 950 // seen 950 -#define SANYO_ONE_MARK 2400 // seen 2400 +#define SANYO_ONE_MARK 2400 // seen 2400 #define SANYO_ZERO_MARK 700 // seen 700 -#define SANYO_DOUBLE_SPACE_USECS 800 // usually see 713 - not using ticks as get number wrapround +#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround #define SANYO_RPT_LENGTH 45000 // Mitsubishi RM 75501 -// 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 +// 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 // #define MITSUBISHI_HDR_MARK 250 // seen range 3500 #define MITSUBISHI_HDR_SPACE 350 // 7*50+100 @@ -85,17 +72,6 @@ // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround // #define MITSUBISHI_RPT_LENGTH 45000 -// Mitsubishi A/C -// Values were initially obtained from: -// https://github.com/r45635/HVAC-IR-Control/blob/master/HVAC_ESP8266/HVAC_ESP8266.ino#L84 -#define MITSUBISHI_AC_HDR_MARK 3400 -#define MITSUBISHI_AC_HDR_SPACE 1750 -#define MITSUBISHI_AC_BIT_MARK 450 -#define MITSUBISHI_AC_ONE_SPACE 1300 -#define MITSUBISHI_AC_ZERO_SPACE 420 -#define MITSUBISHI_AC_RPT_MARK 440 -#define MITSUBISHI_AC_RPT_SPACE 17100L - #define RC5_T1 889 #define RC5_RPT_LENGTH 46000 @@ -160,33 +136,9 @@ #define SHARP_BITS 15 #define DISH_BITS 16 -// Daikin, from https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet/tree/master/IRremote -#define DAIKIN_HDR_MARK 3650 //DAIKIN_ZERO_MARK*8 -#define DAIKIN_HDR_SPACE 1623 //DAIKIN_ZERO_MARK*4 -#define DAIKIN_ONE_SPACE 1280 -#define DAIKIN_ONE_MARK 428 -#define DAIKIN_ZERO_MARK 428 -#define DAIKIN_ZERO_SPACE 428 - -//Denon, from https://github.com/z3t0/Arduino-IRremote/blob/master/ir_Denon.cpp -#define DENON_BITS 14 // The number of bits in the command -#define DENON_HDR_MARK 300 // The length of the Header:Mark -#define DENON_HDR_SPACE 750 // The lenght of the Header:Space -#define DENON_BIT_MARK 300 // The length of a Bit:Mark -#define DENON_ONE_SPACE 1800 // The length of a Bit:Space for 1's -#define DENON_ZERO_SPACE 750 // The length of a Bit:Space for 0's - -#define KELVINATOR_HDR_MARK 8990U -#define KELVINATOR_HDR_SPACE 4490U -#define KELVINATOR_BIT_MARK 675U -#define KELVINATOR_ONE_SPACE 1560U -#define KELVINATOR_ZERO_SPACE 520U -#define KELVINATOR_GAP_SPACE 19950U -#define KELVINATOR_CMD_FOOTER 2U - #define TOLERANCE 25 // percent tolerance in measurements -#define LTOL (1.0 - TOLERANCE/100.) -#define UTOL (1.0 + TOLERANCE/100.) +#define LTOL (1.0 - TOLERANCE/100.) +#define UTOL (1.0 + TOLERANCE/100.) #define _GAP 5000 // Minimum map between transmissions #define GAP_TICKS (_GAP/USECPERTICK) @@ -200,6 +152,9 @@ #define STATE_SPACE 4 #define STATE_STOP 5 +#define ERR 0 +#define DECODED 1 + // information for the interrupt handler typedef struct { uint8_t recvpin; // pin for IR data from detector @@ -207,8 +162,7 @@ typedef struct { unsigned int timer; // state timer, counts 50uS ticks. unsigned int rawbuf[RAWBUF]; // raw data uint8_t rawlen; // counter of entries in rawbuf - uint8_t overflow; -} +} irparams_t; // Defined in IRremote.cpp @@ -231,7 +185,5 @@ extern volatile irparams_t irparams; #define LG_BITS 28 #define SAMSUNG_BITS 32 #define WHYNTER_BITS 32 -#define COOLIX_NBYTES 3 -#define DAIKIN_BITS 99 #endif diff --git a/lib/IRremoteESP8266-1.0.2a/LICENSE.txt b/lib/IRremoteESP8266/LICENSE.txt similarity index 100% rename from lib/IRremoteESP8266-1.0.2a/LICENSE.txt rename to lib/IRremoteESP8266/LICENSE.txt diff --git a/lib/IRremoteESP8266-1.0.2a/README.md b/lib/IRremoteESP8266/README.md similarity index 90% rename from lib/IRremoteESP8266-1.0.2a/README.md rename to lib/IRremoteESP8266/README.md index bb9040cd2..6864df455 100644 --- a/lib/IRremoteESP8266-1.0.2a/README.md +++ b/lib/IRremoteESP8266/README.md @@ -1,7 +1,5 @@ # IRremote ESP8266 Library -[![Build Status](https://travis-ci.org/markszabo/IRremoteESP8266.svg?branch=master)](https://travis-ci.org/markszabo/IRremoteESP8266) - This library enables you to **send and receive** infra-red signals on an ESP8266 using Arduino framework (https://github.com/esp8266/Arduino) This library is based on Ken Shirriff's work (https://github.com/shirriff/Arduino-IRremote/) diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRServer/IRServer.ino b/lib/IRremoteESP8266/examples/IRServer/IRServer.ino similarity index 98% rename from lib/IRremoteESP8266-1.0.2a/examples/IRServer/IRServer.ino rename to lib/IRremoteESP8266/examples/IRServer/IRServer.ino index 94cf929ee..b51ad2c10 100644 --- a/lib/IRremoteESP8266-1.0.2a/examples/IRServer/IRServer.ino +++ b/lib/IRremoteESP8266/examples/IRServer/IRServer.ino @@ -27,7 +27,7 @@ void handleIr(){ if(server.argName(i) == "code") { unsigned long code = server.arg(i).toInt(); - irsend.sendNEC(code, 32); + irsend.sendNEC(code, 36); } } handleRoot(); diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRrecvDemo/IRrecvDemo.ino b/lib/IRremoteESP8266/examples/IRrecvDemo/IRrecvDemo.ino similarity index 100% rename from lib/IRremoteESP8266-1.0.2a/examples/IRrecvDemo/IRrecvDemo.ino rename to lib/IRremoteESP8266/examples/IRrecvDemo/IRrecvDemo.ino diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRrecvDump/IRrecvDump.ino b/lib/IRremoteESP8266/examples/IRrecvDump/IRrecvDump.ino similarity index 100% rename from lib/IRremoteESP8266-1.0.2a/examples/IRrecvDump/IRrecvDump.ino rename to lib/IRremoteESP8266/examples/IRrecvDump/IRrecvDump.ino diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRrecvDumpV2/IRrecvDumpV2.ino b/lib/IRremoteESP8266/examples/IRrecvDumpV2/IRrecvDumpV2.ino similarity index 97% rename from lib/IRremoteESP8266-1.0.2a/examples/IRrecvDumpV2/IRrecvDumpV2.ino rename to lib/IRremoteESP8266/examples/IRrecvDumpV2/IRrecvDumpV2.ino index 877c99268..15a8cf249 100644 --- a/lib/IRremoteESP8266-1.0.2a/examples/IRrecvDumpV2/IRrecvDumpV2.ino +++ b/lib/IRremoteESP8266/examples/IRrecvDumpV2/IRrecvDumpV2.ino @@ -62,11 +62,6 @@ void encoding (decode_results *results) // void dumpInfo (decode_results *results) { - if (results->overflow) { - Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF"); - return; - } - // Show Encoding standard Serial.print("Encoding : "); encoding(results); diff --git a/lib/IRremoteESP8266-1.0.2a/examples/IRsendDemo/IRsendDemo.ino b/lib/IRremoteESP8266/examples/IRsendDemo/IRsendDemo.ino similarity index 93% rename from lib/IRremoteESP8266-1.0.2a/examples/IRsendDemo/IRsendDemo.ino rename to lib/IRremoteESP8266/examples/IRsendDemo/IRsendDemo.ino index 449b79a22..341db61ae 100644 --- a/lib/IRremoteESP8266-1.0.2a/examples/IRsendDemo/IRsendDemo.ino +++ b/lib/IRremoteESP8266/examples/IRsendDemo/IRsendDemo.ino @@ -17,7 +17,7 @@ void setup() void loop() { Serial.println("NEC"); - irsend.sendNEC(0x00FFE01FUL, 32); + irsend.sendNEC(0x00FFE01F, 36); delay(2000); Serial.println("Sony"); irsend.sendSony(0xa90, 12); diff --git a/lib/IRremoteESP8266-1.0.2a/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino b/lib/IRremoteESP8266/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino similarity index 100% rename from lib/IRremoteESP8266-1.0.2a/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino rename to lib/IRremoteESP8266/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino diff --git a/lib/IRremoteESP8266-1.0.2a/keywords.txt b/lib/IRremoteESP8266/keywords.txt similarity index 66% rename from lib/IRremoteESP8266-1.0.2a/keywords.txt rename to lib/IRremoteESP8266/keywords.txt index 7bdc4c91c..607e22610 100644 --- a/lib/IRremoteESP8266-1.0.2a/keywords.txt +++ b/lib/IRremoteESP8266/keywords.txt @@ -21,25 +21,19 @@ resume KEYWORD2 begin KEYWORD2 enableIROut KEYWORD2 sendNEC KEYWORD2 -sendNECRepeat KEYWORD2 sendSony KEYWORD2 sendSanyo KEYWORD2 sendMitsubishi KEYWORD2 sendRaw KEYWORD2 sendRC5 KEYWORD2 sendRC6 KEYWORD2 -sendDISH KEYWORD2 -sendSharp KEYWORD2 -sendSharpRaw KEYWORD2 -sendPanasonic KEYWORD2 -sendJVC KEYWORD2 -sendWhynter KEYWORD2 -sendSAMSUNG KEYWORD2 -sendCOOLIX KEYWORD2 -sendDenon KEYWORD2 -sendKelvinator KEYWORD2 -sendSherwood KEYWORD2 -sendMitsubishiAC KEYWORD2 +sendDISH KEYWORD2 +sendSharp KEYWORD2 +sendSharpRaw KEYWORD2 +sendPanasonic KEYWORD2 +sendJVC KEYWORD2 +sendWhynter KEYWORD2 +sendSAMSUNG KEYWORD2 ####################################### # Constants (LITERAL1) @@ -51,18 +45,13 @@ SANYO LITERAL1 MITSUBISHI LITERAL1 RC5 LITERAL1 RC6 LITERAL1 -DISH LITERAL1 -SHARP LITERAL1 -PANASONIC LITERAL1 -JVC LITERAL1 -LG LITERAL1 +DISH LITERAL1 +SHARP LITERAL1 +PANASONIC LITERAL1 +JVC LITERAL1 +LG LITERAL1 SAMSUNG LITERAL1 WHYNTER LITERAL1 AIWA_RC_T501 LITERAL1 -COOLIX LITERAL1 UNKNOWN LITERAL1 -REPEAT LITERAL1 -DENON LITERAL1 -KELVINATOR LITERAL1 -SHERWOOD LITERAL1 -MITSUBISHIAC LITERAL1 +REPEAT LITERAL1 \ No newline at end of file diff --git a/lib/IRremoteESP8266/library.json b/lib/IRremoteESP8266/library.json new file mode 100644 index 000000000..9327be84f --- /dev/null +++ b/lib/IRremoteESP8266/library.json @@ -0,0 +1,12 @@ +{ + "name": "IRremoteESP8266", + "keywords": "infrared, ir, remote", + "description": "Send and receive infrared signals with multiple protocols", + "repository": + { + "type": "git", + "url": "https://github.com/sebastienwarin/IRremoteESP8266.git" + }, + "frameworks": "arduino", + "platforms": "esp8266" +} diff --git a/lib/IRremoteESP8266/library.properties b/lib/IRremoteESP8266/library.properties new file mode 100644 index 000000000..d031ef778 --- /dev/null +++ b/lib/IRremoteESP8266/library.properties @@ -0,0 +1,9 @@ +name=IRremoteESP8266 +version=1.0.0 +author=Sebastien Warin, Mark Szabo, Ken Shirriff +maintainer=Sebastien Warin +sentence=Send and receive infrared signals with multiple protocols. +paragraph=This library enables you to send and receive infra-red signals on an ESP8266. +category=Device Control +url=https://github.com/sebastienwarin/IRremoteESP8266 +architectures=esp8266