Bugfixing und einige Platzhalterseiten mit Daten gefüllt

This commit is contained in:
Thomas Hooge 2025-10-07 11:19:08 +02:00
parent e7a2f4bb54
commit f969df8cb8
11 changed files with 146 additions and 84 deletions

View File

@ -654,6 +654,7 @@ def init_profile(config, cfg, boatdata):
except AttributeError: except AttributeError:
# Klasse nicht vorhanden, Seite wird nicht benutzt # Klasse nicht vorhanden, Seite wird nicht benutzt
log.error(f"Klasse '{p['type']}' nicht gefunden") log.error(f"Klasse '{p['type']}' nicht gefunden")
clist[i] = pages.Unknown(i, cfg, appdata, boatdata)
continue continue
c = cls(i, cfg, appdata, boatdata, *[v for v in p['values'].values()]) c = cls(i, cfg, appdata, boatdata, *[v for v in p['values'].values()])
clist[i] = c clist[i] = c

View File

@ -42,4 +42,8 @@ from .rudder import Rudder
from .voltage import Voltage from .voltage import Voltage
from .wind import Wind from .wind import Wind
from .windrose import WindRose from .windrose import WindRose
from .white import White
from .xtetrack import XTETrack from .xtetrack import XTETrack
# Fehlerseite
from .unknown import Unknown

View File

@ -46,13 +46,13 @@ class Clock(Page):
return True return True
return False return False
def set_location(self, city, country, lat, lon): def set_location(self, city, country, lat, lon, tz='UTC'):
try: try:
# Astral ab Debian 13 # Astral ab Debian 13
self.location = astral.LocationInfo((city, country, lat, lon, 'UTC')) self.location = astral.LocationInfo((city, country, lat, lon, tz))
except AttributeError: except AttributeError:
# Astral bis Debian 12 (Version 1.6.1) # Astral bis Debian 12 (Version 1.6.1)
self.location = astral.Location((city, country, lat, lon, 'UTC')) self.location = astral.Location((city, country, lat, lon, tz))
self.location.astral = astral.Astral() self.location.astral = astral.Astral()
def display_new(self): def display_new(self):

View File

@ -22,10 +22,10 @@ class FourValues(Page):
def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2, boatvalue3, boatvalue4): def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2, boatvalue3, boatvalue4):
super().__init__(pageno, cfg, appdata, boatdata) super().__init__(pageno, cfg, appdata, boatdata)
self.value1 = boatvalue1 self.ref1 = self.bd.getRef(boatvalue1)
self.value2 = boatvalue2 self.ref2 = self.bd.getRef(boatvalue2)
self.value3 = boatvalue3 self.ref3 = self.bd.getRef(boatvalue3)
self.value4 = boatvalue4 self.ref4 = self.bd.getRef(boatvalue4)
def draw(self, ctx): def draw(self, ctx):
# Seitenunterteilung # Seitenunterteilung
@ -34,42 +34,39 @@ class FourValues(Page):
ctx.rectangle(0, 214, 400, 3) ctx.rectangle(0, 214, 400, 3)
ctx.fill() ctx.fill()
# # Titel
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD) ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(32) ctx.set_font_size(32)
ctx.move_to(20, 45) ctx.move_to(20, 45)
ctx.show_text("AWA") ctx.show_text(self.ref1.valname)
ctx.move_to(20, 113) ctx.move_to(20, 113)
ctx.show_text("AWS") ctx.show_text(self.ref2.valname)
ctx.move_to(20, 181) ctx.move_to(20, 181)
ctx.show_text("COG") ctx.show_text(self.ref3.valname)
ctx.move_to(20, 249) ctx.move_to(20, 249)
ctx.show_text("STW") ctx.show_text(self.ref4.valname)
ctx.stroke()
# Units # Units
ctx.set_font_size(16) ctx.set_font_size(16)
ctx.move_to(20, 65) ctx.move_to(20, 65)
ctx.show_text("Deg") ctx.show_text(self.ref1.unit)
ctx.move_to(20, 133) ctx.move_to(20, 133)
ctx.show_text("kn") ctx.show_text(self.ref2.unit)
ctx.move_to(20, 201) ctx.move_to(20, 201)
ctx.show_text("Deg") ctx.show_text(self.ref3.unit)
ctx.move_to(20, 269) ctx.move_to(20, 269)
ctx.show_text("kn") ctx.show_text(self.ref4.unit)
ctx.stroke()
# Meßwerte # Meßwerte
ctx.select_font_face("DSEG7 Classic") ctx.select_font_face("DSEG7 Classic")
ctx.set_font_size(40) ctx.set_font_size(40)
ctx.move_to(180, 65) ctx.move_to(180, 65)
ctx.show_text("150") ctx.show_text(self.ref1.format())
ctx.move_to(180, 133) ctx.move_to(180, 133)
ctx.show_text("25.3") ctx.show_text(self.ref2.format())
ctx.move_to(180, 201) ctx.move_to(180, 201)
ctx.show_text("146") ctx.show_text(self.ref3.format())
ctx.move_to(180, 269) ctx.move_to(180, 269)
ctx.show_text("56.4") ctx.show_text(self.ref4.format())
ctx.stroke()

