From 19be18f9b182b86f4d05545dd8e0a51a0af8b71f Mon Sep 17 00:00:00 2001 From: gehelem Date: Fri, 15 Dec 2023 07:50:54 +0100 Subject: [PATCH] TeenAstro pulse behaviour #1977 (#1978) --- drivers.xml | 2 +- drivers/telescope/lx200_TeenAstro.cpp | 75 +++++++++++++++++++++++++-- drivers/telescope/lx200_TeenAstro.h | 9 ++++ 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/drivers.xml b/drivers.xml index 52f6e6d72d..c5c4125775 100644 --- a/drivers.xml +++ b/drivers.xml @@ -41,7 +41,7 @@ indi_lx200_TeenAstro - 1.3 + 1.4 indi_lx200_16 diff --git a/drivers/telescope/lx200_TeenAstro.cpp b/drivers/telescope/lx200_TeenAstro.cpp index 9e5ab71023..2e4dae7ebf 100644 --- a/drivers/telescope/lx200_TeenAstro.cpp +++ b/drivers/telescope/lx200_TeenAstro.cpp @@ -58,7 +58,7 @@ extern std::mutex lx200CommsLock; */ LX200_TeenAstro::LX200_TeenAstro() { - setVersion(1, 3); // don't forget to update drivers.xml + setVersion(1, 4); // don't forget to update drivers.xml DBG_SCOPE = INDI::Logger::getInstance().addDebugLevel("Scope Verbose", "SCOPE"); @@ -1152,25 +1152,65 @@ bool LX200_TeenAstro::SetGuideRate(float guideRate) IPState LX200_TeenAstro::GuideNorth(uint32_t ms) { SendPulseCmd(LX200_NORTH, ms); - return IPS_OK; + if(MovementNSSP.s == IPS_BUSY) + return IPS_ALERT; + + if (GuideNSTID) + { + IERmTimer(GuideNSTID); + GuideNSTID = 0; + } + + GuideNSTID = IEAddTimer(static_cast(ms), guideTimeoutHelperNS, this); + return IPS_BUSY; } IPState LX200_TeenAstro::GuideSouth(uint32_t ms) { SendPulseCmd(LX200_SOUTH, ms); - return IPS_OK; + if(MovementNSSP.s == IPS_BUSY) + return IPS_ALERT; + + if (GuideNSTID) + { + IERmTimer(GuideNSTID); + GuideNSTID = 0; + } + + GuideNSTID = IEAddTimer(static_cast(ms), guideTimeoutHelperNS, this); + return IPS_BUSY; } IPState LX200_TeenAstro::GuideEast(uint32_t ms) { SendPulseCmd(LX200_EAST, ms); - return IPS_OK; + if(MovementWESP.s == IPS_BUSY) + return IPS_ALERT; + + if (GuideWETID) + { + IERmTimer(GuideWETID); + GuideWETID = 0; + } + + GuideWETID = IEAddTimer(static_cast(ms), guideTimeoutHelperWE, this); + return IPS_BUSY; } IPState LX200_TeenAstro::GuideWest(uint32_t ms) { SendPulseCmd(LX200_WEST, ms); - return IPS_OK; + if(MovementWESP.s == IPS_BUSY) + return IPS_ALERT; + + if (GuideWETID) + { + IERmTimer(GuideWETID); + GuideWETID = 0; + } + + GuideWETID = IEAddTimer(static_cast(ms), guideTimeoutHelperWE, this); + return IPS_BUSY; } void LX200_TeenAstro::SendPulseCmd(int8_t direction, uint32_t duration_msec) @@ -1371,5 +1411,30 @@ void LX200_TeenAstro::sendCommand(const char *cmd) INDI_UNUSED(rc); } +void LX200_TeenAstro::guideTimeoutHelperNS(void * p) +{ + static_cast(p)->guideTimeoutNS(); +} + +void LX200_TeenAstro::guideTimeoutHelperWE(void * p) +{ + static_cast(p)->guideTimeoutWE(); +} +void LX200_TeenAstro::guideTimeoutNS() +{ + GuideNSNP.np[0].value = 0; + GuideNSNP.np[1].value = 0; + GuideNSNP.s = IPS_IDLE; + GuideNSTID = 0; + IDSetNumber(&GuideNSNP, nullptr); +} +void LX200_TeenAstro::guideTimeoutWE() +{ + GuideWENP.np[0].value = 0; + GuideWENP.np[1].value = 0; + GuideWENP.s = IPS_IDLE; + GuideWETID = 0; + IDSetNumber(&GuideWENP, nullptr); +} diff --git a/drivers/telescope/lx200_TeenAstro.h b/drivers/telescope/lx200_TeenAstro.h index ffc01f060e..6474fec7ac 100644 --- a/drivers/telescope/lx200_TeenAstro.h +++ b/drivers/telescope/lx200_TeenAstro.h @@ -108,6 +108,12 @@ class LX200_TeenAstro : public INDI::Telescope, public INDI::GuiderInterface bool sendScopeTime(); bool sendScopeLocation(); + void guideTimeoutNS(); + void guideTimeoutWE(); + + static void guideTimeoutHelperNS(void * p); + static void guideTimeoutHelperWE(void * p); + // User interface INumber SlewAccuracyN[2]; @@ -152,4 +158,7 @@ class LX200_TeenAstro : public INDI::Telescope, public INDI::GuiderInterface const char *statusCommand; // :GU# for version 1.1, :GXI# for 1.2 and later const char *guideSpeedCommand; // :SXR0 + int GuideNSTID { -1 }; + int GuideWETID { -1 }; + };