Skip to content

Commit

Permalink
FP2 motor status (#2139)
Browse files Browse the repository at this point in the history
Co-authored-by: Pavle Gartner <[email protected]>
  • Loading branch information
DeepSkyDad and Pavle Gartner authored Oct 16, 2024
1 parent ab5f6da commit 3b6e514
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 38 deletions.
140 changes: 102 additions & 38 deletions drivers/auxiliary/deepskydad_fp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,17 @@ bool DeepSkyDadFP::getStatus()
else
sscanf(response, "(%d)", &lightStatus);

if (!sendCommand("[GPOS]", response))
return false;
else
sscanf(response, "(%d)", &coverStatus);
if(isFP2) {
if (!sendCommand("[GOPS]", response))
return false;
else
sscanf(response, "(%d)", &coverStatus);
} else {
if (!sendCommand("[GPOS]", response))
return false;
else
sscanf(response, "(%d)", &coverStatus);
}

if (!sendCommand("[GHTT]", response))
return false;
Expand All @@ -342,56 +349,112 @@ bool DeepSkyDadFP::getStatus()

bool statusUpdated = false;

if (coverStatus != prevCoverStatus)
{
if(motorStatus == 1)
if(isFP2) {
if (coverStatus != prevCoverStatus)
{
if(coverStatus == 0)
if(motorStatus == 1)
{
IUSaveText(&StatusT[0], "Open");
}
else if(coverStatus == 270)
{
IUSaveText(&StatusT[0], "Closed");
if(coverStatus == 0)
{
IUSaveText(&StatusT[0], "Closed");
}
else if(coverStatus == 1)
{
IUSaveText(&StatusT[0], "Open");
}
else
{
IUSaveText(&StatusT[0], "Not open/closed");
}
}
else
{
IUSaveText(&StatusT[0], "Not open/closed");
}
}
else
{
prevCoverStatus = coverStatus;
prevCoverStatus = coverStatus;

statusUpdated = true;
statusUpdated = true;

if(coverStatus == 0)
{
IUSaveText(&StatusT[0], "Open");
if (ParkCapSP.getState() == IPS_BUSY || ParkCapSP.getState() == IPS_IDLE)
if(coverStatus == 1)
{
IUSaveText(&StatusT[0], "Open");
if (ParkCapSP.getState() == IPS_BUSY || ParkCapSP.getState() == IPS_IDLE)
{
ParkCapSP.reset();
ParkCapSP[1].setState(ISS_ON);
ParkCapSP.setState(IPS_OK);
LOG_INFO("Cover open.");
ParkCapSP.apply();
}
}
else if(coverStatus == 0)
{
IUSaveText(&StatusT[0], "Closed");
if (ParkCapSP.getState() == IPS_BUSY || ParkCapSP.getState() == IPS_IDLE)
{
ParkCapSP.reset();
ParkCapSP[0].setState(ISS_ON);
ParkCapSP.setState(IPS_OK);
LOG_INFO("Cover closed.");
ParkCapSP.apply();
}
}
else
{
ParkCapSP.reset();
ParkCapSP[1].setState(ISS_ON);
ParkCapSP.setState(IPS_OK);
LOG_INFO("Cover open.");
ParkCapSP.apply();
IUSaveText(&StatusT[0], "Not open/closed");
}
}
else if(coverStatus == 270)
}
} else {
if (coverStatus != prevCoverStatus)
{
if(motorStatus == 1)
{
IUSaveText(&StatusT[0], "Closed");
if (ParkCapSP.getState() == IPS_BUSY || ParkCapSP.getState() == IPS_IDLE)
if(coverStatus == 0)
{
ParkCapSP.reset();
ParkCapSP[0].setState(ISS_ON);
ParkCapSP.setState(IPS_OK);
LOG_INFO("Cover closed.");
ParkCapSP.apply();
IUSaveText(&StatusT[0], "Open");
}
else if(coverStatus == 270)
{
IUSaveText(&StatusT[0], "Closed");
}
else
{
IUSaveText(&StatusT[0], "Not open/closed");
}
}
else
{
IUSaveText(&StatusT[0], "Not open/closed");
prevCoverStatus = coverStatus;

statusUpdated = true;

if(coverStatus == 0)
{
IUSaveText(&StatusT[0], "Open");
if (ParkCapSP.getState() == IPS_BUSY || ParkCapSP.getState() == IPS_IDLE)
{
ParkCapSP.reset();
ParkCapSP[1].setState(ISS_ON);
ParkCapSP.setState(IPS_OK);
LOG_INFO("Cover open.");
ParkCapSP.apply();
}
}
else if(coverStatus == 270)
{
IUSaveText(&StatusT[0], "Closed");
if (ParkCapSP.getState() == IPS_BUSY || ParkCapSP.getState() == IPS_IDLE)
{
ParkCapSP.reset();
ParkCapSP[0].setState(ISS_ON);
ParkCapSP.setState(IPS_OK);
LOG_INFO("Cover closed.");
ParkCapSP.apply();
}
}
else
{
IUSaveText(&StatusT[0], "Not open/closed");
}
}
}
}
Expand Down Expand Up @@ -494,6 +557,7 @@ bool DeepSkyDadFP::getFirmwareVersion()
snprintf(versionString, 6, "%s", response + 31);
IUSaveText(&FirmwareT[0], response);
IDSetText(&FirmwareTP, nullptr);
isFP2 = strstr(response, "DeepSkyDad.FP2") != nullptr;

return true;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/auxiliary/deepskydad_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class DeepSkyDadFP : public INDI::DefaultDevice, public INDI::LightBoxInterface,
// Firmware version
ITextVectorProperty FirmwareTP;
IText FirmwareT[1] {};
bool isFP2;

int PortFD{ -1 };

Expand Down

0 comments on commit 3b6e514

Please sign in to comment.