Slowly cookin'
This commit is contained in:
parent
1f054aee2a
commit
acc27cb94b
3 changed files with 29 additions and 11 deletions
|
@ -3,9 +3,10 @@ import cairo
|
||||||
|
|
||||||
from typing import Iterable, List
|
from typing import Iterable, List
|
||||||
|
|
||||||
|
from hexagram.pattern import HexagonPattern
|
||||||
from hexagram.gauge import Gauge
|
from hexagram.gauge import Gauge
|
||||||
from hexagram.dial import Dial
|
from hexagram.dial import Dial
|
||||||
from hexagram.pattern import HexagonPattern
|
from hexagram.speedo import Speedo
|
||||||
|
|
||||||
class ShiftIndicator(Gauge):
|
class ShiftIndicator(Gauge):
|
||||||
LIGHT_WIDTH = 48
|
LIGHT_WIDTH = 48
|
||||||
|
@ -62,13 +63,24 @@ class Cluster():
|
||||||
SHIFT_INDICATOR_X = 392
|
SHIFT_INDICATOR_X = 392
|
||||||
SHIFT_INDICATOR_Y = 24
|
SHIFT_INDICATOR_Y = 24
|
||||||
|
|
||||||
__slots__ = 'gauges',
|
__slots__ = 'gauges', 'speedo', 'tacho',
|
||||||
|
|
||||||
def __init__(self, rpm_redline: float, rpm_max: float):
|
def __init__(self, rpm_redline: float, rpm_max: float):
|
||||||
self.gauges: List[Gauge] = list()
|
self.gauges: List[Gauge] = list()
|
||||||
|
|
||||||
for x in (self.HEIGHT / 2, self.WIDTH - self.HEIGHT / 2):
|
self.speedo = Speedo(self.HEIGHT / 2,
|
||||||
self.gauges.append(Dial(x, self.HEIGHT / 2, 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.gauges.append(ShiftIndicator(self.SHIFT_INDICATOR_X,
|
||||||
self.SHIFT_INDICATOR_Y,
|
self.SHIFT_INDICATOR_Y,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import cairo
|
||||||
from hexagram.gauge import Gauge
|
from hexagram.gauge import Gauge
|
||||||
|
|
||||||
class Dial(Gauge):
|
class Dial(Gauge):
|
||||||
__slots = 'x', 'y', 'radius',
|
__slots = 'x', 'y', 'radius', 'min_angle', 'max_angle',
|
||||||
|
|
||||||
BEZEL_WIDTH = 16
|
BEZEL_WIDTH = 16
|
||||||
|
|
||||||
|
@ -13,10 +13,12 @@ class Dial(Gauge):
|
||||||
(1, 0.4, 0.0, 0.4, 0.0)
|
(1, 0.4, 0.0, 0.4, 0.0)
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, x: float, y: float, radius: float):
|
def __init__(self, x: float, y: float, radius: float, min_angle: float, max_angle: float):
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
self.radius = radius
|
self.radius = radius
|
||||||
|
self.min_angle = min_angle
|
||||||
|
self.max_angle = max_angle
|
||||||
|
|
||||||
def _gradient(self):
|
def _gradient(self):
|
||||||
gradient = cairo.LinearGradient(self.x - self.radius,
|
gradient = cairo.LinearGradient(self.x - self.radius,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import enum
|
import enum
|
||||||
|
import math
|
||||||
|
|
||||||
from hexagram.cluster import Dial
|
from hexagram.cluster import Dial
|
||||||
|
|
||||||
|
@ -7,10 +8,13 @@ class SpeedUnits(enum.Enum):
|
||||||
MPH = 1
|
MPH = 1
|
||||||
|
|
||||||
class Speedo(Dial):
|
class Speedo(Dial):
|
||||||
|
MIN_ANGLE = 232.0 * (math.pi / 180.0)
|
||||||
|
MAX_ANGLE = 488.0 * (math.pi / 180.0)
|
||||||
|
|
||||||
__slots__ = 'units', 'max_speed',
|
__slots__ = 'units', 'max_speed',
|
||||||
|
|
||||||
def __init__(self, x: float, y: float, radius: float, units: SpeedUnits, max_speed: float):
|
def __init__(self, x: float, y: float, radius: float, max_speed: float, units: SpeedUnits=SpeedUnits.KPH):
|
||||||
super().__init__(x, y, radius)
|
super().__init__(x, y, radius, self.MIN_ANGLE, self.MAX_ANGLE)
|
||||||
|
|
||||||
self.units = units
|
self.units = units
|
||||||
self.max_speed = max_speed
|
self.max_speed = max_speed
|
||||||
|
|
Loading…
Add table
Reference in a new issue