From 597c25914a037b3fe4278d62b9e155ce750afdd6 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 9 Jan 2024 00:04:04 -0500 Subject: [PATCH] Don't hardcode tachometer redline --- py/hexagram/cluster.py | 2 +- py/hexagram/tacho.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/py/hexagram/cluster.py b/py/hexagram/cluster.py index ee4a171..4f689de 100644 --- a/py/hexagram/cluster.py +++ b/py/hexagram/cluster.py @@ -110,7 +110,7 @@ class Cluster(): self.tacho = Tacho(self.WIDTH - self.HEIGHT / 2, self.HEIGHT / 2, self.HEIGHT / 2, - 8000) + rpm_redline, rpm_max) self.thermo = Thermometer(self.WIDTH - self.HEIGHT / 2, self.HEIGHT / 2, diff --git a/py/hexagram/tacho.py b/py/hexagram/tacho.py index 504ab20..6772f1c 100644 --- a/py/hexagram/tacho.py +++ b/py/hexagram/tacho.py @@ -7,17 +7,18 @@ from hexagram.dial import Dial from hexagram.trans import Gear, ShiftMode class Tacho(Dial): - __slots__ = 'gear', 'shift_mode', + __slots__ = 'redline', 'gear', 'shift_mode', MIN_ANGLE = 232.0 * (math.pi / 180.0) MAX_ANGLE = 488.0 * (math.pi / 180.0) FONT_FACE = "Muli" - def __init__(self, x: float, y: float, radius: float, max_value: float): + def __init__(self, x: float, y: float, radius: float, redline: float, max_value: float): super().__init__(x, y, radius, self.MIN_ANGLE, self.MAX_ANGLE, 0, max_value) - self.value = 0 + self.value = 0 + self.redline = redline self.gear: Gear = Gear.N self.shift_mode: ShiftMode = ShiftMode.NORMAL @@ -44,7 +45,7 @@ class Tacho(Dial): for speed in range(0, int(self.max_value)+1, 500): min_radius = 0.81 if speed % 1000 == 0 else 0.82 - if speed >= 7000: + if speed >= self.redline: cr.set_source_rgb(0.6, 0.1, 0.1) cr.set_line_width(6.0 if speed % 1000 == 0 else 2.0) @@ -53,7 +54,7 @@ class Tacho(Dial): cr.set_source_rgb(1.0, 1.0, 1.0) for speed in range(0, int(self.max_value)+1, 1000): - if speed >= 7000: + if speed >= self.redline: cr.set_source_rgb(1.0, 0.1, 0.1) self.draw_number(cr, 0.69, speed, "%d" % int(speed / 1000))