-
Notifications
You must be signed in to change notification settings - Fork 387
/
arduino_st4.h
80 lines (58 loc) · 2.57 KB
/
arduino_st4.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*******************************************************************************
Copyright(c) 2018 Jasem Mutlaq. All rights reserved.
Arduino ST4 Driver.
For this project: https://github.com/kevinferrare/arduino-st4
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
The full GNU General Public License is included in this distribution in the
file called LICENSE.
*******************************************************************************/
#pragma once
#include "defaultdevice.h"
#include "indiguiderinterface.h"
#include <stdint.h>
namespace Connection
{
class Serial;
}
class ArduinoST4 : public INDI::DefaultDevice, public INDI::GuiderInterface
{
public:
ArduinoST4();
typedef enum { ARD_N, ARD_S, ARD_W, ARD_E } ARDUINO_DIRECTION;
virtual bool initProperties() override;
virtual bool updateProperties() override;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override ;
void guideTimeout(ARDUINO_DIRECTION direction);
protected:
const char *getDefaultName() override;
virtual bool Disconnect() override;
virtual IPState GuideNorth(uint32_t ms) override;
virtual IPState GuideSouth(uint32_t ms) override;
virtual IPState GuideEast(uint32_t ms) override;
virtual IPState GuideWest(uint32_t ms) override;
// Helper functions
static void guideTimeoutHelperN(void *p);
static void guideTimeoutHelperS(void *p);
static void guideTimeoutHelperW(void *p);
static void guideTimeoutHelperE(void *p);
private:
bool Handshake();
bool sendCommand(const char *cmd);
int GuideNSTID { -1 };
int GuideWETID { -1 };
ARDUINO_DIRECTION guideDirection;
int PortFD { -1 };
Connection::Serial *serialConnection { nullptr };
const uint8_t ARDUINO_TIMEOUT = 3;
};