Skip to content

Commit 34ffdab

Browse files
authored
Merge pull request #987 from SAY-5/fix-progressbar-min-value-954
2 parents cc6b0d4 + 17f13b4 commit 34ffdab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

library/lcd/lcd_comm.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,11 @@ def DisplayProgressBar(self, x: int, y: int, width: int, height: int, min_value:
357357
# Crop bitmap to keep only the progress bar background
358358
bar_image = bar_image.crop(box=(x, y, x + width, y + height))
359359

360-
# Draw progress bar
360+
# Draw progress bar. Fill has to be computed from the offset
361+
# into [min_value, max_value], not the raw value; otherwise a
362+
# bar with min_value > 0 (e.g. a 25..95 temperature bar) is
363+
# filled by the wrong fraction. DisplayRadialProgressBar below
364+
# already does this correctly. See issue #954.
361365
if width > height:
362366
bar_filled_width = ((value - min_value) / (max_value - min_value) * width) - 1
363367
if bar_filled_width < 0:

0 commit comments

Comments
 (0)