OBP60v/pages/system.py

108 lines
2.9 KiB
Python

import cairo
from .page import Page
import datetime
class System(Page):
def __init__(self, pageno, cfg, boatdata):
super().__init__(pageno, cfg, boatdata)
self.buttonlabel[1] = 'MODE'
self.buttonlabel[2] = 'STBY'
self.mode = ('I', 'N') # (I)nformation (N)MEA2000 Device List
self.modeindex = 1
self.standby = False
def handle_key(self, buttonid):
if self.standby and buttonid != 1:
return True
if buttonid == 1:
if self.standby:
self.standby = False
self.buttonlabel[1] = 'MODE'
self.buttonlabel[2] = 'STBY'
self.header = True
self.footer = True
else:
if self.modeindex < len(self.mode):
self.modeindex += 1
else:
self.modeindex = 0
return True
if buttonid == 2:
self.buttonlabel[1] = None
self.buttonlabel[2] = None
self.header = False
self.footer = False
self.standby = True
return False
def draw_stby(self, ctx):
# Standby
# TODO Kopf und Fußzeile ausschalten
# Ein Klick auf die Mode-Taste weckt das System wieder auf
pass
def draw_info(self, ctx):
# Bezeichnung
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
ctx.set_font_size(32)
self.draw_text_center(ctx, 200, 40 , "System Info")
ctx.set_font_size(16)
# System name
# Software version
# Linke Seite
ctx.move_to(2, 80)
ctx.show_text("Simulation: ")
ctx.move_to(140, 80)
ctx.show_text('On' if self.cfg['simulation'] else 'Off')
ctx.move_to(2, 100)
ctx.show_text("BME280/BMP280: ")
ctx.move_to(140, 100)
ctx.show_text('On' if self.cfg['bme280'] else 'Off')
ctx.move_to(2, 120)
ctx.show_text("GPS: ")
ctx.move_to(140, 120)
ctx.show_text('On' if self.cfg['gps'] else 'Off')
# Rechte Seite
ctx.move_to(202, 80)
ctx.show_text("Wifi: ")
ctx.move_to(340, 80)
ctx.show_text('On')
ctx.move_to(202, 100)
ctx.show_text("Buzzer: ")
ctx.move_to(340, 100)
ctx.show_text('60%')
ctx.move_to(202, 120)
ctx.show_text("Timezone: ")
ctx.move_to(340, 120)
ctx.show_text(datetime.datetime.now().astimezone().tzname())
ctx.stroke()
# Geräteliste
ctx.move_to(2, 150)
ctx.show_text("NMEA2000 Device List")
ctx.set_line_width(1.5)
ctx.rectangle(2, 155, 394, 100)
ctx.stroke()
def draw_devlist(self, ctx):
# NMEA2000 Geräteliste, Vollbild
# scrollen mit Up/Down
pass
def draw(self, ctx):
if self.standby:
return
self.draw_info(ctx)