diff --git a/Changelog.md b/Changelog.md index 659ee6fe..3fd484bc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +**V1.13.16 - Updates** +- Throttled InfoDisplay updates. Turned off on two axis slew, limited to 5Hz on one-axis slew. +- Guide pulses are now ignored for DEC as well when at the limits. + **V1.13.15 - Updates** - Check `INFO_DISPLAY_TYPE` builds in CI - Fix `INFO_DISPLAY_TYPE_I2C_SSD1306_128x64` for esp32 builds diff --git a/ConfigurationValidation.hpp b/ConfigurationValidation.hpp index 6660e854..292f5b9e 100644 --- a/ConfigurationValidation.hpp +++ b/ConfigurationValidation.hpp @@ -449,7 +449,7 @@ #endif #endif -// For OAT, we must have DEC limits defined, otherwise free slew does nto work. +// For OAT, we must have DEC limits defined, otherwise free slew does not work. #ifndef OAM #ifndef DEC_LIMIT_UP #error "You must set DEC_LIMIT_UP to the number of degrees that your OAT can move upwards from the home position." diff --git a/Version.h b/Version.h index 81278909..e069b894 100644 --- a/Version.h +++ b/Version.h @@ -3,4 +3,4 @@ // Also, numbers are interpreted as simple numbers. _ __ _ // So 1.8 is actually 1.08, meaning that 1.12 is a later version than 1.8. \_(..)_/ -#define VERSION "V1.13.15" +#define VERSION "V1.13.16" diff --git a/src/Mount.cpp b/src/Mount.cpp index 6ff13987..02adf545 100644 --- a/src/Mount.cpp +++ b/src/Mount.cpp @@ -79,7 +79,7 @@ Mount::Mount(LcdMenu *lcdMenu) { _commandReceived = 0; #if (INFO_DISPLAY_TYPE != INFO_DISPLAY_TYPE_NONE) - _loops = 0; + _lastInfoUpdate = millis(); #endif _lcdMenu = lcdMenu; initializeVariables(); @@ -349,7 +349,7 @@ void Mount::configureAZStepper(byte pin1, byte pin2, int maxSpeed, int maxAccele #ifdef NEW_STEPPER_LIB _stepperAZ = new StepperAzSlew(AccelStepper::DRIVER, pin1, pin2); #else - _stepperAZ = new AccelStepper(AccelStepper::DRIVER, pin1, pin2); + _stepperAZ = new AccelStepper(AccelStepper::DRIVER, pin1, pin2); #endif _stepperAZ->setMaxSpeed(maxSpeed); _stepperAZ->setAcceleration(maxAcceleration); @@ -367,7 +367,7 @@ void Mount::configureALTStepper(byte pin1, byte pin2, int maxSpeed, int maxAccel #ifdef NEW_STEPPER_LIB _stepperALT = new StepperAltSlew(AccelStepper::DRIVER, pin1, pin2); #else - _stepperALT = new AccelStepper(AccelStepper::DRIVER, pin1, pin2); + _stepperALT = new AccelStepper(AccelStepper::DRIVER, pin1, pin2); #endif _stepperALT->setMaxSpeed(maxSpeed); _stepperALT->setAcceleration(maxAcceleration); @@ -758,7 +758,7 @@ void Mount::configureALTdriver(uint16_t ALT_SW_RX, uint16_t ALT_SW_TX, float rse _driverALT->pdn_disable(true); #if UART_CONNECTION_TEST_TXRX == 1 bool UART_Rx_connected = false; - UART_Rx_connected = connectToDriver("ALT"); + UART_Rx_connected = connectToDriver("ALT"); if (!UART_Rx_connected) { digitalWrite(ALT_EN_PIN, @@ -849,7 +849,7 @@ void Mount::configureFocusDriver( _driverFocus->pdn_disable(true); #if UART_CONNECTION_TEST_TXRX == 1 bool UART_Rx_connected = false; - UART_Rx_connected = connectToDriver("FOC"); + UART_Rx_connected = connectToDriver("FOC"); if (!UART_Rx_connected) { digitalWrite(FOCUS_EN_PIN, @@ -1649,23 +1649,46 @@ void Mount::guidePulse(byte direction, int duration) switch (direction) { case NORTH: - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: guidePulse: DEC guide speed : %f", - DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _stepperGUIDE->setSpeed(DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; - _guideDecEndTime = millis() + duration; + // If a upper limit is set, check we're not there. If we are, refuse the guide pulse. + if (_decUpperLimit != 0 && _stepperDEC->currentPosition() >= _decUpperLimit) + { + // TODO: Make sure Southern hemisphere does not need a sign/direction inversion. + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC is at (%l) which is at or above upper limit (%l), ignoring guide pulse", + _stepperDEC->currentPosition(), + _decUpperLimit); + } + else + { + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC guide speed : %f", + DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _stepperGUIDE->setSpeed(DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; + _guideDecEndTime = millis() + duration; + } break; case SOUTH: - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); - LOG(DEBUG_STEPPERS | DEBUG_GUIDE, - "[GUIDE]: guidePulse: DEC guide speed : %f", - -DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _stepperGUIDE->setSpeed(-DEC_PULSE_MULTIPLIER * decGuidingSpeed); - _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; - _guideDecEndTime = millis() + duration; + if (_decLowerLimit != 0 && _stepperDEC->currentPosition() <= _decLowerLimit) + { + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC is at (%l) which is at or below lower limit (%l), ignoring guide pulse", + _stepperDEC->currentPosition(), + _decLowerLimit); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC is at lower limit, ignoring guide pulse"); + } + else + { + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, "[GUIDE]: guidePulse: DEC base speed : %f", decGuidingSpeed); + LOG(DEBUG_STEPPERS | DEBUG_GUIDE, + "[GUIDE]: guidePulse: DEC guide speed : %f", + -DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _stepperGUIDE->setSpeed(-DEC_PULSE_MULTIPLIER * decGuidingSpeed); + _mountStatus |= STATUS_GUIDE_PULSE | STATUS_GUIDE_PULSE_DEC; + _guideDecEndTime = millis() + duration; + } break; case WEST: @@ -1868,7 +1891,7 @@ void Mount::getAZALTPositions(long &azPos, long &altPos) #if (AZ_STEPPER_TYPE != STEPPER_TYPE_NONE) azPos = _stepperAZ->currentPosition(); #else - azPos = 0; + azPos = 0; #endif #if (ALT_STEPPER_TYPE != STEPPER_TYPE_NONE) altPos = _stepperALT->currentPosition(); @@ -3225,13 +3248,26 @@ void Mount::setupInfoDisplay() void Mount::updateInfoDisplay() { #if (INFO_DISPLAY_TYPE != INFO_DISPLAY_TYPE_NONE) - _loops++; - // Update display every 8 cycles - if (_loops % 8 == 0) + // If we update this display too often while slewing, the serial port is unable to process commands fast enough. Which makes the driver + // timeout, causing ASCOM errors. + // We will update at 30Hz when idle, 5Hz when slewing one axis and skip updates when slewing both. + int refreshRateHz = 30; + long now = millis(); + if ((slewStatus() & (SLEWING_DEC | SLEWING_RA)) == (SLEWING_DEC | SLEWING_RA)) + { + return; + } + else if (isSlewingRAorDEC()) + { + refreshRateHz = 5; + } + + if (now - _lastInfoUpdate > (1000 / refreshRateHz)) { LOG(DEBUG_DISPLAY, "[DISPLAY]: Render state to OLED ..."); infoDisplay->render(this); LOG(DEBUG_DISPLAY, "[DISPLAY]: Rendered state to OLED ..."); + _lastInfoUpdate = now; } #endif } @@ -3267,6 +3303,7 @@ bool Mount::isBootComplete() // // setDecLimitPosition // +// If limitAngle is 0, no offset is given, so the current position is used. ///////////////////////////////// void Mount::setDecLimitPosition(bool upper, float limitAngle) { diff --git a/src/Mount.hpp b/src/Mount.hpp index 80d53351..b63632f4 100644 --- a/src/Mount.hpp +++ b/src/Mount.hpp @@ -403,7 +403,7 @@ class Mount void setupInfoDisplay(); void updateInfoDisplay(); InfoDisplayRender *getInfoDisplay(); - long _loops; + long _lastInfoUpdate; #endif // Called by Meade processor every time a command is received.