-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpimoco_focuser.h
executable file
·88 lines (64 loc) · 3.24 KB
/
pimoco_focuser.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
81
82
83
84
85
86
87
88
/*
PiMoCo: Raspberry Pi Telescope Mount and Focuser Control
Copyright (C) 2021 Markus Noga
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 3 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 General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef PIMOCO_FOCUSER_H
#define PIMOCO_FOCUSER_H
#include <libindi/indifocuser.h>
#include "pimoco_stepper.h"
// Indi class for pimoco focusers
class PimocoFocuser : public INDI::Focuser {
public:
// Creates a Pimoco focuser
PimocoFocuser();
// Destroys this pimoco focuser. Stops device motion for safety's sake
~PimocoFocuser();
virtual const char *getDefaultName() override;
virtual bool initProperties() override;
virtual bool updateProperties() override;
virtual bool ISNewBLOB(const char *dev, const char *name, int sizes[], int blobsizes[], char *blobs[], char *formats[], char *names[], int n) override;
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
virtual bool ISSnoopDevice(XMLEle *root) override;
// Updates number vector property with the given values if res is true and display status IPS_OK, else display status IPS_ALERT. Returns res for convenience.
bool ISUpdateNumber(INumberVectorProperty *NP, double values[], char *names[], int n, bool res);
protected:
virtual bool saveConfigItems(FILE *fp) override;
virtual bool Connect() override;
virtual bool Disconnect() override;
virtual bool Handshake() override;
virtual void TimerHit() override;
// Updates focuser position and status flags from device. Returns true on success, else false.
bool ReadFocuserStatus();
virtual IPState MoveAbsFocuser(uint32_t targetTicks) override;
virtual IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
virtual bool AbortFocuser() override;
virtual bool ReverseFocuser(bool enabled) override;
virtual bool SetFocuserSpeed(int speed) override;
virtual bool SyncFocuser(uint32_t ticks) override;
Stepper stepper;
const char *spiDeviceFilename;
// Physical connector GPIO pin numbers for stepper DIAG0 lines
enum { FOCUSER_DIAG0_PIN = 38 };
// UI controls
//
INumber MotorN[Stepper::MOTORN_SIZE]={};
INumberVectorProperty MotorNP;
ISwitch MSwitchS[Stepper::MSWITCHS_SIZE]={};
ISwitchVectorProperty MSwitchSP;
INumber RampN[Stepper::RAMPN_SIZE]={};
INumberVectorProperty RampNP;
};
#endif // PIMOCO_FOCUSER_H