Ankerseite verbessert
This commit is contained in:
@@ -48,6 +48,14 @@ class Anchor(Page):
|
||||
self.scale = 425 # Radius of display circle in meter
|
||||
|
||||
self._bd = boatdata
|
||||
self.zoom = 15
|
||||
self.app.mapsrv.set_output_size(260, 260)
|
||||
self.app.mapsrv.get_px_meters(self._bd.lat.getRawValue(), self.zoom)
|
||||
self.bgimage = None
|
||||
self._map_tick = 10
|
||||
# Vor Hafeneinfahrt Wedel
|
||||
#self.lat = 53.56938345759218
|
||||
#self.lon = 9.679658234303275
|
||||
|
||||
# Der sinnvolle Abstand ist abhängig von der Länge der gesteckten Kette
|
||||
# Die initial eingegebene Position des Ankers sollte nactträglich justiert
|
||||
@@ -60,8 +68,6 @@ class Anchor(Page):
|
||||
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
|
||||
self.depth = -1
|
||||
self.alarm_range = 20
|
||||
@@ -69,10 +75,6 @@ class Anchor(Page):
|
||||
self.alarm = False # Alarm ist ausgelöst und aktiv
|
||||
self.wind_angle = -1
|
||||
|
||||
# Seekarte, mit Hintergrund wie das Display
|
||||
self.app.mapsrv.set_output_size(260, 260)
|
||||
self.bgimage = self.app.mapsrv.get_round_bwmap_cairo(53.56938345759218, 9.679658234303275, 15, (220, 220, 220))
|
||||
|
||||
# Menüsteuerung für Konfiguration
|
||||
self._menu = Menu("Options", 20, 80)
|
||||
self._menu.setItemDimension(120, 20)
|
||||
@@ -80,7 +82,7 @@ class Anchor(Page):
|
||||
newitem.setRange(0, 200, (1, 5, 10))
|
||||
newitem = self._menu.addItem("chainmax", "Chain max", "int", self.chain_length, "m")
|
||||
newitem.setRange(0, 200, (1, 5, 10))
|
||||
newitem = self._menu.addItem("zoom", "Zoom", "int", 2)
|
||||
newitem = self._menu.addItem("zoom", "Zoom", "int", 15)
|
||||
newitem.setRange(1, 8, (1,))
|
||||
newitem = self._menu.addItem("range", "Alarm range", "int", 40, "m")
|
||||
newitem.setRange(1, 200, (1, 5, 10))
|
||||
@@ -88,6 +90,10 @@ class Anchor(Page):
|
||||
|
||||
self._test = 0
|
||||
|
||||
def display_new(self):
|
||||
if self._bd.lat.valid and self._bd.lon.valid:
|
||||
self.bgimage = self.app.mapsrv.get_round_bwmap_cairo(self._bd.lat.getValueRaw(), self._bd.lon.getValueRaw(), self.zoom, (220, 220, 220))
|
||||
|
||||
def handle_key(self, buttonid):
|
||||
if buttonid == 1:
|
||||
if self.mode == 'N':
|
||||
@@ -110,8 +116,8 @@ class Anchor(Page):
|
||||
# Normal
|
||||
if buttonid == 2:
|
||||
if not self.anchor_set:
|
||||
self.anchor_lat = self._bd.lat
|
||||
self.anchor_lon = self._bd.lon
|
||||
self.anchor_lat = self._bd.lat.getValueRaw()
|
||||
self.anchor_lon = self._bd.lon.getValueRaw()
|
||||
self.anchor_set = True
|
||||
self.anchor_ts = time.time()
|
||||
self.buttonlabel[2] = 'RISE'
|
||||
@@ -185,10 +191,15 @@ class Anchor(Page):
|
||||
# self.anchor_lat =
|
||||
|
||||
# Seekarte als Hintergrundbild
|
||||
ctx.save()
|
||||
ctx.set_source_surface(self.bgimage, (400 - 260) // 2, 20)
|
||||
ctx.paint()
|
||||
ctx.restore()
|
||||
if self._bd.lat.valid and self._bd.lon.valid:
|
||||
self._map_tick -= 1
|
||||
if not self.bgimage or self._map_tick == 0:
|
||||
self.bgimage = self.app.mapsrv.get_round_bwmap_cairo(self._bd.lat.getValueRaw(), self._bd.lon.getValueRaw(), self.zoom, (220, 220, 220))
|
||||
self._map_tick = 10
|
||||
ctx.save()
|
||||
ctx.set_source_surface(self.bgimage, (400 - 260) // 2, 20)
|
||||
ctx.paint()
|
||||
ctx.restore()
|
||||
|
||||
# Name
|
||||
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||
@@ -212,8 +223,13 @@ class Anchor(Page):
|
||||
ctx.show_text(f"{self.chain} m")
|
||||
|
||||
ctx.move_to(10, 220)
|
||||
if self._bd.dbs.valid:
|
||||
ctx.show_text(self._bd.dbs.format())
|
||||
#if self._bd.dbs.valid:
|
||||
ctx.show_text(self._bd.dbs.format())
|
||||
|
||||
# Aktuelle Koordinaten
|
||||
self.draw_text_ralign(ctx, 396, 235, "Boat")
|
||||
self.draw_text_ralign(ctx, 396, 255, self._bd.lat.format())
|
||||
self.draw_text_ralign(ctx, 396, 275, self._bd.lon.format())
|
||||
|
||||
ctx.stroke()
|
||||
|
||||
|
||||
@@ -64,6 +64,24 @@ class Page():
|
||||
c = 2 * asin(sqrt(a))
|
||||
return c * 3440
|
||||
|
||||
@staticmethod
|
||||
def format_lat(latitude, decpl=4):
|
||||
if not latitude:
|
||||
return '---'
|
||||
degrees = int(latitude)
|
||||
minutes = (latitude - degrees) * 60
|
||||
direction = 'N' if latitude > 0 else 'S'
|
||||
return "{0}° {1:.{3}f}' {2}".format(degrees, minutes, direction, decpl)
|
||||
|
||||
@staticmethod
|
||||
def format_lon(longitude, decpl=4):
|
||||
if not longitude:
|
||||
return '---'
|
||||
degrees = int(longitude)
|
||||
minutes = (longitude - degrees) * 60
|
||||
direction = 'E' if longitude > 0 else 'W'
|
||||
return "{0}° {1:.{3}f}' {2}".format(degrees, minutes, direction, decpl)
|
||||
|
||||
def __init__(self, pageno, cfg, appdata, boatdata):
|
||||
self.pageno = pageno
|
||||
self.cfg = cfg
|
||||
|
||||
Reference in New Issue
Block a user