diff --git a/src/ir_Trotec.cpp b/src/ir_Trotec.cpp index 230ea22e2..8a0b3b2ab 100644 --- a/src/ir_Trotec.cpp +++ b/src/ir_Trotec.cpp @@ -347,7 +347,7 @@ bool IRrecv::decodeTrotec(decode_results *results, uint16_t offset, #if SEND_TROTEC_3550 /// Send a Trotec 3550 message. -/// Status: BETA / Probably works. Untested on real device. +/// Status: STABLE / Known to be working. /// @param[in] data The message to be sent. /// @param[in] nbytes The number of bytes of message to be sent. /// @param[in] repeat The number of times the command is to be repeated. @@ -491,21 +491,32 @@ uint8_t IRTrotec3550::getMode(void) const { return _.Mode; } /// Set the temperature. /// @param[in] degrees The temperature in degrees. /// @param[in] celsius Use celsius units. True, Celsius; False Fahrenheit. -/// @note Fahrenheit is not yet supported. Waiting on data analysis. void IRTrotec3550::setTemp(const uint8_t degrees, const bool celsius) { setTempUnit(celsius); uint8_t minTemp = kTrotec3550MinTempC; uint8_t maxTemp = kTrotec3550MaxTempC; + if (!celsius) { // Fahrenheit? + minTemp = kTrotec3550MinTempF; + maxTemp = kTrotec3550MaxTempF; + } uint8_t temp = std::max(degrees, minTemp); temp = std::min(temp, maxTemp); - _.Temp = _.Temp2 = temp - minTemp; + if (celsius) { + _.TempC = temp - minTemp; + _.TempF = celsiusToFahrenheit(temp) - kTrotec3550MinTempF; + } else { + _.TempF = temp - minTemp; + _.TempC = fahrenheitToCelsius(temp) - kTrotec3550MinTempC; + } } /// Get the current temperature setting. /// @return The current setting for temp. in degrees. -/// @note Fahrenheit is not yet supported. Waiting on data analysis. uint8_t IRTrotec3550::getTemp(void) const { - return _.Temp + kTrotec3550MinTempC; + if (getTempUnit()) // Is Celsius? + return _.TempC + kTrotec3550MinTempC; + else + return _.TempF + kTrotec3550MinTempF; } /// Set the temperature unit that the A/C will use.. @@ -582,7 +593,7 @@ stdAc::state_t IRTrotec3550::toCommon(void) const { result.protocol = decode_type_t::TROTEC_3550; result.power = _.Power; result.mode = toCommonMode(_.Mode); - result.celsius = _.Celsius; + result.celsius = getTempUnit(); result.degrees = getTemp(); result.fanspeed = toCommonFanSpeed(_.Fan); result.swingv = _.SwingV ? stdAc::swingv_t::kAuto : stdAc::swingv_t::kOff; diff --git a/src/ir_Trotec.h b/src/ir_Trotec.h index 983f0a7fe..fd49ecef8 100644 --- a/src/ir_Trotec.h +++ b/src/ir_Trotec.h @@ -86,12 +86,11 @@ union Trotec3550Protocol{ uint8_t Power :1; uint8_t :1; // Unknown uint8_t TimerSet :1; - uint8_t Temp :4; // Temp +16 for degC) + uint8_t TempC :4; // Temp + kTrotec3550MinTempC for degC) // Byte 2 uint8_t :8; // Unknown // Byte 3 - uint8_t :1; // Unknown - uint8_t Temp2 :4; // Temp +16 for degC) + uint8_t TempF :5; // Temp + kTrotec3550MinTempF for degF) uint8_t :3; // Unknown // Byte 4 uint8_t :8; // Unknown @@ -111,8 +110,9 @@ union Trotec3550Protocol{ }; const uint8_t kTrotec3550MinTempC = 16; -const uint8_t kTrotec3550DefTempC = 25; const uint8_t kTrotec3550MaxTempC = 30; +const uint8_t kTrotec3550MinTempF = 59; +const uint8_t kTrotec3550MaxTempF = 86; // Legacy defines. (Deprecated) #define TROTEC_AUTO kTrotecAuto diff --git a/test/ir_Trotec_test.cpp b/test/ir_Trotec_test.cpp index 11b581281..fa06ca81b 100644 --- a/test/ir_Trotec_test.cpp +++ b/test/ir_Trotec_test.cpp @@ -280,8 +280,10 @@ TEST(TestTrotec3550Class, SetAndGetFan) { TEST(TestTrotec3550Class, SetAndGetTemp) { IRTrotec3550 ac(kGpioUnused); + // Celsius ac.setTemp(25); EXPECT_EQ(25, ac.getTemp()); + EXPECT_TRUE(ac.getTempUnit()); ac.setTemp(kTrotec3550MinTempC); EXPECT_EQ(kTrotec3550MinTempC, ac.getTemp()); ac.setTemp(kTrotec3550MaxTempC); @@ -290,6 +292,26 @@ TEST(TestTrotec3550Class, SetAndGetTemp) { EXPECT_EQ(kTrotec3550MinTempC, ac.getTemp()); ac.setTemp(kTrotec3550MaxTempC + 1); EXPECT_EQ(kTrotec3550MaxTempC, ac.getTemp()); + // Fahrenheit + ac.setTemp(72, false); + EXPECT_EQ(72, ac.getTemp()); + EXPECT_FALSE(ac.getTempUnit()); + ac.setTemp(kTrotec3550MinTempF, false); + EXPECT_EQ(kTrotec3550MinTempF, ac.getTemp()); + ac.setTemp(kTrotec3550MaxTempF, false); + EXPECT_EQ(kTrotec3550MaxTempF, ac.getTemp()); + ac.setTemp(kTrotec3550MinTempF - 1, false); + EXPECT_EQ(kTrotec3550MinTempF, ac.getTemp()); + ac.setTemp(kTrotec3550MaxTempF + 1, false); + EXPECT_EQ(kTrotec3550MaxTempF, ac.getTemp()); + // Celsius + ac.setTemp(25, true); + EXPECT_EQ(25, ac.getTemp()); + EXPECT_TRUE(ac.getTempUnit()); + uint8_t deg79F[9] = {0x55, 0xA3, 0x00, 0x14, 0x00, 0x00, 0x31, 0x40, 0x7D}; + ac.setRaw(deg79F); + EXPECT_FALSE(ac.getTempUnit()); // Fahrenheit + EXPECT_EQ(79, ac.getTemp()); } TEST(TestTrotec3550Class, SwingV) {