diff --git a/py/hexagram/cluster.py b/py/hexagram/cluster.py index 67f1e53..57f6c81 100644 --- a/py/hexagram/cluster.py +++ b/py/hexagram/cluster.py @@ -100,6 +100,28 @@ class Odometer(Gauge): cr.move_to(self.x, self.y) cr.show_text("%d mi" % self.value) +class AmbientTemp(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(32) + + cr.move_to(self.x, self.y) + cr.show_text("%.1f°C" % self.value) + class Cluster(): WIDTH = 1280 HEIGHT = 480 @@ -107,7 +129,7 @@ class Cluster(): SHIFT_INDICATOR_X = 392 SHIFT_INDICATOR_Y = 24 - __slots__ = 'gauges', 'speedo', 'fuel', 'tacho', 'thermo', 'odo', + __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() @@ -132,11 +154,14 @@ class Cluster(): self.odo = Odometer(self.HEIGHT, self.HEIGHT - 32) + self.ambient = AmbientTemp(self.WIDTH - self.HEIGHT - 64, self.HEIGHT - 32) + self.gauges.append(self.speedo) self.gauges.append(self.fuel) self.gauges.append(self.tacho) self.gauges.append(self.thermo) self.gauges.append(self.odo) + self.gauges.append(self.ambient) self.gauges.append(ShiftIndicator(self.SHIFT_INDICATOR_X, self.SHIFT_INDICATOR_Y,