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

ZWO AM5 Save home position in the mount #2091

Closed
wants to merge 2 commits into from
Closed
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
38 changes: 34 additions & 4 deletions drivers/telescope/lx200am5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ bool LX200AM5::initProperties()
SlewRateS[9].s = ISS_ON;

// Home/Zero position
HomeSP[0].fill("GO", "Go", ISS_OFF);
HomeSP[GoHome].fill("GO", "Go", ISS_OFF);
HomeSP[SaveHome].fill("SAVE", "Save", ISS_OFF);
HomeSP.fill(getDeviceName(), "TELESCOPE_HOME", "Home", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE);

// Guide Rate
Expand Down Expand Up @@ -213,9 +214,28 @@ bool LX200AM5::ISNewSwitch(const char *dev, const char *name, ISState *states, c
{
if (HomeSP.getState() != IPS_BUSY)
{
HomeSP[0].setState(ISS_ON);
HomeSP.setState(goHome() ? IPS_BUSY : IPS_ALERT);
LOG_INFO("Homing in progress...");
HomeSP.update(states, names, n);
switch (HomeSP.findOnSwitchIndex())
{
case GoHome:
LOG_INFO("Homing in progress...");
HomeSP[GoHome].setState(ISS_ON);
HomeSP.setState(goHome() ? IPS_BUSY : IPS_ALERT);
break;
case SaveHome:
if (saveHome())
{
HomeSP.setState(IPS_OK);
LOG_INFO("Current position written as home position in the mount.");
}
else
{
HomeSP.setState(IPS_ALERT);
LOG_WARN("Failed to write current home position in the mount. It is possible that the position is too far from the factory position.");
}
HomeSP[SaveHome].setState(ISS_OFF);
break;
}
}
HomeSP.apply();
return true;
Expand Down Expand Up @@ -416,6 +436,16 @@ bool LX200AM5::goHome()
return sendCommand(":hC#");
}

/////////////////////////////////////////////////////////////////////////////
///
/////////////////////////////////////////////////////////////////////////////
bool LX200AM5::saveHome()
{
const char cmd[] = ":SOa#";
char status ='0';
return sendCommand(cmd, &status, strlen(cmd), sizeof(status)) && status == '1';
}

/////////////////////////////////////////////////////////////////////////////
///
/////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 7 additions & 1 deletion drivers/telescope/lx200am5.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ class LX200AM5 : public LX200Generic
/// Properties
//////////////////////////////////////////////////////////////////////////////////
// Go Home
INDI::PropertySwitch HomeSP {1};
enum
{
GoHome,
SaveHome
};
INDI::PropertySwitch HomeSP {2};
// Mount Type
INDI::PropertySwitch MountTypeSP {2};
enum
Expand All @@ -109,6 +114,7 @@ class LX200AM5 : public LX200Generic

// Homing
bool goHome();
bool saveHome();

// Guide Rate
bool setGuideRate(double value);
Expand Down
Loading