DisplayProgressBar: honour min_value when computing fill width#987
Open
SAY-5 wants to merge 1 commit intomathoudebine:mainfrom
Open
DisplayProgressBar: honour min_value when computing fill width#987SAY-5 wants to merge 1 commit intomathoudebine:mainfrom
SAY-5 wants to merge 1 commit intomathoudebine:mainfrom
Conversation
Reported as mathoudebine#954. DisplayProgressBar computes the filled extent from the raw value rather than the value's offset from min_value: bar_filled_width = (value / (max_value - min_value) * width) - 1 When min_value is 0 (default) this happens to be correct, which is why the bug has not surfaced. For any bar with a non-zero minimum (e.g. a temperature bar with min=25, max=95) the fill is wrong: value=25 renders at 36% instead of 0%, value=95 overshoots the bar. DisplayRadialProgressBar already uses the offset-from-min formula a couple of hundred lines down, so the two bar primitives are now consistent. Fixes mathoudebine#954 Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #954.
Problem
DisplayProgressBarinlibrary/lcd/lcd_comm.pycomputes the filled extent from the raw value, not the value's offset frommin_value:When
min_value == 0(default) this is correct, which is why the bug has gone unnoticed. For any bar with a non-zero minimum (e.g. a 25..95 temperature bar) the fill is wrong:DisplayRadialProgressBar(around line 560) already uses the offset-from-min form:Fix
Subtract
min_valuein both the horizontal and vertical branches ofDisplayProgressBarso the two bar primitives agree. One-character change per branch.Signed off per DCO.