Skip to content

Commit

Permalink
upgraded IRremoteESP8266 from v1.0.2 to v1.2.0. fixes #188
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Jun 21, 2017
1 parent 3e23031 commit 1c63589
Show file tree
Hide file tree
Showing 13 changed files with 723 additions and 486 deletions.
9 changes: 5 additions & 4 deletions lib/IRremoteESP8266/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
language: c
env:
- BD=esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M
- BD=esp8266:esp8266:d1_mini: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
- wget http://downloads.arduino.cc/arduino-1.8.2-linux64.tar.xz
- tar xf arduino-1.8.2-linux64.tar.xz
- sudo mv arduino-1.8.2 /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/
Expand All @@ -25,7 +26,7 @@ script:
- 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
- arduino --verify --board $BD $PWD/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino

notifications:
email:
Expand Down
36 changes: 18 additions & 18 deletions lib/IRremoteESP8266/IRDaikinESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ IRDaikinESP::IRDaikinESP(int pin) : _irsend(pin)
{
}

void IRDaikinESP::begin()
void ICACHE_FLASH_ATTR IRDaikinESP::begin()
{
_irsend.begin();
}

void IRDaikinESP::send()
void ICACHE_FLASH_ATTR IRDaikinESP::send()
{
_irsend.sendDaikin(daikin);
}

void IRDaikinESP::checksum()
void ICACHE_FLASH_ATTR IRDaikinESP::checksum()
{
uint8_t sum = 0;
uint8_t i;
Expand All @@ -36,39 +36,39 @@ void IRDaikinESP::checksum()
daikin[26] = sum &0xFF;
}

void IRDaikinESP::on()
void ICACHE_FLASH_ATTR IRDaikinESP::on()
{
//state = ON;
daikin[13] |= 0x01;
checksum();
}

void IRDaikinESP::off()
void ICACHE_FLASH_ATTR IRDaikinESP::off()
{
//state = OFF;
daikin[13] &= 0xFE;
checksum();
}

uint8_t IRDaikinESP::getPower()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getPower()
{
return (daikin[13])&0x01;
}

// DAIKIN_SILENT or DAIKIN_POWERFUL
void IRDaikinESP::setAux(uint8_t aux)
void ICACHE_FLASH_ATTR IRDaikinESP::setAux(uint8_t aux)
{
daikin[21] = aux;
checksum();
}

uint8_t IRDaikinESP::getAux(){
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getAux(){
return daikin[21];
}


// Set the temp in deg C
void IRDaikinESP::setTemp(uint8_t temp)
void ICACHE_FLASH_ATTR IRDaikinESP::setTemp(uint8_t temp)
{
if (temp < 18)
temp = 18;
Expand All @@ -78,13 +78,13 @@ void IRDaikinESP::setTemp(uint8_t temp)
checksum();
}

uint8_t IRDaikinESP::getTemp()
uint8_t ICACHE_FLASH_ATTR 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)
void ICACHE_FLASH_ATTR IRDaikinESP::setFan(uint8_t fan)
{
// Set the fan speed bits, leave low 4 bits alone
uint8_t fanset;
Expand All @@ -97,7 +97,7 @@ void IRDaikinESP::setFan(uint8_t fan)
checksum();
}

uint8_t IRDaikinESP::getFan()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getFan()
{
uint8_t fan = daikin[16] >> 4;
fan = fan - 2;
Expand All @@ -106,7 +106,7 @@ uint8_t IRDaikinESP::getFan()
return fan;
}

