Documentation
¶
Overview ¶
Package vibration converts the shared motion frame into a vibrator drive level. It is a pure function of the frame, the user's profile and its own smoothing state: it never invents motion, never reshapes the frame, and never raises a level above the user's live intensity.
Index ¶
Constants ¶
const ( FollowSpeed = "speed" FollowDepth = "depth" FollowSteady = "steady" )
Follow profiles: what the vibration level follows.
const ( DepthBase = "base" DepthTip = "tip" )
Depth ends in the frame's semantic coordinates: base is position 0 and tip is position 100. The stroker's reverse-direction setting corrects how a stroker is mounted and does not change them.
const ( // SpeedWindowMillis is the look-back window for averaged absolute // velocity. Averaging |dp| over the window keeps a reversal from // cancelling, which an endpoint difference would. SpeedWindowMillis = 250 // FadeMillis is the fade-in at every Play and Resume. FadeMillis = 2000 )
Rendering constants. They are starting points, not measured values: the smoothing, the speed scale and the user's timing offset are tuned together during hardware acceptance, because smoothing, radio and motor lag add up.
Variables ¶
This section is empty.
Functions ¶
func Output ¶
Output maps a drive fraction into the range from the minimum up to the live intensity. At an intensity of zero the vibrator is silent whatever the motion does, and a zero drive is always exactly zero.
func Quantize ¶
Quantize picks the actuator step for level with steps steps. last is the step sent before, or -1. The ceiling quantizes downward: a coarse motor gets its nearest step at or below it, never above.
func SpeedPercentLevel ¶
SpeedPercentLevel places a commanded speed within the saved speed band on the same scale as following speed: 35% at the slowest saved speed up to 1 at the fastest. It is The Handy's intensity for profiles that do not follow speed.
Types ¶
type Profile ¶
Profile is the user's conversion profile. SpeedLow and SpeedHigh are the averaged carriage speeds, in full spans per second, at the user's slowest and fastest saved Handy speeds; zero keeps the saturating curve.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer converts the frame into a drive fraction in 0..1.
func NewRenderer ¶
NewRenderer returns a renderer for profile.
func (*Renderer) Drive ¶
Drive returns the drive fraction at streamMillis and whether the frame covered it. Uncovered time is silent: the owner reports starvation instead of holding the last level.
func (*Renderer) DriveEnvelope ¶
DriveEnvelope reads engine-sampled drive, keeping the same coverage and startup fade. The conversion profile does not reshape an independent lane.
func (*Renderer) Restart ¶
Restart begins a new or resumed stream at streamMillis: smoothing resets and output fades in from zero.
func (*Renderer) SetProfile ¶
SetProfile applies a new profile from the next level on.