Instrument Neutral Distributed Interface INDI 2.2.5
lx200am5.h
Go to the documentation of this file.
1/*
2 ZWO Mount INDI driver
3
4 Copyright (C) 2015-2027 Jasem Mutlaq
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#pragma once
22
23#include "lx200generic.h"
24#include "indipropertyswitch.h"
25#include "indipropertynumber.h"
26#include "indipropertytext.h"
27
28#include <chrono>
29
30class LX200AM5 : public LX200Generic
31{
32 public:
33 LX200AM5();
34 virtual ~LX200AM5() override = default;
35
36 virtual bool updateProperties() override;
37 virtual bool initProperties() override;
38
39 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
41
42 protected:
43 virtual const char *getDefaultName() override;
44
45 // Communication
46 virtual bool checkConnection() override;
47
48 // Motion & Goto
49 virtual bool ReadScopeStatus() override;
50 virtual bool SetSlewRate(int index) override;
51 virtual bool SetMountType(TelescopeMountType type) override;
52
53 // Tracking
54 virtual bool SetTrackEnabled(bool enabled) override;
55
56 // Time & Location
57 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
58 virtual bool setUTCOffset(double offset) override;
59 virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override;
60
61 // Parking
62 virtual bool Park() override;
63 virtual bool UnPark() override;
64 virtual bool SetCurrentPark() override;
65 virtual bool SetDefaultPark() override;
66
67 // Home
68 virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override;
69
70 // Config
71 virtual bool saveConfigItems(FILE *fp) override;
72
73 private:
74
78
89 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
97 bool sendStatusCommand(const char * cmd, char * res);
98 void hexDump(char * buf, const char * data, int size);
99 std::vector<std::string> split(const std::string &input, const std::string &regex);
100
104 // Go Home
105 //INDI::PropertySwitch HomeSP {1};
106 // Guide Rate
107 INDI::PropertyNumber GuideRateNP {1};
108 // Buzzer control
109 INDI::PropertySwitch BuzzerSP {3};
110 enum
111 {
112 Off,
113 Low,
114 High
115 };
116
117 // Heavy duty control
118 INDI::PropertySwitch HeavyDutyModeSP {2};
119
120 // Meridian Flip Control
121 INDI::PropertySwitch MeridianFlipSP {2};
122
123 // Post Meridian Track Control
124 INDI::PropertySwitch PostMeridianTrackSP {2};
125 enum
126 {
127 TRACK,
128 STOP
129 };
130
131 // Meridian Limit
132 INDI::PropertyNumber MeridianLimitNP {1};
133
134 // Altitude Limits
135 INDI::PropertySwitch AltitudeLimitSP {3};
136 enum
137 {
138 ALT_LIMIT_ENABLE,
139 ALT_LIMIT_DISABLE,
140 ALT_LIMIT_GET
141 };
142 INDI::PropertyNumber AltitudeLimitUpperNP {1};
143 INDI::PropertyNumber AltitudeLimitLowerNP {1};
144
145 // Multi-Star Alignment
146 INDI::PropertySwitch MultiStarAlignSP {1};
147 enum
148 {
149 CLEAR_ALIGNMENT_DATA
150 };
151
152 // Variable Slew Speed
153 INDI::PropertyNumber VariableSlewRateNP {1};
154
155 // Mount model and firmware version
156 INDI::PropertyText FirmwareTP {2};
157 enum
158 {
159 FIRMWARE_MODEL,
160 FIRMWARE_VERSION
161 };
162
163 // Whether a custom park position was stored in the mount (:Sp01#). The mount cannot be queried
164 // for it, so it is kept in the config only and never defined. Without one, park goes home.
165 INDI::PropertySwitch CustomParkSP {1};
166
167
171 void setup();
172
173 // Homing
174 bool goHome();
175 bool park();
176 bool setHome();
177
178 // Firmware
179 void getFirmwareInfo();
180 bool hasMountPark() const
181 {
182 return m_FirmwareVersion >= FIRMWARE_MOUNT_PARK;
183 }
184 bool hasCustomParkPosition() const
185 {
186 return m_FirmwareVersion >= FIRMWARE_CUSTOM_PARK_POSITION;
187 }
188
189 // Mount park position (firmware dependent)
190 bool parkToMountPosition();
191 bool getMountParkState(char &state);
192 void checkMountParkState();
193 void updateMountPark(bool slewComplete);
194 void failMountPark(const char *reason);
195
196 // Altitude Limits
197 bool setAltitudeLimitEnabled(bool enable);
198 bool getAltitudeLimitStatus();
199 bool setAltitudeLimitUpper(double limit);
200 bool getAltitudeLimitUpper();
201 bool setAltitudeLimitLower(double limit);
202 bool getAltitudeLimitLower();
203
204 // Multi-Star Alignment
205 bool clearMultiStarAlignmentData();
206
207 // Variable Slew Speed
208 bool setVariableSlewRate(double rate);
209
210 // Guide Rate
211 bool setGuideRate(double value);
212 bool getGuideRate();
213
214 // Buzzer
215 bool getBuzzer();
216 bool setBuzzer(int value);
217
218 // Heavy Duty Mode
219 bool getHeavyDutyMode();
220 bool setHeavyDutyMode(bool enable);
221
222 // Mount type
223 bool readMountType();
224
225 // Track Mode
226 bool getTrackMode();
227 bool isTracking();
228
229 // Meridian Flip
230 bool setMeridianFlipSettings(bool enabled, bool track, double limit);
231 bool getMeridianFlipSettings();
232
233
237 // # is the stop char
238 static const char DRIVER_STOP_CHAR { 0x23 };
239 // Wait up to a maximum of 3 seconds for serial input
240 static constexpr const uint8_t DRIVER_TIMEOUT {3};
241 // Maximum buffer for sending/receiving.
242 static constexpr const uint8_t DRIVER_LEN {64};
243 // Slew Modes
244 static constexpr const uint8_t SLEW_MODES {10};
245 static constexpr const char * MERIDIAN_FLIP_TAB {"Meridian Flip"};
246 static constexpr const char * ALTITUDE_LIMIT_TAB {"Altitude Limits"};
247 static constexpr const char * ALIGNMENT_TAB {"Alignment"};
248
249 // Firmware versions encoded as (major << 16) | (minor << 8) | patch
250 // :hP# parks, :Gps# reports the park state and :Spu# unparks.
251 static constexpr uint32_t FIRMWARE_MOUNT_PARK {0x010109};
252 // :Sp01# stores the current position as the park position.
253 static constexpr uint32_t FIRMWARE_CUSTOM_PARK_POSITION {0x010300};
254 // Give up a park that does not start moving within this time.
255 static constexpr std::chrono::seconds PARK_START_TIMEOUT {5};
256
257 uint32_t m_FirmwareVersion {0};
258
259 // Parking to the mount park position (:hP#), tracked with :Gps#.
260 bool m_MountParking {false};
261 bool m_ParkMoved {false};
262 std::chrono::steady_clock::time_point m_ParkDeadline;
263};
int SetSlewRate(void)
TelescopeMountType
Mount geometry reported in the standard TELESCOPE_MOUNT_TYPE property. The values are the indices of ...
virtual bool ReadScopeStatus() override
Read telescope status.
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition lx200am5.cpp:178
virtual bool SetMountType(TelescopeMountType type) override
SetMountType Called when the user selects a different mount type in TELESCOPE_MOUNT_TYPE....
Definition lx200am5.cpp:449
virtual bool SetDefaultPark() override
Definition lx200am5.cpp:999
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition lx200am5.cpp:810
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition lx200am5.cpp:56
virtual bool Park() override
Park the telescope to its home position.
Definition lx200am5.cpp:897
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition lx200am5.cpp:391
virtual const char * getDefaultName() override
Definition lx200am5.cpp:247
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition lx200am5.cpp:916
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool checkConnection() override
Definition lx200am5.cpp:255
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition lx200am5.cpp:302
virtual ~LX200AM5() override=default
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition lx200am5.cpp:862
virtual bool setUTCOffset(double offset) override
Definition lx200am5.cpp:789
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition lx200am5.cpp:948
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
Definition lx200am5.cpp:800
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
*brief user defined string literal for JSON values *sa std::size_t n
uint16_t type
Definition pwc-ioctl.h:0
uint8_t cmd[4]
Definition pwc-ioctl.h:2