Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transcold: Add detailed support. #1278

Merged
merged 11 commits into from
Sep 24, 2020
72 changes: 72 additions & 0 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "ir_Technibel.h"
#include "ir_Teco.h"
#include "ir_Toshiba.h"
#include "ir_Transcold.h"
#include "ir_Trotec.h"
#include "ir_Vestel.h"
#include "ir_Voltas.h"
Expand Down Expand Up @@ -261,6 +262,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
#if SEND_TOSHIBA_AC
case decode_type_t::TOSHIBA_AC:
#endif
#if SEND_TRANSCOLD
case decode_type_t::TRANSCOLD:
#endif
#if SEND_TROTEC
case decode_type_t::TROTEC:
#endif
Expand Down Expand Up @@ -2013,6 +2017,48 @@ void IRac::whirlpool(IRWhirlpoolAc *ac, const whirlpool_ac_remote_model_t model,
}
#endif // SEND_WHIRLPOOL_AC

#if SEND_TRANSCOLD
/// Send a Transcold A/C message with the supplied settings.
/// @note May result in multiple messages being sent.
/// @param[in, out] ac A Ptr to an IRTranscoldAc object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @note -1 is Off, >= 0 is on.
void IRac::transcold(IRTranscoldAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv,
const stdAc::swingh_t swingh) {
ac->begin();
ac->setPower(on);
if (!on) {
// after turn off AC no more commands should
// be accepted
ac->send();
return;
}
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
// No Filter setting available.
// No Beep setting available.
// No Clock setting available.
// No Econo setting available.
// No Quiet setting available.
if (swingv != stdAc::swingv_t::kOff || swingh != stdAc::swingh_t::kOff) {
// Swing has a special command that needs to be sent independently.
ac->setSwing();
ac->send();
}

ac->send();
}
#endif // SEND_TRANSCOLD

/// Create a new state base on the provided state that has been suitably fixed.
/// @note This is for use with Home Assistant, which requires mode to be off if
/// the power is off.
Expand Down Expand Up @@ -2040,6 +2086,7 @@ stdAc::state_t IRac::handleToggles(const stdAc::state_t desired,
// Check if we have to handle toggle settings for specific A/C protocols.
switch (desired.protocol) {
case decode_type_t::COOLIX:
case decode_type_t::TRANSCOLD:
if ((desired.swingv == stdAc::swingv_t::kOff) ^
(prev->swingv == stdAc::swingv_t::kOff)) // It changed, so toggle.
result.swingv = stdAc::swingv_t::kAuto;
Expand Down Expand Up @@ -2569,6 +2616,15 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
break;
}
#endif // SEND_WHIRLPOOL_AC
#if SEND_TRANSCOLD
case TRANSCOLD:
{
IRTranscoldAc ac(_pin, _inverted, _modulation);
transcold(&ac, send.power, send.mode, degC, send.fanspeed, send.swingv,
send.swingh);
break;
}
#endif // SEND_TRANSCOLD_AC
default:
return false; // Fail, didn't match anything.
}
Expand Down Expand Up @@ -3272,6 +3328,14 @@ namespace IRAcUtils {
return ac.isValidLgAc() ? ac.toString() : "";
}
#endif // DECODE_LG
#if DECODE_TRANSCOLD
case decode_type_t::TRANSCOLD: {
IRTranscoldAc ac(kGpioUnused);
ac.on();
ac.setRaw(result->value); // TRANSCOLD uses value instead of state.
return ac.toString();
}
#endif // DECODE_TRANSCOLD
default:
return "";
}
Expand Down Expand Up @@ -3668,6 +3732,14 @@ namespace IRAcUtils {
break;
}
#endif // DECODE_WHIRLPOOL_AC
#if DECODE_TRANSCOLD
case decode_type_t::TRANSCOLD: {
IRTranscoldAc ac(kGpioUnused);
ac.setRaw(decode->value); // TRANSCOLD Uses value instead of state.
*result = ac.toCommon(prev);
break;
}
#endif // DECODE_TRANSCOLD
default:
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions src/IRac.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "ir_Technibel.h"
#include "ir_Teco.h"
#include "ir_Toshiba.h"
#include "ir_Transcold.h"
#include "ir_Trotec.h"
#include "ir_Vestel.h"
#include "ir_Voltas.h"
Expand Down Expand Up @@ -429,6 +430,12 @@ void electra(IRElectraAc *ac,
const bool turbo, const bool light,
const int16_t sleep = -1, const int16_t clock = -1);
#endif // SEND_WHIRLPOOL_AC
#if SEND_TRANSCOLD
void transcold(IRTranscoldAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh);
#endif // SEND_TRANSCOLD
static stdAc::state_t cleanState(const stdAc::state_t state);
static stdAc::state_t handleToggles(const stdAc::state_t desired,
const stdAc::state_t *prev = NULL);
Expand Down
3 changes: 2 additions & 1 deletion src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,8 @@ const uint16_t kToshibaACStateLengthShort = kToshibaACStateLength - 2;
const uint16_t kToshibaACBitsShort = kToshibaACStateLengthShort * 8;
const uint16_t kToshibaACStateLengthLong = kToshibaACStateLength + 1;
const uint16_t kToshibaACBitsLong = kToshibaACStateLengthLong * 8;
const uint16_t kTranscoldBits = 48;
const uint16_t kTranscoldBits = 24;
const uint16_t kTranscoldDefaultRepeat = kNoRepeat;
const uint16_t kTrotecStateLength = 9;
const uint16_t kTrotecBits = kTrotecStateLength * 8;
const uint16_t kTrotecDefaultRepeat = kNoRepeat;
Expand Down
2 changes: 1 addition & 1 deletion src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
case MIDEA24:
case NIKAI:
case RCMM:
case TRANSCOLD:
return 24;
case LG:
case LG2:
Expand Down Expand Up @@ -655,7 +656,6 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
return kSanyoLC7461Bits; // 42
case GOODWEATHER:
case MIDEA:
case TRANSCOLD:
case PANASONIC:
return 48;
case MAGIQUEST:
Expand Down
2 changes: 1 addition & 1 deletion src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ class IRsend {
#endif // SEND_METZ
#if SEND_TRANSCOLD
void sendTranscold(const uint64_t data, const uint16_t nbits = kTranscoldBits,
const uint16_t repeat = kNoRepeat);
const uint16_t repeat = kTranscoldDefaultRepeat);
#endif // SEND_TRANSCOLD

protected:
Expand Down
Loading