|
| 1 | +void handleDECandRACalculations() |
| 2 | +{ |
| 3 | + float hourPos = RATime.getTotalHours(); |
| 4 | + // Map [0 to 24] range to [-12 to +12] range |
| 5 | + if (hourPos > 12) { |
| 6 | + hourPos = hourPos - 24; |
| 7 | + } |
| 8 | + |
| 9 | + // How many steps moves the RA ring one hour along (15degrees?) |
| 10 | + stepsPerHour = (float(RAsteps) / 288.0) * RevSteps; |
| 11 | + |
| 12 | + // Where do ww want to move RA to? |
| 13 | + float moveRA = hourPos * stepsPerHour / 2; |
| 14 | + |
| 15 | + // Where do we want to move DEC to? |
| 16 | + moveDEC = (degreeDEC * float(DECsteps) + minDEC * (float(DECsteps) / 60.0f) + secDEC * (float(DECsteps) / 3600.0f)); |
| 17 | + |
| 18 | + // We can move 6 hours in either direction. Outside of that we need to flip directions. |
| 19 | + float RALimit = (6.0f * stepsPerHour / 2); |
| 20 | + |
| 21 | + // If we reach the limit in the positive direction ... |
| 22 | + if (moveRA > RALimit) { |
| 23 | + // ... turn both RA and DEC axis around |
| 24 | + float oldRA = moveRA; |
| 25 | + moveRA -= long(12.0f * stepsPerHour / 2); |
| 26 | + moveDEC = -moveDEC; |
| 27 | + //Serial.println(format("> %s HRPos: %f MoveRA: %f newMoveRA: %f RALimit: %f", RATime.ToString().c_str(), hourPos, oldRA, moveRA, RALimit)); |
| 28 | + } |
| 29 | + // If we reach the limit in the negative direction... |
| 30 | + else if (moveRA < -RALimit) { |
| 31 | + // ... turn both RA and DEC axis around |
| 32 | + float oldRA = moveRA; |
| 33 | + moveRA += long(12.0f * stepsPerHour / 2); |
| 34 | + moveDEC = -moveDEC; |
| 35 | + //Serial.println(format("< %s HRPos: %f MoveRA: %f newMoveRA: %f RALimit: %f", RATime.ToString().c_str(), hourPos, oldRA, moveRA, RALimit)); |
| 36 | + } else { |
| 37 | + //Serial.println(format("= %s HRPos: %f MoveRA: %f newMoveRA: %f RALimit: %f", RATime.ToString().c_str(), hourPos, moveRA, moveRA, RALimit)); |
| 38 | + } |
| 39 | + |
| 40 | + // Since the Control menu does it's own stepping, don't move the axes. |
| 41 | + if (lcdMenu.getActive() != Control_Menu) { |
| 42 | + stepperRA.moveTo(-moveRA); |
| 43 | + stepperDEC.moveTo(moveDEC); |
| 44 | + } |
| 45 | +} |
0 commit comments