NAVTEX-Feature hinzugefügt. Daten nur über das Netzwerk

This commit is contained in:
2025-10-01 06:54:56 +02:00
parent 99dcf00242
commit fb7c688a99
9 changed files with 329 additions and 7 deletions

View File

@@ -32,6 +32,7 @@ from .dst810 import DST810
from .epropulsion import EPropulsion
from .keel import Keel
from .mob import MOB
from .navtex import Navtex
from .racetracker import RaceTracker
from .rollpitch import RollPitch
from .skyview import SkyView

View File

@@ -25,7 +25,7 @@ class Clock(Page):
self.buttonlabel[1] = 'MODE'
self.buttonlabel[2] = 'TZ'
self.mode = ('A', 'D', 'T') # (A)nalog (D)igital (T)imer
self.modeindex = 1
self.modeindex = 0
self.utc = True
self.tzoffset = cfg['tzoffset']
self.bv_lat = boatdata.getRef("LAT")

112
pages/navtex.py Normal file
View File

@@ -0,0 +1,112 @@
"""
NAVTEX
- Meldungen anzeigen
"""
import cairo
from .page import Page
class Navtex(Page):
def __init__(self, pageno, cfg, appdata, boatdata):
super().__init__(pageno, cfg, appdata, boatdata)
self.disabled = self.app.navtex is None
self.ids = self.app.navtex.get_ids()
if len(self.ids) > 0:
self.current = 1
self.msgid = self.ids[self.current - 1]
else:
self.current = 0
self.msgid = None
self.buttonlabel[1] = 'PREV'
self.buttonlabel[2] = 'NEXT'
self.buttonlabel[5] = 'MORE'
self.skip = 0
def handle_key(self, buttonid):
if buttonid == 1:
if self.current > 1:
self.current -= 1
else:
self.current = len(self.ids)
self.msgid = self.ids[self.current - 1]
self.skip = 0
return True
if buttonid == 2:
if self.current < len(self.ids):
self.current += 1
else:
self.current = 1
self.msgid = self.ids[self.current - 1]
self.skip = 0
return True
if buttonid == 5:
self.skip += 1
return True
return False
def draw(self, ctx):
# Title
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(24)
ctx.move_to(8, 40)
ctx.show_text("NAVTEX")
ctx.set_line_width(1)
ctx.move_to(4.5, 42.5)
ctx.line_to(395.5, 42.5)
ctx.move_to(4.5, 272.5)
ctx.line_to(395.5, 272.5)
ctx.move_to(4.5, 32.5)
ctx.line_to(4.5, 272.5)
ctx.move_to(396.5, 32.5)
ctx.line_to(396.5, 272.5)
#ctx.rectangle(4.5, 20.5, 392, 250)
ctx.stroke()
ctx.set_font_size(16)
if self.disabled:
ctx.move_to(8, 75)
ctx.show_text("Feature ist disabled by configuration")
return
ctx.move_to(150, 40)
self.draw_text_ralign(ctx, 392, 38, "Message {} of {}".format(self.current, len(self.ids)))
ctx.select_font_face("AtariST8x16SystemFont")
ctx.move_to(8, 59)
if self.current == 0:
ctx.show_text("NIL")
return
# 48 Zeichen je Zeile möglich
# Max. 14 Zeilen auf dem Bildschirm
rawmsg = self.app.navtex.get_message(self.msgid).splitlines()
output = []
for line in rawmsg:
if len(line) <= 48:
output.append(line)
else:
i = 0
j = 48
while i < len(line):
output.append(line[i:j])
i += 48
j += 48
x = 8
y = 59
n = 0
for line in output:
if n >= self.skip:
ctx.move_to(x, y)
ctx.show_text(line)
y += 16
n += 1
if n >= 14 + self.skip:
break

View File

@@ -190,7 +190,7 @@ class RaceTracker(Page):
Absätzen auf dem Bildschirma ausgibt.
"""
x = 8
y = 50
y = 48
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(24)
ctx.move_to(x, y)
@@ -199,7 +199,7 @@ class RaceTracker(Page):
y += 25
ctx.set_font_size(16)
ctx.move_to(x, y)
ctx.show_text("Disabled by 'NONE in configuration'.")
ctx.show_text("Disabled by 'NONE' in configuration.")
y += 30
ctx.move_to(x, y)
ctx.show_text("Currently only tracker types 'HERO' and 'LOCAL'")
@@ -225,7 +225,7 @@ class RaceTracker(Page):
def draw_local(self, ctx):
x = 8
x1 = 130
y = 50
y = 48
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(24)
ctx.move_to(x, y)