Ankerseite und mehr NMEA0183 code
This commit is contained in:
@@ -14,6 +14,7 @@ Daten
|
||||
- Alarm aktiv J/N
|
||||
- Alarmradius
|
||||
- GPS Abweichung/ Fehler in der Horizontalen
|
||||
- Zeitpunkt des Ankeraus
|
||||
|
||||
Darstellung:
|
||||
- Modi:
|
||||
@@ -29,6 +30,7 @@ Es gibt verschiedene Unterseiten
|
||||
import os
|
||||
import cairo
|
||||
import math
|
||||
import time
|
||||
from .page import Page
|
||||
|
||||
class Anchor(Page):
|
||||
@@ -41,6 +43,7 @@ class Anchor(Page):
|
||||
self.buttonlabel[5] = '' # ALARM erst möglich wenn der Anker unten ist
|
||||
|
||||
self.mode = 'N' # (N)ormal, (C)onfiguration
|
||||
self.scale = 50 # Radius of display circle in meter
|
||||
|
||||
self._bd = boatdata
|
||||
|
||||
@@ -54,6 +57,7 @@ class Anchor(Page):
|
||||
self.anchor_lat = 0
|
||||
self.anchor_lon = 0
|
||||
self.anchor_depth = -1
|
||||
self.anchor_ts = None # Timestamp of dropped anchor
|
||||
self.lat = 0
|
||||
self.lon = 0
|
||||
self.heading = -1
|
||||
@@ -75,13 +79,15 @@ class Anchor(Page):
|
||||
self.anchor_lat = self._bd.lat
|
||||
self.anchor_lon = self._bd.lon
|
||||
self.anchor_set = True
|
||||
self.anchor_ts = time.time()
|
||||
self.buttonlabel[2] = 'RISE'
|
||||
self.buttonlabel[5] = 'ALARM'
|
||||
else:
|
||||
self.anchor_set = False
|
||||
self.alarm = False
|
||||
self.alarm_enabled = False
|
||||
self.buttonlabel[2] = 'SET'
|
||||
self.anchor_ts = None
|
||||
self.buttonlabel[2] = 'DROP'
|
||||
self.buttonlabel[5] = ''
|
||||
if buttonid == 5:
|
||||
# Bei aktivem Alarm kann mit dieser Taste der Alarm zurückgesetzt
|
||||
@@ -142,27 +148,57 @@ class Anchor(Page):
|
||||
cy = 150
|
||||
r = 125
|
||||
|
||||
ctx.set_line_width(1.5)
|
||||
# Skala
|
||||
ctx.set_line_width(1)
|
||||
ctx.arc(cx, cy, r, 0, 2*math.pi)
|
||||
ctx.move_to(cx + 10, cy + 0.5)
|
||||
ctx.line_to(cx + r - 4, cy + 0.5)
|
||||
ctx.move_to(cx + r / 2, cy + 20)
|
||||
# Pfeil links
|
||||
ctx.move_to(cx + 10, cy + 0.5)
|
||||
ctx.line_to(cx + 16, cy - 4 + 0.5)
|
||||
ctx.move_to(cx + 10, cy + 0.5)
|
||||
ctx.line_to(cx + 16, cy + 4 + 0.5)
|
||||
# Pfeil rechts
|
||||
ctx.move_to(cx + r - 4, cy + 0.5)
|
||||
ctx.line_to(cx + r - 10, cy - 4 + 0.5)
|
||||
ctx.move_to(cx + r - 4, cy + 0.5)
|
||||
ctx.line_to(cx + r - 10, cy + 4 + 0.5)
|
||||
|
||||
ctx.set_font_size(16)
|
||||
self.draw_text_center(ctx, cx + r / 2, cy + 8, str(self.scale) + " m")
|
||||
ctx.stroke()
|
||||
|
||||
# Ankersymbol falls Anker fallen gelassen wurde, ansonsten nur Kreis-
|
||||
# mittelpunkt kennzeichnen
|
||||
ctx.set_line_width(1.5)
|
||||
# Ankersymbol falls Anker fallen gelassen wurde
|
||||
# Ansonsten ist das Boot-Symbol im Mittelpunkt
|
||||
if self.anchor_set:
|
||||
ctx.save()
|
||||
ctx.set_source_surface(self.sym_anchor, cx-8, cy-8)
|
||||
ctx.paint()
|
||||
ctx.restore()
|
||||
else:
|
||||
ctx.move_to(cx-6, cy-6)
|
||||
ctx.line_to(cx+6, cy+6)
|
||||
ctx.move_to(cx+6, cy-6)
|
||||
ctx.line_to(cx-6, cy+6)
|
||||
ctx.stroke()
|
||||
|
||||
# Boot zeichnen
|
||||
# Heading beachten
|
||||
|
||||
# Wir arbeiten mit einer Kopie, weil bx/by im Laufe der Zeit von
|
||||
# cx/cy abweichen werden
|
||||
if self.anchor_set:
|
||||
bx = cx
|
||||
by = cy + 30
|
||||
else:
|
||||
bx = cx
|
||||
by = cy + 8
|
||||
p = ((bx - 5, by), (bx - 5, by - 10), (bx, by - 16), (bx + 5, by - 10), (bx + 5, by), (bx - 6, by))
|
||||
if self._bd.hdt.value:
|
||||
# Rotiere Boot-Symbol um eigenes Zentrum
|
||||
boat = self.rotate((bx, by - 8), p, self._bd.hdt.value)
|
||||
else:
|
||||
# Kein Heading, Boot immer zeichnen
|
||||
boat = p
|
||||
ctx.move_to(*boat[0])
|
||||
for point in boat[1:]:
|
||||
ctx.line_to(*point)
|
||||
ctx.stroke()
|
||||
|
||||
# Windpfeil zeichnen
|
||||
if self._bd.awa.value:
|
||||
|
||||
Reference in New Issue
Block a user