Skip to content

Commit

Permalink
Experimental detailed support for Truma A/Cs. (#1449)
Browse files Browse the repository at this point in the history
* add `sendTruma()` & `decodeTruma()`.
* update ancillary routines as needed.
* Support settings of:
  - Power
  - Temperature
  - Operating Mode
  - Fan Speed
  - Quiet
  - Checksums.
* Update `IRac` class to add support as described.
* Add unit test coverage for new protocol & class.

Fixes #1440
  • Loading branch information
crankyoldgit committed Apr 4, 2021
1 parent cd8d600 commit 77ba26b
Show file tree
Hide file tree
Showing 13 changed files with 880 additions and 1 deletion.
58 changes: 58 additions & 0 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "ir_Toshiba.h"
#include "ir_Transcold.h"
#include "ir_Trotec.h"
#include "ir_Truma.h"
#include "ir_Vestel.h"
#include "ir_Voltas.h"
#include "ir_Whirlpool.h"
Expand Down Expand Up @@ -275,6 +276,9 @@ bool IRac::isProtocolSupported(const decode_type_t protocol) {
#if SEND_TROTEC
case decode_type_t::TROTEC:
#endif
#if SEND_TRUMA
case decode_type_t::TRUMA:
#endif // SEND_TRUMA
#if SEND_VESTEL_AC
case decode_type_t::VESTEL_AC:
#endif
Expand Down Expand Up @@ -1980,6 +1984,37 @@ void IRac::trotec(IRTrotecESP *ac,
}
#endif // SEND_TROTEC

#if SEND_TRUMA
/// Send a Truma A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRTrumaAc 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] quiet Run the device quietly if we can.
void IRac::truma(IRTrumaAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const bool quiet) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setQuiet(quiet); // Only available in Cool mode.
// No Vertical swing setting available.
// No Horizontal swing setting available.
// No Turbo setting available.
// No Light setting available.
// No Filter setting available.
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
// No Clock setting available.
ac->send();
}
#endif // SEND_TRUMA

#if SEND_VESTEL_AC
/// Send a Vestel A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRVestelAc object to use.
Expand Down Expand Up @@ -2713,6 +2748,14 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
break;
}
#endif // SEND_TROTEC
#if SEND_TRUMA
case TRUMA:
{
IRTrumaAc ac(_pin, _inverted, _modulation);
truma(&ac, send.power, send.mode, degC, send.fanspeed, send.quiet);
break;
}
#endif // SEND_TRUMA
#if SEND_VESTEL_AC
case VESTEL_AC:
{
Expand Down Expand Up @@ -3298,6 +3341,13 @@ namespace IRAcUtils {
return ac.toString();
}
#endif // DECODE_TROTEC
#if DECODE_TRUMA
case decode_type_t::TRUMA: {
IRTrumaAc ac(kGpioUnused);
ac.setRaw(result->value); // Truma uses value instead of state.
return ac.toString();
}
#endif // DECODE_TRUMA
#if DECODE_GOODWEATHER
case decode_type_t::GOODWEATHER: {
IRGoodweatherAc ac(kGpioUnused);
Expand Down Expand Up @@ -3878,6 +3928,14 @@ namespace IRAcUtils {
break;
}
#endif // DECODE_TROTEC
#if DECODE_TRUMA
case decode_type_t::TRUMA: {
IRTrumaAc ac(kGpioUnused);
ac.setRaw(decode->value); // Uses value instead of state.
*result = ac.toCommon();
break;
}
#endif // DECODE_TRUMA
#if DECODE_VESTEL_AC
case decode_type_t::VESTEL_AC: {
IRVestelAc ac(kGpioUnused);
Expand Down
6 changes: 6 additions & 0 deletions src/IRac.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "ir_Toshiba.h"
#include "ir_Transcold.h"
#include "ir_Trotec.h"
#include "ir_Truma.h"
#include "ir_Vestel.h"
#include "ir_Voltas.h"
#include "ir_Whirlpool.h"
Expand Down Expand Up @@ -420,6 +421,11 @@ void electra(IRElectraAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const int16_t sleep = -1);
#endif // SEND_TROTEC
#if SEND_TRUMA
void truma(IRTrumaAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const bool quiet);
#endif // SEND_TRUMA
#if SEND_VESTEL_AC
void vestel(IRVestelAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
Expand Down
5 changes: 5 additions & 0 deletions src/IRrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,11 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
DPRINTLN("Attempting Doshisha decode");
if (decodeDoshisha(results, offset)) return true;
#endif // DECODE_DOSHISHA
#if DECODE_TRUMA
// Needs to happen before decodeMultibrackets() as they can appear similar.
DPRINTLN("Attempting Truma decode");
if (decodeTruma(results, offset)) return true;
#endif // DECODE_TRUMA
#if DECODE_MULTIBRACKETS
DPRINTLN("Attempting Multibrackets decode");
if (decodeMultibrackets(results, offset)) return true;
Expand Down
4 changes: 4 additions & 0 deletions src/IRrecv.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@ class IRrecv {
bool decodeXmp(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kXmpBits, const bool strict = true);
#endif // DECODE_XMP
#if DECODE_TRUMA
bool decodeTruma(decode_results *results, uint16_t offset = kStartOffset,
const uint16_t nbits = kTrumaBits, const bool strict = true);
#endif // DECODE_TRUMA
};

#endif // IRRECV_H_
11 changes: 10 additions & 1 deletion src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,13 @@
#define SEND_XMP _IR_ENABLE_DEFAULT_
#endif // SEND_XMP

#ifndef DECODE_TRUMA
#define DECODE_TRUMA _IR_ENABLE_DEFAULT_
#endif // DECODE_TRUMA
#ifndef SEND_TRUMA
#define SEND_TRUMA _IR_ENABLE_DEFAULT_
#endif // SEND_TRUMA

#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
Expand Down Expand Up @@ -891,8 +898,9 @@ enum decode_type_t {
MILESTAG2,
ECOCLIM,
XMP,
TRUMA, // 100
// Add new entries before this one, and update it to point to the last entry.
kLastDecodeType = XMP,
kLastDecodeType = TRUMA,
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -1111,6 +1119,7 @@ const uint16_t kTranscoldDefaultRepeat = kNoRepeat;
const uint16_t kTrotecStateLength = 9;
const uint16_t kTrotecBits = kTrotecStateLength * 8;
const uint16_t kTrotecDefaultRepeat = kNoRepeat;
const uint16_t kTrumaBits = 56;
const uint16_t kWhirlpoolAcStateLength = 21;
const uint16_t kWhirlpoolAcBits = kWhirlpoolAcStateLength * 8;
const uint16_t kWhirlpoolAcDefaultRepeat = kNoRepeat;
Expand Down
6 changes: 6 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
case MAGIQUEST:
case VESTEL_AC:
case TECHNIBEL_AC:
case TRUMA:
return 56;
case AMCOR:
case CARRIER_AC64:
Expand Down Expand Up @@ -1022,6 +1023,11 @@ bool IRsend::send(const decode_type_t type, const uint64_t data,
sendTranscold(data, nbits, min_repeat);
break;
#endif // SEND_TRANSCOLD
#if SEND_TRUMA
case TRUMA:
sendTruma(data, nbits, min_repeat);
break;
#endif // SEND_TRUMA
#if SEND_VESTEL_AC
case VESTEL_AC:
sendVestelAc(data, nbits, min_repeat);
Expand Down
4 changes: 4 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,10 @@ class IRsend {
void sendXmp(const uint64_t data, const uint16_t nbits = kXmpBits,
const uint16_t repeat = kNoRepeat);
#endif // SEND_XMP
#if SEND_TRUMA
void sendTruma(const uint64_t data, const uint16_t nbits = kTrumaBits,
const uint16_t repeat = kNoRepeat);
#endif // SEND_TRUMA

protected:
#ifdef UNIT_TEST
Expand Down
1 change: 1 addition & 0 deletions src/IRtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,6 @@ const PROGMEM char *kAllProtocolNamesStr =
D_STR_MILESTAG2 "\x0"
D_STR_ECOCLIM "\x0"
D_STR_XMP "\x0"
D_STR_TRUMA "\x0"
///< New protocol strings should be added just above this line.
"\x0"; ///< This string requires double null termination.
Loading

0 comments on commit 77ba26b

Please sign in to comment.