Add odometer
This commit is contained in:
parent
8552e2259b
commit
74103a1c32
1 changed files with 26 additions and 1 deletions
|
@ -78,6 +78,28 @@ class ShiftIndicator(Gauge):
|
|||
for l in range(0, len(self.LIGHT_LEVELS)):
|
||||
self.draw_level(cr, level, l >= level)
|
||||
|
||||
class Odometer(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("%d mi" % self.value)
|
||||
|
||||
class Cluster():
|
||||
WIDTH = 1280
|
||||
HEIGHT = 480
|
||||
|
@ -85,7 +107,7 @@ class Cluster():
|
|||
SHIFT_INDICATOR_X = 392
|
||||
SHIFT_INDICATOR_Y = 24
|
||||
|
||||
__slots__ = 'gauges', 'speedo', 'fuel', 'tacho', 'thermo',
|
||||
__slots__ = 'gauges', 'speedo', 'fuel', 'tacho', 'thermo', 'odo',
|
||||
|
||||
def __init__(self, rpm_min: float, rpm_redline: float, rpm_max: float):
|
||||
self.gauges: List[Gauge] = list()
|
||||
|
@ -108,10 +130,13 @@ class Cluster():
|
|||
self.HEIGHT / 2,
|
||||
self.HEIGHT / 2)
|
||||
|
||||
self.odo = Odometer(self.HEIGHT, 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(ShiftIndicator(self.SHIFT_INDICATOR_X,
|
||||
self.SHIFT_INDICATOR_Y,
|
||||
|
|
Loading…
Add table
Reference in a new issue