Slowly cookin'

This commit is contained in:
XANTRONIX 2023-12-31 19:12:19 -05:00
parent 1f054aee2a
commit acc27cb94b
3 changed files with 29 additions and 11 deletions

View file

@ -3,9 +3,10 @@ import cairo
from typing import Iterable, List
from hexagram.pattern import HexagonPattern
from hexagram.gauge import Gauge
from hexagram.dial import Dial
from hexagram.pattern import HexagonPattern
from hexagram.speedo import Speedo
class ShiftIndicator(Gauge):
LIGHT_WIDTH = 48
@ -62,13 +63,24 @@ class Cluster():
SHIFT_INDICATOR_X = 392
SHIFT_INDICATOR_Y = 24
__slots__ = 'gauges',
__slots__ = 'gauges', 'speedo', 'tacho',
def __init__(self, rpm_redline: float, rpm_max: float):
self.gauges: List[Gauge] = list()
for x in (self.HEIGHT / 2, self.WIDTH - self.HEIGHT / 2):
self.gauges.append(Dial(x, self.HEIGHT / 2, self.HEIGHT / 2))
self.speedo = Speedo(self.HEIGHT / 2,
self.HEIGHT / 2,
self.HEIGHT / 2,
350.0)
self.tacho = Dial(self.WIDTH - self.HEIGHT / 2,
self.HEIGHT / 2,
self.HEIGHT / 2,
232.0 * (math.pi / 180.0),
488.0 * (math.pi / 180.0))
self.gauges.append(self.speedo)
self.gauges.append(self.tacho)
self.gauges.append(ShiftIndicator(self.SHIFT_INDICATOR_X,
self.SHIFT_INDICATOR_Y,

View file

@ -4,7 +4,7 @@ import cairo
from hexagram.gauge import Gauge
class Dial(Gauge):
__slots = 'x', 'y', 'radius',
__slots = 'x', 'y', 'radius', 'min_angle', 'max_angle',
BEZEL_WIDTH = 16
@ -13,10 +13,12 @@ class Dial(Gauge):
(1, 0.4, 0.0, 0.4, 0.0)
)
def __init__(self, x: float, y: float, radius: float):
self.x = x
self.y = y
self.radius = radius
def __init__(self, x: float, y: float, radius: float, min_angle: float, max_angle: float):
self.x = x
self.y = y
self.radius = radius
self.min_angle = min_angle
self.max_angle = max_angle
def _gradient(self):
gradient = cairo.LinearGradient(self.x - self.radius,

View file

@ -1,4 +1,5 @@
import enum
import math
from hexagram.cluster import Dial
@ -7,10 +8,13 @@ class SpeedUnits(enum.Enum):
MPH = 1
class Speedo(Dial):
MIN_ANGLE = 232.0 * (math.pi / 180.0)
MAX_ANGLE = 488.0 * (math.pi / 180.0)
__slots__ = 'units', 'max_speed',
def __init__(self, x: float, y: float, radius: float, units: SpeedUnits, max_speed: float):
super().__init__(x, y, radius)
def __init__(self, x: float, y: float, radius: float, max_speed: float, units: SpeedUnits=SpeedUnits.KPH):
super().__init__(x, y, radius, self.MIN_ANGLE, self.MAX_ANGLE)
self.units = units
self.max_speed = max_speed