Skip to content

Commit be7ccda

Browse files
committed
fix: inverted angles limits if the direction is inverted
1 parent 7616d9a commit be7ccda

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ func NewDefaultHandler(
142142
rightLimitAngle = actuationRange
143143
}
144144

145+
// If the direction is inverted, swap the left and right limit angles
146+
if isDirectionInverted {
147+
leftLimitAngle, rightLimitAngle = actuationRange - rightLimitAngle, actuationRange - leftLimitAngle
148+
}
149+
145150
// Initialize the servo with the provided parameters
146151
handler := &DefaultHandler{
147152
afterSetAngleFunc: afterSetAngleFunc,

0 commit comments

Comments
 (0)