|
1 | 1 | #ifndef HEADLESS_CLIENT
|
2 | 2 |
|
| 3 | +// HIGHLIGHT states allow you to pick one of the three sub functions. |
3 | 4 | #define HIGHLIGHT_POLAR 1
|
4 | 5 | #define HIGHLIGHT_SPEED 2
|
5 |
| -#define POLAR_CALIBRATION_WAIT 3 |
6 |
| -#define POLAR_CALIBRATION_GO 4 |
7 |
| -#define POLAR_CALIBRATION_WAIT_HOME 5 |
8 |
| -#define SPEED_CALIBRATION 6 |
9 |
| - |
| 6 | +#define HIGHLIGHT_DRIFT 3 |
| 7 | + |
| 8 | +// Polar calibration goes through these three states: |
| 9 | +// 4 - moving to RA of Polaris and then waiting on confirmation that Polaris is centered |
| 10 | +// 5 - moving to DEC beyond Polaris and waiting on confirmation that Polaris is centered |
| 11 | +// 6 - moving back to home position |
| 12 | +#define POLAR_CALIBRATION_WAIT 4 |
| 13 | +#define POLAR_CALIBRATION_GO 5 |
| 14 | +#define POLAR_CALIBRATION_WAIT_HOME 6 |
| 15 | + |
| 16 | +// Speed calibration only has one state, allowing you to adjust the speed with UP and DOWN |
| 17 | +#define SPEED_CALIBRATION 7 |
| 18 | + |
| 19 | +// Drift calibration goes through 4 states |
| 20 | +// 8 - Display four durations and wait for the user to select one |
| 21 | +// 9 - Start the calibration run after user presses SELECT. This state waits 1.5s, takes duration time |
| 22 | +// to slew east in half the time selected, then waits 1.5s and slews west in the same duration, and waits 1.5s. |
| 23 | +#define DRIFT_CALIBRATION_GET_DURATION 8 |
| 24 | +#define DRIFT_CALIBRATION_RUNNING 9 |
| 25 | + |
| 26 | +// Start off with Polar Alignment higlighted. |
10 | 27 | byte calState = HIGHLIGHT_POLAR;
|
11 | 28 |
|
| 29 | +// The index of durations that the user has selected. |
| 30 | +byte driftSubIndex = 1; |
| 31 | + |
| 32 | +// The requested total duration of the drift alignment run. |
| 33 | +byte driftDuration = 0; |
| 34 | + |
12 | 35 | bool processCalibrationKeys() {
|
13 | 36 | byte key;
|
14 | 37 | bool waitForRelease = false;
|
@@ -43,10 +66,33 @@ bool processCalibrationKeys() {
|
43 | 66 | lcdMenu.updateDisplay();
|
44 | 67 | calState = HIGHLIGHT_POLAR;
|
45 | 68 | }
|
| 69 | + } else if (calState == DRIFT_CALIBRATION_RUNNING) { |
| 70 | + lcdMenu.setCursor(0, 1); |
| 71 | + lcdMenu.printMenu("Pause 1.5s ..."); |
| 72 | + mount.stopSlewing(TRACKING); |
| 73 | + mount.delay(1500); |
| 74 | + |
| 75 | + lcdMenu.setCursor(0, 1); |
| 76 | + lcdMenu.printMenu("Eastward pass..."); |
| 77 | + mount.runDriftAlignmentPhase(EAST, driftDuration); |
| 78 | + |
| 79 | + lcdMenu.setCursor(0, 1); |
| 80 | + lcdMenu.printMenu("Pause 1.5s ..."); |
| 81 | + mount.delay(1500); |
| 82 | + |
| 83 | + lcdMenu.setCursor(0, 1); |
| 84 | + lcdMenu.printMenu("Westward pass..."); |
| 85 | + mount.runDriftAlignmentPhase(WEST, driftDuration); |
| 86 | + |
| 87 | + lcdMenu.setCursor(0, 1); |
| 88 | + lcdMenu.printMenu("Done. Pause 1.5s"); |
| 89 | + mount.delay(1500); |
| 90 | + mount.runDriftAlignmentPhase(0, 0); |
| 91 | + |
| 92 | + mount.startSlewing(TRACKING); |
| 93 | + calState = HIGHLIGHT_DRIFT; |
46 | 94 | }
|
47 | 95 |
|
48 |
| - |
49 |
| - |
50 | 96 | if (checkForKeyChange && lcdButtons.keyChanged(key)) {
|
51 | 97 | waitForRelease = true;
|
52 | 98 |
|
@@ -87,13 +133,13 @@ bool processCalibrationKeys() {
|
87 | 133 |
|
88 | 134 | case HIGHLIGHT_POLAR:
|
89 | 135 | if (key == btnDOWN) calState = HIGHLIGHT_SPEED;
|
90 |
| - else if (key == btnUP) calState = HIGHLIGHT_SPEED; |
| 136 | + else if (key == btnUP) calState = HIGHLIGHT_DRIFT; |
91 | 137 | else if (key == btnSELECT) {
|
92 | 138 | calState = POLAR_CALIBRATION_WAIT;
|
93 | 139 |
|
94 | 140 | // Move the RA to that of Polaris. Moving to this RA aligns the DEC axis such that
|
95 | 141 | // it swings along the line between Polaris and the Celestial Pole.
|
96 |
| - mount.targetRA() = DayTime(PolarisRAHour, PolarisRAMinute, PolarisRASecond); |
| 142 | + mount.targetRA() = DayTime(PolarisRAHour, PolarisRAMinute, PolarisRASecond); |
97 | 143 | // Account for the current settings.
|
98 | 144 | mount.targetRA().addTime(mount.getHACorrection());
|
99 | 145 | mount.targetRA().subtractTime(mount.HA());
|
@@ -122,14 +168,45 @@ bool processCalibrationKeys() {
|
122 | 168 | break;
|
123 | 169 |
|
124 | 170 | case HIGHLIGHT_SPEED:
|
125 |
| - if (key == btnDOWN) calState = HIGHLIGHT_POLAR; |
| 171 | + if (key == btnDOWN) calState = HIGHLIGHT_DRIFT; |
126 | 172 | if (key == btnUP) calState = HIGHLIGHT_POLAR;
|
127 | 173 | else if (key == btnSELECT) calState = SPEED_CALIBRATION;
|
128 | 174 | else if (key == btnRIGHT) {
|
129 | 175 | lcdMenu.setNextActive();
|
130 | 176 | calState = HIGHLIGHT_POLAR;
|
131 | 177 | }
|
132 | 178 | break;
|
| 179 | + |
| 180 | + case HIGHLIGHT_DRIFT: |
| 181 | + if (key == btnDOWN) calState = HIGHLIGHT_POLAR; |
| 182 | + if (key == btnUP) calState = HIGHLIGHT_SPEED; |
| 183 | + else if (key == btnSELECT) calState = DRIFT_CALIBRATION_GET_DURATION; |
| 184 | + else if (key == btnRIGHT) { |
| 185 | + lcdMenu.setNextActive(); |
| 186 | + calState = HIGHLIGHT_POLAR; |
| 187 | + } |
| 188 | + break; |
| 189 | + |
| 190 | + case DRIFT_CALIBRATION_GET_DURATION : |
| 191 | + if (key == btnDOWN || key == btnLEFT) { |
| 192 | + driftSubIndex = adjustWrap(driftSubIndex, 1, 0, 3); |
| 193 | + } |
| 194 | + if (key == btnUP) { |
| 195 | + driftSubIndex = adjustWrap(driftSubIndex, -1, 0, 3); |
| 196 | + } |
| 197 | + if (key == btnSELECT) { |
| 198 | + // Take off 6s padding time. 1.5s start pause, 1.5s pause in the middle and 1.5s end pause and general time slop. |
| 199 | + // These are the times for one way. So total time is 2 x duration + 4.5s |
| 200 | + int duration[] = { 27, 57, 87, 147}; |
| 201 | + driftDuration = duration[driftSubIndex]; |
| 202 | + calState = DRIFT_CALIBRATION_RUNNING; |
| 203 | + } |
| 204 | + else if (key == btnRIGHT) { |
| 205 | + // RIGHT cancels duration selection and returns to menu |
| 206 | + calState = HIGHLIGHT_DRIFT; |
| 207 | + driftSubIndex = 1; |
| 208 | + } |
| 209 | + break; |
133 | 210 | }
|
134 | 211 | }
|
135 | 212 |
|
@@ -161,6 +238,13 @@ void printCalibrationSubmenu() {
|
161 | 238 | dtostrf(mount.getSpeedCalibration(), 6, 4, &scratchBuffer[9]);
|
162 | 239 | lcdMenu.printMenu(scratchBuffer);
|
163 | 240 | break;
|
| 241 | + case HIGHLIGHT_DRIFT: |
| 242 | + lcdMenu.printMenu(">Drift alignment"); |
| 243 | + case DRIFT_CALIBRATION_GET_DURATION: |
| 244 | + sprintf(scratchBuffer, " 1m 2m 3m 5m"); |
| 245 | + scratchBuffer[driftSubIndex * 4] = '>'; |
| 246 | + lcdMenu.printMenu(scratchBuffer); |
| 247 | + break; |
164 | 248 | }
|
165 | 249 | }
|
166 | 250 | #endif
|
0 commit comments