From 2ffb78b4ac237b882f45d6522b58d66a5c9623d9 Mon Sep 17 00:00:00 2001 From: martha-johnston Date: Mon, 23 Sep 2024 14:34:56 -0400 Subject: [PATCH] only check if we've hit the wrong limit switch when we know there's 2 limit switches --- components/gantry/singleaxis/singleaxis.go | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/gantry/singleaxis/singleaxis.go b/components/gantry/singleaxis/singleaxis.go index b47d6204707..2f64b20d066 100644 --- a/components/gantry/singleaxis/singleaxis.go +++ b/components/gantry/singleaxis/singleaxis.go @@ -442,20 +442,22 @@ func (g *singleAxis) testLimit(ctx context.Context, pin int) (float64, error) { break } - // check if the wrong limit switch was hit - wrongHit, err := g.limitHit(ctx, wrongPin) - if err != nil { - return 0, err - } - if wrongHit { - err = g.motor.Stop(ctx, nil) + if len(g.limitSwitchPins) > 1 { + // check if the wrong limit switch was hit + wrongHit, err := g.limitHit(ctx, wrongPin) if err != nil { return 0, err } - return 0, errors.Errorf( - "expected limit switch %v but hit limit switch %v, try switching the order in the config", - pin, - wrongPin) + if wrongHit { + err = g.motor.Stop(ctx, nil) + if err != nil { + return 0, err + } + return 0, errors.Errorf( + "expected limit switch %v but hit limit switch %v, try switching the order in the config", + pin, + wrongPin) + } } elapsed := time.Since(start)