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

SamsungAc: Change beep setting to a toggle. #1671

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/IRac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ void IRac::panasonic32(IRPanasonicAc32 *ac,
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] filter Turn on the (ion/pollen/etc) filter mode.
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
/// @param[in] beep Enable/Disable beeps when receiving IR messages.
/// @param[in] beep Toggle beep setting for receiving IR messages.
/// @param[in] sleep Nr. of minutes for sleep mode. <= 0 is Off, > 0 is on.
/// @param[in] prevpower The power setting from the previous A/C state.
/// @param[in] prevsleep Nr. of minutes for sleep from the previous A/C state.
Expand Down Expand Up @@ -1853,7 +1853,7 @@ void IRac::samsung(IRSamsungAc *ac,
ac->setEcono(econo);
ac->setIon(filter);
ac->setClean(clean);
ac->setBeep(beep);
ac->setBeep(beep); // Toggle
ac->setSleepTimer((sleep <= 0) ? 0 : sleep);
// No Clock setting available.
// Do setMode() again as it can affect fan speed.
Expand Down Expand Up @@ -2525,6 +2525,9 @@ stdAc::state_t IRac::handleToggles(const stdAc::state_t desired,
if (desired.model == panasonic_ac_remote_model_t::kPanasonicCkp)
result.power = desired.power ^ prev->power;
break;
case decode_type_t::SAMSUNG_AC:
result.beep = desired.beep ^ prev->beep;
break;
default:
{};
}
Expand Down
17 changes: 7 additions & 10 deletions src/ir_Samsung.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ using irutils::addIntToString;
using irutils::addLabeledString;
using irutils::addModeToString;
using irutils::addTempToString;
using irutils::addToggleToString;
using irutils::minsToString;

#if SEND_SAMSUNG
Expand Down Expand Up @@ -590,17 +591,13 @@ void IRSamsungAc::setSwingH(const bool on) {
}
}

/// Get the Beep setting of the A/C.
/// Get the Beep toggle setting of the A/C.
/// @return true, the setting is on. false, the setting is off.
bool IRSamsungAc::getBeep(void) const {
return _.Beep;
}
bool IRSamsungAc::getBeep(void) const { return _.BeepToggle; }

/// Set the Beep setting of the A/C.
/// Set the Beep toggle setting of the A/C.
/// @param[in] on true, the setting is on. false, the setting is off.
void IRSamsungAc::setBeep(const bool on) {
_.Beep = on;
}
void IRSamsungAc::setBeep(const bool on) { _.BeepToggle = on; }

/// Get the Clean setting of the A/C.
/// @return true, the setting is on. false, the setting is off.
Expand Down Expand Up @@ -886,7 +883,7 @@ stdAc::state_t IRSamsungAc::toCommon(void) const {
result.turbo = getPowerful();
result.econo = getEcono();
result.clean = getClean();
result.beep = _.Beep;
result.beep = _.BeepToggle;
result.light = _.Display;
result.filter = _.Ion;
result.sleep = _Sleep ? getSleepTimer() : -1;
Expand Down Expand Up @@ -931,7 +928,7 @@ String IRSamsungAc::toString(void) const {
result += ')';
result += addBoolToString(getSwing(), kSwingVStr);
result += addBoolToString(getSwingH(), kSwingHStr);
result += addBoolToString(_.Beep, kBeepStr);
result += addToggleToString(_.BeepToggle, kBeepStr);
result += addBoolToString(getClean(), kCleanStr);
result += addBoolToString(getQuiet(), kQuietStr);
result += addBoolToString(getPowerful(), kPowerfulStr);
Expand Down
10 changes: 5 additions & 5 deletions src/ir_Samsung.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ union SamsungProtocol{
uint8_t Mode :3;
uint8_t :1;
// Byte 13
uint8_t :2;
uint8_t Beep :1;
uint8_t :1;
uint8_t Power2 :2;
uint8_t :2;
uint8_t :2;
uint8_t BeepToggle :1;
uint8_t :1;
uint8_t Power2 :2;
uint8_t :2;
};
struct { // Extended message map
// 1st Section
Expand Down
8 changes: 4 additions & 4 deletions test/IRac_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1652,8 +1652,8 @@ TEST(TestIRac, Samsung) {
IRrecv capture(kGpioUnused);
const char expected[] =
"Power: On, Mode: 0 (Auto), Temp: 28C, Fan: 6 (Auto), "
"Swing(V): On, Swing(H): On, "
"Beep: On, Clean: On, Quiet: On, Powerful: Off, Econo: Off, Breeze: Off, "
"Swing(V): On, Swing(H): On, Beep: Toggle, "
"Clean: On, Quiet: On, Powerful: Off, ""Econo: Off, Breeze: Off, "
"Light: On, Ion: Off";

ac.begin();
Expand Down Expand Up @@ -1716,7 +1716,7 @@ TEST(TestIRac, Samsung) {
const char sleep[] =
"Power: On, Mode: 0 (Auto), Temp: 28C, Fan: 6 (Auto), "
"Swing(V): On, Swing(H): Off, "
"Beep: On, Clean: On, Quiet: On, Powerful: Off, Econo: Off, Breeze: Off, "
"Beep: -, Clean: On, Quiet: On, Powerful: Off, Econo: Off, Breeze: Off, "
"Light: On, Ion: Off, Sleep Timer: 08:00";
irac.samsung(&ac,
true, // Power
Expand All @@ -1731,7 +1731,7 @@ TEST(TestIRac, Samsung) {
true, // Light (Display)
false, // Filter (Ion)
true, // Clean
true, // Beep
false, // Beep
8 * 60, // Sleep
true, // Previous power state
-1, // Previous Sleep
Expand Down
Loading