Skip to content

Commit 607a3f0

Browse files
Fix DisplayProgressBar min_value offset in fill calculation
DisplayProgressBar calculated bar_filled_width/height from the raw value rather than the value's offset from min_value. When min_value was 0 (the default), this had no effect — which is why the bug went unnoticed — but any bar with a non-zero minimum rendered the fill incorrectly. DisplayRadialProgressBar already uses the correct form (value - min_value) / (max_value - min_value). Fixes #954
1 parent 396bdb6 commit 607a3f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/lcd/lcd_comm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,11 @@ def DisplayProgressBar(self, x: int, y: int, width: int, height: int, min_value:
359359

360360
# Draw progress bar
361361
if width > height:
362-
bar_filled_width = (value / (max_value - min_value) * width) - 1
362+
bar_filled_width = ((value - min_value) / (max_value - min_value) * width) - 1
363363
if bar_filled_width < 0:
364364
bar_filled_width = 0
365365
else:
366-
bar_filled_height = (value / (max_value - min_value) * height) - 1
366+
bar_filled_height = ((value - min_value) / (max_value - min_value) * height) - 1
367367
if bar_filled_height < 0:
368368
bar_filled_height = 0
369369
draw = ImageDraw.Draw(bar_image)

0 commit comments

Comments
 (0)