Updated library

This commit is contained in:
arendst 2017-03-29 18:14:16 +02:00
parent ae27ec26a4
commit 659fa92610
32 changed files with 3138 additions and 1437 deletions

View File

@ -0,0 +1,33 @@
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

View File

@ -0,0 +1,13 @@
## 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)

View File

@ -0,0 +1,152 @@
/*
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.h>
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;
}

View File

@ -0,0 +1,100 @@
#include <IRremoteESP8266.h>
#include <Arduino.h>
#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;
};

View File

@ -0,0 +1,233 @@
/*
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 <IRKelvinator.h>
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);
}

View File

@ -0,0 +1,160 @@
#include <IRremoteESP8266.h>
#include <Arduino.h>
#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;
};

View File

@ -0,0 +1,149 @@
/*
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:
* <Add models (A/C & remotes) you've gotten it working with here>
*/
#include <IRMitsubishiAC.h>
// 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);
}

View File

@ -0,0 +1,52 @@
#include <IRremoteESP8266.h>
#include <Arduino.h>
#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;
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,221 @@
/***************************************************
* 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 <stdint.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
/*
* 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

View File

@ -1,7 +1,7 @@
/*************************************************** /***************************************************
* IRremote for ESP8266 * 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 * Version 0.11 August, 2009
* Copyright 2009 Ken Shirriff * Copyright 2009 Ken Shirriff
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
@ -14,8 +14,14 @@
* *
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) * 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 * 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 * GPL license, all text above must be included in any redistribution
****************************************************/ ****************************************************/
@ -32,6 +38,12 @@
// Pulse parms are *50-100 for the Mark and *50+100 for the space // Pulse parms are *50-100 for the Mark and *50+100 for the space
// First MARK is the one after the long gap // First MARK is the one after the long gap
// pulse parameters in usec // 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_MARK 2850
#define WHYNTER_HDR_SPACE 2850 #define WHYNTER_HDR_SPACE 2850
#define WHYNTER_BIT_MARK 750 #define WHYNTER_BIT_MARK 750
@ -46,24 +58,25 @@
#define NEC_ONE_SPACE 1690 #define NEC_ONE_SPACE 1690
#define NEC_ZERO_SPACE 560 #define NEC_ZERO_SPACE 560
#define NEC_RPT_SPACE 2250 #define NEC_RPT_SPACE 2250
#define NEC_MIN_COMMAND_LENGTH 108000UL
#define SONY_HDR_MARK 2400 #define SONY_HDR_MARK 2400
#define SONY_HDR_SPACE 600 #define SONY_HDR_SPACE 600
#define SONY_ONE_MARK 1200 #define SONY_ONE_MARK 1200
#define SONY_ZERO_MARK 600 #define SONY_ZERO_MARK 600
#define SONY_RPT_LENGTH 45000 #define SONY_RPT_LENGTH 45000
#define SONY_DOUBLE_SPACE_USECS 500 // usually ssee 713 - not using ticks as get number wrapround #define SONY_DOUBLE_SPACE_USECS 500 // usually see 713 - not using ticks as get number wrapround
// SA 8650B // SA 8650B
#define SANYO_HDR_MARK 3500 // seen range 3500 #define SANYO_HDR_MARK 3500 // seen range 3500
#define SANYO_HDR_SPACE 950 // seen 950 #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_ZERO_MARK 700 // seen 700
#define SANYO_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround #define SANYO_DOUBLE_SPACE_USECS 800 // usually see 713 - not using ticks as get number wrapround
#define SANYO_RPT_LENGTH 45000 #define SANYO_RPT_LENGTH 45000
// Mitsubishi RM 75501 // 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_MARK 250 // seen range 3500
#define MITSUBISHI_HDR_SPACE 350 // 7*50+100 #define MITSUBISHI_HDR_SPACE 350 // 7*50+100
@ -72,6 +85,17 @@
// #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually ssee 713 - not using ticks as get number wrapround
// #define MITSUBISHI_RPT_LENGTH 45000 // #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_T1 889
#define RC5_RPT_LENGTH 46000 #define RC5_RPT_LENGTH 46000
@ -136,9 +160,33 @@
#define SHARP_BITS 15 #define SHARP_BITS 15
#define DISH_BITS 16 #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 TOLERANCE 25 // percent tolerance in measurements
#define LTOL (1.0 - TOLERANCE/100.) #define LTOL (1.0 - TOLERANCE/100.)
#define UTOL (1.0 + TOLERANCE/100.) #define UTOL (1.0 + TOLERANCE/100.)
#define _GAP 5000 // Minimum map between transmissions #define _GAP 5000 // Minimum map between transmissions
#define GAP_TICKS (_GAP/USECPERTICK) #define GAP_TICKS (_GAP/USECPERTICK)
@ -152,9 +200,6 @@
#define STATE_SPACE 4 #define STATE_SPACE 4
#define STATE_STOP 5 #define STATE_STOP 5
#define ERR 0
#define DECODED 1
// information for the interrupt handler // information for the interrupt handler
typedef struct { typedef struct {
uint8_t recvpin; // pin for IR data from detector uint8_t recvpin; // pin for IR data from detector
@ -162,7 +207,8 @@ typedef struct {
unsigned int timer; // state timer, counts 50uS ticks. unsigned int timer; // state timer, counts 50uS ticks.
unsigned int rawbuf[RAWBUF]; // raw data unsigned int rawbuf[RAWBUF]; // raw data
uint8_t rawlen; // counter of entries in rawbuf uint8_t rawlen; // counter of entries in rawbuf
} uint8_t overflow;
}
irparams_t; irparams_t;
// Defined in IRremote.cpp // Defined in IRremote.cpp
@ -185,5 +231,7 @@ extern volatile irparams_t irparams;
#define LG_BITS 28 #define LG_BITS 28
#define SAMSUNG_BITS 32 #define SAMSUNG_BITS 32
#define WHYNTER_BITS 32 #define WHYNTER_BITS 32
#define COOLIX_NBYTES 3
#define DAIKIN_BITS 99
#endif #endif

View File

@ -1,5 +1,7 @@
# IRremote ESP8266 Library # 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 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/) This library is based on Ken Shirriff's work (https://github.com/shirriff/Arduino-IRremote/)

View File

@ -0,0 +1,26 @@
/*
* 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 <IRremoteESP8266.h>
// 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);
}

View File

@ -0,0 +1,85 @@
/*
* 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 <IRremoteESP8266.h>
#include <IRremoteInt.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
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);
}
}

View File

@ -27,7 +27,7 @@ void handleIr(){
if(server.argName(i) == "code") if(server.argName(i) == "code")
{ {
unsigned long code = server.arg(i).toInt(); unsigned long code = server.arg(i).toInt();
irsend.sendNEC(code, 36); irsend.sendNEC(code, 32);
} }
} }
handleRoot(); handleRoot();

View File

@ -62,6 +62,11 @@ void encoding (decode_results *results)
// //
void dumpInfo (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 // Show Encoding standard
Serial.print("Encoding : "); Serial.print("Encoding : ");
encoding(results); encoding(results);

View File

@ -17,7 +17,7 @@ void setup()
void loop() { void loop() {
Serial.println("NEC"); Serial.println("NEC");
irsend.sendNEC(0x00FFE01F, 36); irsend.sendNEC(0x00FFE01FUL, 32);
delay(2000); delay(2000);
Serial.println("Sony"); Serial.println("Sony");
irsend.sendSony(0xa90, 12); irsend.sendSony(0xa90, 12);

View File

@ -0,0 +1,27 @@
#include <IRDaikinESP.h>
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);
}

View File

@ -0,0 +1,52 @@
#include <IRKelvinator.h>
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);
}

View File

@ -0,0 +1,42 @@
#include <IRMitsubishiAC.h>
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);
}

View File

@ -21,19 +21,25 @@ resume KEYWORD2
begin KEYWORD2 begin KEYWORD2
enableIROut KEYWORD2 enableIROut KEYWORD2
sendNEC KEYWORD2 sendNEC KEYWORD2
sendNECRepeat KEYWORD2
sendSony KEYWORD2 sendSony KEYWORD2
sendSanyo KEYWORD2 sendSanyo KEYWORD2
sendMitsubishi KEYWORD2 sendMitsubishi KEYWORD2
sendRaw KEYWORD2 sendRaw KEYWORD2
sendRC5 KEYWORD2 sendRC5 KEYWORD2
sendRC6 KEYWORD2 sendRC6 KEYWORD2
sendDISH KEYWORD2 sendDISH KEYWORD2
sendSharp KEYWORD2 sendSharp KEYWORD2
sendSharpRaw KEYWORD2 sendSharpRaw KEYWORD2
sendPanasonic KEYWORD2 sendPanasonic KEYWORD2
sendJVC KEYWORD2 sendJVC KEYWORD2
sendWhynter KEYWORD2 sendWhynter KEYWORD2
sendSAMSUNG KEYWORD2 sendSAMSUNG KEYWORD2
sendCOOLIX KEYWORD2
sendDenon KEYWORD2
sendKelvinator KEYWORD2
sendSherwood KEYWORD2
sendMitsubishiAC KEYWORD2
####################################### #######################################
# Constants (LITERAL1) # Constants (LITERAL1)
@ -45,13 +51,18 @@ SANYO LITERAL1
MITSUBISHI LITERAL1 MITSUBISHI LITERAL1
RC5 LITERAL1 RC5 LITERAL1
RC6 LITERAL1 RC6 LITERAL1
DISH LITERAL1 DISH LITERAL1
SHARP LITERAL1 SHARP LITERAL1
PANASONIC LITERAL1 PANASONIC LITERAL1
JVC LITERAL1 JVC LITERAL1
LG LITERAL1 LG LITERAL1
SAMSUNG LITERAL1 SAMSUNG LITERAL1
WHYNTER LITERAL1 WHYNTER LITERAL1
AIWA_RC_T501 LITERAL1 AIWA_RC_T501 LITERAL1
COOLIX LITERAL1
UNKNOWN LITERAL1 UNKNOWN LITERAL1
REPEAT LITERAL1 REPEAT LITERAL1
DENON LITERAL1
KELVINATOR LITERAL1
SHERWOOD LITERAL1
MITSUBISHIAC LITERAL1

View File

@ -0,0 +1,44 @@
{
"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"
}

View File

@ -0,0 +1,9 @@
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

View File

@ -1,20 +0,0 @@
## 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.

File diff suppressed because it is too large Load Diff

View File

@ -1,157 +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
*
* 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

View File

@ -1,12 +0,0 @@
{
"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"
}

View File

@ -1,9 +0,0 @@
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