1
1
// If you really want to look through this code, i apologise for my terrible coding
2
2
// #include <SoftwareSerial.h>
3
+ #include < stdarg.h>
3
4
#include < EEPROM.h>
4
5
#include < AccelStepper.h>
5
6
#include < LiquidCrystal.h>
6
7
#include < SoftwareSerial.h>
8
+
7
9
#define HALFSTEP 8
8
10
#define FULLSTEP 4
9
11
10
12
LiquidCrystal lcd (8 , 9 , 4 , 5 , 6 , 7 );
11
13
// SoftwareSerial BT(10,11);
12
14
15
+ // RA Motor pins
13
16
#define motorPin1 2 // IN1 auf ULN2003 driver 1 // 2 / 22
14
17
#define motorPin2 3 // IN2 auf ULN2003 driver 1 // 3 / 24
15
18
#define motorPin3 11 // IN3 auf ULN2003 driver 1 // 11 / 26
16
19
#define motorPin4 12 // IN4 auf ULN2003 driver 1 // 12 / 28
17
20
21
+ // DEC Motor pins
18
22
#define motorPin11 15 // IN1 auf ULN2003 driver 2
19
23
#define motorPin12 16 // IN2 auf ULN2003 driver 2
20
24
#define motorPin13 17 // IN3 auf ULN2003 driver 2
21
25
#define motorPin14 18 // IN4 auf ULN2003 driver 2
22
26
27
+ // LCD shield buttons
23
28
#define btnRIGHT 0
24
29
#define btnUP 1
25
30
#define btnDOWN 2
26
31
#define btnLEFT 3
27
32
#define btnSELECT 4
28
33
#define btnNONE 5
29
34
30
- int lcd_key = 0 ;
31
- int adc_key_in = 0 ;
32
- int read_LCD_buttons () {
33
- adc_key_in = analogRead (0 );
34
- if (adc_key_in > 1000 ) return btnNONE;
35
- if (adc_key_in < 50 ) return btnRIGHT;
36
- if (adc_key_in < 250 ) return btnUP;
37
- if (adc_key_in < 450 ) return btnDOWN;
38
- if (adc_key_in < 600 ) return btnLEFT;
39
- if (adc_key_in < 920 ) return btnSELECT;
40
- // return btnNONE;
41
- }
42
-
43
- String inString = " " ;
44
-
35
+ // Menu IDs
36
+ #define RA_Menu 0
37
+ #define DEC_Menu 1
38
+ #define HA_Menu 2
39
+ #define Polaris_Menu 3
40
+ #define Heat_Menu 4
41
+ #define Calibration_Menu 5
42
+ #define Control_Menu 6
43
+ #define Home_Menu 7
44
+ #define POI_Menu 8
45
+
46
+ // Stepper control for RA and DEV.
47
+ // TRK is used for live tracking and runs in parallel with RA.
48
+ // GUIDE is used for Stellarium control
45
49
AccelStepper stepperRA (FULLSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
46
50
AccelStepper stepperDEC (HALFSTEP, motorPin11, motorPin13, motorPin12, motorPin14);
47
51
AccelStepper stepperTRK (HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4); // yes, this is the same motor as stepperRA, dont ask why
48
52
AccelStepper stepperGUIDE (HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
49
53
54
+ int lcd_key = 0 ; // The current key state
55
+ int adc_key_in = 0 ; // The analog value of the keys
56
+
57
+ String inString = " " ;
58
+
59
+ bool inStartup = true ; // Start with a guided startup
60
+
61
+ int calDelay = 150 ; // The current delay when changing calibration value. The longer a button is depressed, the samller this gets.
62
+
63
+ bool waitForButtonRelease = false ; // When a button is pressed should we wait for its release before another loop?
64
+
65
+ // Variables for use in the CONTROL menu
66
+ int StateMaskDEC = 0x0011 ; // Is the DEC stepper running?
67
+ int StateMaskUp = 0x0001 ; // Is the DEC stepper moving upwards?
68
+ int StateMaskDown = 0x0010 ; // Is the DEC stepper moving downwards?
69
+ int StateMaskRA = 0x1100 ; // Is the RA stepper running?
70
+ int StateMaskLeft = 0x0100 ; // Is the RA stepper moving left (CW)?
71
+ int StateMaskRight = 0x1000 ; // Is the RA stepper moving right (CCW)?
72
+
73
+ int controlState = 0x0000 ; // The current state of the steppers (combination of above values)
74
+ int controlDisplay = 0 ; // How many loop cycles left before updating the display
75
+ bool inControlMode = false ; // Is manual control enabled
76
+
77
+ int lastKey = btnNONE; // The key state when we last came through the loop
78
+
79
+ float totalDECMove = 0 ; // The number of DEC steps we asked for
80
+ float totalRAMove = 0 ;
81
+ bool isUnreachable = false ;
82
+
50
83
// String inCmd;
51
84
// String inputString = "";
52
85
// String commandString = "";
@@ -58,10 +91,9 @@ String logString;
58
91
boolean isPulseGuiding = true ;
59
92
60
93
unsigned long Zeit;
61
- float onehour ;
94
+ float stepsPerHour ;
62
95
63
96
boolean pcControl = false ;
64
- int menu = 2 ;
65
97
int currentSecs;
66
98
int currentMins;
67
99
float inputcal;
@@ -75,15 +107,9 @@ int mPolarisPosition;
75
107
int tracking = 1 ;
76
108
float trackingspeed;
77
109
78
- // RA stuff
79
- float hourRA;
80
- float minRA = 0 ;
81
- float secRA = 0 ;
110
+ // RA stuff
82
111
float moveRA;
83
112
int RAselect;
84
- int hourRAprint;
85
- int minRAprint;
86
- int secRAprint;
87
113
88
114
// DEC stuff
89
115
int degreeDEC;
@@ -93,29 +119,27 @@ float moveDEC;
93
119
int DECselect;
94
120
int printdegDEC;
95
121
96
- // Hour correction
97
- int hourHA = 0 ;
98
- int minHA = 0 ;
122
+ // Hour stuff
99
123
int HAselect;
100
- int hHAcorrection;
101
- int mHAcorrection = -5 ; // wenn minus dann hHAcorrection -1
102
- int sHAcorrection ;
103
- int hourHAzeit;
104
- int minHAzeit;
105
124
106
- int heatselect;
107
- int RAheat = 0 ;
108
- int DECheat = 1 ;
125
+ // HEAT menu settings
126
+ int heatselect; // Which stepper are we changing?
127
+ int RAheat = 0 ; // Are we heating the RA stepper?
128
+ int DECheat = 0 ; // Are we heating the DEC stepper?
109
129
110
- // Stellarium
130
+ // Stellarium
111
131
char current_RA[9 ];
112
132
char current_DEC[10 ];
113
133
int HAh_save;
114
134
int HAm_save;
115
135
float slew_RA;
116
136
float slew_DEC;
117
137
118
- byte DEG[8 ] = {
138
+ // LCD special chars
139
+ int leftArrow = 3 ;
140
+ int rightArrow = 4 ;
141
+
142
+ byte DegreesBitmap[8 ] = {
119
143
B01100,
120
144
B10010,
121
145
B10010,
@@ -126,7 +150,7 @@ byte DEG[8] = {
126
150
B00000
127
151
};
128
152
129
- byte min [] = {
153
+ byte MinutesBitmap [] = {
130
154
B10000,
131
155
B10000,
132
156
B10000,
@@ -137,7 +161,7 @@ byte min[] = {
137
161
B00000
138
162
};
139
163
140
- byte sec [] = {
164
+ byte SecondsBitmap [] = {
141
165
B10100,
142
166
B10100,
143
167
B10100,
@@ -148,6 +172,5 @@ byte sec[] = {
148
172
B00000
149
173
};
150
174
151
-
152
175
// debugging
153
176
String inBT;
0 commit comments