From a6c654a55d287f8988c72afb49bb9883bd91b7e4 Mon Sep 17 00:00:00 2001 From: James McKenzie Date: Wed, 25 Jan 2023 10:40:55 +0000 Subject: add timer based guiding --- indi-lxd650/lxd650.cpp | 148 +++++++++++++++++++++++++++++++++++++++++++------ indi-lxd650/lxd650.h | 16 ++++++ 2 files changed, 146 insertions(+), 18 deletions(-) diff --git a/indi-lxd650/lxd650.cpp b/indi-lxd650/lxd650.cpp index 8126ac9..813f6bd 100644 --- a/indi-lxd650/lxd650.cpp +++ b/indi-lxd650/lxd650.cpp @@ -495,47 +495,159 @@ bool LXD650::ISNewText(const char *dev, const char *name, char *texts[], char *n ///////////////////////////////////////////////////////////////////////////////////// /// +// +// +// +//void ///////////////////////////////////////////////////////////////////////////////////// +// + + +void LXD650::GuideNorthCB(void) +{ + GuideNorth_TID = 0; + HaltMovement(PortFD, LX200_NORTH); +} + + +void LXD650::GuideNorthProxy(void *context) +{ + static_cast(context)->GuideNorthCB(); +} + + IPState LXD650::GuideNorth(uint32_t ms) { - int8_t rate = static_cast(GuideRateNP[AXIS_ALT].getValue() * 100); - guidePulse(AXIS_DE, ms, rate); + double rate = GuideRateNP[AXIS_ALT].getValue(); + + ms = (uint32_t) (rate * (double) ms); + + setSlewMode(PortFD, LX200_SLEW_GUIDE); + + if (GuideNorth_TID) + { + IERmTimer(GuideNorth_TID); + GuideNorth_TID = 0; + } + + + MoveTo(PortFD, LX200_NORTH); + + GuideNorth_TID = IEAddTimer(ms, GuideNorthProxy, this); + return IPS_BUSY; } + +void LXD650::GuideSouthCB(void) +{ + GuideSouth_TID = 0; + HaltMovement(PortFD, LX200_SOUTH); +} + + +void LXD650::GuideSouthProxy(void *context) +{ + static_cast(context)->GuideSouthCB(); +} + + IPState LXD650::GuideSouth(uint32_t ms) { - int8_t rate = static_cast(GuideRateNP[AXIS_ALT].getValue() * 100); - guidePulse(AXIS_DE, ms, -rate); + double rate = GuideRateNP[AXIS_ALT].getValue(); + + ms = (uint32_t) (rate * (double) ms); + + setSlewMode(PortFD, LX200_SLEW_GUIDE); + + if (GuideSouth_TID) + { + IERmTimer(GuideSouth_TID); + GuideSouth_TID = 0; + } + + + MoveTo(PortFD, LX200_SOUTH); + + GuideSouth_TID = IEAddTimer(ms, GuideSouthProxy, this); + return IPS_BUSY; } -IPState LXD650::GuideEast(uint32_t ms) + +void LXD650::GuideWestCB(void) { - int8_t rate = static_cast(GuideRateNP[AXIS_AZ].getValue() * 100); - guidePulse(AXIS_RA, ms, -rate); - return IPS_BUSY; + GuideWest_TID = 0; + HaltMovement(PortFD, LX200_WEST); +} + + +void LXD650::GuideWestProxy(void *context) +{ + static_cast(context)->GuideWestCB(); } + IPState LXD650::GuideWest(uint32_t ms) { - int8_t rate = static_cast(GuideRateNP[AXIS_AZ].getValue() * 100); - guidePulse(AXIS_RA, ms, rate); + double rate = GuideRateNP[AXIS_ALT].getValue(); + + ms = (uint32_t) (rate * (double) ms); + + setSlewMode(PortFD, LX200_SLEW_GUIDE); + + if (GuideWest_TID) + { + IERmTimer(GuideWest_TID); + GuideWest_TID = 0; + } + + + MoveTo(PortFD, LX200_WEST); + + GuideWest_TID = IEAddTimer(ms, GuideWestProxy, this); + return IPS_BUSY; } -bool LXD650::guidePulse(INDI_EQ_AXIS axis, uint32_t ms, int8_t rate) + +void LXD650::GuideEastCB(void) { - // FIXME - // - // - (void) axis; - (void) ms; - (void) rate; - return true; + GuideEast_TID = 0; + HaltMovement(PortFD, LX200_EAST); +} + + +void LXD650::GuideEastProxy(void *context) +{ + static_cast(context)->GuideEastCB(); } +IPState LXD650::GuideEast(uint32_t ms) +{ + double rate = GuideRateNP[AXIS_ALT].getValue(); + + ms = (uint32_t) (rate * (double) ms); + + setSlewMode(PortFD, LX200_SLEW_GUIDE); + + if (GuideEast_TID) + { + IERmTimer(GuideEast_TID); + GuideEast_TID = 0; + } + + + MoveTo(PortFD, LX200_EAST); + + GuideEast_TID = IEAddTimer(ms, GuideEastProxy, this); + + return IPS_BUSY; +} + + + /************************************************************************************** ** ***************************************************************************************/ diff --git a/indi-lxd650/lxd650.h b/indi-lxd650/lxd650.h index 731c9e4..0c912c1 100644 --- a/indi-lxd650/lxd650.h +++ b/indi-lxd650/lxd650.h @@ -48,6 +48,11 @@ class LXD650 : public INDI::Telescope, virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override; virtual bool ISSnoopDevice(XMLEle *root) override; + static void GuideNorthProxy(void *context); + static void GuideSouthProxy(void *context); + static void GuideWestProxy(void *context); + static void GuideEastProxy(void *context); + protected: virtual bool Abort() override; virtual bool Goto(double, double) override; @@ -79,4 +84,15 @@ class LXD650 : public INDI::Telescope, INDI::PropertyNumber GuideRateNP {2}; bool guidePulse(INDI_EQ_AXIS axis, uint32_t ms, int8_t rate); void show_alignment(const char *wot, double ra1,double dec1, double ra2,double dec2); + + int GuideNorth_TID {0}; + int GuideSouth_TID {0}; + int GuideWest_TID {0}; + int GuideEast_TID {0}; + + void GuideNorthCB(void); + void GuideSouthCB(void); + void GuideWestCB(void); + void GuideEastCB(void); + }; -- cgit v1.2.3