Skip to content

Commit

Permalink
Do not force AUX encoders if user explicitly turned them off
Browse files Browse the repository at this point in the history
  • Loading branch information
knro committed Jul 1, 2024
1 parent 81f39f1 commit aba764e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/telescope/skywatcherAPIMount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ bool SkywatcherAPIMount::initProperties()
AUXEncoderSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", ISS_ON);
AUXEncoderSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", ISS_OFF);
AUXEncoderSP.fill(getDeviceName(), "AUX_ENCODERS", "AUX Encoders", TRACKING_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
AUXEncoderSP.load();

// Snap port
SnapPortSP[INDI_ENABLED].fill("INDI_ENABLED", "On", ISS_OFF);
Expand Down Expand Up @@ -459,7 +460,7 @@ bool SkywatcherAPIMount::ISNewSwitch(const char *dev, const char *name, ISState
auto enabled = AUXEncoderSP.findOnSwitchIndex() == INDI_ENABLED;
TurnRAEncoder(enabled);
TurnDEEncoder(enabled);
saveConfig(true, AUXEncoderSP.getName());
saveConfig(AUXEncoderSP);
return true;
}

Expand Down Expand Up @@ -1369,9 +1370,12 @@ bool SkywatcherAPIMount::updateProperties()

if (HasAuxEncoders())
{
LOG_INFO("AUX encoders detected. Turning on...");
TurnRAEncoder(true);
TurnDEEncoder(true);
// Since config is loaded, let's use this as starting point.
// We should not force AUX encoders if the user explicitly turned them off.
auto enabled = AUXEncoderSP[INDI_ENABLED].getState() == ISS_ON;
LOGF_INFO("AUX encoders detected. Turning %s...", enabled ? "on" : "off");
TurnRAEncoder(enabled);
TurnDEEncoder(enabled);
defineProperty(AUXEncoderSP);
}

Expand Down Expand Up @@ -1424,7 +1428,7 @@ bool SkywatcherAPIMount::updateProperties()
deleteProperty(Axis2TrackRateNP);

if (HasAuxEncoders())
deleteProperty(AUXEncoderSP.getName());
deleteProperty(AUXEncoderSP);

return true;
}
Expand Down

0 comments on commit aba764e

Please sign in to comment.