diff --git a/src/ir_Argo.cpp b/src/ir_Argo.cpp index 06e7f0c08..885406faf 100644 --- a/src/ir_Argo.cpp +++ b/src/ir_Argo.cpp @@ -23,6 +23,9 @@ const uint16_t kArgoOneSpace = 2200; const uint16_t kArgoZeroSpace = 900; const uint32_t kArgoGap = kDefaultMessageGap; // Made up value. Complete guess. +const uint8_t kArgoSensorCheck = 52; // Part of the sensor message check calc. +const uint8_t kArgoSensorFixed = 0b011; + using irutils::addBoolToString; using irutils::addIntToString; using irutils::addLabeledString; @@ -64,23 +67,21 @@ void IRArgoAC::send(const uint16_t repeat) { /// Send current room temperature for the iFeel feature as a silent IR /// message (no acknowledgement from the device). -/// @param[in] temp The temperature in degrees celsius. +/// @param[in] degrees The temperature in degrees celsius. /// @param[in] repeat Nr. of times the message will be repeated. -void IRArgoAC::sendSensorTemp(const uint8_t temp, const uint16_t repeat) { - const uint8_t tempc = temp - kArgoTempDelta; - const uint8_t check = 52 + tempc; - const uint8_t end = 0b011; - - ArgoProtocol data; - _stateReset(&data); - // data.raw[2] = (tempc << 3) | (check >> 5); - data.SensorT = tempc; - data.CheckHi = check >> 5; - // data.raw[3] = (check << 3) | end; - data.CheckLo = check; - data.Fixed = end; - _checksum(&data); - _irsend.sendArgo(data.raw, kArgoStateLength, repeat); +void IRArgoAC::sendSensorTemp(const uint8_t degrees, const uint16_t repeat) { + const uint8_t temp = std::max(std::min(degrees, kArgoMaxRoomTemp), + kArgoTempDelta) - kArgoTempDelta; + const uint8_t check = kArgoSensorCheck + temp; + + ArgoProtocol data; + _stateReset(&data); + data.SensorT = temp; + data.CheckHi = check >> 5; + data.CheckLo = check; + data.Fixed = kArgoSensorFixed; + _checksum(&data); + _irsend.sendArgo(data.raw, kArgoStateLength, repeat); } #endif // SEND_ARGO diff --git a/src/ir_Argo.h b/src/ir_Argo.h index 2097712a6..e0ead8e26 100644 --- a/src/ir_Argo.h +++ b/src/ir_Argo.h @@ -1,4 +1,5 @@ // Copyright 2017 Schmolders +// Copyright 2022 crankyoldgit /// @file /// @brief Support for Argo Ulisse 13 DCI Mobile Split ACs. @@ -145,7 +146,7 @@ class IRArgoAC { #if SEND_ARGO void send(const uint16_t repeat = kArgoDefaultRepeat); - void sendSensorTemp(const uint8_t temp, + void sendSensorTemp(const uint8_t degrees, const uint16_t repeat = kArgoDefaultRepeat); /// Run the calibration to calculate uSec timing offsets for this platform. /// @return The uSec timing offset needed per modulation of the IR Led.