Skip to content

Commit

Permalink
Fix int promotion compile errors on thermostat application (#34627)
Browse files Browse the repository at this point in the history
* Fix int promotion compile errors

* Fix cast types

* Minimize cast size

* Fix typo

---------

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
andy31415 and andreilitvin authored Jul 30, 2024
1 parent a8ff6ef commit 87393f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/thermostat/linux/thermostat-delegate-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ void ThermostatDelegate::InitializePresets()
const uint8_t handle[] = { static_cast<uint8_t>(presetScenario) };
mPresets[index].SetPresetHandle(DataModel::MakeNullable(ByteSpan(handle)));
mPresets[index].SetName(NullOptional);
int16_t coolingSetpointValue = 2500 + index * 100;
int16_t coolingSetpointValue = static_cast<int16_t>(2500 + (index * 100));
mPresets[index].SetCoolingSetpoint(MakeOptional(coolingSetpointValue));

int16_t heatingSetpointValue = 2100 - index * 100;
int16_t heatingSetpointValue = static_cast<int16_t>(2100 - (index * 100));
mPresets[index].SetHeatingSetpoint(MakeOptional(heatingSetpointValue));
mPresets[index].SetBuiltIn(DataModel::MakeNullable(true));
index++;
Expand Down
8 changes: 4 additions & 4 deletions examples/thermostat/linux/thermostat-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ void ThermostatManager::EvalThermostatState()

void ThermostatManager::UpdateRunningModeForHeating()
{
const int16_t heatingOnThreshold = mOccupiedHeatingSetpoint - mOccupiedSetback * 10;
const int16_t heatingOffThreshold = mOccupiedHeatingSetpoint + mOccupiedSetback * 10;
const int16_t heatingOnThreshold = mOccupiedHeatingSetpoint - static_cast<int16_t>(mOccupiedSetback * 10);
const int16_t heatingOffThreshold = mOccupiedHeatingSetpoint + static_cast<int16_t>(mOccupiedSetback * 10);

if (mRunningMode == ThermostatRunningModeEnum::kHeat)
{
Expand Down Expand Up @@ -429,8 +429,8 @@ void ThermostatManager::UpdateRunningModeForHeating()

void ThermostatManager::UpdateRunningModeForCooling()
{
const int16_t coolingOffThreshold = mOccupiedCoolingSetpoint - mOccupiedSetback * 10;
const int16_t coolingOnThreshold = mOccupiedCoolingSetpoint + mOccupiedSetback * 10;
const int16_t coolingOffThreshold = mOccupiedCoolingSetpoint - static_cast<int16_t>(mOccupiedSetback * 10);
const int16_t coolingOnThreshold = mOccupiedCoolingSetpoint + static_cast<int16_t>(mOccupiedSetback * 10);

if (mRunningMode == ThermostatRunningModeEnum::kCool)
{
Expand Down

0 comments on commit 87393f8

Please sign in to comment.