7878
7979// Extended bits
8080#define EEPROM_PARKING_POS_MARKER_BIT 0x0001
81+ #define EEPROM_DEC_LIMIT_MARKER_BIT 0x0002
8182
8283const char * formatStringsDEC[] = {
8384 " " ,
@@ -155,6 +156,8 @@ Mount::Mount(int stepsPerRADegree, int stepsPerDECDegree, LcdMenu* lcdMenu) {
155156 _slewingToPark = false ;
156157 _raParkingPos = 0 ;
157158 _decParkingPos = 0 ;
159+ _decLowerLimit = 0 ;
160+ _decUpperLimit = 0 ;
158161
159162 #if USE_GYRO_LEVEL == 1
160163 _pitchCalibrationAngle = 0 ;
@@ -324,6 +327,15 @@ void Mount::readPersistentData()
324327 else {
325328 LOGV1 (DEBUG_INFO|DEBUG_EEPROM,F (" Mount: EEPROM: No stored value for Parking position" ));
326329 }
330+ if (nextMarker & EEPROM_DEC_LIMIT_MARKER_BIT){
331+ _decLowerLimit = EPROMStore::readInt32 (31 ); // 31-34
332+ _decUpperLimit = EPROMStore::readInt32 (35 ); // 35-38
333+ LOGV3 (DEBUG_INFO|DEBUG_EEPROM,F (" Mount: EEPROM: DEC limitsread as %l -> %l" ), _decLowerLimit, _decUpperLimit );
334+ }
335+ else {
336+ LOGV1 (DEBUG_INFO|DEBUG_EEPROM,F (" Mount: EEPROM: No stored value for Parking position" ));
337+ }
338+
327339 }
328340 else {
329341 LOGV1 (DEBUG_INFO|DEBUG_EEPROM,F (" Mount: EEPROM: No ExtendedMarker present" ));
@@ -444,7 +456,7 @@ void Mount::writePersistentData(int which, long val)
444456 case EEPROM_RA_PARKING_POS:
445457 case EEPROM_DEC_PARKING_POS:
446458 {
447- // ... set bit 8 to indicate pitch offset angle value has been written to 19/20
459+ // ... set bit 0 in extended flag to indicate Parking pos has been written to 23-30
448460 writeExtended = true ;
449461 extendedFlag |= EEPROM_PARKING_POS_MARKER_BIT;
450462 if (which == EEPROM_RA_PARKING_POS ){
@@ -457,6 +469,23 @@ void Mount::writePersistentData(int which, long val)
457469 }
458470 }
459471 break ;
472+
473+ case EEPROM_DEC_UPPER_LIMIT:
474+ case EEPROM_DEC_LOWER_LIMIT:
475+ {
476+ // ... set bit 1 in extended flag to indicate Parking pos has been written to 23-30
477+ writeExtended = true ;
478+ extendedFlag |= EEPROM_DEC_LIMIT_MARKER_BIT;
479+ if (which == EEPROM_DEC_UPPER_LIMIT ){
480+ EPROMStore::updateInt32 (31 , val);
481+ LOGV2 (DEBUG_INFO|DEBUG_EEPROM,F (" Mount: EEPROM Write: Updating DEC Upper limit to %l at 31-34" ), val);
482+ }
483+ else {
484+ EPROMStore::updateInt32 (35 , val);
485+ LOGV2 (DEBUG_INFO|DEBUG_EEPROM,F (" Mount: EEPROM Write: Updating DEC Lower limit to %l at 35-38" ), val);
486+ }
487+ }
488+ break ;
460489 }
461490
462491
@@ -704,6 +733,7 @@ float Mount::getPitchCalibrationAngle()
704733void Mount::setPitchCalibrationAngle (float angle)
705734{
706735 uint16_t angleValue = (angle * 100 ) + 16384 ;
736+ LOGV3 (DEBUG_GYRO, " Mount: Setting Pitch calibration to %d (%f)" , angleValue, angle);
707737 writePersistentData (EEPROM_PITCH_OFFSET, angleValue);
708738 _pitchCalibrationAngle = angle;
709739}
@@ -727,6 +757,7 @@ float Mount::getRollCalibrationAngle()
727757void Mount::setRollCalibrationAngle (float angle)
728758{
729759 uint16_t angleValue = (angle * 100 ) + 16384 ;
760+ LOGV3 (DEBUG_GYRO, " Mount: Setting Roll calibration to %d (%f)" , angleValue, angle);
730761 writePersistentData (EEPROM_ROLL_OFFSET, angleValue);
731762 _rollCalibrationAngle = angle;
732763}
@@ -1867,7 +1898,6 @@ void Mount::interruptLoop()
18671898// Process any stepper changes.
18681899// ///////////////////////////////
18691900void Mount::loop () {
1870- unsigned long now = millis ();
18711901 bool raStillRunning = false ;
18721902 bool decStillRunning = false ;
18731903
@@ -2005,7 +2035,7 @@ void Mount::loop() {
20052035 _stepperDEC->moveTo (_decParkingPos);
20062036 _totalDECMove = 1 .0f * _stepperDEC->distanceToGo ();
20072037 _totalRAMove = 1 .0f * _stepperRA->distanceToGo ();
2008- LOGV5 (DEBUG_MOUNT|DEBUG_STEPPERS,F (" Mount::Loop: Park Position is R:%l D:%l, TotalMove is R:%f, D:%f" ), _raParkingPos,_decParkingPos,_totalRAMove, _totalDECMove);
2038+ LOGV5 (DEBUG_MOUNT|DEBUG_STEPPERS,F (" Mount::Loop: Park Position is R:%l D:%l, TotalMove is R:%f, D:%f" ), _raParkingPos, _decParkingPos,_totalRAMove, _totalDECMove);
20092039 if ((_stepperDEC->distanceToGo () != 0 ) || (_stepperRA->distanceToGo () != 0 )) {
20102040 _mountStatus |= STATUS_PARKING_POS | STATUS_SLEWING;
20112041 }
@@ -2026,17 +2056,8 @@ void Mount::loop() {
20262056
20272057 // Make sure we do one last update when the steppers have stopped.
20282058 displayStepperPosition ();
2029- if (!inSerialControl) {
2030- _lcdMenu->updateDisplay ();
2031- }
20322059 }
20332060 }
2034-
2035- if ((_bootComplete) && (now - _lastTrackingPrint > 200 )) {
2036- _lcdMenu->printAt (15 ,0 , isSlewingTRK () ? ' &' : ' `' );
2037- _lastTrackingPrint = now;
2038- }
2039-
20402061 }
20412062
20422063 _stepperWasRunning = raStillRunning || decStillRunning;
@@ -2051,12 +2072,18 @@ void Mount::bootComplete() {
20512072 _bootComplete = true ;
20522073}
20532074
2075+ bool Mount::isBootComplete (){
2076+ return _bootComplete;
2077+ }
2078+
2079+
2080+
20542081// ///////////////////////////////
20552082//
20562083// setParkingPosition
20572084//
20582085// ///////////////////////////////
2059- void Mount::setParkingPosition (){
2086+ void Mount::setParkingPosition () {
20602087 _raParkingPos = _stepperRA->currentPosition () - _stepperTRK->currentPosition ();
20612088 _decParkingPos = _stepperDEC->currentPosition ();
20622089
@@ -2066,6 +2093,42 @@ void Mount::setParkingPosition(){
20662093 writePersistentData (EEPROM_DEC_PARKING_POS, _decParkingPos);
20672094}
20682095
2096+ // ///////////////////////////////
2097+ //
2098+ // setDecLimitPosition
2099+ //
2100+ // ///////////////////////////////
2101+ void Mount::setDecLimitPosition (bool upper) {
2102+ if (upper) {
2103+ _decUpperLimit = _stepperDEC->currentPosition ();
2104+ writePersistentData (EEPROM_DEC_UPPER_LIMIT, _decUpperLimit);
2105+ LOGV3 (DEBUG_MOUNT,F (" Mount::setDecLimitPosition(Upper): limit DEC: %l -> %l" ), _decLowerLimit, _decUpperLimit);
2106+ }
2107+ else {
2108+ _decLowerLimit = _stepperDEC->currentPosition ();
2109+ writePersistentData (EEPROM_DEC_LOWER_LIMIT, _decLowerLimit);
2110+ LOGV3 (DEBUG_MOUNT,F (" Mount::setDecLimitPosition(Lower): limit DEC: %l -> %l" ), _decLowerLimit, _decUpperLimit);
2111+ }
2112+ }
2113+
2114+ // ///////////////////////////////
2115+ //
2116+ // clearDecLimitPosition
2117+ //
2118+ // ///////////////////////////////
2119+ void Mount::clearDecLimitPosition (bool upper) {
2120+ if (upper) {
2121+ _decUpperLimit = 0 ;
2122+ writePersistentData (EEPROM_DEC_UPPER_LIMIT, _decUpperLimit);
2123+ LOGV3 (DEBUG_MOUNT,F (" Mount::clearDecLimitPosition(Upper): limit DEC: %l -> %l" ), _decLowerLimit, _decUpperLimit);
2124+ }
2125+ else {
2126+ _decLowerLimit = 0 ;
2127+ writePersistentData (EEPROM_DEC_LOWER_LIMIT, _decLowerLimit);
2128+ LOGV3 (DEBUG_MOUNT,F (" Mount::clearDecLimitPosition(Lower): limit DEC: %l -> %l" ), _decLowerLimit, _decUpperLimit);
2129+ }
2130+ }
2131+
20692132// ///////////////////////////////
20702133//
20712134// setHome
0 commit comments