Add clock
This commit is contained in:
parent
c80e9f1905
commit
d474fa5ae9
1 changed files with 34 additions and 7 deletions
|
@ -95,7 +95,7 @@ class Odometer(Gauge):
|
|||
cairo.FontSlant.NORMAL,
|
||||
cairo.FontWeight.BOLD)
|
||||
|
||||
cr.set_font_size(32)
|
||||
cr.set_font_size(24)
|
||||
|
||||
cr.move_to(self.x, self.y)
|
||||
cr.show_text("%d mi" % self.value)
|
||||
|
@ -117,20 +117,46 @@ class AmbientTemp(Gauge):
|
|||
cairo.FontSlant.NORMAL,
|
||||
cairo.FontWeight.BOLD)
|
||||
|
||||
cr.set_font_size(32)
|
||||
cr.set_font_size(24)
|
||||
|
||||
cr.move_to(self.x, self.y)
|
||||
cr.show_text("%.1f°C" % self.value)
|
||||
|
||||
class Clock(Gauge):
|
||||
__slots__ = 'x', 'y',
|
||||
|
||||
def __init__(self, x: float, y: float):
|
||||
self.value = 0
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def draw_bg(self, cr: cairo.Context):
|
||||
pass
|
||||
|
||||
def draw_fg(self, cr: cairo.Context):
|
||||
cr.set_source_rgb(1, 1, 1)
|
||||
cr.select_font_face("Muli",
|
||||
cairo.FontSlant.NORMAL,
|
||||
cairo.FontWeight.BOLD)
|
||||
|
||||
cr.set_font_size(24)
|
||||
|
||||
cr.move_to(self.x, self.y)
|
||||
cr.show_text("%d:%02d" % (
|
||||
(self.value - (self.value % 60)) / 60,
|
||||
self.value % 60
|
||||
))
|
||||
|
||||
class Cluster():
|
||||
__slots__ = 'gauges', 'speedo', 'fuel', 'tacho', 'thermo', 'odo', \
|
||||
'ambient', 'clock'
|
||||
|
||||
WIDTH = 1280
|
||||
HEIGHT = 480
|
||||
|
||||
SHIFT_INDICATOR_X = 392
|
||||
SHIFT_INDICATOR_Y = 24
|
||||
|
||||
__slots__ = 'gauges', 'speedo', 'fuel', 'tacho', 'thermo', 'odo', 'ambient',
|
||||
|
||||
def __init__(self, rpm_min: float, rpm_redline: float, rpm_max: float):
|
||||
self.gauges: List[Gauge] = list()
|
||||
|
||||
|
@ -153,8 +179,8 @@ class Cluster():
|
|||
self.HEIGHT / 2)
|
||||
|
||||
self.odo = Odometer(self.HEIGHT, self.HEIGHT - 32)
|
||||
|
||||
self.ambient = AmbientTemp(self.WIDTH - self.HEIGHT - 82, self.HEIGHT - 32)
|
||||
self.ambient = AmbientTemp(self.WIDTH - self.HEIGHT - 72, self.HEIGHT - 32)
|
||||
self.clock = Clock(self.HEIGHT, 72)
|
||||
|
||||
self.gauges.append(self.speedo)
|
||||
self.gauges.append(self.fuel)
|
||||
|
@ -162,6 +188,7 @@ class Cluster():
|
|||
self.gauges.append(self.thermo)
|
||||
self.gauges.append(self.odo)
|
||||
self.gauges.append(self.ambient)
|
||||
self.gauges.append(self.clock)
|
||||
|
||||
self.gauges.append(ShiftIndicator(self.SHIFT_INDICATOR_X,
|
||||
self.SHIFT_INDICATOR_Y,
|
||||
|
|
Loading…
Add table
Reference in a new issue