View File

@ -20,10 +20,10 @@ class FourValues2(Page):
def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2, boatvalue3, boatvalue4): def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2, boatvalue3, boatvalue4):
super().__init__(pageno, cfg, appdata, boatdata) super().__init__(pageno, cfg, appdata, boatdata)
self.value1 = boatvalue1 self.ref1 = self.bd.getRef(boatvalue1)
self.value2 = boatvalue2 self.ref2 = self.bd.getRef(boatvalue2)
self.value3 = boatvalue3 self.ref3 = self.bd.getRef(boatvalue3)
self.value4 = boatvalue4 self.ref4 = self.bd.getRef(boatvalue4)
def draw(self, ctx): def draw(self, ctx):
@ -38,40 +38,40 @@ class FourValues2(Page):
# Titel # Titel
ctx.set_font_size(40) ctx.set_font_size(40)
ctx.move_to(20, 55) ctx.move_to(20, 55)
ctx.show_text("AWA") ctx.show_text(self.ref1.valname)
ctx.move_to(20, 145) ctx.move_to(20, 145)
ctx.show_text("AWS") ctx.show_text(self.ref2.valname)
ctx.set_font_size(24) ctx.set_font_size(24)
ctx.move_to(20, 220) ctx.move_to(20, 220)
ctx.show_text("COG") ctx.show_text(self.ref3.valname)
ctx.move_to(220, 220) ctx.move_to(220, 220)
ctx.show_text("STW") ctx.show_text(self.ref4.valname)
# Einheiten # Einheiten
ctx.set_font_size(16) ctx.set_font_size(16)
ctx.move_to(20, 90) ctx.move_to(20, 90)
ctx.show_text("Deg") ctx.show_text(self.ref1.unit)
ctx.move_to(20, 180) ctx.move_to(20, 180)
ctx.show_text("kn") ctx.show_text(self.ref2.unit)
ctx.set_font_size(16) ctx.set_font_size(16)
ctx.move_to(20, 240) ctx.move_to(20, 240)
ctx.show_text("Deg") ctx.show_text(self.ref3.unit)
ctx.move_to(220, 240) ctx.move_to(220, 240)
ctx.show_text("kn") ctx.show_text(self.ref4.unit)
# Meßwerte # Meßwerte
ctx.select_font_face("DSEG7 Classic") ctx.select_font_face("DSEG7 Classic")
ctx.set_font_size(60) ctx.set_font_size(60)
ctx.move_to(180, 90) ctx.move_to(180, 90)
ctx.show_text("150") ctx.show_text(self.ref1.format())
ctx.move_to(180, 180) ctx.move_to(180, 180)
ctx.show_text("33.0") ctx.show_text(self.ref2.format())
ctx.set_font_size(40) ctx.set_font_size(40)
ctx.move_to(80, 270) ctx.move_to(80, 270)
ctx.show_text("146") ctx.show_text(self.ref3.format())
ctx.move_to(280, 270) ctx.move_to(280, 270)
ctx.show_text("50.5") ctx.show_text(self.ref4.format())
ctx.stroke() ctx.stroke()

View File

@ -24,10 +24,6 @@ class OneValue(Page):
ctx.select_font_face("DSEG7 Classic") ctx.select_font_face("DSEG7 Classic")
ctx.set_font_size(100) ctx.set_font_size(100)
ctx.move_to(40, 240) ctx.move_to(40, 240)
if self.ref1.value: ctx.show_text(self.ref1.format())
ctx.show_text(self.ref1.format())
else:
#print(dir(self.bd))
#ctx.show_text("---") # self.bd.getPlaceholder())
ctx.show_text(self.placeholder)
ctx.stroke() ctx.stroke()

View File

