From b83a4f4455cfd701ed876390b63c4095cb3a673c Mon Sep 17 00:00:00 2001 From: rouggy Date: Thu, 16 Jul 2026 00:48:10 +0200 Subject: [PATCH] fix: correcting proper bit to see when Steppir is moving --- internal/steppir/steppir.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/steppir/steppir.go b/internal/steppir/steppir.go index 4e6551c..bf79136 100644 --- a/internal/steppir/steppir.go +++ b/internal/steppir/steppir.go @@ -253,10 +253,14 @@ func parseStatus(b []byte) (*Status, error) { freqHz := int(int32(binary.BigEndian.Uint32(b[2:6]))) * 10 active := b[6] dir := decodeDir(b[7]) - // active==0xFF means "command just received" (not motion); the 0x01 bit is - // documented as always set. Treat anything else non-zero as motors busy. + // active-motors byte: one bit per element that is currently moving. + // 0x04 driver · 0x08 DIR1 · 0x10 reflector · 0x20 DIR2 (mask 0x3C) + // Bit 0 (0x01) is documented as always set — not a motor. 0xFF means the + // controller just received a command, not motion. So "moving" is precisely + // "any real motor bit set", ignoring the always-on bit and the ack value. + const motorBits = 0x3C moving := 0 - if active != 0xFF && (active & ^byte(0x01)) != 0 { + if active != 0xFF && active&motorBits != 0 { moving = 1 } return &Status{Frequency: freqHz / 1000, Direction: dir, MotorsMoving: moving}, nil