|
| 1 | +struct PointOfInterest { |
| 2 | + char* pDisplay; |
| 3 | + int hourRA; |
| 4 | + int minRA; |
| 5 | + int secRA; |
| 6 | + int degreeDEC; |
| 7 | + int minDEC; |
| 8 | + int secDEC; |
| 9 | +}; |
| 10 | + |
| 11 | +PointOfInterest pointOfInterest[] = { |
| 12 | + // Name (15chars) RA (hms) DEC (dms) |
| 13 | + // 012345678901234 |
| 14 | + { ">Big Dipper ", 12, 16, 26, 56, 55, 7 }, |
| 15 | + { ">M31 Andromeda ", 0, 43, 52, 41, 22, 53 }, |
| 16 | + { ">M81 Bodes Galxy", 9, 57, 13, 68, 58, 1 }, |
| 17 | +}; |
| 18 | + |
| 19 | +int currentPOI = 0; |
| 20 | +int lastPOI = sizeof(pointOfInterest) / sizeof(pointOfInterest[0]) - 1; |
| 21 | +int statePOI = 0; |
| 22 | +bool poiMoving = false; |
| 23 | + |
| 24 | +void processPOIKeys(int key) { |
| 25 | + switch (key) { |
| 26 | + case btnSELECT: { |
| 27 | + if (lastKey != btnSELECT) { |
| 28 | + stopSteppers(); |
| 29 | + PointOfInterest* poi = &pointOfInterest[currentPOI]; |
| 30 | + RATime.set(poi->hourRA, poi->minRA, poi->secRA); |
| 31 | + degreeDEC = poi->degreeDEC - (north ? 90 : -90); // iternal DEC degree is 0 at celestial poles |
| 32 | + minDEC = poi->minDEC; |
| 33 | + secDEC = poi->secDEC; |
| 34 | + |
| 35 | + // Calculate the target stepper positions |
| 36 | + handleDECandRACalculations(); |
| 37 | + |
| 38 | + Serial.println(degreeDEC); |
| 39 | + |
| 40 | + if (isUnreachable) { |
| 41 | + ShowStatusMessage("Unreachable..."); |
| 42 | + } |
| 43 | + else { |
| 44 | + // Calculate total steps needed |
| 45 | + startMoveSteppersToTargetAsync(); |
| 46 | + if (!stepperRA.isRunning() && !stepperDEC.isRunning()) { |
| 47 | + ShowStatusMessage("Already there.."); |
| 48 | + } else { |
| 49 | + poiMoving = true; |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + break; |
| 55 | + |
| 56 | + case btnLEFT: |
| 57 | + case btnDOWN: { |
| 58 | + currentPOI = adjustWrap(currentPOI, 1, 0, lastPOI); |
| 59 | + } |
| 60 | + break; |
| 61 | + |
| 62 | + case btnUP: { |
| 63 | + currentPOI = adjustWrap(currentPOI, -1, 0, lastPOI); |
| 64 | + } |
| 65 | + break; |
| 66 | + |
| 67 | + case btnRIGHT: { |
| 68 | + stopSteppers(); |
| 69 | + poiMoving = false; |
| 70 | + lcdMenu.setNextActive(); |
| 71 | + } |
| 72 | + break; |
| 73 | + } |
| 74 | + |
| 75 | + lastKey = key; |
| 76 | + if (poiMoving) { |
| 77 | + moveSteppersToTargetAsync(); |
| 78 | + if (!stepperRA.isRunning() && !stepperDEC.isRunning()) { |
| 79 | + poiMoving = false; |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +void printPOISubmenu() { |
| 85 | + if (poiMoving) { |
| 86 | + } |
| 87 | + else { |
| 88 | + lcdMenu.printMenu(pointOfInterest[currentPOI].pDisplay); |
| 89 | + } |
| 90 | +} |
0 commit comments