Skip to content

Commit

Permalink
Update src/app/clusters/fan-control-server/fan-control-server.cpp
Browse files Browse the repository at this point in the history
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
andy31415 and bzbarsky-apple authored Jul 13, 2023
1 parent fdc74b5 commit 66262a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/clusters/fan-control-server/fan-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
ChipLogError(Zcl, "Failed to get SpeedSetting with error: 0x%02x", status));

uint16_t percent = percentSetting.Value();
// Plus 99 then devide by 100 instead of multiplying 0.01 to workaround floating point precision error
uint8_t speedSetting = static_cast<uint8_t>(ceil((speedMax * percent + 99) / 100));
// Plus 99 then integer divide by 100 instead of multiplying 0.01 to avoid floating point precision error
uint8_t speedSetting = static_cast<uint8_t>((speedMax * percent + 99) / 100);

if (currentSpeedSetting.IsNull() || speedSetting != currentSpeedSetting.Value())
{
Expand Down

0 comments on commit 66262a3

Please sign in to comment.