Skip to content

Commit 1028132

Browse files
kkasperczyk-nopull[bot]
authored andcommitted
[nrfconnect] Fixed setting tilt/lift for window covering (#25108)
Window covering sample has a bug that allows to set only lift/tilt positions that are multiple of 5% (step value). It was fixed by adding a logic that compares the next step value with the target value.
1 parent 03593a7 commit 1028132

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

examples/window-app/nrfconnect/main/WindowCovering.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,20 @@ void WindowCovering::DriveCurrentLiftPosition(intptr_t)
6262
VerifyOrReturn(Attributes::CurrentPositionLiftPercent100ths::Get(Endpoint(), current) == EMBER_ZCL_STATUS_SUCCESS);
6363
VerifyOrReturn(Attributes::TargetPositionLiftPercent100ths::Get(Endpoint(), target) == EMBER_ZCL_STATUS_SUCCESS);
6464

65-
UpdateOperationalStatus(MoveType::LIFT, ComputeOperationalState(target, current));
65+
OperationalState state = ComputeOperationalState(target, current);
66+
UpdateOperationalStatus(MoveType::LIFT, state);
67+
68+
chip::Percent100ths step = CalculateSingleStep(MoveType::LIFT);
69+
70+
if (state == OperationalState::MovingUpOrOpen)
71+
{
72+
positionToSet.SetNonNull(step > target.Value() ? step : target.Value());
73+
}
74+
else if (state == OperationalState::MovingDownOrClose)
75+
{
76+
positionToSet.SetNonNull(step < target.Value() ? step : target.Value());
77+
}
6678

67-
positionToSet.SetNonNull(CalculateSingleStep(MoveType::LIFT));
6879
LiftPositionSet(Endpoint(), positionToSet);
6980

7081
// assume single move completed
@@ -156,9 +167,20 @@ void WindowCovering::DriveCurrentTiltPosition(intptr_t)
156167
VerifyOrReturn(Attributes::CurrentPositionTiltPercent100ths::Get(Endpoint(), current) == EMBER_ZCL_STATUS_SUCCESS);
157168
VerifyOrReturn(Attributes::TargetPositionTiltPercent100ths::Get(Endpoint(), target) == EMBER_ZCL_STATUS_SUCCESS);
158169

159-
UpdateOperationalStatus(MoveType::TILT, ComputeOperationalState(target, current));
170+
OperationalState state = ComputeOperationalState(target, current);
171+
UpdateOperationalStatus(MoveType::TILT, state);
172+
173+
chip::Percent100ths step = CalculateSingleStep(MoveType::TILT);
174+
175+
if (state == OperationalState::MovingUpOrOpen)
176+
{
177+
positionToSet.SetNonNull(step > target.Value() ? step : target.Value());
178+
}
179+
else if (state == OperationalState::MovingDownOrClose)
180+
{
181+
positionToSet.SetNonNull(step < target.Value() ? step : target.Value());
182+
}
160183

161-
positionToSet.SetNonNull(CalculateSingleStep(MoveType::TILT));
162184
TiltPositionSet(Endpoint(), positionToSet);
163185

164186
// assume single move completed

0 commit comments

Comments
 (0)