83 lines
2.1 KiB
Python
83 lines
2.1 KiB
Python
"""
|
|
|
|
Ankerinfo / -alarm
|
|
|
|
Daten
|
|
- Position des Ankers
|
|
- Wassertiefe beim Ankern
|
|
- Gesteckte Kettenlänge
|
|
- aktuelle Position des Schiffs
|
|
- aktuelle Wassertiefe an Schiffsposition
|
|
- aktuelle Schiffsausrichtung bearing/heading
|
|
- aktuelle Windrichtung
|
|
- aktuelle Windstärke
|
|
- Alarm aktiv J/N
|
|
- Alarmradius
|
|
|
|
"""
|
|
|
|
import os
|
|
import cairo
|
|
import math
|
|
from .page import Page
|
|
|
|
class Anchor(Page):
|
|
|
|
def __init__(self, pageno, cfg, boatdata):
|
|
super().__init__(pageno, cfg, boatdata)
|
|
self.sym_anchor = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "anchor.png"))
|
|
self.buttonlabel[1] = 'DEC'
|
|
self.buttonlabel[2] = 'INC'
|
|
self.buttonlabel[5] = 'SET'
|
|
|
|
# Der sinnvolle Abstand ist abhängig von der Länge der gesteckten Kette
|
|
# Die initial eingegebene Position des Ankers sollte nactträglich justiert
|
|
# werden können
|
|
|
|
self.chain_length = 60 # maximale Länge die ausgesteckt werden kann
|
|
self.chain = 35 # aktuell gesteckte Länge
|
|
self.anchor_lat = 0
|
|
self.anchor_lon = 0
|
|
self.anchor_depth = -1
|
|
self.lat = 0
|
|
self.lon = 0
|
|
self.heading = -1
|
|
self.depth = -1
|
|
self.alarm_range = 20
|
|
self.alarm_armed = False
|
|
self.alarm = False # Alarm ist ausgelöst und aktiv
|
|
self.wind_angle = -1
|
|
|
|
def draw(self, ctx):
|
|
|
|
# Name
|
|
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
|
ctx.set_font_size(20)
|
|
|
|
ctx.move_to(2, 50)
|
|
ctx.show_text("Anchor")
|
|
ctx.move_to(320, 50)
|
|
ctx.show_text("Chain")
|
|
|
|
ctx.set_font_size(16)
|
|
ctx.move_to(2, 70)
|
|
ctx.show_text("Alarm: off")
|
|
ctx.move_to(320, 70)
|
|
ctx.show_text("45 m")
|
|
ctx.stroke()
|
|
|
|
|
|
# Spezialseite
|
|
cx = 200
|
|
cy = 150
|
|
r = 125
|
|
|
|
ctx.set_line_width(1.5)
|
|
ctx.arc(cx, cy, r, 0, 2*math.pi)
|
|
ctx.stroke()
|
|
|
|
ctx.save()
|
|
ctx.set_source_surface(self.sym_anchor, cx-8, cy-8)
|
|
ctx.paint()
|
|
ctx.restore()
|