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

[nrfconnect] Fixed window app setting value issue. #25243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 16 additions & 8 deletions examples/window-app/nrfconnect/main/WindowCovering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,19 @@ void WindowCovering::DriveCurrentLiftPosition(intptr_t)
OperationalState state = ComputeOperationalState(target, current);
UpdateOperationalStatus(MoveType::LIFT, state);

chip::Percent100ths step = CalculateSingleStep(MoveType::LIFT);
chip::Percent100ths position = CalculateNextPosition(MoveType::LIFT);

if (state == OperationalState::MovingUpOrOpen)
{
positionToSet.SetNonNull(step > target.Value() ? step : target.Value());
positionToSet.SetNonNull(position > target.Value() ? position : target.Value());
}
else if (state == OperationalState::MovingDownOrClose)
{
positionToSet.SetNonNull(step < target.Value() ? step : target.Value());
positionToSet.SetNonNull(position < target.Value() ? position : target.Value());
}
else
{
positionToSet.SetNonNull(current.Value());
}

LiftPositionSet(Endpoint(), positionToSet);
Expand All @@ -95,7 +99,7 @@ void WindowCovering::DriveCurrentLiftPosition(intptr_t)
}
}

chip::Percent100ths WindowCovering::CalculateSingleStep(MoveType aMoveType)
chip::Percent100ths WindowCovering::CalculateNextPosition(MoveType aMoveType)
{
EmberAfStatus status{};
chip::Percent100ths percent100ths{};
Expand Down Expand Up @@ -170,15 +174,19 @@ void WindowCovering::DriveCurrentTiltPosition(intptr_t)
OperationalState state = ComputeOperationalState(target, current);
UpdateOperationalStatus(MoveType::TILT, state);

chip::Percent100ths step = CalculateSingleStep(MoveType::TILT);
chip::Percent100ths position = CalculateNextPosition(MoveType::TILT);

if (state == OperationalState::MovingUpOrOpen)
{
positionToSet.SetNonNull(step > target.Value() ? step : target.Value());
positionToSet.SetNonNull(position > target.Value() ? position : target.Value());
}
else if (state == OperationalState::MovingDownOrClose)
{
positionToSet.SetNonNull(step < target.Value() ? step : target.Value());
positionToSet.SetNonNull(position < target.Value() ? position : target.Value());
}
else
{
positionToSet.SetNonNull(current.Value());
}

TiltPositionSet(Endpoint(), positionToSet);
Expand Down Expand Up @@ -226,7 +234,7 @@ void WindowCovering::StartMove(MoveType aMoveType)
void WindowCovering::SetSingleStepTarget(OperationalState aDirection)
{
UpdateOperationalStatus(mCurrentUIMoveType, aDirection);
SetTargetPosition(aDirection, CalculateSingleStep(mCurrentUIMoveType));
SetTargetPosition(aDirection, CalculateNextPosition(mCurrentUIMoveType));
}

void WindowCovering::UpdateOperationalStatus(MoveType aMoveType, OperationalState aDirection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class WindowCovering
static void UpdateOperationalStatus(MoveType aMoveType, OperationalState aDirection);
static bool TargetCompleted(MoveType aMoveType, NPercent100ths aCurrent, NPercent100ths aTarget);
static void StartTimer(MoveType aMoveType, uint32_t aTimeoutMs);
static chip::Percent100ths CalculateSingleStep(MoveType aMoveType);
static chip::Percent100ths CalculateNextPosition(MoveType aMoveType);
static void DriveCurrentLiftPosition(intptr_t);
static void DriveCurrentTiltPosition(intptr_t);
static void MoveTimerTimeoutCallback(chip::System::Layer * systemLayer, void * appState);
Expand Down