Skip to content

Commit

Permalink
Only update on state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Jun 8, 2024
1 parent c23d117 commit 0905b87
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/auxiliary/wanderer_cover_v4_ec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,19 @@ void WandererCoverV4EC::updateData(double closesetread, double opensetread, doub
DataNP.setState(IPS_OK);
DataNP.apply();

auto prevParked = ParkCapS[CAP_PARK].s == ISS_ON;
auto prevState = ParkCapSP.s;

ParkCapS[CAP_PARK].s = (positionread - 10 <= closesetread) ? ISS_ON : ISS_OFF;
ParkCapS[CAP_UNPARK].s = (positionread + 10 >= opensetread) ? ISS_ON : ISS_OFF;
ParkCapSP.s = (ParkCapS[CAP_PARK].s == ISS_ON || ParkCapS[CAP_UNPARK].s == ISS_ON) ? IPS_OK : IPS_IDLE;

auto currentParked = ParkCapS[CAP_PARK].s == ISS_ON;
auto currentState = ParkCapSP.s;

// Only update on state changes
if ((prevParked != currentParked) || (prevState != currentState))
IDSetSwitch(&ParkCapSP, nullptr);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -416,7 +426,7 @@ bool WandererCoverV4EC::SetLightBoxBrightness(uint16_t value)
{
EnableLightBox(false);
LightS[INDI_ENABLED].s = ISS_OFF;
LightS[INDI_DISABLED].s = ISS_OFF;
LightS[INDI_DISABLED].s = ISS_ON;
LightSP.s = IPS_IDLE;
IDSetSwitch(&LightSP, nullptr);
}
Expand Down

0 comments on commit 0905b87

Please sign in to comment.