rotate the map to face direction of travel
there is a bit of smoothing so it does not instantly lurch to the new new course, as the visual effect was quite jarring
This commit is contained in:
parent
8c51113d6e
commit
8ec64bb1b0
@ -65,7 +65,8 @@ label.readout {
|
|||||||
:lat 49
|
:lat 49
|
||||||
:lon 0
|
:lon 0
|
||||||
:zoom 17
|
:zoom 17
|
||||||
:course 22
|
:course 0
|
||||||
|
:smooth-course 0
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -253,6 +254,10 @@ label.readout {
|
|||||||
bounds.pixels.y)
|
bounds.pixels.y)
|
||||||
(draw-onto-map-surface bounds app-state.zoom)))))
|
(draw-onto-map-surface bounds app-state.zoom)))))
|
||||||
|
|
||||||
|
(g:translate (+ (/ viewport-width 2)) (+ (/ viewport-height 2)))
|
||||||
|
(g:rotate (* (/ (- 360 app-state.smooth-course) 180) math.pi))
|
||||||
|
(g:translate (- (/ viewport-width 2)) (- (/ viewport-height 2)))
|
||||||
|
|
||||||
(g:set_source_surface map-surface (- offset-x) (- offset-y))
|
(g:set_source_surface map-surface (- offset-x) (- offset-y))
|
||||||
(g:set_operator cairo.Operator.SOURCE)
|
(g:set_operator cairo.Operator.SOURCE)
|
||||||
(g:rectangle 0 0 viewport-width viewport-height)
|
(g:rectangle 0 0 viewport-width viewport-height)
|
||||||
@ -293,9 +298,6 @@ 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 update-app-state [new-vals]
|
(fn update-app-state [new-vals]
|
||||||
(let [old-bounds
|
(let [old-bounds
|
||||||
(map-bounds app-state.lat app-state.lon app-state.zoom)]
|
(map-bounds app-state.lat app-state.lon app-state.zoom)]
|
||||||
@ -306,6 +308,9 @@ label.readout {
|
|||||||
(not (= old-bounds.min.x bounds.min.x))
|
(not (= old-bounds.min.x bounds.min.x))
|
||||||
(not (= old-bounds.min.y bounds.min.y)))
|
(not (= old-bounds.min.y bounds.min.y)))
|
||||||
(set map-surface nil)))
|
(set map-surface nil)))
|
||||||
|
(set app-state.smooth-course
|
||||||
|
(+ app-state.smooth-course
|
||||||
|
(* 0.05 (- app-state.course app-state.smooth-course))))
|
||||||
(each [name widget (pairs state-widgets)]
|
(each [name widget (pairs state-widgets)]
|
||||||
(case name
|
(case name
|
||||||
:speed (widget:set_label
|
:speed (widget:set_label
|
||||||
@ -340,7 +345,8 @@ label.readout {
|
|||||||
(fn [self g]
|
(fn [self g]
|
||||||
(g:set_source_rgb 0.4 0.0 0.1)
|
(g:set_source_rgb 0.4 0.0 0.1)
|
||||||
(g:translate (// height 2) (// height 2))
|
(g:translate (// height 2) (// height 2))
|
||||||
(g:rotate (* (/ app-state.course 180) math.pi))
|
(g:rotate (* (/ (- app-state.course app-state.smooth-course)
|
||||||
|
180) math.pi))
|
||||||
(g:translate (// height -2) (// height -2))
|
(g:translate (// height -2) (// height -2))
|
||||||
(g:set_line_width 4)
|
(g:set_line_width 4)
|
||||||
(g:move_to 10 height)
|
(g:move_to 10 height)
|
||||||
@ -393,7 +399,11 @@ label.readout {
|
|||||||
GLib.PRIORITY_DEFAULT
|
GLib.PRIORITY_DEFAULT
|
||||||
20 ; ms
|
20 ; ms
|
||||||
(fn []
|
(fn []
|
||||||
|
;; run cqueues scheduler
|
||||||
(cq:step 0)
|
(cq:step 0)
|
||||||
|
;; for smoother rotation when course changes, repaint more often than
|
||||||
|
;; once per gnss message
|
||||||
|
(update-app-state {})
|
||||||
true)
|
true)
|
||||||
nil nil)
|
nil nil)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user