7
7
#define STATUS_SLEWING_TO_TARGET B00000100
8
8
#define STATUS_SLEWING_FREE B00000010
9
9
#define STATUS_TRACKING B00001000
10
+ #define STATUS_PARKING B00010000
10
11
11
12
// slewingStatus()
12
13
#define SLEWING_DEC B00000010
@@ -273,6 +274,20 @@ void Mount::startSlewingToTarget() {
273
274
_totalRAMove = 1 .0f * _stepperRA->distanceToGo ();
274
275
}
275
276
277
+ // ///////////////////////////////
278
+ //
279
+ // park
280
+ //
281
+ // ///////////////////////////////
282
+ void Mount::park ()
283
+ {
284
+ stopSlewing (ALL_DIRECTIONS | TRACKING);
285
+ waitUntilStopped (ALL_DIRECTIONS);
286
+ setTargetToHome ();
287
+ startSlewingToTarget ();
288
+ _mountStatus |= STATUS_PARKING;
289
+ }
290
+
276
291
// ///////////////////////////////
277
292
//
278
293
// mountStatus
@@ -290,19 +305,24 @@ byte Mount::mountStatus() {
290
305
// ///////////////////////////////
291
306
String Mount::mountStatusString () {
292
307
if (_mountStatus == STATUS_PARKED) {
293
- return " PRKD " ;
308
+ return " PARKED " ;
294
309
}
295
310
String disp = " " ;
296
- if (_mountStatus & STATUS_TRACKING) disp += " TRK " ;
297
- if (_mountStatus & STATUS_SLEWING) disp += " SLW " ;
298
- if (_mountStatus & STATUS_SLEWING_TO_TARGET) disp += " 2TRG " ;
299
- if (_mountStatus & STATUS_SLEWING_FREE) disp += " FR " ;
300
-
301
- if (_mountStatus & STATUS_SLEWING) {
302
- byte slew = slewStatus ();
303
- if (slew & SLEWING_RA) disp += " SRA " ;
304
- if (slew & SLEWING_DEC) disp += " SDEC " ;
305
- if (slew & SLEWING_TRACKING) disp += " STRK " ;
311
+ if (_mountStatus & STATUS_PARKING) {
312
+ disp = " PARKNG " ;
313
+ }
314
+ else {
315
+ if (_mountStatus & STATUS_TRACKING) disp += " TRK " ;
316
+ if (_mountStatus & STATUS_SLEWING) disp += " SLW " ;
317
+ if (_mountStatus & STATUS_SLEWING_TO_TARGET) disp += " 2TRG " ;
318
+ if (_mountStatus & STATUS_SLEWING_FREE) disp += " FR " ;
319
+
320
+ if (_mountStatus & STATUS_SLEWING) {
321
+ byte slew = slewStatus ();
322
+ if (slew & SLEWING_RA) disp += " SRA " ;
323
+ if (slew & SLEWING_DEC) disp += " SDEC " ;
324
+ if (slew & SLEWING_TRACKING) disp += " STRK " ;
325
+ }
306
326
}
307
327
308
328
disp += " RA:" + String (_stepperRA->currentPosition ());
@@ -337,6 +357,7 @@ byte Mount::slewStatus() {
337
357
//
338
358
// ///////////////////////////////
339
359
bool Mount::isSlewingDEC () {
360
+ if (isParking ()) return true ;
340
361
return (slewStatus () & SLEWING_DEC) != 0 ;
341
362
}
342
363
@@ -346,6 +367,7 @@ bool Mount::isSlewingDEC() {
346
367
//
347
368
// ///////////////////////////////
348
369
bool Mount::isSlewingRA () {
370
+ if (isParking ()) return true ;
349
371
return (slewStatus () & SLEWING_RA) != 0 ;
350
372
}
351
373
@@ -355,6 +377,7 @@ bool Mount::isSlewingRA() {
355
377
//
356
378
// ///////////////////////////////
357
379
bool Mount::isSlewingRAorDEC () {
380
+ if (isParking ()) return true ;
358
381
return (slewStatus () & (SLEWING_DEC | SLEWING_RA)) != 0 ;
359
382
}
360
383
@@ -364,6 +387,7 @@ bool Mount::isSlewingRAorDEC() {
364
387
//
365
388
// ///////////////////////////////
366
389
bool Mount::isSlewingIdle () {
390
+ if (isParking ()) return false ;
367
391
return (slewStatus () & (SLEWING_DEC | SLEWING_RA)) == 0 ;
368
392
}
369
393
@@ -382,38 +406,51 @@ bool Mount::isSlewingTRK() {
382
406
//
383
407
// ///////////////////////////////
384
408
bool Mount::isParked () {
385
- return slewStatus () == NOT_SLEWING;
409
+ return (slewStatus () == NOT_SLEWING) && (_mountStatus == STATUS_PARKED);
410
+ }
411
+
412
+ // ///////////////////////////////
413
+ //
414
+ // isParking
415
+ //
416
+ // ///////////////////////////////
417
+ bool Mount::isParking () {
418
+ return _mountStatus & STATUS_PARKING;
386
419
}
387
420
388
421
// ///////////////////////////////
389
422
//
390
423
// startSlewing
391
424
//
392
- // Starts manual slewing in one of eight directions or tracking
425
+ // Starts manual slewing in one of eight directions or
426
+ // tracking, but only if not currently parking!
393
427
// ///////////////////////////////
394
428
void Mount::startSlewing (int direction) {
395
- if (direction & TRACKING) {
396
- _stepperTRK->setSpeed (_trackingSpeed);
429
+ if (!isParking ())
430
+ {
431
+ if (direction & TRACKING) {
432
+ _stepperTRK->setSpeed (_trackingSpeed);
397
433
398
- // Turn on tracking
399
- _mountStatus |= STATUS_TRACKING;
400
- }
401
- else {
402
- if (direction & NORTH) {
403
- _stepperDEC->moveTo (30000 );
404
- _mountStatus |= STATUS_SLEWING;
405
- }
406
- if (direction & SOUTH ) {
407
- _stepperDEC->moveTo (-30000 );
408
- _mountStatus |= STATUS_SLEWING;
409
- }
410
- if (direction & EAST ) {
411
- _stepperRA->moveTo (-30000 );
412
- _mountStatus |= STATUS_SLEWING;
434
+ // Turn on tracking
435
+ _mountStatus |= STATUS_TRACKING;
413
436
}
414
- if (direction & WEST) {
415
- _stepperRA->moveTo (30000 );
416
- _mountStatus |= STATUS_SLEWING;
437
+ else {
438
+ if (direction & NORTH) {
439
+ _stepperDEC->moveTo (30000 );
440
+ _mountStatus |= STATUS_SLEWING;
441
+ }
442
+ if (direction & SOUTH ) {
443
+ _stepperDEC->moveTo (-30000 );
444
+ _mountStatus |= STATUS_SLEWING;
445
+ }
446
+ if (direction & EAST ) {
447
+ _stepperRA->moveTo (-30000 );
448
+ _mountStatus |= STATUS_SLEWING;
449
+ }
450
+ if (direction & WEST) {
451
+ _stepperRA->moveTo (30000 );
452
+ _mountStatus |= STATUS_SLEWING;
453
+ }
417
454
}
418
455
}
419
456
}
@@ -450,7 +487,6 @@ void Mount::waitUntilStopped(byte direction) {
450
487
|| ((direction & (NORTH | SOUTH)) && _stepperDEC->isRunning ())
451
488
|| ((direction & TRACKING) && (((_mountStatus & STATUS_TRACKING) == 0 ) && _stepperTRK->isRunning ()))
452
489
) {
453
- // //Serial.print("W4Stp: ");
454
490
loop ();
455
491
}
456
492
}
@@ -536,6 +572,14 @@ void Mount::loop() {
536
572
// Mount is at Target!
537
573
_currentRA = _targetRA;
538
574
_currentDEC = _targetDEC;
575
+
576
+ // If we we're parking, we just reached home. Clear the flag, reset the motors and stop tracking.
577
+ if (isParking ()) {
578
+ _mountStatus &= ~STATUS_PARKING;
579
+ stopSlewing (TRACKING);
580
+ setHome ();
581
+ }
582
+
539
583
_currentDECStepperPosition = _stepperDEC->currentPosition ();
540
584
_currentRAStepperPosition = _stepperRA->currentPosition ();
541
585
_totalDECMove = _totalRAMove = 0 ;
@@ -560,7 +604,6 @@ void Mount::setHome() {
560
604
_stepperRA->setCurrentPosition (0 );
561
605
_stepperDEC->setCurrentPosition (0 );
562
606
_stepperTRK->setCurrentPosition (0 );
563
- startSlewing (TRACKING);
564
607
}
565
608
566
609
// ///////////////////////////////
0 commit comments