Verbesserungen für Clock-Seite, neue allgemeine display_new Methode
This commit is contained in:
parent
e7a96390f2
commit
f47379b6d3
|
@ -397,7 +397,9 @@ class Frontend(Gtk.Window):
|
||||||
self.keylock = False
|
self.keylock = False
|
||||||
self.pages = profile
|
self.pages = profile
|
||||||
self.pageno = 1
|
self.pageno = 1
|
||||||
|
self.pageno_last = 1
|
||||||
self.curpage = self.pages[self.pageno]
|
self.curpage = self.pages[self.pageno]
|
||||||
|
self.curpage.display_new()
|
||||||
|
|
||||||
print("Wische von 2 nach 1 für Programmende")
|
print("Wische von 2 nach 1 für Programmende")
|
||||||
|
|
||||||
|
@ -556,6 +558,7 @@ class Frontend(Gtk.Window):
|
||||||
else:
|
else:
|
||||||
self.pageno = len(self.pages) - 1
|
self.pageno = len(self.pages) - 1
|
||||||
self.curpage = self.pages[self.pageno]
|
self.curpage = self.pages[self.pageno]
|
||||||
|
self.curpage.display_new()
|
||||||
elif selected == 4:
|
elif selected == 4:
|
||||||
if not self.curpage.handle_key(4):
|
if not self.curpage.handle_key(4):
|
||||||
if self.pageno < len(self.pages) - 1:
|
if self.pageno < len(self.pages) - 1:
|
||||||
|
@ -564,6 +567,7 @@ class Frontend(Gtk.Window):
|
||||||
self.pageno = 1
|
self.pageno = 1
|
||||||
# hoch / eine Seite zurück
|
# hoch / eine Seite zurück
|
||||||
self.curpage = self.pages[self.pageno]
|
self.curpage = self.pages[self.pageno]
|
||||||
|
self.curpage.display_new()
|
||||||
elif selected == 5:
|
elif selected == 5:
|
||||||
# Ok/Menü
|
# Ok/Menü
|
||||||
if self.button_clicked == 4:
|
if self.button_clicked == 4:
|
||||||
|
@ -737,6 +741,9 @@ if __name__ == "__main__":
|
||||||
history = History("press", 75)
|
history = History("press", 75)
|
||||||
boatdata.addHistory(history, "press")
|
boatdata.addHistory(history, "press")
|
||||||
|
|
||||||
|
# Zeitzonenoffset, aus Kompatibilitätsgründen zum OBP60
|
||||||
|
cfg['tzoffset'] = config.getint('settings', 'timezone')
|
||||||
|
|
||||||
# Tracker data
|
# Tracker data
|
||||||
cfg['tracker']['type'] = config.get('tracker', 'type').upper()
|
cfg['tracker']['type'] = config.get('tracker', 'type').upper()
|
||||||
cfg['tracker']['host'] = config.get('tracker', 'host')
|
cfg['tracker']['host'] = config.get('tracker', 'host')
|
||||||
|
|
|
@ -15,7 +15,7 @@ import os
|
||||||
import cairo
|
import cairo
|
||||||
import math
|
import math
|
||||||
from .page import Page
|
from .page import Page
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone, timedelta
|
||||||
import astral
|
import astral
|
||||||
|
|
||||||
class Clock(Page):
|
class Clock(Page):
|
||||||
|
@ -27,8 +27,11 @@ class Clock(Page):
|
||||||
self.mode = ('A', 'D', 'T') # (A)nalog (D)igital (T)imer
|
self.mode = ('A', 'D', 'T') # (A)nalog (D)igital (T)imer
|
||||||
self.modeindex = 1
|
self.modeindex = 1
|
||||||
self.utc = True
|
self.utc = True
|
||||||
self.location = astral.Location(('Norderstedt', 'Germany', 53.710105, 10.0574378, 'UTC'))
|
self.tzoffset = cfg['tzoffset']
|
||||||
self.location.astral = astral.Astral()
|
self.bv_lat = boatdata.getRef("LAT")
|
||||||
|
self.bv_lon = boatdata.getRef("LON")
|
||||||
|
# Eine beliebiger Ort damit irgendetwas gesetzt ist
|
||||||
|
self.set_location('Norderstedt', 'Germany', 53.710105, 10.0574378)
|
||||||
self.bgimg = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "unknown.png"))
|
self.bgimg = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "unknown.png"))
|
||||||
|
|
||||||
def handle_key(self, buttonid):
|
def handle_key(self, buttonid):
|
||||||
|
@ -43,6 +46,25 @@ class Clock(Page):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def set_location(self, city, country, lat, lon):
|
||||||
|
try:
|
||||||
|
# Astral ab Debian 13
|
||||||
|
self.location = astral.LocationInfo((city, country, lat, lon, 'UTC'))
|
||||||
|
except AttributeError:
|
||||||
|
# Astral bis Debian 12 (Version 1.6.1)
|
||||||
|
self.location = astral.Location((city, country, lat, lon, 'UTC'))
|
||||||
|
self.location.astral = astral.Astral()
|
||||||
|
|
||||||
|
def display_new(self):
|
||||||
|
"""
|
||||||
|
Position für Sonnenauf- und Untergang neu ermitteln
|
||||||
|
Machen wir hier einmal je Seitenaufruf, besser wäre es
|
||||||
|
in regelmäßigen Zeitabständen. Das kann dann später implementiert
|
||||||
|
werden.
|
||||||
|
"""
|
||||||
|
if self.bv_lat.valid and self.bv_lon.valid:
|
||||||
|
self.set_location('Ship', 'World', self.bv_lat.getValue, self.bv_lon.getValue, 'UTC')
|
||||||
|
|
||||||
def draw(self, ctx):
|
def draw(self, ctx):
|
||||||
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||||
|
|
||||||
|
@ -56,6 +78,10 @@ class Clock(Page):
|
||||||
|
|
||||||
def draw_digital(self, ctx):
|
def draw_digital(self, ctx):
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# Sonnenauf- und Untergang
|
||||||
|
# Zeitzone
|
||||||
|
|
||||||
ts = datetime.now()
|
ts = datetime.now()
|
||||||
|
|
||||||
ctx.set_font_size(20)
|
ctx.set_font_size(20)
|
||||||
|
@ -86,14 +112,15 @@ class Clock(Page):
|
||||||
def draw_analog(self, ctx):
|
def draw_analog(self, ctx):
|
||||||
|
|
||||||
ts = datetime.now()
|
ts = datetime.now()
|
||||||
|
if self.utc:
|
||||||
|
pass
|
||||||
|
# Location ist in UTC definiert
|
||||||
sunrise = self.location.sunrise(ts)
|
sunrise = self.location.sunrise(ts)
|
||||||
sunset = self.location.sunset(ts)
|
sunset = self.location.sunset(ts)
|
||||||
#print(sunrise)
|
if not self.utc:
|
||||||
#print(sunset)
|
td = timedelta(hours=self.tzoffset)
|
||||||
|
sunrise += td
|
||||||
# Datum und Uhrzeit
|
sunset += td
|
||||||
# Sonnenaufgang
|
|
||||||
# Sonnenuntergang
|
|
||||||
|
|
||||||
# Wochentag
|
# Wochentag
|
||||||
# ts.strftime('%a')
|
# ts.strftime('%a')
|
||||||
|
@ -112,17 +139,21 @@ class Clock(Page):
|
||||||
|
|
||||||
ctx.set_font_size(16)
|
ctx.set_font_size(16)
|
||||||
|
|
||||||
|
# Datum links oben
|
||||||
ctx.move_to(10, 65)
|
ctx.move_to(10, 65)
|
||||||
ctx.show_text(ts.strftime("%d.%m.%Y"))
|
ctx.show_text(ts.strftime("%d.%m.%Y"))
|
||||||
|
# Uhrzeit links unten
|
||||||
ctx.move_to(10, 250)
|
ctx.move_to(10, 250)
|
||||||
ctx.show_text(ts.strftime("%H:%M"))
|
ctx.show_text(ts.strftime("%H:%M"))
|
||||||
|
# Sonnenaufgang rechts oben
|
||||||
ctx.move_to(335, 65)
|
ctx.move_to(335, 65)
|
||||||
ctx.show_text(sunrise.strftime("%H:%M"))
|
ctx.show_text(sunrise.strftime("%H:%M"))
|
||||||
|
# Sonnenuntergang rechts unten
|
||||||
ctx.move_to(335, 250)
|
ctx.move_to(335, 250)
|
||||||
ctx.show_text(sunset.strftime("%H:%M"))
|
ctx.show_text(sunset.strftime("%H:%M"))
|
||||||
ctx.stroke()
|
ctx.stroke()
|
||||||
|
|
||||||
# Horizontal separators
|
# Horizontale Trennlinien
|
||||||
ctx.rectangle(0, 149, 60, 3)
|
ctx.rectangle(0, 149, 60, 3)
|
||||||
ctx.rectangle(340, 149, 60, 3)
|
ctx.rectangle(340, 149, 60, 3)
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
|
|
|
@ -126,6 +126,13 @@ class Page():
|
||||||
ctx.restore()
|
ctx.restore()
|
||||||
self.hbled = not self.hbled
|
self.hbled = not self.hbled
|
||||||
|
|
||||||
|
def display_new(self):
|
||||||
|
"""
|
||||||
|
Aufruf jedenfalls bei Seitenwechsel.
|
||||||
|
Überladen in spezialisierten Seiten bei Bedarf
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def draw_header(self, ctx):
|
def draw_header(self, ctx):
|
||||||
"""
|
"""
|
||||||
Mögliche Zeichen für aktivierte Funktionen (max. 8)
|
Mögliche Zeichen für aktivierte Funktionen (max. 8)
|
||||||
|
|
Loading…
Reference in New Issue