@ -21,56 +21,71 @@ class SixValues(Page):
def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2, def __init__(self, pageno, cfg, appdata, boatdata, boatvalue1, boatvalue2,
boatvalue3, boatvalue4, boatvalue5, boatvalue6): boatvalue3, boatvalue4, boatvalue5, boatvalue6):
super().__init__(pageno, cfg, appdata, boatdata) super().__init__(pageno, cfg, appdata, boatdata)
self.value1 = boatvalue1 self.ref1 = self.bd.getRef(boatvalue1)
self.value2 = boatvalue2 self.ref2 = self.bd.getRef(boatvalue2)
self.value3 = boatvalue3 self.ref3 = self.bd.getRef(boatvalue3)
self.value4 = boatvalue4 self.ref4 = self.bd.getRef(boatvalue4)
self.value5 = boatvalue5 self.ref5 = self.bd.getRef(boatvalue5)
self.value6 = boatvalue6 self.ref6 = self.bd.getRef(boatvalue6)
def draw(self, ctx): def draw(self, ctx):
# Seitenunterteilung # Seitenunterteilung
ctx.rectangle(0, 80, 400, 3) ctx.rectangle(0, 105, 400, 3)
ctx.rectangle(0, 146, 400, 3) ctx.rectangle(0, 195, 400, 3)
ctx.rectangle(0, 214, 400, 3) ctx.rectangle(200, 22, 3, 256)
ctx.fill() ctx.fill()
# # Titel
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD) ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(32) ctx.set_font_size(24)
ctx.move_to(20, 45)
ctx.show_text("AWA") ctx.move_to(20, 40)
ctx.move_to(20, 113) ctx.show_text(self.ref1.valname)
ctx.show_text("AWS") ctx.move_to(220, 40)
ctx.move_to(20, 181) ctx.show_text(self.ref2.valname)
ctx.show_text("COG") ctx.move_to(20, 130)
ctx.move_to(20, 249) ctx.show_text(self.ref3.valname)
ctx.show_text("STW") ctx.move_to(220, 130)
ctx.show_text(self.ref4.valname)
ctx.move_to(20, 220)
ctx.show_text(self.ref5.valname)
ctx.move_to(220, 220)
ctx.show_text(self.ref6.valname)
ctx.stroke() ctx.stroke()
# Units # Units
ctx.set_font_size(16) ctx.set_font_size(16)
ctx.move_to(20, 65)
ctx.show_text("Deg") ctx.move_to(20, 60)
ctx.move_to(20, 133) ctx.show_text(self.ref1.unit)
ctx.show_text("kn") ctx.move_to(220, 60)
ctx.move_to(20, 201) ctx.show_text(self.ref2.unit)
ctx.show_text("Deg") ctx.move_to(20, 150)
ctx.move_to(20, 269) ctx.show_text(self.ref3.unit)
ctx.show_text("kn") ctx.move_to(220, 150)
ctx.show_text(self.ref4.unit)
ctx.move_to(20, 240)
ctx.show_text(self.ref5.unit)
ctx.move_to(220, 240)
ctx.show_text(self.ref6.unit)
ctx.stroke() ctx.stroke()
# Meßwerte # Meßwerte
ctx.select_font_face("DSEG7 Classic") ctx.select_font_face("DSEG7 Classic")
ctx.set_font_size(40) ctx.set_font_size(40)
ctx.move_to(180, 65) ctx.move_to(80, 90)
ctx.show_text("150") ctx.show_text(self.ref1.format())
ctx.move_to(180, 133) ctx.move_to(280, 90)
ctx.show_text("25.3") ctx.show_text(self.ref2.format())
ctx.move_to(180, 201) ctx.move_to(80, 180)
ctx.show_text("146") ctx.show_text(self.ref3.format())
ctx.move_to(180, 269) ctx.move_to(280, 180)
ctx.show_text("56.4") ctx.show_text(self.ref4.format())
ctx.move_to(80, 270)
ctx.show_text(self.ref5.format())
ctx.move_to(280, 270)
ctx.show_text(self.ref6.format())
ctx.stroke()

View File

@ -1,3 +1,18 @@
"""
Drei frei auswählbare Meßwerte
Layout
+--------------------+
| 1 |
+--------------------+
| 2 |
+--------------------+
| 3 |
+--------------------+
"""
import cairo import cairo
from .page import Page from .page import Page

View File

@ -56,7 +56,7 @@ class TwoValues(Page):
ctx.show_text(self.ref1.format()) ctx.show_text(self.ref1.format())
if type(self.ref2) == nmea2000.boatdata.BoatValueGeo: if type(self.ref2) == nmea2000.boatdata.BoatValueGeo:
ctx.select_font_face("Ubuntu") ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(40) ctx.set_font_size(40)
ctx.move_to(140, 210) ctx.move_to(140, 210)
else: else:

22
pages/unknown.py Normal file
View File

@ -0,0 +1,22 @@
"""
Fehlerseite
"""
import os
import cairo
from .page import Page
class Unknown(Page):
def __init__(self, pageno, cfg, appdata, boatdata):
super().__init__(pageno, cfg, appdata, boatdata)
self.bgimg = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "unknown.png"))
def draw(self, ctx):
ctx.select_font_face("AtariST8x16SystemFont")
ctx.set_font_size(16)
self.draw_text_center(ctx, 200, 230, "Here be dragons")
ctx.save()
ctx.set_source_surface(self.bgimg, 140, 80)
ctx.paint()
ctx.restore()

12
pages/white.py Normal file
View File

@ -0,0 +1,12 @@
"""
White Page
Aus Kompabilitätsgründen zum OBP60
"""
import cairo
from .page import Page
class White(Page):
def draw(self, ctx):
pass