Skip to content

motor.cgi: press-and-hold instead of one-step-per-click#55

Open
moontwister wants to merge 1 commit into
OpenIPC:masterfrom
moontwister:motor-cgi-press-and-hold
Open

motor.cgi: press-and-hold instead of one-step-per-click#55
moontwister wants to merge 1 commit into
OpenIPC:masterfrom
moontwister:motor-cgi-press-and-hold

Conversation

@moontwister
Copy link
Copy Markdown

Summary

The current motor arrow buttons fire `gpio-motors` once per click, which is impractical on most motorized cameras — you have to repeatedly click an arrow to pan smoothly.

Replace with a mousedown/touchstart → `setInterval(250 ms)` loop that re-fires while the button is held, with mouseup / mouseleave / touchend / touchcancel / window-blur all stopping the loop. An inflight guard prevents queueing if a previous request hasn't returned yet (slow links, slow PTZ daemons).

Step size and phase timing preserved at the upstream defaults (5 steps, 10 ms phase). The 🆗 center button keeps its existing single-fire behaviour, so any board that maps `gpio-motors 0 0 N` to a "home" / "stop" / "no-op" in its wrapper keeps that behaviour.

Test plan

  • Held arrows with mouse → pan/tilt motors continuously rotate at ~7°/sec pan, ~14°/sec tilt (TP-Link Kasa KC110, OV2735 + ULN2803 + 24BYJ48 steppers).
  • Released → motors stop within one tick.
  • Dragged finger off button on touch device → motors stop (touchcancel).
  • Switched tab away mid-hold → motors stop (window blur).
  • Center button still triggers `gpio-motors 0 0 10`.

Context

Split out from the closed OpenIPC/firmware#2151 (KC110 board package, re-filed at OpenIPC/builder#99 per @widgetii's review). This particular change is fully generic — useful on any motorized camera using the upstream `gpio-motors` interface.

🤖 Generated with Claude Code

The previous click-handler fires gpio-motors once per mouse click,
which means smooth-panning a motorized camera requires repeatedly
clicking the arrow buttons. On most PTZ cameras this is impractical
— users want to hold a direction button and have the gimbal pan
continuously until released.

Replace with a mousedown/touchstart → setInterval(250ms) loop that
fires gpio-motors steps as long as the button is held, with mouseup,
mouseleave, touchend, touchcancel, and window blur all stopping it.
An inflight flag prevents queuing if a previous request hasn't
returned yet (slow links / slow PTZ daemons).

Step size and phase timing preserved at upstream defaults (5 steps,
10 ms phase). Center button preserved as a single fire (boards that
implement a "home" / "park" position in their gpio-motors wrapper
can interpret the x=0/y=0 call accordingly; most use this slot for
a stop or no-op).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant