clamp minimum turn speed

if there's less than ten degrees between target and actual, snap to
target. Otherwise we only approach the target asymptotically and never
reach it
This commit is contained in:
Daniel Barlow 2025-06-15 17:49:46 +01:00
parent ccca847e3c
commit 6b921e2c25

View File

@ -301,6 +301,11 @@ label.readout {
(expect= (hhmmss (+ 45 (* 60 12) (* 60 60 3))) "3:12:45") (expect= (hhmmss (+ 45 (* 60 12) (* 60 60 3))) "3:12:45")
(fn turn-smoothly [from to]
(if (< (math.abs (- from to)) 10) to
(+ from (* 0.05 (- to from)))))
(fn update-app-state [new-vals] (fn update-app-state [new-vals]
(let [old-state (merge {} app-state) (let [old-state (merge {} app-state)
@ -320,10 +325,7 @@ label.readout {
(when (not (= app-state.orientation-target app-state.orientation-actual)) (when (not (= app-state.orientation-target app-state.orientation-actual))
(set app-state.orientation-actual (set app-state.orientation-actual
(+ app-state.orientation-actual (turn-smoothly app-state.orientation-actual app-state.orientation-target)))
(* 0.05 (- app-state.orientation-target app-state.orientation-actual))))
)
(each [name widget (pairs state-widgets)] (each [name widget (pairs state-widgets)]
(case name (case name
:speed (widget:set_label :speed (widget:set_label