1 /*******************************************************************************
2   Copyright(c) 2016 Andy Kirkham. All rights reserved.
3 
4  HitecAstroDCFocuser Focuser
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
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  Library General Public License for more details.
14  .
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB.  If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 *******************************************************************************/
20 
21 #pragma once
22 
23 #include "hidapi.h"
24 #include "indifocuser.h"
25 #include "indiusbdevice.h"
26 
27 class HitecAstroDCFocuser : public INDI::Focuser, public INDI::USBDevice
28 {
29     public:
30         typedef enum { IDLE, SLEWING } STATE;
31 
32         HitecAstroDCFocuser();
33         virtual ~HitecAstroDCFocuser() override;
34 
35         virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
36 
37     protected:
38         const char *getDefaultName() override;
39         virtual bool initProperties() override;
40         virtual bool updateProperties() override;
41         virtual bool saveConfigItems(FILE *fp) override;
42 
43         bool Connect() override;
44         bool Disconnect() override;
45 
46         void TimerHit() override;
47 
48         virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
49         virtual IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override;
ReverseFocuser(bool enabled)50         virtual bool ReverseFocuser(bool enabled) override
51         {
52             INDI_UNUSED(enabled);
53             return true;
54         }
55 
56     private:
57         hid_device *m_HIDHandle;
58         char m_StopChar;
59         STATE m_State;
60         uint16_t m_Duration;
61 
62         //        INumber MaxPositionN[1];
63         //        INumberVectorProperty MaxPositionNP;
64 
65         INumber SlewSpeedN[1];
66         INumberVectorProperty SlewSpeedNP;
67 
68         //        ISwitch ReverseDirectionS[1];
69         //        ISwitchVectorProperty ReverseDirectionSP;
70 };
71