From 607a3f0e668799a1de48bc6fcb4e37a324e25324 Mon Sep 17 00:00:00 2001 From: "Matthew G. Johnson" <33068032+matthewgjohnson@users.noreply.github.com> Date: Sat, 18 Apr 2026 21:16:32 +0800 Subject: [PATCH] Fix DisplayProgressBar min_value offset in fill calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- library/lcd/lcd_comm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/lcd/lcd_comm.py b/library/lcd/lcd_comm.py index 06ab44a2..041fd023 100644 --- a/library/lcd/lcd_comm.py +++ b/library/lcd/lcd_comm.py @@ -359,11 +359,11 @@ def DisplayProgressBar(self, x: int, y: int, width: int, height: int, min_value: # Draw progress bar if width > height: - bar_filled_width = (value / (max_value - min_value) * width) - 1 + bar_filled_width = ((value - min_value) / (max_value - min_value) * width) - 1 if bar_filled_width < 0: bar_filled_width = 0 else: - bar_filled_height = (value / (max_value - min_value) * height) - 1 + bar_filled_height = ((value - min_value) / (max_value - min_value) * height) - 1 if bar_filled_height < 0: bar_filled_height = 0 draw = ImageDraw.Draw(bar_image)