uint8_t IRDaikinESP::getMode()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getMode()
{/*
DAIKIN_COOL
DAIKIN_HEAT
Expand All @@ -117,13 +117,13 @@ uint8_t IRDaikinESP::getMode()
return (daikin[13])>>4;
}

void IRDaikinESP::setMode(uint8_t mode)
void ICACHE_FLASH_ATTR IRDaikinESP::setMode(uint8_t mode)
{
daikin[13]=mode<<4 | getPower();
checksum();
}

void IRDaikinESP::setSwingVertical(uint8_t swing)
void ICACHE_FLASH_ATTR IRDaikinESP::setSwingVertical(uint8_t swing)
{
if (swing)
daikin[16] = daikin[16] | 0x0F;
Expand All @@ -132,12 +132,12 @@ void IRDaikinESP::setSwingVertical(uint8_t swing)
checksum();
}

uint8_t IRDaikinESP::getSwingVertical()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getSwingVertical()
{
return (daikin[16])&0x01;
}

void IRDaikinESP::setSwingHorizontal(uint8_t swing)
void ICACHE_FLASH_ATTR IRDaikinESP::setSwingHorizontal(uint8_t swing)
{
if (swing)
daikin[17] = daikin[17] | 0x0F;
Expand All @@ -146,7 +146,7 @@ void IRDaikinESP::setSwingHorizontal(uint8_t swing)
checksum();
}

uint8_t IRDaikinESP::getSwingHorizontal()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getSwingHorizontal()
{
return (daikin[17])&0x01;
}
60 changes: 30 additions & 30 deletions lib/IRremoteESP8266/IRKelvinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,36 @@ IRKelvinatorAC::IRKelvinatorAC(int pin) : _irsend(pin) {
stateReset();
}

void IRKelvinatorAC::stateReset() {
void ICACHE_FLASH_ATTR 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() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::begin() {
_irsend.begin();
}

void IRKelvinatorAC::fixup() {
void ICACHE_FLASH_ATTR 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() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::send() {
fixup(); // Ensure correct settings before sending.
_irsend.sendKelvinator(remote_state);
}

uint8_t* IRKelvinatorAC::getRaw() {
uint8_t* ICACHE_FLASH_ATTR IRKelvinatorAC::getRaw() {
fixup(); // Ensure correct settings before sending.
return remote_state;
}

// Many Bothans died to bring us this information.
void IRKelvinatorAC::checksum() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::checksum() {
// For each command + options block.
for (uint8_t offset = 0; offset < KELVINATOR_STATE_LENGTH; offset += 8) {
uint8_t sum = KELVINATOR_CHECKSUM_START;
Expand All @@ -68,44 +68,44 @@ void IRKelvinatorAC::checksum() {
}
}

void IRKelvinatorAC::on() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::on() {
//state = ON;
remote_state[0] |= KELVINATOR_POWER;
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}

void IRKelvinatorAC::off() {
void ICACHE_FLASH_ATTR 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) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setPower(bool state) {
if (state)
on();
else
off();
}

bool IRKelvinatorAC::getPower() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getPower() {
return ((remote_state[0] & KELVINATOR_POWER) != 0);
}

// Set the temp. in deg C
void IRKelvinatorAC::setTemp(uint8_t temp) {
void ICACHE_FLASH_ATTR 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() {
uint8_t ICACHE_FLASH_ATTR 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) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setFan(uint8_t fan) {
fan = min(KELVINATOR_FAN_MAX, fan); // Bounds check

// Only change things if we need to.
Expand All @@ -122,11 +122,11 @@ void IRKelvinatorAC::setFan(uint8_t fan) {
}
}

uint8_t IRKelvinatorAC::getFan() {
uint8_t ICACHE_FLASH_ATTR IRKelvinatorAC::getFan() {
return ((remote_state[14] & ~KELVINATOR_FAN_MASK) >> KELVINATOR_FAN_OFFSET);
}

uint8_t IRKelvinatorAC::getMode() {
uint8_t ICACHE_FLASH_ATTR IRKelvinatorAC::getMode() {
/*
KELVINATOR_AUTO
KELVINATOR_COOL
Expand All @@ -137,7 +137,7 @@ uint8_t IRKelvinatorAC::getMode() {
return (remote_state[0] & ~KELVINATOR_MODE_MASK);
}

void IRKelvinatorAC::setMode(uint8_t mode) {
void ICACHE_FLASH_ATTR 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;
Expand All @@ -147,7 +147,7 @@ void IRKelvinatorAC::setMode(uint8_t mode) {
setTemp(KELVINATOR_AUTO_TEMP);
}

void IRKelvinatorAC::setSwingVertical(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setSwingVertical(bool state) {
if (state) {
remote_state[0] |= KELVINATOR_VENT_SWING;
remote_state[4] |= KELVINATOR_VENT_SWING_V;
Expand All @@ -160,11 +160,11 @@ void IRKelvinatorAC::setSwingVertical(bool state) {
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}

bool IRKelvinatorAC::getSwingVertical() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getSwingVertical() {
return ((remote_state[4] & KELVINATOR_VENT_SWING_V) != 0);
}

void IRKelvinatorAC::setSwingHorizontal(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setSwingHorizontal(bool state) {
if (state) {
remote_state[0] |= KELVINATOR_VENT_SWING;
remote_state[4] |= KELVINATOR_VENT_SWING_H;
Expand All @@ -177,57 +177,57 @@ void IRKelvinatorAC::setSwingHorizontal(bool state) {
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}

bool IRKelvinatorAC::getSwingHorizontal() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getSwingHorizontal() {
return ((remote_state[4] & KELVINATOR_VENT_SWING_H) != 0);
}

void IRKelvinatorAC::setQuiet(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setQuiet(bool state) {
remote_state[12] &= ~KELVINATOR_QUIET;
remote_state[12] |= (state << KELVINATOR_QUIET_OFFSET);
}

bool IRKelvinatorAC::getQuiet() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getQuiet() {
return ((remote_state[12] & KELVINATOR_QUIET) != 0);
}

void IRKelvinatorAC::setIonFilter(bool state) {
void ICACHE_FLASH_ATTR 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() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getIonFilter() {
return ((remote_state[2] & KELVINATOR_ION_FILTER) != 0);
}

void IRKelvinatorAC::setLight(bool state) {
void ICACHE_FLASH_ATTR 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() {
bool ICACHE_FLASH_ATTR 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) {
void ICACHE_FLASH_ATTR 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() {
bool ICACHE_FLASH_ATTR 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) {
void ICACHE_FLASH_ATTR 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() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getTurbo() {
return ((remote_state[2] & KELVINATOR_TURBO) != 0);
}
Loading

2 comments on commit 1c63589

@nonflammable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to v1.2.0 ? not v2.0 ?

@psy0rz
Copy link
Member Author

@psy0rz psy0rz commented on 1c63589 Jun 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, 2.0 breaks existing code. (api changed)

Please sign in to comment.