add aroow to show direction of travel

This commit is contained in:
Daniel 2025-05-18 23:18:15 +00:00
parent e49173cfdd
commit 21471654cb
2 changed files with 27 additions and 2 deletions

View File

@ -129,6 +129,28 @@ label.readout {
(: :add (readout :elapsed-time ""))
(: :add (readout :speed "0"))))
(fn arrow []
(let [height 40
w (Gtk.Label {
:halign Gtk.Align.CENTER
:valign Gtk.Align.CENTER
:width height :height height
:on_draw
(fn [self g]
(g:set_source_rgb 0.4 0.0 0.1)
(g:translate (// height 2) (// height 2))
(g:rotate (/ (* -2 app-state.course math.pi) 360) )
(g:translate (// height -2) (// height -2))
(g:set_line_width 4)
(g:move_to 10 height)
(g:line_to (// height 2) 0)
(g:line_to (- height 10) height)
(g:fill)
true)
})]
w))
(local socket-path (or (. arg 1) "/var/run/gnss-share.sock"))
(local gnss-socket
@ -153,7 +175,10 @@ label.readout {
}
)
{ : speed-knots }
(update-app-state { :speed (* speed-knots knot-in-m-s) })))))
(update-app-state { :speed (* speed-knots knot-in-m-s) }))
(if message.bearing-true
(update-app-state { :course message.bearing-true }))
)))
true)
(let [sock (gnss-socket:get_socket)
@ -168,6 +193,7 @@ label.readout {
(doto (Gtk.Overlay {})
(: :add (osm-widget))
(: :add_overlay (readouts))
(: :add_overlay (arrow))
))
(window:show_all)

View File

@ -58,7 +58,6 @@
(if (= value "")
nil
(let [(deg min) (string.match value "(..)(.+)")]
(print :deg value deg :min min)
(*
(+ (tonumber deg)
(/ (tonumber min) 60))