Instrument Neutral Distributed Interface INDI 2.2.5
moonlite.h
Go to the documentation of this file.
1/*
2 Moonlite Focuser
3 Copyright (C) 2013-2019 Jasem Mutlaq ([email protected])
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#pragma once
22
23#include "indifocuser.h"
24
25#include <chrono>
26
27class MoonLite : public INDI::Focuser
28{
29 public:
30 MoonLite();
31 virtual ~MoonLite() override = default;
32
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 static void timedMoveHelper(void * context);
42
43 protected:
48 virtual bool Handshake() override;
49
57 virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
58
64 virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
65
72 virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
73
79 virtual bool SyncFocuser(uint32_t ticks) override;
80
81 virtual bool SetFocuserSpeed(int speed) override;
82 virtual bool AbortFocuser() override;
83 virtual void TimerHit() override;
84 virtual bool saveConfigItems(FILE * fp) override;
85
86 private:
87 bool Ack();
97 bool sendCommand(const char * cmd, char * res = nullptr, bool silent = false, int nret = 0);
98
99 // Get initial focuser parameter when we first connect
100 void GetFocusParams();
101 // Read and update Step Mode
102 bool readStepMode();
103 // Read and update Temperature
104 bool readTemperature();
105 // Read and update Temperature Coefficient
106 bool readTemperatureCoefficient();
107 // Read and update Position
108 bool readPosition();
109 // Read and update speed
110 bool readSpeed();
111 // Read version
112 bool readVersion();
113 // Are we moving?
114 bool isMoving();
115
116 bool MoveFocuser(uint32_t position);
117 bool setStepMode(FocusStepMode mode);
118 bool setSpeed(int speed);
119 bool setTemperatureCalibration(double calibration);
120 bool setTemperatureCoefficient(double coefficient);
121 bool setTemperatureCompensation(bool enable);
122 void timedMoveCallback();
123
124 uint32_t targetPos { 0 }, lastPos { 0 }, lastTemperature { 0 };
125
126 // Read Only Temperature Reporting
127 INDI::PropertyNumber TemperatureNP {1};
128
129 // Full/Half Step modes
130 INDI::PropertySwitch StepModeSP {2};
131
132 // Temperature Settings
133 INDI::PropertyNumber TemperatureSettingNP {2};
134 enum
135 {
136 Calibration,
137 Coefficient
138 };
139
140 // Temperature Compensation Enable/Disable
141 INDI::PropertySwitch TemperatureCompensateSP {2};
142
143 // MoonLite Buffer
144 static const uint8_t ML_RES { 32 };
145 // MoonLite Delimiter
146 static const char ML_DEL { '#' };
147 // MoonLite Timeout
148 static const uint8_t ML_TIMEOUT { 3 };
149};
virtual ~MoonLite() override=default
virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser Move focuser in a specific direction and speed for period of time.
Definition moonlite.cpp:464
virtual bool saveConfigItems(FILE *fp) override
Definition moonlite.cpp:574
static void timedMoveHelper(void *context)
Definition moonlite.cpp:483
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition moonlite.cpp:528
virtual bool SetFocuserSpeed(int speed) override
SetFocuserSpeed Set Focuser speed.
Definition moonlite.cpp:459
FocusStepMode
Definition moonlite.h:33
@ FOCUS_HALF_STEP
Definition moonlite.h:33
@ FOCUS_FULL_STEP
Definition moonlite.h:33
const char * getDefaultName() override
Definition moonlite.cpp:130
virtual bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set the supplied position as the current focuser position.
Definition moonlite.cpp:312
virtual bool Handshake() override
Handshake Try to communicate with Focuser and see if there is a valid response.
Definition moonlite.cpp:117
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition moonlite.cpp:569
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...
Definition moonlite.cpp:356
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveAbsFocuser Move to an absolute target position.
Definition moonlite.cpp:500
virtual bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
Definition moonlite.cpp:91
virtual bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
Definition moonlite.cpp:43
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Processes incoming new number values from the client for this device. Handles updates to FocuserInter...
Definition moonlite.cpp:416
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveRelFocuser Move focuser for a relative amount of ticks in a specific direction.
Definition moonlite.cpp:510
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2