Prevent needle from moving past max value
This commit is contained in:
parent
eda71d1d0c
commit
4e14c44266
1 changed files with 1 additions and 1 deletions
|
@ -37,8 +37,8 @@ class Dial(Gauge):
|
||||||
return gradient
|
return gradient
|
||||||
|
|
||||||
def angle(self, value: float):
|
def angle(self, value: float):
|
||||||
adj = value - self.min_value
|
|
||||||
adj_max = self.max_value - self.min_value
|
adj_max = self.max_value - self.min_value
|
||||||
|
adj = min(adj_max, value - self.min_value)
|
||||||
|
|
||||||
return self.min_angle + \
|
return self.min_angle + \
|
||||||
(self.max_angle - self.min_angle) * (adj / adj_max) \
|
(self.max_angle - self.min_angle) * (adj / adj_max) \
|
||||||
|
|
Loading…
Add table
Reference in a new issue