Instrument Neutral Distributed Interface INDI 2.2.5
teenastro.h
Go to the documentation of this file.
1/*
2 TeenAstro Focuser
3 Copyright (C) 2021 Markus Noga
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#ifndef TEENASTRO_FOCUSER_H
22#define TEENASTRO_FOCUSER_H
23
24#include "indifocuser.h"
25
27{
28 public:
31
32 const char * getDefaultName();
33 virtual bool Handshake();
34
35 virtual bool ISNewNumber (const char *dev, const char *name, double values[], char *names[], int n);
36 virtual bool ISNewSwitch (const char *dev, const char *name, ISState *states, char *names[], int n);
37
38 protected:
39 // Helper function to update NP with the values if res is true and display status IPS_OK, else display status IPS_ALERT. Returns res for convenience.
40 bool ISNewNumberHelper(INDI::PropertyNumber &NP, double values[], char *names[], int n, bool res);
41
42 virtual bool initProperties();
43
44 // Initializes value ranges and steps for position UI controls based on maxPos.
45 // Does not force redraw via deleteMainControlProperties() and defineMainControlProperties()
46 void initPositionPropertiesRanges(uint32_t maxPos);
47
48 virtual bool updateProperties();
53
54 virtual IPState MoveAbsFocuser(uint32_t ticks);
55 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks);
56 virtual bool AbortFocuser();
57 virtual void TimerHit();
58
59 // Syncs device focuser position to given value. Returns true on success else false.
60 virtual bool SyncFocuser(uint32_t value);
61
62 bool SetFocuserMaxPosition(uint32_t value);
63
64 bool ReverseFocuser(bool enable);
65
66 bool saveConfigItems(FILE *fp);
67
68
69 // Sends a command to the focuser. Returns true on success and false on failure.
70 bool send(const char *const msg);
71
72 // Sends a command to the focuser, and waits for a response terminated by '#'. Returns true on success and false on failure.
73 bool sendAndReceive(const char *const msg, char *resp, int bufsize);
74
75 // Sends a command to the focuser, and waits for a single character response. Returns true if successful and response is '1', otherwise false.
76 bool sendAndReceiveBool(const char *const msg);
77
78 // Sends a command to the focuser, and expects a timeout. Returns true if timeout happens, else false
79 bool sendAndExpectTimeout(const char *const msg, char *resp, int bufsize);
80
81 // Updates device version string from device
83
84 // Updates current state from device, consisting of position, speed, and temperature. Returns true on success and false on failure.
85 bool updateState();
86
87 // Returns true if focuser is moving, else false.
88 bool isMoving();
89
90 // Updates motion configuration from device. Returns true on success and false on failure.
91 bool updateMotionConfig();
92
93 // Sets given configuration item on to device to provided value in device native units. Returns true on success and false on failure.
94 bool setConfigItem(char item, uint32_t deviceValue);
95 bool setParkPos(uint32_t value);
96 bool SetFocuserSpeed(int value); // sets TeenAstro GoTo speed
97 bool setManualSpeed(uint32_t value);
98 bool setGoToAcc(uint32_t value);
99 bool setManualAcc(uint32_t value);
100 bool setManualDec(uint32_t value);
101
102 // Updates motor configuration from device. Returns true on success and false on failure.
103 bool updateMotorConfig();
104
105 bool setMotorMicrosteps(uint32_t value);
106 bool setMotorResolution(uint32_t value);
107 bool setMotorCurrent(uint32_t value);
108 bool setMotorStepsPerRevolution(uint32_t value);
109
110 // Starts movement of focuser towards the given absolute position. Returns immediately, true on success else false.
111 bool goTo(uint32_t position);
112
113 // Starts movement of focuser towards the parking position. Returns immediately, true on success else false.
114 bool goToPark();
115
116 // Stop focuser movement. Returns immediately, true on success else false.
117 bool stop();
118
119 // Reboots the device microcontroller
120 bool rebootDevice();
121
122 // Clears the device EEPROM
123 bool eraseDeviceEEPROM();
124
125 // Main control tab
126 //
127
128 // Focuser park position
130
131 // Go to park button
134
135 // Focuser max position is inherited from superclass as FocusMaxPosN, FocusMaxPosNP
136 // Sync current focuser position to given value inherited from superclass as FocusSyncN, FocusSyncNP
137
138 // Current focuser speed
141
142 // Focuser temperature
145
146 // Focuser current position is inherited from superclass as FocusAbsPosN, FocusAbsPosNP
147
148
149 // Focuser configuration tab: motion configuration
150 //
151
152 // Device version string
155
156 // Focuser goto speed: FocusSpeedNP and FocusSpeedN[1] from superclass
157
158 // Focuser manual speed
160
161 // Go-to acceleration
163 // INumberVectorProperty CfgGoToAccNP;
164
165 // Manual acceleration
167
168 // Manual deceleration
170
171
172 // Focuser configuration tab: motor configuration
173 //
174
175 // Reverse motor direction: FocusReverseSP and FocusReverseS[2] from superclass. [0] is enable, [1] is disable (i.e. normal)
176
177 // Configuration element: Motor microsteps
178 enum
179 {
181 };
184
185 // Configuration element: Impulse resolution (???)
187
188 // Configuration element: Motor current
190
191 // Configuration element: Motor steps per revolution
193
194 // Reboot device microcontroller button
197
198 // Erase device EEPROM button
201};
202
203#endif // TEENASTRROFOCUSER_H
ISwitchVectorProperty RebootDeviceSP
Definition teenastro.h:196
bool setManualSpeed(uint32_t value)
void deleteOtherProperties()
ISwitchVectorProperty CfgMotorMicrostepsSP
Definition teenastro.h:183
bool setMotorCurrent(uint32_t value)
bool setManualAcc(uint32_t value)
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
bool sendAndReceiveBool(const char *const msg)
INDI::PropertyNumber CfgMotorCurrentNP
Definition teenastro.h:189
bool setConfigItem(char item, uint32_t deviceValue)
void deleteMainControlProperties()
void defineOtherProperties()
virtual bool AbortFocuser()
AbortFocuser all focus motion.
virtual void TimerHit()
Callback function to be called once SetTimer duration elapses.
bool saveConfigItems(FILE *fp)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
bool setMotorStepsPerRevolution(uint32_t value)
INDI::PropertyNumber CfgManualSpeedNP
Definition teenastro.h:159
bool send(const char *const msg)
INumberVectorProperty TempNP
Definition teenastro.h:144
INDI::PropertyNumber CfgMotorResolutionNP
Definition teenastro.h:186
void initPositionPropertiesRanges(uint32_t maxPos)
bool ReverseFocuser(bool enable)
ReverseFocuser Reverse focuser motion direction.
virtual bool SyncFocuser(uint32_t value)
SyncFocuser Set current position to ticks without moving the focuser.
void defineMainControlProperties()
bool updateMotorConfig()
INumber TempN[1]
Definition teenastro.h:143
bool eraseDeviceEEPROM()
INDI::PropertyNumber CfgManualAccNP
Definition teenastro.h:166
bool setMotorMicrosteps(uint32_t value)
bool setMotorResolution(uint32_t value)
ITextVectorProperty DeviceVersionTP
Definition teenastro.h:154
INDI::PropertyNumber CfgManualDecNP
Definition teenastro.h:169
ISwitchVectorProperty GoToParkSP
Definition teenastro.h:133
ISwitch RebootDeviceS[1]
Definition teenastro.h:195
const char * getDefaultName()
Definition teenastro.cpp:77
bool SetFocuserMaxPosition(uint32_t value)
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
INumber CurSpeedN[1]
Definition teenastro.h:139
bool sendAndReceive(const char *const msg, char *resp, int bufsize)
ISwitchVectorProperty EraseEEPROMSP
Definition teenastro.h:200
bool updateDeviceVersion()
ISwitch GoToParkS[1]
Definition teenastro.h:132
bool sendAndExpectTimeout(const char *const msg, char *resp, int bufsize)
ISwitch CfgMotorMicrostepsS[TAF_MICROS_N]
Definition teenastro.h:182
IText DeviceVersionT[1]
Definition teenastro.h:153
INDI::PropertyNumber CfgGoToAccNP
Definition teenastro.h:162
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks)
MoveFocuser the focuser to an relative position.
virtual bool updateProperties()
Updates the state and definition of properties based on the current connection status....
bool SetFocuserSpeed(int value)
SetFocuserSpeed Set Focuser speed.
bool setParkPos(uint32_t value)
ISwitch EraseEEPROMS[1]
Definition teenastro.h:199
bool setManualDec(uint32_t value)
INumberVectorProperty CurSpeedNP
Definition teenastro.h:140
virtual IPState MoveAbsFocuser(uint32_t ticks)
MoveFocuser the focuser to an absolute position.
INDI::PropertyNumber CfgMotorStepsPerRevolutionNP
Definition teenastro.h:192
virtual bool initProperties()
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
INDI::PropertyNumber CfgParkPosNP
Definition teenastro.h:129
virtual bool Handshake()
Performs a device-specific handshake after a connection is established. This method should be overrid...
Definition teenastro.cpp:82
bool ISNewNumberHelper(INDI::PropertyNumber &NP, double values[], char *names[], int n, bool res)
bool updateMotionConfig()
bool goTo(uint32_t position)
bool setGoToAcc(uint32_t value)
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
One number descriptor.
One switch descriptor.
One text descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365
Text vector property descriptor.
Definition indiapi.h:244