diff --git a/kstars/ekos/focus/focus.h b/kstars/ekos/focus/focus.h --- a/kstars/ekos/focus/focus.h +++ b/kstars/ekos/focus/focus.h @@ -622,5 +622,7 @@ // Experimental linear focuser. std::unique_ptr linearFocuser; int focuserAdditionalMovement { 0 }; + + bool hasDeviation { false }; }; } diff --git a/kstars/ekos/focus/focus.cpp b/kstars/ekos/focus/focus.cpp --- a/kstars/ekos/focus/focus.cpp +++ b/kstars/ekos/focus/focus.cpp @@ -453,6 +453,8 @@ disconnect(oneFocuser, &ISD::GDInterface::numberUpdated, this, &Ekos::Focus::processFocusNumber); } + hasDeviation = currentFocuser->hasDeviation(); + canAbsMove = currentFocuser->canAbsMove(); if (canAbsMove) diff --git a/kstars/indi/indifocuser.h b/kstars/indi/indifocuser.h --- a/kstars/indi/indifocuser.h +++ b/kstars/indi/indifocuser.h @@ -24,12 +24,17 @@ { Q_OBJECT + public: enum FocusDirection { FOCUS_INWARD, FOCUS_OUTWARD }; + enum FocusDeviation + { + NIKONZ6 + }; explicit Focuser(GDInterface *iPtr) : DeviceDecorator(iPtr) { @@ -61,6 +66,7 @@ double getLastManualFocusDriveValue(); bool hasBacklash(); + bool hasDeviation(); bool setBacklash(int32_t steps); int32_t getBacklash(); @@ -75,5 +81,7 @@ private: uint32_t m_maxPosition {0}; + int deviation = -1; + }; } diff --git a/kstars/indi/indifocuser.cpp b/kstars/indi/indifocuser.cpp --- a/kstars/indi/indifocuser.cpp +++ b/kstars/indi/indifocuser.cpp @@ -170,19 +170,34 @@ bool Focuser::moveRel(int steps) { INumberVectorProperty *focusProp; + if(canManualFocusDriveMove()) { focusProp = baseDevice->getNumber("manualfocusdrive"); - if (steps == getLastManualFocusDriveValue()) - steps = steps + 1; + FocusDirection dir; + getFocusDirection(&dir); + if (dir == FOCUS_INWARD) + steps = -abs(steps); + else if (dir == FOCUS_OUTWARD) + steps = abs(steps); + + //manualfocusdrive needs different steps value ​​at every turn + if (steps == getLastManualFocusDriveValue()) + steps += 1; + + //Nikon Z6 fails if step is -1, 0, 1 + if (deviation == NIKONZ6) + { + if (abs(steps) < 2) + steps = 2; + } } else { focusProp = baseDevice->getNumber("REL_FOCUS_POSITION"); } - if (focusProp == nullptr) return false; @@ -294,4 +309,15 @@ return focusProp->np[0].value; } + +bool Focuser::hasDeviation() +{ + if (!strcmp(getDeviceName(), "Nikon DSLR Z6")) + { + deviation = NIKONZ6; + return true; + } + return false; +} + }