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

Workaround Fan PercentSetting floating point precision error after "ceil()" #27912

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Restyled by clang-format
restyled-commits authored and erwinpan1 committed Jul 13, 2023
commit 0040b88b1c6c368dd35045de3f5f523c9009d25e
2 changes: 1 addition & 1 deletion src/app/clusters/fan-control-server/fan-control-server.cpp
Original file line number Diff line number Diff line change
@@ -346,7 +346,7 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status,
ChipLogError(Zcl, "Failed to get SpeedSetting with error: 0x%02x", status));

float percent = percentSetting.Value();
float percent = percentSetting.Value();
// Minus insignificant number 0.00000001 before ceil() to avoid floating point precision error
uint8_t speedSetting = static_cast<uint8_t>(ceil(speedMax * (percent * 0.01) - 0.00000001));
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
erwinpan1 marked this conversation as resolved.
Show resolved Hide resolved