biscuit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit d8963679d619b1ca41ee79218102aec03a9a6ad0
parent 6c3f019ab76ac1716f292ac2e00d7cfea30748b3
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 10 Jun 2025 13:51:10 +0100

add compass rose

Diffstat:
Mpkgs/maps/main.fnl | 44++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+), 0 deletions(-)

diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl @@ -312,6 +312,7 @@ label.readout { (string.format "%.1f km/h" (* app-state.speed 3.6))) :osm (: (widget:get_window) :invalidate_rect nil) :arrow (: (widget:get_window) :invalidate_rect nil) + :rose (: (widget:get_window) :invalidate_rect nil) :time (widget:set_label (hhmmss (+ utc-offset app-state.time-of-day))) )))) @@ -351,6 +352,48 @@ label.readout { true) })))) +(fn deg->rad [degrees] + (* math.pi (/ degrees 180))) + +(fn rose [] + (let [height 60] + (register-widget + :rose + (Gtk.Label { + :halign Gtk.Align.START + :valign Gtk.Align.START + :width height :height height + :on_draw + (fn [self g] + (g:save) + (g:set_line_width 1) + (g:set_source_rgb 0.4 0.0 0.1) + (g:arc (// height 2) (// height 2) 15 + 0 (* 2 math.pi)) + (g:stroke) + + (g:translate (// height 2) (// height 2)) + (g:rotate (- (deg->rad app-state.orientation))) + (g:translate (// height -2) (// height -2)) + + (g:set_line_width 2) + (g:move_to (// height 2) height) + (g:line_to (// height 2) 0) + + (g:move_to 10 20) + (g:line_to (// height 2) 0) + (g:line_to (- height 10) 20) + (g:stroke) + + (g:set_source_rgb 1 1 0) + (g:move_to (// height -2) (// height -2)) + (g:text_path "N") + (g:fill) + + (g:restore) + true) + })))) + (local socket-path (or (. arg 1) "/var/run/gnss-share.sock")) @@ -407,6 +450,7 @@ label.readout { (: :add (osm-widget)) (: :add_overlay (readouts)) (: :add_overlay (arrow)) + (: :add_overlay (rose)) )) (window:show_all)