-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathDobson.h
83 lines (61 loc) · 2.53 KB
/
Dobson.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
#pragma once
/*
* Dobson.h
*
* Created on: 27.08.2019
* Author: lukas
*/
#include <AccelStepper.h>
#include <FuGPS.h>
#include "./location.h"
#include "./Observer.h"
#include "./Mount.h"
class Dobson: public Mount {
public:
Dobson(AccelStepper &azimuthStepper, AccelStepper &altitudeSteppers, Observer &observer);
// This runs at the very end of the Arduino setup() function and sets the operating mode and initial target
void initialize();
// Calculates the next targets for the steppers, based on the GPS position, current time and target
// This does not yet update the stepper motor targets, but stores them in the protected member variable _steppersTarget
// It also calls the azAltToRaDec() method with the current stepper position and stores the result
void calculateMotorTargets();
AzAlt<double> raDecToAltAz(RaDecPosition target);
AzAlt<double> getMotorAngles() {
return {
_azimuthStepper.currentPosition() / AZ_STEPS_PER_DEG,
_altitudeStepper.currentPosition() / ALT_STEPS_PER_DEG,
};
}
void setAlignment(RaDecPosition alignment);
// Calculates the current position in Ra/Dec, which is reported back to Stellarium or other connected tools
RaDecPosition azAltToRaDec(AzAlt<double> position);
// Sets the actual motor targets, based on the contents of _steppersTarget
void move();
// It is set to true at the end of the move() method, if at least one stepper target was changed
// It is then reset at the beginning of calculateMotorTargets()
bool _didMove = false;
#ifdef DEBUG_TIMING
// How long calculateMotorTargets took to execute (including azAltToRaDec())
long _lastCalcMicros = 0;
#endif
protected:
// Reference to the azimuth stepper
AccelStepper &_azimuthStepper;
// Reference to the altitude stepper
AccelStepper &_altitudeStepper;
// Reference to the Observer (GPS/Fixed)
Observer &_observer;
// Stores the current local sidereal time
// This is written to (and used) by calculateMotorTargets() and just used by azAltToRaDec()
double _currentLocalSiderealTime;
// Target position in degrees
AzAlt<double> _targetDegrees;
// The position of the steppers when homing was performed (in steps).
AzAlt<long> _steppersHomed;
// Current stepper target position for the steppers (in steps). It is written to at the end of calculateMotorTargets()
AzAlt<long> _steppersTarget;
// Target position for the steppers before the last move (in steps). It is written to at the end of move()
AzAlt<long> _steppersLastTarget;
// Outputs various debug statements
void debugMove(long diffAz, long diffAlt);
};