13
13
#define HIGHLIGHT_RA_STEPS 4
14
14
#define HIGHLIGHT_DEC_STEPS 5
15
15
#define HIGHLIGHT_BACKLASH_STEPS 6
16
- #define HIGHLIGHT_AZIMUTH_CONTROL 7
16
+ #define HIGHLIGHT_AZIMUTH_ALTITUDE_CONTROL 7
17
17
#define HIGHLIGHT_LAST 7
18
18
19
19
// Polar calibration goes through these three states:
45
45
// #define BACKLIGHT_CALIBRATION 20
46
46
47
47
// Azimuth control only has one state, allowing you to move the motor UP and DOWN
48
- #define AZIMUTH_CONTROL 20
48
+ #define AZIMUTH_ALTITUDE_CONTROL 20
49
49
50
50
// Start off with Polar Alignment higlighted.
51
51
byte calState = HIGHLIGHT_FIRST;
@@ -68,6 +68,8 @@ int BacklashSteps = 0;
68
68
// The speed of the Azimuth Motor (scaled from 0-100)
69
69
int AzimuthSpeed = 0 ;
70
70
int lastAzimuthSpeed = 0 ;
71
+ int AltitudeSpeed = 0 ;
72
+ int lastAltitudeSpeed = 0 ;
71
73
72
74
// The brightness of the backlight of the LCD shield.
73
75
// int Brightness = 255;
@@ -148,7 +150,7 @@ bool processCalibrationKeys() {
148
150
calDelay = 150 ;
149
151
}
150
152
}
151
- else if (calState == AZIMUTH_CONTROL ) {
153
+ else if (calState == AZIMUTH_ALTITUDE_CONTROL ) {
152
154
if (lcdButtons.currentState () == btnLEFT) {
153
155
// Speed up to the left
154
156
if (AzimuthSpeed < 100 ) {
@@ -159,7 +161,7 @@ bool processCalibrationKeys() {
159
161
calDelay = max (2 , 0.98 * calDelay);
160
162
checkForKeyChange = false ;
161
163
}
162
- else if (lcdButtons.currentState () == btnRIGHT) {
164
+ if (lcdButtons.currentState () == btnRIGHT) {
163
165
// Speed up to the right
164
166
if (AzimuthSpeed > -100 ) {
165
167
AzimuthSpeed -= 1 ; // 0.0001;
@@ -169,18 +171,51 @@ bool processCalibrationKeys() {
169
171
calDelay = max (2 , 0.98 * calDelay);
170
172
checkForKeyChange = false ;
171
173
}
172
- else {
173
- // No more buttons pressed, decelerate at 3% per cycle
174
+ // If neither Left nor Right is pressed...
175
+ if ((lcdButtons.currentState () != btnRIGHT) && (lcdButtons.currentState () != btnLEFT)) {
176
+ // ... decelerate at 3% per cycle
174
177
if (AzimuthSpeed > 0 ) {
175
178
AzimuthSpeed = adjustClamp (AzimuthSpeed, -3 , 0 , 100 );
176
179
}
177
180
else if (AzimuthSpeed < 0 ) {
178
181
AzimuthSpeed = adjustClamp (AzimuthSpeed, 3 , -100 , 0 );
179
182
}
180
- else {
183
+ }
184
+
185
+ if (lcdButtons.currentState () == btnUP) {
186
+ // Speed up to the left
187
+ if (AltitudeSpeed < 100 ) {
188
+ AltitudeSpeed += 1 ; // 0.0001;
189
+ }
190
+
191
+ // Accelerate speed increase over time
192
+ calDelay = max (2 , 0.98 * calDelay);
193
+ checkForKeyChange = false ;
194
+ }
195
+ if (lcdButtons.currentState () == btnDOWN) {
196
+ // Speed up to the right
197
+ if (AltitudeSpeed > -100 ) {
198
+ AltitudeSpeed -= 1 ; // 0.0001;
199
+ }
200
+
201
+ // Accelerate speed increase over time
202
+ calDelay = max (2 , 0.98 * calDelay);
203
+ checkForKeyChange = false ;
204
+ }
205
+ // If neither Up nor Down is pressed...
206
+ if ((lcdButtons.currentState () != btnUP) && (lcdButtons.currentState () != btnDOWN)) {
207
+ // ... decelerate at 3% per cycle
208
+ if (AltitudeSpeed > 0 ) {
209
+ AltitudeSpeed = adjustClamp (AltitudeSpeed, -3 , 0 , 100 );
210
+ }
211
+ else if (AltitudeSpeed < 0 ) {
212
+ AltitudeSpeed = adjustClamp (AltitudeSpeed, 3 , -100 , 0 );
213
+ }
214
+ }
215
+
216
+ if ((AzimuthSpeed == 0 ) && (AltitudeSpeed == 0 )) {
181
217
// Once we're stopped, set the initial key delay back to 100ms
182
218
calDelay = 100 ;
183
- }
184
219
}
185
220
186
221
// If we changed speeds, tell the mount motor
@@ -189,6 +224,11 @@ bool processCalibrationKeys() {
189
224
lastAzimuthSpeed = AzimuthSpeed;
190
225
}
191
226
227
+ if (AltitudeSpeed != lastAltitudeSpeed) {
228
+ mount.setSpeed (ALTITUDE_STEPS, 300.0 * AltitudeSpeed / 100.0 );
229
+ lastAltitudeSpeed = AltitudeSpeed;
230
+ }
231
+
192
232
mount.delay (calDelay);
193
233
}
194
234
else if (calState == RA_STEP_CALIBRATION) {
@@ -325,15 +365,14 @@ bool processCalibrationKeys() {
325
365
}
326
366
break ;
327
367
328
- case AZIMUTH_CONTROL :
368
+ case AZIMUTH_ALTITUDE_CONTROL :
329
369
{
330
- // UP and DOWN are handled above
370
+ // UP, DOWN, LEFT, and RIGHT are handled above
331
371
if (key == btnSELECT) {
332
- calState = HIGHLIGHT_AZIMUTH_CONTROL;
333
- }
334
- else if (key == btnRIGHT) {
335
- lcdMenu.setNextActive ();
336
- calState = HIGHLIGHT_AZIMUTH_CONTROL;
372
+ // Make sure motors are stoppped!
373
+ mount.setSpeed (AZIMUTH_STEPS, 0 );
374
+ mount.setSpeed (ALTITUDE_STEPS, 0 );
375
+ calState = HIGHLIGHT_AZIMUTH_ALTITUDE_CONTROL;
337
376
}
338
377
}
339
378
break ;
@@ -501,14 +540,14 @@ bool processCalibrationKeys() {
501
540
}
502
541
break ;
503
542
504
- case HIGHLIGHT_AZIMUTH_CONTROL :
543
+ case HIGHLIGHT_AZIMUTH_ALTITUDE_CONTROL :
505
544
{
506
545
if (key == btnDOWN)
507
546
gotoNextHighlightState (1 );
508
547
if (key == btnUP)
509
548
gotoNextHighlightState (-1 );
510
549
else if (key == btnSELECT)
511
- calState = AZIMUTH_CONTROL ;
550
+ calState = AZIMUTH_ALTITUDE_CONTROL ;
512
551
else if (key == btnRIGHT) {
513
552
lcdMenu.setNextActive ();
514
553
calState = HIGHLIGHT_FIRST;
@@ -553,8 +592,8 @@ void printCalibrationSubmenu()
553
592
else if (calState == HIGHLIGHT_BACKLASH_STEPS) {
554
593
lcdMenu.printMenu (" >Backlash Adjust" );
555
594
}
556
- else if (calState == HIGHLIGHT_AZIMUTH_CONTROL ) {
557
- lcdMenu.printMenu (" >Azimuth Control" );
595
+ else if (calState == HIGHLIGHT_AZIMUTH_ALTITUDE_CONTROL ) {
596
+ lcdMenu.printMenu (" >Az/Alt Control" );
558
597
}
559
598
// else if (calState == HIGHLIGHT_BACKLIGHT) {
560
599
// lcdMenu.printMenu(">LCD Brightness");
@@ -589,8 +628,8 @@ void printCalibrationSubmenu()
589
628
sprintf (scratchBuffer, " Backlash: %d" , BacklashSteps);
590
629
lcdMenu.printMenu (scratchBuffer);
591
630
}
592
- else if (calState == AZIMUTH_CONTROL ) {
593
- sprintf (scratchBuffer, " AzimuthSpd : %d%%" , AzimuthSpeed);
631
+ else if (calState == AZIMUTH_ALTITUDE_CONTROL ) {
632
+ sprintf (scratchBuffer, " Az/Alt : %d%% %d%% " , AzimuthSpeed, AltitudeSpeed );
594
633
lcdMenu.printMenu (scratchBuffer);
595
634
}
596
635
// else if (calState == BACKLIGHT_CALIBRATION) {
0 commit comments