1
1
#pragma once
2
+ #include " Globals.hpp"
2
3
3
4
#if HEADLESS_CLIENT == 0
4
5
12
13
#define HIGHLIGHT_RA_STEPS 4
13
14
#define HIGHLIGHT_DEC_STEPS 5
14
15
#define HIGHLIGHT_BACKLASH_STEPS 6
16
+ // #define HIGHLIGHT_BACKLIGHT 7
15
17
#define HIGHLIGHT_LAST 6
16
18
17
19
// Polar calibration goes through these three states:
18
- // 11- moving to RA of Polaris and then waiting on confirmation that Polaris is centered
19
- // 12- moving to DEC beyond Polaris and waiting on confirmation that Polaris is centered
20
+ // 11- moving to RA and DEC beyond Polaris and waiting on confirmation that Polaris is centered
20
21
// 13- moving back to home position
21
- #define POLAR_CALIBRATION_WAIT 11
22
- #define POLAR_CALIBRATION_GO 12
23
- #define POLAR_CALIBRATION_WAIT_HOME 13
22
+ #define POLAR_CALIBRATION_WAIT_CENTER_POLARIS 11
23
+ #define POLAR_CALIBRATION_WAIT_HOME 12
24
24
25
25
// Speed calibration only has one state, allowing you to adjust the speed with UP and DOWN
26
26
#define SPEED_CALIBRATION 14
41
41
// Backlash calibration only has one state, allowing you to adjust the number of steps with UP and DOWN
42
42
#define BACKLASH_CALIBRATION 19
43
43
44
+ // Brightness setting only has one state, allowing you to adjust the brightness with UP and DOWN
45
+ // #define BACKLIGHT_CALIBRATION 20
46
+
44
47
// Start off with Polar Alignment higlighted.
45
48
byte calState = HIGHLIGHT_FIRST;
46
49
47
- // SPeed adjustment variable. Added to 1.0 after dividing by 10000 to get final speed
50
+ // Speed adjustment variable. Added to 1.0 after dividing by 10000 to get final speed
48
51
float SpeedCalibration;
49
52
50
53
// The current delay in ms when changing calibration value. The longer a button is depressed, the smaller this gets.
@@ -59,6 +62,9 @@ byte driftDuration = 0;
59
62
// The number of steps to use for backlash compensation (read from the mount).
60
63
int BacklashSteps = 0 ;
61
64
65
+ // The brightness of the backlight of the LCD shield.
66
+ // int Brightness = 255;
67
+
62
68
bool checkProgressiveUpDown (int * val) {
63
69
bool ret = true ;
64
70
@@ -99,6 +105,9 @@ void gotoNextHighlightState(int dir) {
99
105
else if (calState == HIGHLIGHT_SPEED) {
100
106
SpeedCalibration = (mount.getSpeedCalibration () - 1.0 ) * 10000.0 + 0.5 ;
101
107
}
108
+ // else if (calState == HIGHLIGHT_BACKLIGHT) {
109
+ // Brightness = lcdMenu.getBacklightBrightness();
110
+ // }
102
111
}
103
112
104
113
bool processCalibrationKeys () {
@@ -141,8 +150,22 @@ bool processCalibrationKeys() {
141
150
else if (calState == BACKLASH_CALIBRATION) {
142
151
checkForKeyChange = checkProgressiveUpDown (&BacklashSteps);
143
152
}
153
+ // else if (calState == BACKLIGHT_CALIBRATION) {
154
+ // checkForKeyChange = checkProgressiveUpDown(&Brightness);
155
+ // if (!checkForKeyChange) {
156
+ // LOGV2(DEBUG_INFO,"CAL: Brightness changed to %d", Brightness);
157
+ // Brightness = clamp(Brightness, 0, 255);
158
+ // LOGV2(DEBUG_INFO,"CAL: Brightness clamped to %d", Brightness);
159
+ // lcdMenu.setBacklightBrightness(Brightness, false);
160
+ // LOGV2(DEBUG_INFO,"CAL: Brightness set %d", (int)lcdMenu.getBacklightBrightness());
161
+ // }
162
+ // }
163
+ else if (calState == RA_STEP_CALIBRATION) {
164
+ checkForKeyChange = checkProgressiveUpDown (&RAStepsPerDegree);
165
+ }
144
166
else if (calState == POLAR_CALIBRATION_WAIT_HOME) {
145
167
if (!mount.isSlewingRAorDEC ()) {
168
+
146
169
lcdMenu.updateDisplay ();
147
170
calState = HIGHLIGHT_POLAR;
148
171
}
@@ -179,13 +202,9 @@ bool processCalibrationKeys() {
179
202
180
203
switch (calState) {
181
204
182
- case POLAR_CALIBRATION_GO : {
205
+ case POLAR_CALIBRATION_WAIT_HOME : {
183
206
if (key == btnSELECT) {
184
- lcdMenu.printMenu (" Aligned, homing" );
185
- mount.delay (600 );
186
- mount.setTargetToHome ();
187
- mount.startSlewingToTarget ();
188
- calState = POLAR_CALIBRATION_WAIT_HOME;
207
+ calState = HIGHLIGHT_POLAR;
189
208
}
190
209
if (key == btnRIGHT) {
191
210
lcdMenu.setNextActive ();
@@ -259,18 +278,36 @@ bool processCalibrationKeys() {
259
278
}
260
279
break ;
261
280
281
+ // case BACKLIGHT_CALIBRATION:
282
+ // {
283
+ // // UP and DOWN are handled above
284
+ // if (key == btnSELECT) {
285
+ // LOGV2(DEBUG_GENERAL, "CAL Menu: Set brightness to %d", Brightness);
286
+ // lcdMenu.setBacklightBrightness(Brightness);
287
+ // lcdMenu.printMenu("Level stored.");
288
+ // mount.delay(500);
289
+ // calState = HIGHLIGHT_BACKLIGHT;
290
+ // }
291
+ // else if (key == btnRIGHT) {
292
+ // lcdMenu.setNextActive();
293
+ // calState = HIGHLIGHT_BACKLIGHT;
294
+ // }
295
+ // }
296
+ // break;
297
+
262
298
case HIGHLIGHT_POLAR: {
263
299
if (key == btnDOWN) gotoNextHighlightState (1 );
264
300
else if (key == btnUP) gotoNextHighlightState (-1 );
265
301
else if (key == btnSELECT) {
266
- calState = POLAR_CALIBRATION_WAIT ;
302
+ calState = POLAR_CALIBRATION_WAIT_CENTER_POLARIS ;
267
303
268
304
// Move the RA to that of Polaris. Moving to this RA aligns the DEC axis such that
269
305
// it swings along the line between Polaris and the Celestial Pole.
270
306
mount.targetRA () = DayTime (PolarisRAHour, PolarisRAMinute, PolarisRASecond);
271
307
272
- // Now set DEC to move to Home position
273
- mount.targetDEC () = DegreeTime (90 - (NORTHERN_HEMISPHERE ? 90 : -90 ), 0 , 0 );
308
+ // Set DEC to move the same distance past Polaris as
309
+ // it is from the Celestial Pole. That equates to 88deg 42' 11.2".
310
+ mount.targetDEC () = DegreeTime (88 - (NORTHERN_HEMISPHERE ? 90 : -90 ), 42 , 11 );
274
311
mount.startSlewingToTarget ();
275
312
}
276
313
else if (key == btnRIGHT) {
@@ -279,14 +316,21 @@ bool processCalibrationKeys() {
279
316
}
280
317
break ;
281
318
282
- case POLAR_CALIBRATION_WAIT : {
319
+ case POLAR_CALIBRATION_WAIT_CENTER_POLARIS : {
283
320
if (key == btnSELECT) {
284
- calState = POLAR_CALIBRATION_GO;
321
+ calState = POLAR_CALIBRATION_WAIT_HOME;
322
+ lcdMenu.printMenu (" Aligned, homing" );
323
+ mount.delay (750 );
285
324
286
- // RA is already set. Now set DEC to move the same distance past Polaris as
287
- // it is from the Celestial Pole. That equates to 88deg 42' 6".
288
- mount.targetDEC () = DegreeTime (89 - (NORTHERN_HEMISPHERE ? 90 : -90 ), 21 , 3 );
325
+ // Sync the mount to Polaris, since that's where it's pointing
326
+ DayTime currentRa = mount.currentRA ();
327
+ mount.syncPosition (currentRa.getHours (), currentRa.getMinutes (), currentRa.getSeconds (), 89 - (NORTHERN_HEMISPHERE ? 90 : -90 ), 21 , 6 );
328
+
329
+ // Go home from here
330
+ mount.setTargetToHome ();
289
331
mount.startSlewingToTarget ();
332
+ lcdMenu.setNextActive ();
333
+ calState = HIGHLIGHT_POLAR;
290
334
}
291
335
else if (key == btnRIGHT) {
292
336
lcdMenu.setNextActive ();
@@ -371,6 +415,16 @@ bool processCalibrationKeys() {
371
415
}
372
416
}
373
417
break ;
418
+ // case HIGHLIGHT_BACKLIGHT : {
419
+ // if (key == btnDOWN) gotoNextHighlightState(1);
420
+ // if (key == btnUP) gotoNextHighlightState(-1);
421
+ // else if (key == btnSELECT) calState = BACKLIGHT_CALIBRATION;
422
+ // else if (key == btnRIGHT) {
423
+ // lcdMenu.setNextActive();
424
+ // calState = HIGHLIGHT_FIRST;
425
+ // }
426
+ // }
427
+ // break;
374
428
}
375
429
}
376
430
@@ -398,7 +452,10 @@ void printCalibrationSubmenu()
398
452
else if (calState == HIGHLIGHT_BACKLASH_STEPS) {
399
453
lcdMenu.printMenu (" >Backlash Adjust" );
400
454
}
401
- else if ((calState == POLAR_CALIBRATION_WAIT_HOME) || (calState == POLAR_CALIBRATION_WAIT) || (calState == POLAR_CALIBRATION_GO)) {
455
+ // else if (calState == HIGHLIGHT_BACKLIGHT) {
456
+ // lcdMenu.printMenu(">LCD Brightness");
457
+ // }
458
+ else if (calState == POLAR_CALIBRATION_WAIT_CENTER_POLARIS) {
402
459
if (!mount.isSlewingRAorDEC ()) {
403
460
lcdMenu.setCursor (0 , 0 );
404
461
lcdMenu.printMenu (" Centr on Polaris" );
@@ -428,6 +485,10 @@ void printCalibrationSubmenu()
428
485
sprintf (scratchBuffer, " Backlash: %d" , BacklashSteps);
429
486
lcdMenu.printMenu (scratchBuffer);
430
487
}
488
+ // else if (calState == BACKLIGHT_CALIBRATION) {
489
+ // sprintf(scratchBuffer, "Brightness: %d", Brightness);
490
+ // lcdMenu.printMenu(scratchBuffer);
491
+ // }
431
492
}
432
493
#endif
433
494
0 commit comments