Skip to content

Commit 9e82098

Browse files
committed
fix(steami_screen): handle division by zero in ratio calculation
1 parent 608d8b8 commit 9e82098

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/steami_screen/steami_screen/screen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def gauge(self, val, min_val=0, max_val=100, unit=None, color=LIGHT):
209209
r = self.radius - arc_w // 2 - 1
210210
start_angle = 135
211211
sweep = 270
212-
ratio = (val - min_val) / (max_val - min_val)
212+
ratio = (val - min_val) / (max_val - min_val) if max_val != min_val else 0 # Avoid division by zero; show empty gauge if min=max
213213
ratio = max(0.0, min(1.0, ratio))
214214

215215
# Background arc

0 commit comments

Comments
 (0)