Instrument Neutral Distributed Interface INDI  1.9.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 "indibase/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(INumberVectorProperty *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();
50  void defineOtherProperties();
52  void deleteOtherProperties();
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
82  bool updateDeviceVersion();
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
131 
132  // Go to park button
135 
136  // Focuser max position is inherited from superclass as FocusMaxPosN, FocusMaxPosNP
137  // Sync current focuser position to given value inherited from superclass as FocusSyncN, FocusSyncNP
138 
139  // Current focuser speed
142 
143  // Focuser temperature
146 
147  // Focuser current position is inherited from superclass as FocusAbsPosN, FocusAbsPosNP
148 
149 
150  // Focuser configuration tab: motion configuration
151  //
152 
153  // Device version string
156 
157  // Focuser goto speed: FocusSpeedNP and FocusSpeedN[1] from superclass
158 
159  // Focuser manual speed
162 
163  // Go-to acceleration
166 
167  // Manual acceleration
170 
171  // Manual deceleration
174 
175 
176  // Focuser configuration tab: motor configuration
177  //
178 
179  // Reverse motor direction: FocusReverseSP and FocusReverseS[2] from superclass. [0] is enable, [1] is disable (i.e. normal)
180 
181  // Configuration element: Motor microsteps
182  enum
183  {
185  };
188 
189  // Configuration element: Impulse resolution (???)
192 
193  // Configuration element: Motor current
196 
197  // Configuration element: Motor steps per revolution
200 
201  // Reboot device microcontroller button
204 
205  // Erase device EEPROM button
208 };
209 
210 #endif // TEENASTRROFOCUSER_H
TeenAstroFocuser::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process the client newSwitch command.
Definition: teenastro.cpp:304
TeenAstroFocuser::setParkPos
bool setParkPos(uint32_t value)
Definition: teenastro.cpp:676
TeenAstroFocuser::ReverseFocuser
bool ReverseFocuser(bool enable)
ReverseFocuser Reverse focuser motion direction.
Definition: teenastro.cpp:756
TeenAstroFocuser
Definition: teenastro.h:26
TeenAstroFocuser::CfgManualSpeedN
INumber CfgManualSpeedN[1]
Definition: teenastro.h:160
TeenAstroFocuser::DeviceVersionTP
ITextVectorProperty DeviceVersionTP
Definition: teenastro.h:155
TeenAstroFocuser::CfgMotorStepsPerRevolutionN
INumber CfgMotorStepsPerRevolutionN[1]
Definition: teenastro.h:198
TeenAstroFocuser::getDefaultName
const char * getDefaultName()
Definition: teenastro.cpp:77
IPState
IPState
Property state.
Definition: indiapi.h:158
TeenAstroFocuser::CfgManualAccNP
INumberVectorProperty CfgManualAccNP
Definition: teenastro.h:169
TeenAstroFocuser::CfgMotorResolutionN
INumber CfgMotorResolutionN[1]
Definition: teenastro.h:190
ISwitch
One switch descriptor.
TeenAstroFocuser::setManualSpeed
bool setManualSpeed(uint32_t value)
Definition: teenastro.cpp:686
INumber
One number descriptor.
TeenAstroFocuser::CfgMotorCurrentN
INumber CfgMotorCurrentN[1]
Definition: teenastro.h:194
TeenAstroFocuser::CfgManualSpeedNP
INumberVectorProperty CfgManualSpeedNP
Definition: teenastro.h:161
TeenAstroFocuser::CfgGoToAccN
INumber CfgGoToAccN[1]
Definition: teenastro.h:164
TeenAstroFocuser::CfgMotorMicrostepsS
ISwitch CfgMotorMicrostepsS[TAF_MICROS_N]
Definition: teenastro.h:186
TeenAstroFocuser::updateMotorConfig
bool updateMotorConfig()
Definition: teenastro.cpp:712
TeenAstroFocuser::AbortFocuser
virtual bool AbortFocuser()
AbortFocuser all focus motion.
Definition: teenastro.cpp:476
TeenAstroFocuser::initProperties
virtual bool initProperties()
Initilize properties initial state and value. The child class must implement this function.
Definition: teenastro.cpp:115
TeenAstroFocuser::updateProperties
virtual bool updateProperties()
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: teenastro.cpp:209
TeenAstroFocuser::setManualAcc
bool setManualAcc(uint32_t value)
Definition: teenastro.cpp:701
TeenAstroFocuser::RebootDeviceSP
ISwitchVectorProperty RebootDeviceSP
Definition: teenastro.h:203
TeenAstroFocuser::sendAndReceiveBool
bool sendAndReceiveBool(const char *const msg)
Definition: teenastro.cpp:531
TeenAstroFocuser::setMotorResolution
bool setMotorResolution(uint32_t value)
Definition: teenastro.cpp:770
TeenAstroFocuser::CfgManualDecN
INumber CfgManualDecN[1]
Definition: teenastro.h:172
TeenAstroFocuser::setGoToAcc
bool setGoToAcc(uint32_t value)
Definition: teenastro.cpp:696
TeenAstroFocuser::send
bool send(const char *const msg)
Definition: teenastro.cpp:496
TeenAstroFocuser::CfgMotorCurrentNP
INumberVectorProperty CfgMotorCurrentNP
Definition: teenastro.h:195
TeenAstroFocuser::updateDeviceVersion
bool updateDeviceVersion()
Definition: teenastro.cpp:570
TeenAstroFocuser::EraseEEPROMS
ISwitch EraseEEPROMS[1]
Definition: teenastro.h:206
indifocuser.h
TeenAstroFocuser::EraseEEPROMSP
ISwitchVectorProperty EraseEEPROMSP
Definition: teenastro.h:207
TeenAstroFocuser::CfgMotorMicrostepsSP
ISwitchVectorProperty CfgMotorMicrostepsSP
Definition: teenastro.h:187
TeenAstroFocuser::CfgManualDecNP
INumberVectorProperty CfgManualDecNP
Definition: teenastro.h:173
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
TeenAstroFocuser::eraseDeviceEEPROM
bool eraseDeviceEEPROM()
Definition: teenastro.cpp:818
TeenAstroFocuser::MoveRelFocuser
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks)
MoveFocuser the focuser to an relative position.
Definition: teenastro.cpp:454
TeenAstroFocuser::TempNP
INumberVectorProperty TempNP
Definition: teenastro.h:145
TeenAstroFocuser::RebootDeviceS
ISwitch RebootDeviceS[1]
Definition: teenastro.h:202
TeenAstroFocuser::CfgMotorStepsPerRevolutionNP
INumberVectorProperty CfgMotorStepsPerRevolutionNP
Definition: teenastro.h:199
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
TeenAstroFocuser::setManualDec
bool setManualDec(uint32_t value)
Definition: teenastro.cpp:706
TeenAstroFocuser::CurSpeedNP
INumberVectorProperty CurSpeedNP
Definition: teenastro.h:141
IText
One text descriptor.
TeenAstroFocuser::updateMotionConfig
bool updateMotionConfig()
Definition: teenastro.cpp:627
TeenAstroFocuser::CurSpeedN
INumber CurSpeedN[1]
Definition: teenastro.h:140
TeenAstroFocuser::TAF_MICROS_8
@ TAF_MICROS_8
Definition: teenastro.h:184
TeenAstroFocuser::TAF_MICROS_N
@ TAF_MICROS_N
Definition: teenastro.h:184
TeenAstroFocuser::saveConfigItems
bool saveConfigItems(FILE *fp)
saveConfigItems Saves the Device Port and Focuser Presets in the configuration file
Definition: teenastro.cpp:826
TeenAstroFocuser::CfgManualAccN
INumber CfgManualAccN[1]
Definition: teenastro.h:168
TeenAstroFocuser::deleteMainControlProperties
void deleteMainControlProperties()
Definition: teenastro.cpp:255
TeenAstroFocuser::TAF_MICROS_64
@ TAF_MICROS_64
Definition: teenastro.h:184
TeenAstroFocuser::ISNewNumberHelper
bool ISNewNumberHelper(INumberVectorProperty *NP, double values[], char *names[], int n, bool res)
Definition: teenastro.cpp:356
TeenAstroFocuser::updateState
bool updateState()
Definition: teenastro.cpp:583
TeenAstroFocuser::CfgParkPosN
INumber CfgParkPosN[1]
Definition: teenastro.h:129
TeenAstroFocuser::defineMainControlProperties
void defineMainControlProperties()
Definition: teenastro.cpp:236
TeenAstroFocuser::TAF_MICROS_32
@ TAF_MICROS_32
Definition: teenastro.h:184
TeenAstroFocuser::isMoving
bool isMoving()
Definition: teenastro.cpp:619
TeenAstroFocuser::GoToParkS
ISwitch GoToParkS[1]
Definition: teenastro.h:133
TeenAstroFocuser::TimerHit
virtual void TimerHit()
Callback function to be called once SetTimer duration elapses.
Definition: teenastro.cpp:467
TeenAstroFocuser::setMotorCurrent
bool setMotorCurrent(uint32_t value)
Definition: teenastro.cpp:775
TeenAstroFocuser::deleteOtherProperties
void deleteOtherProperties()
Definition: teenastro.cpp:286
TeenAstroFocuser::goToPark
bool goToPark()
Definition: teenastro.cpp:800
TeenAstroFocuser::sendAndExpectTimeout
bool sendAndExpectTimeout(const char *const msg, char *resp, int bufsize)
Definition: teenastro.cpp:551
TeenAstroFocuser::SyncFocuser
virtual bool SyncFocuser(uint32_t value)
SyncFocuser Set current position to ticks without moving the focuser.
Definition: teenastro.cpp:785
TeenAstroFocuser::SetFocuserSpeed
bool SetFocuserSpeed(int value)
SetFocuserSpeed Set Focuser speed.
Definition: teenastro.cpp:691
name
const char * name
Definition: indiserver.c:116
TeenAstroFocuser::TeenAstroFocuser
TeenAstroFocuser()
Definition: teenastro.cpp:67
TeenAstroFocuser::defineOtherProperties
void defineOtherProperties()
Definition: teenastro.cpp:263
TeenAstroFocuser::sendAndReceive
bool sendAndReceive(const char *const msg, char *resp, int bufsize)
Definition: teenastro.cpp:513
TeenAstroFocuser::initPositionPropertiesRanges
void initPositionPropertiesRanges(uint32_t maxPos)
Definition: teenastro.cpp:203
TeenAstroFocuser::TAF_MICROS_4
@ TAF_MICROS_4
Definition: teenastro.h:184
TeenAstroFocuser::CfgMotorResolutionNP
INumberVectorProperty CfgMotorResolutionNP
Definition: teenastro.h:191
TeenAstroFocuser::setConfigItem
bool setConfigItem(char item, uint32_t deviceValue)
Definition: teenastro.cpp:669
TeenAstroFocuser::TAF_MICROS_16
@ TAF_MICROS_16
Definition: teenastro.h:184
TeenAstroFocuser::rebootDevice
bool rebootDevice()
Definition: teenastro.cpp:810
INDI::FocuserInterface::FocusDirection
FocusDirection
Definition: indifocuserinterface.h:66
TeenAstroFocuser::stop
bool stop()
Definition: teenastro.cpp:805
TeenAstroFocuser::setMotorStepsPerRevolution
bool setMotorStepsPerRevolution(uint32_t value)
Definition: teenastro.cpp:780
TeenAstroFocuser::CfgParkPosNP
INumberVectorProperty CfgParkPosNP
Definition: teenastro.h:130
TeenAstroFocuser::~TeenAstroFocuser
~TeenAstroFocuser()
Definition: teenastro.cpp:73
TeenAstroFocuser::GoToParkSP
ISwitchVectorProperty GoToParkSP
Definition: teenastro.h:134
ISState
ISState
Switch state.
Definition: indiapi.h:148
TeenAstroFocuser::TempN
INumber TempN[1]
Definition: teenastro.h:144
TeenAstroFocuser::setMotorMicrosteps
bool setMotorMicrosteps(uint32_t value)
Definition: teenastro.cpp:761
TeenAstroFocuser::goTo
bool goTo(uint32_t position)
Definition: teenastro.cpp:793
TeenAstroFocuser::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process the client newNumber command.
Definition: teenastro.cpp:365
INDI::Focuser
Definition: indifocuser.h:43
TeenAstroFocuser::TAF_MICROS_128
@ TAF_MICROS_128
Definition: teenastro.h:184
TeenAstroFocuser::Handshake
virtual bool Handshake()
perform handshake with device to check communication
Definition: teenastro.cpp:82
TeenAstroFocuser::SetFocuserMaxPosition
bool SetFocuserMaxPosition(uint32_t value)
SetFocuserMaxPosition Update focuser maximum position. It only updates the PresetNP property limits.
Definition: teenastro.cpp:681
TeenAstroFocuser::CfgGoToAccNP
INumberVectorProperty CfgGoToAccNP
Definition: teenastro.h:165
TeenAstroFocuser::MoveAbsFocuser
virtual IPState MoveAbsFocuser(uint32_t ticks)
MoveFocuser the focuser to an absolute position.
Definition: teenastro.cpp:436
TeenAstroFocuser::DeviceVersionT
IText DeviceVersionT[1]
Definition: teenastro.h:154
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365