Skip to content

Commit

Permalink
Added common sensor temp. support to all protos exposing iFeel already
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Bronk <[email protected]>
  • Loading branch information
mbronk committed Dec 4, 2022
1 parent 4065940 commit 0abf6cc
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 61 deletions.
123 changes: 87 additions & 36 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,19 +469,27 @@ void IRac::amcor(IRAmcorAc *ac,
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] sleep Nr. of minutes for sleep mode.
/// @note -1 is Off, >= 0 is on.
void IRac::argo(IRArgoAC *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swingv,
const float sensorTemp, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const bool iFeel,
const bool turbo, const int16_t sleep) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setTemp(static_cast<uint8_t>(degrees + 0.5));
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5));
}
ac->setiFeel(iFeel);
ac->setFan(ac->convertFan(fan));
ac->setFlap(ac->convertSwingV(swingv));
// No Quiet setting available.
Expand Down Expand Up @@ -523,9 +531,9 @@ void IRac::argoWrem3_ACCommand(IRArgoAC_WREM3 *ac, const bool on,
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5));
}
ac->setiFeel(iFeel);
ac->setFan(ac->convertFan(fan));
ac->setFlap(ac->convertSwingV(swingv));
ac->setiFeel(iFeel);
ac->setNight(night);
ac->setEco(econo);
ac->setMax(turbo);
Expand Down Expand Up @@ -683,20 +691,24 @@ void IRac::carrier64(IRCarrierAc64 *ac,
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
/// @param[in] sleep Nr. of minutes for sleep mode.
/// @note -1 is Off, >= 0 is on.
void IRac::coolix(IRCoolixAC *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh,
const bool turbo, const bool light, const bool clean,
const int16_t sleep) {
const bool iFeel, const bool turbo, const bool light,
const bool clean, const int16_t sleep) {
ac->begin();
ac->setPower(on);
if (!on) {
Expand All @@ -713,6 +725,12 @@ void IRac::coolix(IRCoolixAC *ac,
// No Clock setting available.
// No Econo setting available.
// No Quiet setting available.
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5));
} else {
ac->clearSensorTemp();
}
ac->setZoneFollow(iFeel);
ac->send(); // Send the state, which will also power on the unit.
// The following are all options/settings that create their own special
// messages. Often they only make sense to be sent after the unit is turned
Expand Down Expand Up @@ -1077,13 +1095,16 @@ void IRac::delonghiac(IRDelonghiAc *ac,
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] sleep Nr. of minutes for sleep mode. -1 is Off, >= 0 is on.
/// @param[in] clock The time in Nr. of mins since midnight. < 0 is ignore.
void IRac::ecoclim(IREcoclimAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const int16_t sleep, const int16_t clock) {
const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan, const int16_t sleep,
const int16_t clock) {
ac->begin();
ac->setPower(on);
uint8_t new_mode;
Expand All @@ -1093,8 +1114,13 @@ void IRac::ecoclim(IREcoclimAc *ac,
new_mode = ac->convertMode(mode); // Not Sleep, so use the supplied mode.
ac->setMode(new_mode);
ac->setTemp(degrees);
ac->setSensorTemp(degrees); //< Set to the desired temp until we cab disable.
ac->setFan(ac->convertFan(fan));
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5));
} else {
ac->setSensorTemp(degrees); //< Set to the desired temp
// until we cab disable.
}
// No SwingV setting available
// No SwingH setting available
// No Quiet setting available.
Expand All @@ -1116,22 +1142,28 @@ void IRac::ecoclim(IREcoclimAc *ac,
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] lighttoggle Should we toggle the LED/Display?
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
void IRac::electra(IRElectraAc *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, const bool turbo,
const bool lighttoggle, const bool clean) {
const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swingv,
const stdAc::swingh_t swingh, const bool iFeel,
const bool turbo, const bool lighttoggle, const bool clean) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5));
}
ac->setFan(ac->convertFan(fan));
ac->setSwingV(swingv != stdAc::swingv_t::kOff);
ac->setSwingH(swingh != stdAc::swingh_t::kOff);
Expand All @@ -1144,6 +1176,7 @@ void IRac::electra(IRElectraAc *ac,
// No Beep setting available.
// No Sleep setting available.
// No Clock setting available.
ac->setIFeel(iFeel);
ac->send();
}
#endif // SEND_ELECTRA_AC
Expand Down Expand Up @@ -1269,6 +1302,7 @@ void IRac::goodweather(IRGoodweatherAc *ac,
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] econo Toggle the device's economical mode.
/// @param[in] light Turn on the LED/Display mode.
Expand All @@ -1278,8 +1312,8 @@ void IRac::gree(IRGreeAC *ac, const gree_ac_remote_model_t model,
const bool on, const stdAc::opmode_t mode, const bool celsius,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh,
const bool turbo, const bool econo, const bool light,
const bool clean, const int16_t sleep) {
const bool iFeel, const bool turbo, const bool econo,
const bool light, const bool clean, const int16_t sleep) {
ac->begin();
ac->setModel(model);
ac->setPower(on);
Expand All @@ -1289,6 +1323,7 @@ void IRac::gree(IRGreeAC *ac, const gree_ac_remote_model_t model,
ac->setSwingVertical(swingv == stdAc::swingv_t::kAuto, // Set auto flag.
ac->convertSwingV(swingv));
ac->setSwingHorizontal(ac->convertSwingH(swingh));
ac->setIFeel(iFeel);
ac->setLight(light);
ac->setTurbo(turbo);
ac->setEcono(econo);
Expand Down Expand Up @@ -1798,8 +1833,11 @@ void IRac::lg(IRLgAc *ac, const lg_ac_remote_model_t model,
/// @param[in] mode The operation mode setting.
/// @param[in] celsius Temperature units. True is Celsius, False is Fahrenheit.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading
/// in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @param[in] quiet_prev The device's previous quiet/silent mode.
/// @param[in] turbo Toggle the device's turbo/powerful mode.
Expand All @@ -1810,16 +1848,20 @@ void IRac::lg(IRLgAc *ac, const lg_ac_remote_model_t model,
/// @note On Danby A/C units, swingv controls the Ion Filter instead.
void IRac::midea(IRMideaAC *ac,
const bool on, const stdAc::opmode_t mode, const bool celsius,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv,
const bool quiet, const bool quiet_prev,
const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swingv,
const bool iFeel, const bool quiet, const bool quiet_prev,
const bool turbo, const bool econo, const bool light,
const bool clean, const int16_t sleep) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setUseCelsius(celsius);
ac->setTemp(degrees, celsius);
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(sensorTemp, celsius);
}
ac->setEnableSensorTemp(iFeel);
ac->setFan(ac->convertFan(fan));
ac->setSwingVToggle(swingv != stdAc::swingv_t::kOff);
// No Horizontal swing setting available.
Expand Down Expand Up @@ -2217,19 +2259,28 @@ void IRac::samsung(IRSamsungAc *ac,
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] beep Enable/Disable beeps when receiving IR messages.
/// @param[in] sleep Nr. of minutes for sleep mode. -1 is Off, >= 0 is on.
void IRac::sanyo(IRSanyoAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const bool beep,
const int16_t sleep) {
const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swingv,
const bool iFeel, const bool beep, const int16_t sleep) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(sensorTemp + 0.5));
} else {
ac->setSensorTemp(degrees); // Set the sensor temp to the desired temp.
}
ac->setSensor(!iFeel);
ac->setFan(ac->convertFan(fan));
ac->setSwingV(ac->convertSwingV(swingv));
// No Horizontal swing setting available.
Expand All @@ -2242,10 +2293,6 @@ void IRac::sanyo(IRSanyoAc *ac,
ac->setBeep(beep);
ac->setSleep(sleep >= 0); // Sleep is either on/off, so convert to boolean.
// No Clock setting available.

// Extra
ac->setSensor(true); // Set the A/C to use the temp sensor in the Unit/Wall.
ac->setSensorTemp(degrees); // Set the sensor temp to the desired temp.
ac->send();
}
#endif // SEND_SANYO_AC
Expand Down Expand Up @@ -3018,8 +3065,8 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
OUTPUT_DECODE_RESULTS_FOR_UT(ac);
} else {
IRArgoAC ac(_pin, _inverted, _modulation);
argo(&ac, send.power, send.mode, degC, send.fanspeed, send.swingv,
send.turbo, send.sleep);
argo(&ac, send.power, send.mode, degC, sensorTempC, send.fanspeed,
send.swingv, send.iFeel, send.turbo, send.sleep);
OUTPUT_DECODE_RESULTS_FOR_UT(ac);
}
break;
Expand All @@ -3046,8 +3093,9 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
case COOLIX:
{
IRCoolixAC ac(_pin, _inverted, _modulation);
coolix(&ac, send.power, send.mode, degC, send.fanspeed, send.swingv,
send.swingh, send.turbo, send.light, send.clean, send.sleep);
coolix(&ac, send.power, send.mode, degC, sensorTempC, send.fanspeed,
send.swingv, send.swingh, send.iFeel, send.turbo, send.light,
send.clean, send.sleep);
break;
}
#endif // SEND_COOLIX
Expand Down Expand Up @@ -3145,16 +3193,18 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
case ECOCLIM:
{
IREcoclimAc ac(_pin, _inverted, _modulation);
ecoclim(&ac, send.power, send.mode, degC, send.fanspeed, send.clock);
ecoclim(&ac, send.power, send.mode, degC, sensorTempC, send.fanspeed,
send.iFeel, send.clock);
break;
}
#endif // SEND_ECOCLIM
#if SEND_ELECTRA_AC
case ELECTRA_AC:
{
IRElectraAc ac(_pin, _inverted, _modulation);
electra(&ac, send.power, send.mode, degC, send.fanspeed, send.swingv,
send.swingh, send.turbo, send.light, send.clean);
electra(&ac, send.power, send.mode, degC, sensorTempC, send.fanspeed,
send.swingv, send.swingh, send.iFeel, send.turbo, send.light,
send.clean);
break;
}
#endif // SEND_ELECTRA_AC
Expand Down Expand Up @@ -3322,8 +3372,9 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
{
IRMideaAC ac(_pin, _inverted, _modulation);
midea(&ac, send.power, send.mode, send.celsius, send.degrees,
send.fanspeed, send.swingv, send.quiet, prev_quiet, send.turbo,
send.econo, send.light, send.sleep);
send.sensorTemperature, send.fanspeed, send.swingv, send.iFeel,
send.quiet, prev_quiet, send.turbo, send.econo, send.light,
send.sleep);
break;
}
#endif // SEND_MIDEA
Expand Down Expand Up @@ -3432,8 +3483,8 @@ bool IRac::sendAc(const stdAc::state_t desired, const stdAc::state_t *prev) {
case SANYO_AC:
{
IRSanyoAc ac(_pin, _inverted, _modulation);
sanyo(&ac, send.power, send.mode, degC, send.fanspeed, send.swingv,
send.beep, send.sleep);
sanyo(&ac, send.power, send.mode, degC, sensorTempC, send.fanspeed,
send.swingv, send.iFeel, send.beep, send.sleep);
break;
}
#endif // SEND_SANYO_AC
Expand Down
Loading

0 comments on commit 0abf6cc

Please sign in to comment.