Instrument Neutral Distributed Interface INDI 2.2.5
celestron.h
Go to the documentation of this file.
1/*
2 Celestron Focuser for SCT and EDGEHD
3
4 Copyright (C) 2019 Jasem Mutlaq ([email protected])
5 Copyright (C) 2019 Chris Rowland
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21*/
22
23#pragma once
24
25#include "indifocuser.h"
26
27#include <chrono>
28#include "celestronauxpacket.h"
29
31{
32 public:
34
35 const char * getDefaultName() override;
36 virtual bool initProperties() override;
37 virtual bool updateProperties() override;
38 //virtual bool ISNewNumber(const char * dev, const char * name, double values[], char * names[], int n) override;
39 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40
41 protected:
46 virtual bool Handshake() override;
47
53 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
54
61 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
62
67 virtual bool AbortFocuser() override;
68
73 virtual void TimerHit() override;
74 virtual bool SetFocuserBacklash(int32_t steps) override;
75
76 private:
77 Aux::Communicator communicator;
78
79 // Do we have a response from the focuser?
80 bool Ack();
81
82 // Get initial focuser parameters when we first connect
83 bool getStartupParameters();
84
85 // truePos vs absPos:
86 // servo encoder values increase in CCW direction
87 // CCW travel moves primary mirror toward corrector plate, shifting focal plane away from OTA (i.e. increasingly "inside focus")
88 // max CCW travel corresponds to intrafocal limit
89
90 // "absPos" is the position referenced to the INDI focus interface (0 = intrafocal limit, increasing values toward extrafocal limit)
91 inline uint32_t absPos(uint32_t truePos) { return truePosMax - truePos;}
92
93 // "truePos" is the position of the servo motor encoder reported over serial connection
94 inline uint32_t truePos(uint32_t absPos) { return truePosMax - absPos;}
95
96
100 // Read and update Position
101 bool readPosition();
102 // Are we moving?
103 bool isMoving();
104 // read limits
105 bool readLimits();
106
110 bool startMove(uint32_t position);
111
115 // INumber BacklashN[1];
116 // INumberVectorProperty BacklashNP;
117
118 // INumber FocusMinPosN[1];
119 // INumberVectorProperty FocusMinPosNP;
120
121 uint32_t truePosMax;
122 uint32_t truePosMin;
123
124 bool backlashMove; // set if a final move is needed
125 uint32_t finalPosition;
126
127 INDI::PropertySwitch CalibrateSP {2};
128 enum
129 {
130 START,
131 STOP
132 };
133
134 INDI::PropertyText CalibrateStateTP {1};
135
136 bool calibrateInProgress;
137 int calibrateState;
138 bool focuserIsCalibrated;
139
143 // // Celestron Buffer
144 // static const uint8_t CELESTRON_LEN { 32 };
145 // // Celestorn Delimiter
146 // static const char CELESTRON_DEL { '#' };
147 // // Celestron Timeout in seconds
148 // static const uint8_t CELESTRON_TIMEOUT { 3 };
149};
The Communicator class handles high-level communication with the Celestron devices.
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
virtual bool AbortFocuser() override
AbortFocuser Abort Focuser motion.
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveAbsFocuser Move to an absolute target position.
virtual bool Handshake() override
Handshake Try to communicate with Focuser and see if there is a valid response.
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveRelFocuser Move focuser for a relative amount of ticks in a specific direction.
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Definition celestron.cpp:53
virtual void TimerHit() override
TimerHit Primary Loop called every POLLMS milliseconds (set in Options) to check on the focuser statu...
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
const char * getDefaultName() override
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158