1 /* 2 Celestron GPS 3 Copyright (C) 2003-2017 Jasem Mutlaq (mutlaqja@ikarustech.com) 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 19 */ 20 21 /* 22 Version with experimental pulse guide support. GC 04.12.2015 23 */ 24 25 #pragma once 26 27 #include "celestrondriver.h" 28 29 #include "indiguiderinterface.h" 30 #include "inditelescope.h" 31 #include "indifocuserinterface.h" 32 33 class CelestronGPS : public INDI::Telescope, public INDI::GuiderInterface, public INDI::FocuserInterface 34 { 35 public: 36 CelestronGPS(); 37 38 virtual const char *getDefaultName() override; 39 virtual bool Handshake() override; 40 virtual bool ReadScopeStatus() override; 41 virtual void ISGetProperties(const char *dev) override; 42 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; 43 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; 44 virtual bool initProperties() override; 45 virtual bool updateProperties() override; 46 47 virtual bool ISNewText(const char *dev, const char *name, char **texts, char **names, int n) override; 48 49 protected: 50 // Goto, Sync, and Motion 51 virtual bool Goto(double ra, double dec) override; 52 //bool GotoAzAlt(double az, double alt); 53 virtual bool Sync(double ra, double dec) override; 54 virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override; 55 virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override; 56 virtual bool Abort() override; 57 58 // Time and Location 59 virtual bool updateLocation(double latitude, double longitude, double elevation) override; 60 virtual bool updateTime(ln_date *utc, double utc_offset) override; 61 62 //GUIDE: guiding functions 63 virtual IPState GuideNorth(uint32_t ms) override; 64 virtual IPState GuideSouth(uint32_t ms) override; 65 virtual IPState GuideEast(uint32_t ms) override; 66 virtual IPState GuideWest(uint32_t ms) override; 67 // these all call this function 68 IPState Guide(CELESTRON_DIRECTION dirn, uint32_t ms); 69 70 // Guide Rate 71 INumber GuideRateN[2]; // 0 to 1 corresponding to 0 to 1.0x sidereal 72 INumberVectorProperty GuideRateNP; 73 74 uint8_t guideRateRa; // 0 to 255 corresponding to 0 to 100% sidereal 75 uint8_t guideRateDec; 76 77 //GUIDE guideTimerHelper() function 78 static void guideTimerHelperN(void *p); 79 static void guideTimerHelperS(void *p); 80 static void guideTimerHelperW(void *p); 81 static void guideTimerHelperE(void *p); 82 // these all call this function 83 void guideTimer(CELESTRON_DIRECTION dirn); 84 85 void AddGuideTimer(CELESTRON_DIRECTION dirn, int ms); 86 87 // Focus Backlash 88 virtual bool SetFocuserBacklash(int32_t steps) override; 89 90 // Tracking 91 virtual bool SetTrackMode(uint8_t mode) override; 92 virtual bool SetTrackEnabled(bool enabled) override; 93 94 // Parking 95 virtual bool Park() override; 96 virtual bool UnPark() override; 97 virtual bool SetCurrentPark() override; 98 virtual bool SetDefaultPark() override; 99 100 virtual bool saveConfigItems(FILE *fp) override; 101 102 virtual void simulationTriggered(bool enable) override; 103 104 void mountSim(); 105 106 //GUIDE variables. 107 int GuideNSTID; 108 int GuideWETID; 109 int ticksNS; 110 int ticksWE; 111 //CELESTRON_DIRECTION guide_direction; 112 113 /* Firmware */ 114 IText FirmwareT[7] {}; 115 ITextVectorProperty FirmwareTP; 116 117 //INumberVectorProperty HorizontalCoordsNP; 118 //INumber HorizontalCoordsN[2]; 119 120 //ISwitch TrackS[4]; 121 //ISwitchVectorProperty TrackSP; 122 123 // Celestron Track Mode (AltAz, EQ N, EQ S, Ra and Dec) 124 ISwitchVectorProperty CelestronTrackModeSP; 125 ISwitch CelestronTrackModeS[4]; 126 127 //GUIDE Pulse guide switch 128 // ISwitchVectorProperty UsePulseCmdSP; 129 // ISwitch UsePulseCmdS[2]; 130 131 ISwitchVectorProperty UseHibernateSP; 132 ISwitch UseHibernateS[2]; 133 134 // PEC - implemented without using the base definition because this doesn't match what is required 135 // shows status and index 136 IText PecInfoT[2] {}; 137 ITextVectorProperty PecInfoTP; 138 139 ISwitch PecControlS[4]; // Find Index, Stop, Playback, Record 140 ISwitchVectorProperty PecControlSP; 141 enum { PEC_Seek, PEC_Stop, PEC_Playback, PEC_Record } PecControl; 142 143 // move PEC data from file to mount 144 IText PecFileNameT[1] {}; 145 ITextVectorProperty PecFileNameTP; 146 147 // FocuserInterface 148 149 IPState MoveAbsFocuser (uint32_t targetTicks) override; 150 IPState MoveRelFocuser (FocusDirection dir, uint32_t ticks) override; 151 bool AbortFocuser () override; 152 153 // End FocuserInterface 154 155 private: 156 bool setCelestronTrackMode(CELESTRON_TRACK_MODE mode); 157 bool checkMinVersion(double minVersion, const char *feature, bool debug = false); 158 void checkAlignment(); 159 160 double currentRA, currentDEC, currentAZ, currentALT; 161 double targetRA, targetDEC, targetAZ, targetALT; 162 163 CelestronDriver driver; 164 FirmwareInfo fwInfo; 165 166 bool usePreciseCoords {false}; 167 // bool usePulseCommand { false }; 168 bool canAuxGuide { false}; 169 170 //CelestronGuide guider; 171 172 // Last align property 173 ISwitch LastAlignS[1]; 174 ISwitchVectorProperty LastAlignSP; 175 176 // DST setting 177 ISwitch DSTSettingS[1]; 178 ISwitchVectorProperty DSTSettingSP; 179 180 bool slewToIndex; 181 182 size_t numPecBins = 0; 183 184 bool savePecData(); 185 186 // Slew Offsets 187 double SlewOffsetRa = 0.0; 188 189 // focuser 190 // INumber FocusBacklashN[1]; 191 // INumberVectorProperty FocusBacklashNP; 192 193 INumber FocusMinPosN[1]; 194 INumberVectorProperty FocusMinPosNP; 195 196 bool focusBacklashMove; // set if a final move is needed 197 uint32_t focusPosition; 198 bool focusReadLimits(); 199 bool focuserIsCalibrated; 200 }; 201