Erstveröffentlichung Weihnachten 2024
This commit is contained in:
66
pages/battery.py
Normal file
66
pages/battery.py
Normal file
@@ -0,0 +1,66 @@
|
||||
"""
|
||||
|
||||
Batteriewerte eines INA219 oder INA226 Sensors
|
||||
Ähnlich ThreeValue
|
||||
|
||||
"""
|
||||
|
||||
import cairo
|
||||
from .page import Page
|
||||
|
||||
class Battery(Page):
|
||||
|
||||
avg = (1, 10, 60, 300);
|
||||
|
||||
def __init__(self, pageno, cfg, boatdata):
|
||||
super().__init__(pageno, cfg, boatdata)
|
||||
self.avgindex = 0
|
||||
self.buttonlabel[1] = 'AVG'
|
||||
|
||||
def handle_key(self, buttonid):
|
||||
if buttonid == 1:
|
||||
if self.avgindex < len(self.avg) -1:
|
||||
self.avgindex += 1
|
||||
else:
|
||||
self.avgindex = 0
|
||||
return True
|
||||
return False
|
||||
|
||||
def draw(self, ctx):
|
||||
|
||||
# Aufteilung in 3 Bereiche durch 2 Linien
|
||||
ctx.rectangle(0, 105, 400, 3);
|
||||
ctx.rectangle(0, 195, 400, 3);
|
||||
ctx.fill()
|
||||
|
||||
# Name
|
||||
ctx.select_font_face("Ubuntu", cairo.FontSlant.NORMAL, cairo.FontWeight.BOLD)
|
||||
ctx.set_font_size(40)
|
||||
ctx.move_to(20, 55)
|
||||
ctx.show_text("VBat")
|
||||
ctx.move_to(20, 145)
|
||||
ctx.show_text("IBat")
|
||||
ctx.move_to(20, 235)
|
||||
ctx.show_text("PBat")
|
||||
ctx.stroke()
|
||||
|
||||
# Einheit
|
||||
ctx.set_font_size(24)
|
||||
ctx.move_to(20, 90)
|
||||
ctx.show_text("V")
|
||||
ctx.move_to(20, 180)
|
||||
ctx.show_text("A")
|
||||
ctx.move_to(20, 270)
|
||||
ctx.show_text("W")
|
||||
|
||||
|
||||
# Werte
|
||||
ctx.select_font_face("DSEG7 Classic")
|
||||
ctx.set_font_size(60)
|
||||
ctx.move_to(180, 90)
|
||||
ctx.show_text("12.3")
|
||||
ctx.move_to(180, 180)
|
||||
ctx.show_text("3.2")
|
||||
ctx.move_to(180, 270)
|
||||
ctx.show_text("39.4")
|
||||
|
||||
Reference in New Issue
Block a user