Skip to content

Commit

Permalink
modified window app button press behavior (#25701)
Browse files Browse the repository at this point in the history
* modified window app button press behaviour to update the TargetPositionLiftPercent attribute

* added check for tilt mode change

* fixed minor error

* created WindowApp::Cover::UpdateTargetPosition() function that updates respective TargetPosition attributes

* Restyled by whitespace

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 8, 2024
1 parent 299a9b0 commit 1739393
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/window-app/common/include/WindowApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class WindowApp
void TiltSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, true); }
void TiltScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, true); }

void UpdateTargetPosition(OperationalState direction, bool isTilt);
void StepToward(OperationalState direction, bool isTilt);

Type CycleType();
Expand Down
35 changes: 33 additions & 2 deletions examples/window-app/common/src/WindowApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void WindowApp::DispatchEvent(const WindowApp::Event & event)
}
else
{
GetCover().StepToward(OperationalState::MovingUpOrOpen, mTiltMode);
GetCover().UpdateTargetPosition(OperationalState::MovingUpOrOpen, mTiltMode);
}
break;

Expand Down Expand Up @@ -276,7 +276,7 @@ void WindowApp::DispatchEvent(const WindowApp::Event & event)
}
else
{
GetCover().StepToward(OperationalState::MovingDownOrClose, mTiltMode);
GetCover().UpdateTargetPosition(OperationalState::MovingDownOrClose, mTiltMode);
}
break;
case EventId::AttributeChange:
Expand Down Expand Up @@ -594,6 +594,37 @@ void WindowApp::Cover::StepToward(OperationalState direction, bool isTilt)
}
}

void WindowApp::Cover::UpdateTargetPosition(OperationalState direction, bool isTilt)
{
EmberAfStatus status;
NPercent100ths current;
chip::Percent100ths target;

chip::DeviceLayer::PlatformMgr().LockChipStack();

if (isTilt)
{
status = Attributes::CurrentPositionTiltPercent100ths::Get(mEndpoint, current);
if ((status == EMBER_ZCL_STATUS_SUCCESS) && !current.IsNull())
{

target = ComputePercent100thsStep(direction, current.Value(), TILT_DELTA);
(void) Attributes::TargetPositionTiltPercent100ths::Set(mEndpoint, target);
}
}
else
{
status = Attributes::CurrentPositionLiftPercent100ths::Get(mEndpoint, current);
if ((status == EMBER_ZCL_STATUS_SUCCESS) && !current.IsNull())
{

target = ComputePercent100thsStep(direction, current.Value(), LIFT_DELTA);
(void) Attributes::TargetPositionLiftPercent100ths::Set(mEndpoint, target);
}
}
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
}

Type WindowApp::Cover::CycleType()
{
chip::DeviceLayer::PlatformMgr().LockChipStack();
Expand Down

0 comments on commit 1739393

Please sign in to comment.