Instrument Neutral Distributed Interface INDI  2.0.2
esatto.h
Go to the documentation of this file.
1 /*
2  Esatto Focuser
3  Copyright (C) 2022 Jasem Mutlaq
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 #include "inditimer.h"
25 #include "primalucacommandset.h"
26 
27 class Esatto : public INDI::Focuser
28 {
29  public:
30  Esatto();
31  virtual ~Esatto() override = default;
32 
33  const char *getDefaultName() override;
34  virtual bool initProperties() override;
35  virtual bool updateProperties() override;
36  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
37 
38  protected:
39  virtual bool Handshake() override;
40  virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
41  virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
42  virtual bool ReverseFocuser(bool enabled) override;
43  virtual bool AbortFocuser() override;
44  virtual void TimerHit() override;
45  virtual bool SetFocuserBacklash(int32_t steps) override;
46 
47  private:
48  bool Ack();
49 
50  bool updateTemperature();
51  bool updatePosition();
52  bool updateVoltageIn();
53  bool updateMaxLimit();
54 
55  void setConnectionParams();
56  bool initCommandSet();
57 
58  bool getStartupValues();
59  void hexDump(char * buf, const char * data, int size);
60 
61  uint16_t m_TemperatureCounter { 0 };
62 
63  INDI::PropertyNumber TemperatureNP {2};
64  enum
65  {
66  TEMPERATURE_EXTERNAL,
67  TEMPERATURE_MOTOR,
68  };
69 
70  INDI::PropertyText FirmwareTP {2};
71  enum
72  {
73  FIRMWARE_SN,
74  FIRMWARE_VERSION,
75  };
76 
77  INDI::PropertyNumber VoltageNP {2};
78  enum
79  {
80  VOLTAGE_12V,
81  VOLTAGE_USB
82  };
83 
84  INDI::PropertySwitch FastMoveSP {3};
85  enum
86  {
87  FASTMOVE_IN,
88  FASTMOVE_OUT,
89  FASTMOVE_STOP
90  };
91 
92  std::unique_ptr<PrimalucaLabs::Esatto> m_Esatto;
93  static constexpr uint8_t TEMPERATURE_FREQUENCY {10};
94 };
Definition: esatto.h:28
const char * getDefaultName() override
Definition: esatto.cpp:156
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: esatto.cpp:224
virtual bool AbortFocuser() override
AbortFocuser all focus motion.
Definition: esatto.cpp:285
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
Definition: esatto.cpp:271
Esatto()
Definition: esatto.cpp:34
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
Definition: esatto.cpp:260
virtual bool SetFocuserBacklash(int32_t steps) override
SetFocuserBacklash Set the focuser backlash compensation value.
Definition: esatto.cpp:406
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: esatto.cpp:46
virtual bool Handshake() override
perform handshake with device to check communication
Definition: esatto.cpp:140
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: esatto.cpp:296
virtual bool ReverseFocuser(bool enabled) override
ReverseFocuser Reverse focuser motion direction.
Definition: esatto.cpp:364
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: esatto.cpp:109
virtual ~Esatto() override=default
ISState
Switch state.
Definition: indiapi.h:150
IPState
Property state.
Definition: indiapi.h:160