Allow choosing chart skew at runtime

This commit is contained in:
XANTRONIX 2025-03-14 13:09:44 -04:00
parent 933d11ebc7
commit 77fe922d90

View file

@ -32,11 +32,12 @@ def clamp(value, lowest, highest):
return value return value
class SkewTGraph(): class SkewTGraph():
__slots__ = 'width', 'height', 'temp_step_width', __slots__ = 'width', 'height', 'skew', 'temp_step_width',
def __init__(self, width: float, height: float): def __init__(self, width: float, height: float, skew: float=SKEW):
self.width = width self.width = width
self.height = height self.height = height
self.skew = skew
self.temp_step_width = min(self.width, self.height) / TEMP_STEP_COUNT self.temp_step_width = min(self.width, self.height) / TEMP_STEP_COUNT
@ -74,7 +75,7 @@ class SkewTGraph():
cr.restore() cr.restore()
def skew_t_to_graph(self, x: float, y: float): def skew_t_to_graph(self, x: float, y: float):
return (x+SKEW*y, y) return (x+self.skew*y, y)
def sample_to_graph(self, temp: float, pressure: float): def sample_to_graph(self, temp: float, pressure: float):
x = (temp / TEMP_STEP) * self.temp_step_width x = (temp / TEMP_STEP) * self.temp_step_width
@ -241,7 +242,7 @@ class SkewTLegend():
x_rel, y_rel = skew_t.sample_to_screen(temp, PRESSURE_MAX) x_rel, y_rel = skew_t.sample_to_screen(temp, PRESSURE_MAX)
if x_rel < 0: if x_rel < 0:
y_rel = skew_t.height + x_rel / SKEW y_rel = skew_t.height + x_rel / skew_t.skew
x_rel = 0 x_rel = 0
if y_rel <= 0: if y_rel <= 0: