Skip to content

Commit 5c92c26

Browse files
authored
Merge pull request #990 from matthewgjohnson/fix/progressbar-min-value
Fix DisplayProgressBar min_value offset in fill calculation
2 parents 396bdb6 + 607a3f0 commit 5c92c26

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)